From 402300960ea3174ab2181e87dd9a15a21b5db054 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 11 Dec 2024 15:24:05 +0100 Subject: [PATCH] Fixes --- .../Networking/Roboid/HumanoidPlayerRoboid.cs | 119 +++++++++--------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/Runtime/HumanoidControl/Scripts/Networking/Roboid/HumanoidPlayerRoboid.cs b/Runtime/HumanoidControl/Scripts/Networking/Roboid/HumanoidPlayerRoboid.cs index 1a22478..6966cf1 100644 --- a/Runtime/HumanoidControl/Scripts/Networking/Roboid/HumanoidPlayerRoboid.cs +++ b/Runtime/HumanoidControl/Scripts/Networking/Roboid/HumanoidPlayerRoboid.cs @@ -39,7 +39,7 @@ namespace Passer.Humanoid { protected HumanoidClient client; protected Stream dataStream; - public byte networkId; + //public byte networkId; public const byte Pose_Position = 0x01; public const byte Pose_Orientation = 0x02; @@ -149,12 +149,12 @@ namespace Passer.Humanoid { Thing thing = Thing.GetThing(msg.networkId, msg.thingId); Thing parentThing = thing.transform.parent.GetComponentInParent(); if (parentThing != null) - ThingMsg.Send(this, thing.networkId, thing.thingId, parentThing.thingId); + ThingMsg.Send(this, thing.networkId, thing.thingId, thing.objectType, parentThing.thingId); else - ThingMsg.Send(this, thing.networkId, thing.thingId, 0); - NameMsg.Send(this, thing.thingId, thing.name); + ThingMsg.Send(this, thing.networkId, thing.thingId, thing.objectType, 0); + NameMsg.Send(this, thing.networkId, thing.thingId, thing.name); if (thing.modelUrl != null) - ModelUrlMsg.Send(this, thing.thingId, thing.modelUrl); + ModelUrlMsg.Send(this, thing.networkId, thing.thingId, thing.modelUrl); } protected override void ProcessThing(ThingMsg thing) { @@ -451,11 +451,7 @@ namespace Passer.Humanoid { //#region NetworkId void ProcessNetworkId(Client client, NetworkIdMsg msg) { - if (this.networkId == msg.networkId) - return; - - this.networkId = msg.networkId; - client.networkId = msg.networkId; + //this.networkId = msg.networkId; GameObject networkingObj = this.GetGameObject(msg.networkId); if (networkingObj == null) { if (this.debug <= HumanoidNetworking.DebugLevel.Error) @@ -470,9 +466,12 @@ namespace Passer.Humanoid { } remoteHumanoid.nwId = msg.networkId; - SendThing(client, remoteHumanoid); - SendName(remoteHumanoid, 0, "Humanoid"); - SendModel(remoteHumanoid, "https://gitlab.passervr.com/passer/models/humanoid/-/raw/main/MakeHumanPasserMedium.glb?ref_type=heads&inline=false"); + //SendThing(client, remoteHumanoid); + ThingMsg.Send(client, msg.networkId, 0, 1, 0); + NameMsg.Send(client, msg.networkId, 0, "Humanoid"); + //SendName(remoteHumanoid, 0, "Humanoid"); + //SendModel(remoteHumanoid, "https://gitlab.passervr.com/passer/models/humanoid/-/raw/main/MakeHumanPasserMedium.glb?ref_type=heads&inline=false"); + ModelUrlMsg.Send(client, msg.networkId, 0, "https://gitlab.passervr.com/passer/models/humanoid/-/raw/main/MakeHumanPasserMedium.glb?ref_type=heads&inline=false"); InitBone(client, remoteHumanoid, remoteHumanoid.hipsTarget.hips); InitBone(client, remoteHumanoid, remoteHumanoid.hipsTarget.spine); @@ -509,10 +508,10 @@ namespace Passer.Humanoid { protected void InitBone(Client client, HumanoidControl humanoid, HumanoidTarget.TargetedBone bone) { Thing thing = Thing.Create(bone.bone.transform.gameObject, client, client.networkId, (byte)bone.boneId, 0x00); if (bone.parent != null) - ThingMsg.Send(client, thing.thingId, thing.objectType, (byte)bone.parent.boneId); + ThingMsg.Send(client, thing.networkId, thing.thingId, thing.objectType, (byte)bone.parent.boneId); else - ThingMsg.Send(client, thing.thingId, thing.objectType, 0); - NameMsg.Send(client, thing.thingId, bone.bone.transform.name); + ThingMsg.Send(client, thing.networkId, thing.thingId, thing.objectType, 0); + NameMsg.Send(client, thing.networkId, thing.thingId, bone.bone.transform.name); } //#endregion @@ -520,74 +519,74 @@ namespace Passer.Humanoid { //#region Thing - public void SendThing(Client client, HumanoidControl humanoid) { - if (debug <= HumanoidNetworking.DebugLevel.Debug) - Debug.Log("Send Thing " + humanoid.humanoidId + " nwId: " + humanoid.nwId); + //public void SendThing(Client client, HumanoidControl humanoid) { + // if (debug <= HumanoidNetworking.DebugLevel.Debug) + // Debug.Log("Send Thing " + humanoid.humanoidId + " nwId: " + humanoid.nwId); - ThingMsg.Send(client, 0, 1, 0); - //ThingMsg thingMsg = new(0, 1); - //SendMsg(thingMsg); - //if (udpClient != null) { - // byte[] data = thingMsg.Serialize(); - // udpClient.Send(data, data.Length, "127.0.0.1", nssPort); - //} - } + // ThingMsg.Send(client, 0, 1, 0); + // //ThingMsg thingMsg = new(0, 1); + // //SendMsg(thingMsg); + // //if (udpClient != null) { + // // byte[] data = thingMsg.Serialize(); + // // udpClient.Send(data, data.Length, "127.0.0.1", nssPort); + // //} + //} //#endregion Thing //#region SubThing - public void SendSubThing(HumanoidControl humanoid, HumanoidTarget.TargetedBone bone) { - if (debug <= HumanoidNetworking.DebugLevel.Debug) - Debug.Log("Send SubThing " + humanoid.humanoidId + " nwId: " + humanoid.nwId); + //public void SendSubThing(HumanoidControl humanoid, HumanoidTarget.TargetedBone bone) { + // if (debug <= HumanoidNetworking.DebugLevel.Debug) + // Debug.Log("Send SubThing " + humanoid.humanoidId + " nwId: " + humanoid.nwId); - if (bone.parent != null) - ThingMsg.Send(client, (byte)bone.boneId, 0x00, (byte)bone.parent.boneId); - else - ThingMsg.Send(client, (byte)bone.boneId, 0x00, 0); + // if (bone.parent != null) + // ThingMsg.Send(client, (byte)bone.boneId, 0x00, (byte)bone.parent.boneId); + // else + // ThingMsg.Send(client, (byte)bone.boneId, 0x00, 0); - //SubThingMsg thingMsg; - //if (bone.parent != null) - // thingMsg = new((byte)bone.boneId, (byte)bone.parent.boneId, bone.bone.transform.position); - //else - // thingMsg = new((byte)bone.boneId, 0, bone.bone.transform.position); + // //SubThingMsg thingMsg; + // //if (bone.parent != null) + // // thingMsg = new((byte)bone.boneId, (byte)bone.parent.boneId, bone.bone.transform.position); + // //else + // // thingMsg = new((byte)bone.boneId, 0, bone.bone.transform.position); - //if (udpClient != null) { - // byte[] data = thingMsg.Serialize(); - // udpClient.Send(data, data.Length, "127.0.0.1", nssPort); - //} + // //if (udpClient != null) { + // // byte[] data = thingMsg.Serialize(); + // // udpClient.Send(data, data.Length, "127.0.0.1", nssPort); + // //} - SendName(humanoid, (byte)bone.boneId, bone.bone.transform.name); - } + // SendName(humanoid, (byte)bone.boneId, bone.bone.transform.name); + //} //#endregion //#region Name - public void SendName(HumanoidControl humanoid, byte thingId, string name) { - if (debug <= HumanoidNetworking.DebugLevel.Debug) - Debug.Log("Send Name " + humanoid.humanoidId + " nwId: " + humanoid.nwId); + //public void SendName(HumanoidControl humanoid, byte thingId, string name) { + // if (debug <= HumanoidNetworking.DebugLevel.Debug) + // Debug.Log("Send Name " + humanoid.humanoidId + " nwId: " + humanoid.nwId); - NameMsg.Send(client, thingId, name); - //NameMsg nameMsg = new(thingId, name); // humanoid.name; + // NameMsg.Send(client, thingId, name); + // //NameMsg nameMsg = new(thingId, name); // humanoid.name; - //if (udpClient != null) { - // byte[] data = nameMsg.Serialize(); - // udpClient.Send(data, data.Length, "127.0.0.1", nssPort); - //} - } + // //if (udpClient != null) { + // // byte[] data = nameMsg.Serialize(); + // // udpClient.Send(data, data.Length, "127.0.0.1", nssPort); + // //} + //} //#endregion //#region Model - public void SendModel(HumanoidControl humanoid, string url) { - if (debug <= HumanoidNetworking.DebugLevel.Debug) - Debug.Log("Send URL " + humanoid.humanoidId + " nwId: " + humanoid.nwId); + //public void SendModel(HumanoidControl humanoid, string url) { + // if (debug <= HumanoidNetworking.DebugLevel.Debug) + // Debug.Log("Send URL " + humanoid.humanoidId + " nwId: " + humanoid.nwId); - ModelUrlMsg.Send(client, 0, url); - } + // ModelUrlMsg.Send(client, 0, url); + //} bool loaded = false; protected async void ProcessModelURL(Client client, ModelUrlMsg msg) {