From c541b42f7e6b4656becf6f17174276e6b5bbbaa5 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 18 Jan 2011 16:52:37 -0800 Subject: [PATCH] Converted PhysicsActor identification from localID to UUID --- .../PhysEngineToSceneConnector.cs | 19 +++++++------- .../PhysEngineToSceneConnectorModule.cs | 6 ++--- .../SceneToPhysEngineConnector.cs | 25 ++++++++++--------- .../SceneToPhysEngineSyncServer.cs | 8 +++--- .../Framework/Scenes/SceneObjectGroup.cs | 1 + .../Framework/Scenes/SceneObjectPart.cs | 2 ++ .../Region/Framework/Scenes/ScenePresence.cs | 3 ++- .../Region/Physics/Manager/PhysicsActor.cs | 9 ++++++- 8 files changed, 43 insertions(+), 30 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs index 169e99290d..b1c4a5b59c 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs @@ -379,10 +379,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = RegionSyncUtil.DeserializeMessage(msg, LogHeader); try { - uint localID = data["localID"].AsUInteger(); + UUID uuid = data["uuid"].AsUUID(); string actorID = data["actorID"].AsString(); - // m_log.DebugFormat("{0}: HandlPhysUpdateAttributes for {1}", LogHeader, localID); - PhysicsActor pa = FindPhysicsActor(localID); + // m_log.DebugFormat("{0}: HandlPhysUpdateAttributes for {1}", LogHeader, uuid); + PhysicsActor pa = FindPhysicsActor(uuid); if (pa != null) { // pa.Size = data["size"].AsVector3(); @@ -396,7 +396,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule pa.Flying = data["flying"].AsBoolean(); // receive?? pa.Kinematic = data["kinematic"].AsBoolean(); // receive?? pa.Buoyancy = (float)(data["buoyancy"].AsReal()); - SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(localID); + SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(uuid); if (sop != null) { pa.Shape = sop.Shape; @@ -405,7 +405,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - m_log.WarnFormat("{0}: attribute update for unknown localID {1}", LogHeader, localID); + m_log.WarnFormat("{0}: attribute update for unknown uuid {1}", LogHeader, uuid); return; } } @@ -418,14 +418,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } // Find the physics actor whether it is an object or a scene presence - private PhysicsActor FindPhysicsActor(uint localID) + private PhysicsActor FindPhysicsActor(UUID uuid) { - SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(localID); + SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(uuid); if (sop != null) { return sop.PhysActor; } - ScenePresence sp = m_validLocalScene.GetScenePresence(localID); + ScenePresence sp = m_validLocalScene.GetScenePresence(uuid); if (sp != null) { return sp.PhysicsActor; @@ -435,9 +435,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public void SendPhysUpdateAttributes(PhysicsActor pa) { - // m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.LocalID); + // m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.UUID); OSDMap data = new OSDMap(9); data["localID"] = OSD.FromUInteger(pa.LocalID); + data["uuid"] = OSD.FromUUID(pa.UUID); data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID); data["size"] = OSD.FromVector3(pa.Size); data["position"] = OSD.FromVector3(pa.Position); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs index caa6277035..2a36d176b7 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs @@ -240,7 +240,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { try { - sop = ss.GetSceneObjectPart(pa.LocalID); + sop = ss.GetSceneObjectPart(pa.UUID); } catch { @@ -253,7 +253,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } try { - sp = ss.GetScenePresence(pa.LocalID); + sp = ss.GetScenePresence(pa.UUID); } catch { @@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - Console.WriteLine("RouteUpdate: no SOP found for {0}", pa.LocalID); + Console.WriteLine("RouteUpdate: no SOP found for {0}", pa.UUID); } return; } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs index 611eb1ed32..f4e66d54a1 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs @@ -296,16 +296,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = RegionSyncUtil.DeserializeMessage(msg, LogHeader); try { - uint localID = data["localID"].AsUInteger(); - // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, localID); - PhysicsActor pa = FindPhysicsActor(localID); + UUID uuid = data["uuid"].AsUUID(); + // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, uuid); + PhysicsActor pa = FindPhysicsActor(uuid); if (pa != null) { pa.RequestPhysicsterseUpdate(); } else { - m_log.WarnFormat("{0}: terse update for unknown localID {1}", LogHeader, localID); + m_log.WarnFormat("{0}: terse update for unknown uuid {1}", LogHeader, uuid); return; } } @@ -339,10 +339,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = RegionSyncUtil.DeserializeMessage(msg, LogHeader); try { - uint localID = data["localID"].AsUInteger(); + UUID uuid = data["uuid"].AsUUID(); string actorID = data["actorID"].AsString(); - // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, localID); - PhysicsActor pa = FindPhysicsActor(localID); + // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, uuid); + PhysicsActor pa = FindPhysicsActor(uuid); if (pa != null) { pa.ChangingActorID = actorID; @@ -363,7 +363,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - m_log.WarnFormat("{0}: attribute update for unknown localID {1}", LogHeader, localID); + m_log.WarnFormat("{0}: attribute update for unknown uuid {1}", LogHeader, uuid); return; } } @@ -376,14 +376,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } // Find the physics actor whether it is an object or a scene presence - private PhysicsActor FindPhysicsActor(uint localID) + private PhysicsActor FindPhysicsActor(UUID uuid) { - SceneObjectPart sop = m_scene.GetSceneObjectPart(localID); + SceneObjectPart sop = m_scene.GetSceneObjectPart(uuid); if (sop != null) { return sop.PhysActor; } - ScenePresence sp = m_scene.GetScenePresence(localID); + ScenePresence sp = m_scene.GetScenePresence(uuid); if (sp != null) { return sp.PhysicsActor; @@ -393,9 +393,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public void SendPhysUpdateAttributes(PhysicsActor pa) { - // m_log.DebugFormat("{0}: sending PhysUpdateAttributes for {1}", LogHeader, pa.LocalID); + // m_log.DebugFormat("{0}: sending PhysUpdateAttributes for {1}", LogHeader, pa.UUID); OSDMap data = new OSDMap(9); data["localID"] = OSD.FromUInteger(pa.LocalID); + data["uuid"] = OSD.FromUUID(pa.UUID); data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID); data["size"] = OSD.FromVector3(pa.Size); data["position"] = OSD.FromVector3(pa.Position); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs index 8b432030d0..8c61a466da 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs @@ -231,7 +231,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { try { - sop = ss.GetSceneObjectPart(pa.LocalID); + sop = ss.GetSceneObjectPart(pa.UUID); } catch { @@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - ScenePresence sp = ss.GetScenePresence(pa.LocalID); + ScenePresence sp = ss.GetScenePresence(pa.UUID); if (sp != null) { s = ss; @@ -260,12 +260,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - Console.WriteLine("RouteUpdate: SceneToPhysEngineSyncServer is no available"); + Console.WriteLine("RouteUpdate: SceneToPhysEngineSyncServer is not available"); } } else { - Console.WriteLine("RouteUpdate: no SOP for update of {0}", pa.LocalID); + Console.WriteLine("RouteUpdate: no SOP for update of {0}", pa.UUID); } return; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1b0c0fcd7b..044af42cb8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1468,6 +1468,7 @@ namespace OpenSim.Region.Framework.Scenes part.PhysActor.IsPhysical); part.PhysActor.LocalID = part.LocalId; + part.PhysActor.UUID = part.UUID; part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c8941f1c55..bb1669bb6f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1593,6 +1593,7 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info PhysActor.SOPDescription = this.Description; PhysActor.LocalID = LocalId; + PhysActor.UUID = UUID; DoPhysicsPropertyUpdate(RigidBody, true); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); } @@ -4440,6 +4441,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) { pa.LocalID = LocalId; + pa.UUID = this.UUID; DoPhysicsPropertyUpdate(UsePhysics, true); if (m_parentGroup != null) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e92604b570..3a80788147 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3342,8 +3342,9 @@ namespace OpenSim.Region.Framework.Scenes m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong m_physicsActor.SubscribeEvents(500); m_physicsActor.LocalID = LocalId; + m_physicsActor.UUID = this.UUID; } - + private void OutOfBoundsCall(Vector3 pos) { //bool flying = m_physicsActor.Flying; diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index ce4c45a672..cb205de207 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -185,10 +185,17 @@ namespace OpenSim.Region.Physics.Manager // RA: used to be abstract but changed to allow 'get' without changing all the phys engines uint m_baseLocalID; - public virtual uint LocalID { + public virtual uint LocalID + { set { m_baseLocalID = value; } get { return m_baseLocalID; } } + public UUID m_UUID; + public virtual UUID UUID + { + set { m_UUID = value; } + get { return m_UUID; } + } public PhysActorLastValues lastValues; // ID of actor which last updated the values. Send if I did the change. public string ChangingActorID = "YY";