From 1ff16c93a3f27cadade394785aa16cf70f7d8478 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 18 Feb 2011 17:16:57 -0800 Subject: [PATCH] Another attempt to add SOG/SOP to ScenePresence so it can be handled by bucket update code --- .../RegionSyncServerModule.cs | 2 +- .../SymmetricSync/RegionSyncModule.cs | 22 ++++++---------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 10 ++++++-- .../Framework/Scenes/SceneObjectPart.cs | 17 +++++++++++-- .../Region/Framework/Scenes/ScenePresence.cs | 25 ++++++++++++++++--- .../Region/Physics/OdePlugin/ODECharacter.cs | 1 - .../Region/Physics/PEPlugin/PECharacter.cs | 2 +- OpenSim/Region/Physics/PEPlugin/PEScene.cs | 1 + 8 files changed, 55 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs index fc8a074c7e..a2fb25c912 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs @@ -273,7 +273,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_presenceUpdates[presence.UUID] = presence; } - //m_log.WarnFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString()); + m_log.WarnFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString()); } public void SendUpdates() diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 014c15ce8b..dbb963d512 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -253,7 +253,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = new OSDMap(); - data["UUID"] = OSD.FromUUID(updatedPart.UUID); + // data["UUID"] = OSD.FromUUID(updatedPart.UUID); + data["UUID"] = OSD.FromUUID(pa.UUID); data["Bucket"] = OSD.FromString(bucketName); data["GroupPosition"] = OSD.FromVector3(updatedPart.GroupPosition); @@ -280,7 +281,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["LastUpdateActorID"] = OSD.FromString(updatedPart.BucketSyncInfoList[bucketName].LastUpdateActorID); SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedBucketProperties, OSDParser.SerializeJsonString(data)); - m_log.DebugFormat("{0}: PhysBucketSender for {1}", LogHeader, updatedPart.UUID.ToString()); + m_log.DebugFormat("{0}: PhysBucketSender for {1}, pos={2}", LogHeader, updatedPart.UUID.ToString(), pa.Position.ToString()); SendObjectUpdateToRelevantSyncConnectors(updatedPart, syncMsg); } } @@ -409,6 +410,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } List presenceUpdates = new List(); + /* if (m_presenceUpdates.Count > 0) { lock (m_updateScenePresenceLock) @@ -418,6 +420,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_presenceUpdates.Clear(); } } + */ if (updated) { @@ -458,19 +461,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { if (!presence.IsDeleted) { - // Robert admits to doing this terrible kludge - // Someday, ScenePresences will be properly handled but, for the moment, - // we convert a ScenePresence update to a physics bucket transmission. - SceneObjectPart sop = new SceneObjectPart(presence.UUID, new PrimitiveBaseShape(), - Vector3.Zero, Quaternion.Identity, Vector3.Zero); - sop.PhysActor = presence.PhysicsActor; - sop.UUID = presence.UUID; - sop.BucketSyncInfoList = new Dictionary(); - sop.BucketSyncInfoList.Add("Physics", new BucketSyncInfo(DateTime.Now.Ticks, ActorID, "Physics")); - List lsop = new List(); - lsop.Add(sop); - PrimUpdatesPhysicsBucketSender("Physics", lsop); - /* OSDMap data = new OSDMap(10); data["id"] = OSD.FromUUID(presence.UUID); @@ -1525,6 +1515,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule UUID partUUID = data["UUID"].AsUUID(); string bucketName = data["Bucket"].AsString(); + m_log.DebugFormat("{0}: HandleUpdatedBucketProperties {1}: for {2}/{3}", LogHeader, senderActorID, partUUID.ToString(), bucketName); + /* Commented out since OSDMap is now passed all the way through to the unpacker. * Previous implementation is to create a SOP and copy the values into same and copy them out later. SceneObjectPart updatedPart = new SceneObjectPart(); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index bdf11a6161..fb0613b32b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2436,8 +2436,14 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart localPart = GetSceneObjectPart(partUUID); if (localPart == null) { - m_log.Warn("No SOP found: UUID -- " + partUUID); - return Scene.ObjectUpdateResult.Unchanged; + // it's not a prim. Maybe it's a ScenePresence + ScenePresence sp; + if (!m_parentScene.TryGetScenePresence(partUUID, out sp)) + { + m_log.Warn("No SOP found: UUID -- " + partUUID); + return Scene.ObjectUpdateResult.Unchanged; + } + localPart = sp.RegionSyncSOP; } return localPart.UpdateBucketProperties(bucketName, updatedPart, bucketSyncInfo); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 906504feaa..46c3b30d54 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2745,12 +2745,23 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); - + + if (m_parentGroup == null) + { + m_log.Error("[SCENE OBJECT PART]: PhysicsRequestingTerseUpdate: m_parentGroup is null!"); + return; + } + if (m_parentGroup.Scene == null) + { + m_log.Error("[SCENE OBJECT PART]: PhysicsRequestingTerseUpdate: m_parentGroup.Scene is null!"); + return; + } if (m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) { m_parentGroup.AbsolutePosition = newpos; return; } + m_log.DebugFormat("[PHYSICS]: TerseUpdate: newpos={0}", newpos.ToString()); //m_parentGroup.RootPart.m_groupPosition = newpos; } //ScheduleTerseUpdate(); @@ -5447,6 +5458,8 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart localPart = this; PhysicsActor pa = localPart.PhysActor; + m_log.DebugFormat("{0}: PhysicsBucketUpdateProcessor. pos={1}", "[SCENE OBJECT PART]", data["Position"].AsVector3().ToString()); + lock (m_bucketUpdateLocks[bucketName]) { localPart.GroupPosition = data["GroupPosition"].AsVector3(); @@ -5502,7 +5515,7 @@ namespace OpenSim.Region.Framework.Scenes } long timeStamp = DateTime.Now.Ticks; - m_log.Debug("InitializeBucketSyncInfo called at " + timeStamp); + // m_log.Debug("InitializeBucketSyncInfo called at " + timeStamp); for (int i = 0; i < m_propertyBucketNames.Count; i++) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dbe9428c5e..8f28574eef 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -112,6 +112,14 @@ namespace OpenSim.Region.Framework.Scenes } protected List m_attachments = new List(); + // SYMMETRIC SYNC: used to make a ScenePresence look like a SceneObjectPart for synchronization + private SceneObjectGroup m_sog; + private SceneObjectPart m_sop; + public SceneObjectPart RegionSyncSOP + { + get { return m_sop; } + } + private Dictionary scriptedcontrols = new Dictionary(); private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; @@ -2443,14 +2451,19 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { + m_log.DebugFormat("[SCENE PRESENCE]: TerseUpdate: pos={0}", m_physicsActor.Position.ToString()); // REGION SYNC if (m_scene.IsSyncedServer()) { - // the old and new systems live in parallel - m_scene.RegionSyncModule.QueueScenePresenceForTerseUpdate(this); m_scene.RegionSyncServerModule.QueuePresenceForTerseUpdate(this); - return; } + if (m_scene.RegionSyncModule.Active) + { + m_sop.PhysicsRequestingTerseUpdate(); + m_scene.RegionSyncModule.QueueSceneObjectPartForUpdate(m_sop); + } + if (m_scene.IsSyncedServer() || m_scene.RegionSyncModule.Active) + return; m_perfMonMS = Util.EnvironmentTickCount(); @@ -3378,6 +3391,12 @@ namespace OpenSim.Region.Framework.Scenes m_physicsActor.SubscribeEvents(500); m_physicsActor.LocalID = LocalId; m_physicsActor.UUID = this.UUID; + + m_sop = new SceneObjectPart(this.UUID, new PrimitiveBaseShape(), Vector3.Zero, Quaternion.Identity, Vector3.Zero); + m_sop.PhysActor = m_physicsActor; + m_sop.InitializeBucketSyncInfo(); + m_sog = new SceneObjectGroup(m_sop, true); + m_sog.Scene = m_scene; } private void OutOfBoundsCall(Vector3 pos) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 3bc2b7e80b..b04467fa11 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1355,7 +1355,6 @@ namespace OpenSim.Region.Physics.OdePlugin _position.Z = m_taintPosition.Z; } } - Console.WriteLine("ODECharacter: ProcessTaints: doing update"); this.RequestPhysicsterseUpdate(); } diff --git a/OpenSim/Region/Physics/PEPlugin/PECharacter.cs b/OpenSim/Region/Physics/PEPlugin/PECharacter.cs index cc168bacc4..35af7a8e6f 100755 --- a/OpenSim/Region/Physics/PEPlugin/PECharacter.cs +++ b/OpenSim/Region/Physics/PEPlugin/PECharacter.cs @@ -155,7 +155,7 @@ public class PECharacter : PhysicsActor public override Vector3 Velocity { get { return _velocity; } set { _velocity = value; - // SyncUpdated = true; + SyncUpdated = true; } } public override Vector3 Torque { diff --git a/OpenSim/Region/Physics/PEPlugin/PEScene.cs b/OpenSim/Region/Physics/PEPlugin/PEScene.cs index 4064dc379e..2fc516c262 100755 --- a/OpenSim/Region/Physics/PEPlugin/PEScene.cs +++ b/OpenSim/Region/Physics/PEPlugin/PEScene.cs @@ -124,6 +124,7 @@ public class PEScene : PhysicsScene // if the values have changed and it was I who changed them, send an update if (actor.SyncUpdated) { + actor.SyncUpdated = false; actor.RequestPhysicsterseUpdate(); } }