Remove old physics sync code. Attempt to fake ScenePresence in physics bucket sync

dsg
Robert Adams 2011-02-18 08:11:29 -08:00
parent c9c94a5f23
commit a25eac0a40
6 changed files with 41 additions and 51 deletions

View File

@ -364,12 +364,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public void QueueScenePresenceForTerseUpdate(ScenePresence presence) public void QueueScenePresenceForTerseUpdate(ScenePresence presence)
{ {
/*
lock (m_updateScenePresenceLock) lock (m_updateScenePresenceLock)
{ {
m_presenceUpdates[presence.UUID] = presence; m_presenceUpdates[presence.UUID] = presence;
} }
* */
} }
@ -410,17 +408,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
} }
/* List<ScenePresence> presenceUpdates = new List<ScenePresence>();
List<ScenePresence> presenceUpdates = null;
if (m_presenceUpdates.Count > 0) if (m_presenceUpdates.Count > 0)
{ {
lock (m_updateScenePresenceLock) lock (m_updateScenePresenceLock)
{ {
updated = true;
presenceUpdates = new List<ScenePresence>(m_presenceUpdates.Values); presenceUpdates = new List<ScenePresence>(m_presenceUpdates.Values);
m_presenceUpdates.Clear(); m_presenceUpdates.Clear();
} }
} }
* */
if (updated) if (updated)
{ {
@ -455,15 +452,26 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_primUpdatesPerBucketSender[bucketName](bucketName, primUpdates[bucketName]); m_primUpdatesPerBucketSender[bucketName](bucketName, primUpdates[bucketName]);
} }
} }
/*
if(presenceUpdates!=null){
foreach (ScenePresence presence in presenceUpdates) foreach (ScenePresence presence in presenceUpdates)
{ {
try try
{ {
if (!presence.IsDeleted) 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<string, BucketSyncInfo>();
sop.BucketSyncInfoList.Add("Physics", new BucketSyncInfo(DateTime.Now.Ticks, ActorID, "Physics"));
List<SceneObjectPart> lsop = new List<SceneObjectPart>();
lsop.Add(sop);
PrimUpdatesPhysicsBucketSender("Physics", lsop);
/*
OSDMap data = new OSDMap(10); OSDMap data = new OSDMap(10);
data["id"] = OSD.FromUUID(presence.UUID); data["id"] = OSD.FromUUID(presence.UUID);
// Do not include offset for appearance height. That will be handled by RegionSyncClient before sending to viewers // 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)); RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.UpdatedAvatar, OSDParser.SerializeJsonString(data));
m_server.EnqueuePresenceUpdate(presence.UUID, rsm.ToBytes()); m_server.EnqueuePresenceUpdate(presence.UUID, rsm.ToBytes());
*/
} }
} }
catch (Exception e) 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 // Indicate that the current batch of updates has been completed
Interlocked.Exchange(ref m_sendingUpdates, 0); Interlocked.Exchange(ref m_sendingUpdates, 0);

View File

@ -496,40 +496,11 @@ namespace OpenSim.Region.Framework.Scenes
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
//RA: Physics Engine //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<ISceneToPhysEngineServer>();
}
return m_sceneToPhysEngineSyncServer;
}
set { m_sceneToPhysEngineSyncServer = value; }
}
// depending on what mode we're in, the different modules are available
protected bool IsPhysEngineActor() protected bool IsPhysEngineActor()
{ {
if (PhysEngineToSceneConnectorModule != null) // turns out every actor needs the physics engine.
{ return true;
return this.PhysEngineToSceneConnectorModule.IsPhysEngineActor(); // return ActorSyncModule != null && ActorSyncModule.ActorType == DSGActorTypes.PhysicsEngine;
}
if (SceneToPhysEngineSyncServer != null)
{
return this.SceneToPhysEngineSyncServer.IsPhysEngineActor();
}
return false;
} }
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
@ -1513,8 +1484,6 @@ namespace OpenSim.Region.Framework.Scenes
RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>(); RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>();
RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>(); RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>();
ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>(); ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>();
PhysEngineToSceneConnectorModule = RequestModuleInterface<IPhysEngineToSceneConnectorModule>();
SceneToPhysEngineSyncServer = RequestModuleInterface<ISceneToPhysEngineServer>();
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
//SYMMETRIC SYNC (KittyL: started 12/23/2010) //SYMMETRIC SYNC (KittyL: started 12/23/2010)
@ -1723,7 +1692,7 @@ namespace OpenSim.Region.Framework.Scenes
int tmpPhysicsMS2 = Util.EnvironmentTickCount(); int tmpPhysicsMS2 = Util.EnvironmentTickCount();
// Do not simulate physics locally if this is a synced client // Do not simulate physics locally if this is a synced client
//if (!IsSyncedClient()) //if (!IsSyncedClient())
if (IsSyncedServer() || this.IsPhysEngineActor()) if (IsSyncedServer() || IsPhysEngineActor())
{ {
if ((m_frame % m_update_physics == 0) && m_physics_enabled) if ((m_frame % m_update_physics == 0) && m_physics_enabled)
m_sceneGraph.UpdatePreparePhysics(); m_sceneGraph.UpdatePreparePhysics();
@ -1732,7 +1701,7 @@ namespace OpenSim.Region.Framework.Scenes
// Do not simulate physics locally if this is a synced client // Do not simulate physics locally if this is a synced client
//if (!IsSyncedClient()) //if (!IsSyncedClient())
if (IsSyncedServer() || this.IsPhysEngineActor()) if (IsSyncedServer() || IsPhysEngineActor())
{ {
if (m_frame % m_update_entitymovement == 0) if (m_frame % m_update_entitymovement == 0)
m_sceneGraph.UpdateScenePresenceMovement(); m_sceneGraph.UpdateScenePresenceMovement();
@ -1743,7 +1712,7 @@ namespace OpenSim.Region.Framework.Scenes
int tmpPhysicsMS = Util.EnvironmentTickCount(); int tmpPhysicsMS = Util.EnvironmentTickCount();
// Do not simulate physics locally if this is a synced client // Do not simulate physics locally if this is a synced client
//if (!IsSyncedClient()) //if (!IsSyncedClient())
if (IsSyncedServer() || this.IsPhysEngineActor()) if (IsSyncedServer() || IsPhysEngineActor())
{ {
if (m_frame % m_update_physics == 0) if (m_frame % m_update_physics == 0)
{ {

View File

@ -5763,6 +5763,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (updatedProperties != null && updatedProperties.Count > 0) 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) foreach (SceneObjectPartProperties property in updatedProperties)
{ {
TaintBucketSyncInfo(property); TaintBucketSyncInfo(property);

View File

@ -548,6 +548,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
lock (m_scene.SyncRoot) lock (m_scene.SyncRoot)
actor.Velocity = value; actor.Velocity = value;
m_scene.PhysicsScene.AddPhysicsActorTaint(actor);
} }
catch (Exception e) catch (Exception e)
{ {
@ -2444,6 +2446,8 @@ namespace OpenSim.Region.Framework.Scenes
// REGION SYNC // REGION SYNC
if (m_scene.IsSyncedServer()) if (m_scene.IsSyncedServer())
{ {
// the old and new systems live in parallel
m_scene.RegionSyncModule.QueueScenePresenceForTerseUpdate(this);
m_scene.RegionSyncServerModule.QueuePresenceForTerseUpdate(this); m_scene.RegionSyncServerModule.QueuePresenceForTerseUpdate(this);
return; return;
} }
@ -3368,7 +3372,7 @@ namespace OpenSim.Region.Framework.Scenes
new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying); new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying);
scene.AddPhysicsActorTaint(m_physicsActor); scene.AddPhysicsActorTaint(m_physicsActor);
//m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
m_physicsActor.SubscribeEvents(500); m_physicsActor.SubscribeEvents(500);

View File

@ -121,6 +121,7 @@ public class PECharacter : PhysicsActor
public override Vector3 Position { public override Vector3 Position {
get { return _position; } get { return _position; }
set { _position = value; set { _position = value;
SyncUpdated = true;
} }
} }
public override float Mass { public override float Mass {
@ -133,6 +134,7 @@ public class PECharacter : PhysicsActor
public override Vector3 Force { public override Vector3 Force {
get { return _force; } get { return _force; }
set { _force = value; set { _force = value;
SyncUpdated = true;
} }
} }
@ -153,16 +155,19 @@ public class PECharacter : PhysicsActor
public override Vector3 Velocity { public override Vector3 Velocity {
get { return _velocity; } get { return _velocity; }
set { _velocity = value; set { _velocity = value;
// SyncUpdated = true;
} }
} }
public override Vector3 Torque { public override Vector3 Torque {
get { return _torque; } get { return _torque; }
set { _torque = value; set { _torque = value;
// SyncUpdated = true;
} }
} }
public override float CollisionScore { public override float CollisionScore {
get { return _collisionScore; } get { return _collisionScore; }
set { _collisionScore = value; set { _collisionScore = value;
// SyncUpdated = true;
} }
} }
public override Vector3 Acceleration { public override Vector3 Acceleration {

View File

@ -96,7 +96,10 @@ public class PEScene : PhysicsScene
return prim; return prim;
} }
public override void AddPhysicsActorTaint(PhysicsActor prim) { } public override void AddPhysicsActorTaint(PhysicsActor prim)
{
prim.SyncUpdated = true;
}
public override float Simulate(float timeStep) public override float Simulate(float timeStep)
{ {