From a25eac0a402529bae2993852731526a28e6cba8e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 18 Feb 2011 08:11:29 -0800 Subject: [PATCH] Remove old physics sync code. Attempt to fake ScenePresence in physics bucket sync --- .../SymmetricSync/RegionSyncModule.cs | 31 +++++++------ OpenSim/Region/Framework/Scenes/Scene.cs | 43 +++---------------- .../Framework/Scenes/SceneObjectPart.cs | 2 + .../Region/Framework/Scenes/ScenePresence.cs | 6 ++- .../Region/Physics/PEPlugin/PECharacter.cs | 5 +++ OpenSim/Region/Physics/PEPlugin/PEScene.cs | 5 ++- 6 files changed, 41 insertions(+), 51 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 96b0047572..014c15ce8b 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -364,12 +364,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public void QueueScenePresenceForTerseUpdate(ScenePresence presence) { - /* lock (m_updateScenePresenceLock) { m_presenceUpdates[presence.UUID] = presence; } - * */ } @@ -410,17 +408,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } - /* - List presenceUpdates = null; + List presenceUpdates = new List(); if (m_presenceUpdates.Count > 0) { lock (m_updateScenePresenceLock) { + updated = true; presenceUpdates = new List(m_presenceUpdates.Values); m_presenceUpdates.Clear(); } } - * */ if (updated) { @@ -455,15 +452,26 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_primUpdatesPerBucketSender[bucketName](bucketName, primUpdates[bucketName]); } } - /* - if(presenceUpdates!=null){ foreach (ScenePresence presence in presenceUpdates) { try { 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); // Do not include offset for appearance height. That will be handled by RegionSyncClient before sending to viewers @@ -490,16 +498,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.UpdatedAvatar, OSDParser.SerializeJsonString(data)); m_server.EnqueuePresenceUpdate(presence.UUID, rsm.ToBytes()); - + */ } } catch (Exception e) { - m_log.ErrorFormat("[REGION SYNC MODULE] Caught exception sending presence updates for {0}: {1}", presence.Name, e.Message); + m_log.ErrorFormat("[REGION SYNC MODULE] Caught exception sending presence updates for {0}: {1}", presence.Name, e); } - }} - * */ + } // Indicate that the current batch of updates has been completed Interlocked.Exchange(ref m_sendingUpdates, 0); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3605670e54..4e1c0a94ac 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -496,40 +496,11 @@ namespace OpenSim.Region.Framework.Scenes /////////////////////////////////////////////////////////////////////////////////////////////// //RA: Physics Engine /////////////////////////////////////////////////////////////////////////////////////////////// - protected IPhysEngineToSceneConnectorModule m_physEngineToSceneConnectorModule = null; - public IPhysEngineToSceneConnectorModule PhysEngineToSceneConnectorModule - { - get { return m_physEngineToSceneConnectorModule; } - set { m_physEngineToSceneConnectorModule = value; } - } - - protected ISceneToPhysEngineServer m_sceneToPhysEngineSyncServer = null; - public ISceneToPhysEngineServer SceneToPhysEngineSyncServer - { - get - { - if (m_sceneToPhysEngineSyncServer == null) - { - // kludge since this module is loaded in postInitialize - m_sceneToPhysEngineSyncServer = RequestModuleInterface(); - } - return m_sceneToPhysEngineSyncServer; - } - set { m_sceneToPhysEngineSyncServer = value; } - } - - // depending on what mode we're in, the different modules are available protected bool IsPhysEngineActor() { - if (PhysEngineToSceneConnectorModule != null) - { - return this.PhysEngineToSceneConnectorModule.IsPhysEngineActor(); - } - if (SceneToPhysEngineSyncServer != null) - { - return this.SceneToPhysEngineSyncServer.IsPhysEngineActor(); - } - return false; + // turns out every actor needs the physics engine. + return true; + // return ActorSyncModule != null && ActorSyncModule.ActorType == DSGActorTypes.PhysicsEngine; } /////////////////////////////////////////////////////////////////////////////////////////////// @@ -1513,8 +1484,6 @@ namespace OpenSim.Region.Framework.Scenes RegionSyncServerModule = RequestModuleInterface(); RegionSyncClientModule = RequestModuleInterface(); ScriptEngineToSceneConnectorModule = RequestModuleInterface(); - PhysEngineToSceneConnectorModule = RequestModuleInterface(); - SceneToPhysEngineSyncServer = RequestModuleInterface(); ////////////////////////////////////////////////////////////////////// //SYMMETRIC SYNC (KittyL: started 12/23/2010) @@ -1723,7 +1692,7 @@ namespace OpenSim.Region.Framework.Scenes int tmpPhysicsMS2 = Util.EnvironmentTickCount(); // Do not simulate physics locally if this is a synced client //if (!IsSyncedClient()) - if (IsSyncedServer() || this.IsPhysEngineActor()) + if (IsSyncedServer() || IsPhysEngineActor()) { if ((m_frame % m_update_physics == 0) && m_physics_enabled) m_sceneGraph.UpdatePreparePhysics(); @@ -1732,7 +1701,7 @@ namespace OpenSim.Region.Framework.Scenes // Do not simulate physics locally if this is a synced client //if (!IsSyncedClient()) - if (IsSyncedServer() || this.IsPhysEngineActor()) + if (IsSyncedServer() || IsPhysEngineActor()) { if (m_frame % m_update_entitymovement == 0) m_sceneGraph.UpdateScenePresenceMovement(); @@ -1743,7 +1712,7 @@ namespace OpenSim.Region.Framework.Scenes int tmpPhysicsMS = Util.EnvironmentTickCount(); // Do not simulate physics locally if this is a synced client //if (!IsSyncedClient()) - if (IsSyncedServer() || this.IsPhysEngineActor()) + if (IsSyncedServer() || IsPhysEngineActor()) { if (m_frame % m_update_physics == 0) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0f8469d09c..906504feaa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5763,6 +5763,8 @@ namespace OpenSim.Region.Framework.Scenes { if (updatedProperties != null && updatedProperties.Count > 0) { + m_log.DebugFormat("{0}: Tainting bucket for properties {1}", + "[SCENE OBJECT PART]", updatedProperties.ToString()); foreach (SceneObjectPartProperties property in updatedProperties) { TaintBucketSyncInfo(property); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2ada765d8c..dbe9428c5e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -548,6 +548,8 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_scene.SyncRoot) actor.Velocity = value; + m_scene.PhysicsScene.AddPhysicsActorTaint(actor); + } catch (Exception e) { @@ -2444,6 +2446,8 @@ namespace OpenSim.Region.Framework.Scenes // 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; } @@ -3368,7 +3372,7 @@ namespace OpenSim.Region.Framework.Scenes new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying); scene.AddPhysicsActorTaint(m_physicsActor); - //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; + m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong m_physicsActor.SubscribeEvents(500); diff --git a/OpenSim/Region/Physics/PEPlugin/PECharacter.cs b/OpenSim/Region/Physics/PEPlugin/PECharacter.cs index b807e08613..cc168bacc4 100755 --- a/OpenSim/Region/Physics/PEPlugin/PECharacter.cs +++ b/OpenSim/Region/Physics/PEPlugin/PECharacter.cs @@ -121,6 +121,7 @@ public class PECharacter : PhysicsActor public override Vector3 Position { get { return _position; } set { _position = value; + SyncUpdated = true; } } public override float Mass { @@ -133,6 +134,7 @@ public class PECharacter : PhysicsActor public override Vector3 Force { get { return _force; } set { _force = value; + SyncUpdated = true; } } @@ -153,16 +155,19 @@ public class PECharacter : PhysicsActor public override Vector3 Velocity { get { return _velocity; } set { _velocity = value; + // SyncUpdated = true; } } public override Vector3 Torque { get { return _torque; } set { _torque = value; + // SyncUpdated = true; } } public override float CollisionScore { get { return _collisionScore; } set { _collisionScore = value; + // SyncUpdated = true; } } public override Vector3 Acceleration { diff --git a/OpenSim/Region/Physics/PEPlugin/PEScene.cs b/OpenSim/Region/Physics/PEPlugin/PEScene.cs index c7c21fb85c..4064dc379e 100755 --- a/OpenSim/Region/Physics/PEPlugin/PEScene.cs +++ b/OpenSim/Region/Physics/PEPlugin/PEScene.cs @@ -96,7 +96,10 @@ public class PEScene : PhysicsScene return prim; } - public override void AddPhysicsActorTaint(PhysicsActor prim) { } + public override void AddPhysicsActorTaint(PhysicsActor prim) + { + prim.SyncUpdated = true; + } public override float Simulate(float timeStep) {