Using PhysActor sync for avatars and bucket sync for prims. Working with avatars kicking physical objects

dsg
Robert Adams 2011-02-28 14:09:19 -08:00
parent 11db34313d
commit 400c9b5293
8 changed files with 90 additions and 98 deletions

View File

@ -118,11 +118,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
DefaultPort++; DefaultPort++;
//Get sync server info for Physics Engine actors //Get sync server info for Physics Engine actors
// string peServerAddr = scene.RegionInfo.RegionName + "_SceneToPESyncServerIP"; string peServerAddr = scene.RegionInfo.RegionName + "_SceneToPESyncServerIP";
// m_peSyncServeraddr = syncConfig.GetString(peServerAddr, "127.0.0.1"); m_peSyncServeraddr = syncConfig.GetString(peServerAddr, "127.0.0.1");
// string peServerPort = scene.RegionInfo.RegionName + "_SceneToPESyncServerPort"; string peServerPort = scene.RegionInfo.RegionName + "_SceneToPESyncServerPort";
// m_peSyncServerport = syncConfig.GetInt(peServerPort, DefaultPort); m_peSyncServerport = syncConfig.GetInt(peServerPort, DefaultPort);
// DefaultPort++; DefaultPort++;
// m_symsync = syncConfig.GetBoolean("SymSync", false); // m_symsync = syncConfig.GetBoolean("SymSync", false);
@ -190,7 +190,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_sceneToSESyncServer.Start(); m_sceneToSESyncServer.Start();
} }
/*
m_peSyncServeraddr = m_scene.RegionInfo.PhysicsSyncServerAddress; m_peSyncServeraddr = m_scene.RegionInfo.PhysicsSyncServerAddress;
m_peSyncServerport = m_scene.RegionInfo.PhysicsSyncServerPort; m_peSyncServerport = m_scene.RegionInfo.PhysicsSyncServerPort;
if (!m_peSyncServeraddr.Equals(IPAddrUnknown) && m_peSyncServerport != PortUnknown) if (!m_peSyncServeraddr.Equals(IPAddrUnknown) && m_peSyncServerport != PortUnknown)
@ -200,7 +199,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_sceneToPESyncServer = new SceneToPhysEngineSyncServer(m_scene, m_peSyncServeraddr, m_peSyncServerport); m_sceneToPESyncServer = new SceneToPhysEngineSyncServer(m_scene, m_peSyncServeraddr, m_peSyncServerport);
m_sceneToPESyncServer.Start(); m_sceneToPESyncServer.Start();
} }
*/
//m_log.Warn("[REGION SYNC SERVER MODULE] Post-Initialised"); //m_log.Warn("[REGION SYNC SERVER MODULE] Post-Initialised");
} }
@ -273,7 +271,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
m_presenceUpdates[presence.UUID] = presence; m_presenceUpdates[presence.UUID] = presence;
} }
m_log.WarnFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString()); m_log.DebugFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString());
} }
public void SendUpdates() public void SendUpdates()
@ -522,6 +520,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private int m_seSyncServerport; private int m_seSyncServerport;
private SceneToScriptEngineSyncServer m_sceneToSESyncServer = null; private SceneToScriptEngineSyncServer m_sceneToSESyncServer = null;
//Sync-server for physics engines
private string m_peSyncServeraddr;
private int m_peSyncServerport;
private SceneToPhysEngineSyncServer m_sceneToPESyncServer = null;
//a boolean variable to indicate in symmetric sync is configured //a boolean variable to indicate in symmetric sync is configured
//private bool m_symsync = false; //private bool m_symsync = false;

View File

@ -496,27 +496,27 @@ namespace OpenSim.Region.Framework.Scenes
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
//RA: Physics Engine //RA: Physics Engine
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
protected IPhysEngineToSceneConnectorModule m_physEngineToSceneConnectorModule = null; protected IPhysEngineToSceneConnectorModule m_physEngineToSceneConnectorModule = null;
public IPhysEngineToSceneConnectorModule PhysEngineToSceneConnectorModule public IPhysEngineToSceneConnectorModule PhysEngineToSceneConnectorModule
{ {
get { return m_physEngineToSceneConnectorModule; } get { return m_physEngineToSceneConnectorModule; }
set { m_physEngineToSceneConnectorModule = value; } set { m_physEngineToSceneConnectorModule = value; }
} }
protected ISceneToPhysEngineServer m_sceneToPhysEngineSyncServer = null; protected ISceneToPhysEngineServer m_sceneToPhysEngineSyncServer = null;
public ISceneToPhysEngineServer SceneToPhysEngineSyncServer public ISceneToPhysEngineServer SceneToPhysEngineSyncServer
{ {
get get
{ {
if (m_sceneToPhysEngineSyncServer == null) if (m_sceneToPhysEngineSyncServer == null)
{ {
// kludge since this module is loaded in postInitialize // kludge since this module is loaded in postInitialize
m_sceneToPhysEngineSyncServer = RequestModuleInterface<ISceneToPhysEngineServer>(); m_sceneToPhysEngineSyncServer = RequestModuleInterface<ISceneToPhysEngineServer>();
} }
return m_sceneToPhysEngineSyncServer; return m_sceneToPhysEngineSyncServer;
} }
set { m_sceneToPhysEngineSyncServer = value; } set { m_sceneToPhysEngineSyncServer = value; }
} }
protected bool IsPhysEngineActor() protected bool IsPhysEngineActor()
{ {
@ -1505,8 +1505,8 @@ namespace OpenSim.Region.Framework.Scenes
//REGION SYNC //REGION SYNC
RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>(); RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>();
RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>(); RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>();
ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>(); ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>();
PhysEngineToSceneConnectorModule = RequestModuleInterface<IPhysEngineToSceneConnectorModule>(); PhysEngineToSceneConnectorModule = RequestModuleInterface<IPhysEngineToSceneConnectorModule>();
SceneToPhysEngineSyncServer = RequestModuleInterface<ISceneToPhysEngineServer>(); SceneToPhysEngineSyncServer = RequestModuleInterface<ISceneToPhysEngineServer>();
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
//SYMMETRIC SYNC (KittyL: started 12/23/2010) //SYMMETRIC SYNC (KittyL: started 12/23/2010)

View File

@ -2443,14 +2443,8 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart localPart = GetSceneObjectPart(partUUID); SceneObjectPart localPart = GetSceneObjectPart(partUUID);
if (localPart == null) if (localPart == null)
{ {
// it's not a prim. Maybe it's a ScenePresence m_log.Warn("No SOP found: UUID -- " + partUUID);
ScenePresence sp; return Scene.ObjectUpdateResult.Unchanged;
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); return localPart.UpdateBucketProperties(bucketName, updatedPart, bucketSyncInfo);
} }

View File

@ -112,14 +112,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
// 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<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
@ -2456,14 +2448,10 @@ namespace OpenSim.Region.Framework.Scenes
if (m_scene.IsSyncedServer()) if (m_scene.IsSyncedServer())
{ {
m_scene.RegionSyncServerModule.QueuePresenceForTerseUpdate(this); m_scene.RegionSyncServerModule.QueuePresenceForTerseUpdate(this);
} // this.PhysicsRequestingTerseUpdate();
if (m_scene.RegionSyncModule.Active) // m_scene.RegionSyncModule.QueueSceneObjectPartForUpdate(this);
{
m_sop.PhysicsRequestingTerseUpdate();
m_scene.RegionSyncModule.QueueSceneObjectPartForUpdate(m_sop);
}
if (m_scene.IsSyncedServer() || m_scene.RegionSyncModule.Active)
return; return;
}
m_perfMonMS = Util.EnvironmentTickCount(); m_perfMonMS = Util.EnvironmentTickCount();
@ -3391,20 +3379,6 @@ namespace OpenSim.Region.Framework.Scenes
m_physicsActor.SubscribeEvents(500); m_physicsActor.SubscribeEvents(500);
m_physicsActor.LocalID = LocalId; m_physicsActor.LocalID = LocalId;
m_physicsActor.UUID = this.UUID; m_physicsActor.UUID = this.UUID;
m_sop = new SceneObjectPart(this.UUID, new PrimitiveBaseShape(),
new Vector3(1f,1f,1f), Quaternion.Identity, new Vector3(2f, 2f, 2f));
// Vector3.Zero, Quaternion.Identity, Vector3.Zero);
m_sop.PhysActor = m_physicsActor;
m_sop.InitializeBucketSyncInfo();
// pull the values from the PhysActor into the SOP
Vector3 temp = m_sop.GroupPosition;
temp = m_sop.OffsetPosition;
Quaternion tempq = m_sop.RotationOffset;
m_sog = new SceneObjectGroup(m_sop, true);
// m_sog.Scene = m_scene;
m_sog.AttachToSceneBySync(m_scene);
} }
private void OutOfBoundsCall(Vector3 pos) private void OutOfBoundsCall(Vector3 pos)

View File

@ -199,7 +199,7 @@ namespace OpenSim.Region.Physics.Manager
get { return m_UUID; } get { return m_UUID; }
} }
public PhysActorLastValues lastValues; public PhysActorLastValues lastValues;
// ID of actor which last updated the values. Send if I did the change. // ID of actor which last updated the values. Send if I did the change.
public string ChangingActorID = "YY"; public string ChangingActorID = "YY";
// set to true of prim is updated // set to true of prim is updated
public bool SyncUpdated; public bool SyncUpdated;
@ -219,7 +219,7 @@ namespace OpenSim.Region.Physics.Manager
public abstract void LockAngularMotion(Vector3 axis); public abstract void LockAngularMotion(Vector3 axis);
public void RequestPhysicsterseUpdate() public virtual void RequestPhysicsterseUpdate()
{ {
// Make a temporary copy of the event to avoid possibility of // Make a temporary copy of the event to avoid possibility of
// a race condition if the last subscriber unsubscribes // a race condition if the last subscriber unsubscribes

View File

@ -203,6 +203,23 @@ namespace OpenSim.Region.Physics.OdePlugin
m_name = avName; m_name = avName;
} }
public override void RequestPhysicsterseUpdate()
{
if (PhysEngineToSceneConnectorModule.IsPhysEngineActorS)
{
// if the values have changed and it was I who changed them, send an update
if (this.lastValues.Changed(this) && ChangingActorID == RegionSyncServerModule.ActorID)
{
// m_log.DebugFormat("[ODE CHARACTER]: Sending terse update for {0}", LocalID);
PhysEngineToSceneConnectorModule.RouteUpdate(this);
}
}
else
{
base.RequestPhysicsterseUpdate();
}
}
public override int PhysicsActorType public override int PhysicsActorType
{ {
get { return (int) ActorTypes.Agent; } get { return (int) ActorTypes.Agent; }
@ -410,6 +427,7 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return _position; } get { return _position; }
set set
{ {
base.ChangingActorID = RegionSyncServerModule.ActorID;
if (Body == IntPtr.Zero || Shell == IntPtr.Zero) if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
{ {
if (value.IsFinite()) if (value.IsFinite())
@ -455,6 +473,7 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
set set
{ {
base.ChangingActorID = RegionSyncServerModule.ActorID;
if (value.IsFinite()) if (value.IsFinite())
{ {
m_pidControllerActive = true; m_pidControllerActive = true;
@ -776,6 +795,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
m_pidControllerActive = true; m_pidControllerActive = true;
_target_velocity = value; _target_velocity = value;
base.ChangingActorID = RegionSyncServerModule.ActorID;
} }
else else
{ {
@ -833,6 +853,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (force.IsFinite()) if (force.IsFinite())
{ {
base.ChangingActorID = RegionSyncServerModule.ActorID;
if (pushforce) if (pushforce)
{ {
m_pidControllerActive = false; m_pidControllerActive = false;

View File

@ -121,7 +121,6 @@ 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 {
@ -134,7 +133,6 @@ 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;
} }
} }
@ -155,19 +153,16 @@ 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,38 +96,43 @@ 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)
{ {
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count); // if we are a physics engine server, send update information
lock (m_prims) if (SceneToPhysEngineSyncServer.IsPhysEngineScene2S())
{ {
foreach (PEPrim prim in m_prims) if (SceneToPhysEngineSyncServer.IsActivePhysEngineScene2S())
{
// if the values have changed and it was I who changed them, send an update
if (prim.SyncUpdated)
{
prim.SyncUpdated = false;
prim.RequestPhysicsterseUpdate();
}
}
}
lock (m_avatars)
{
foreach (PECharacter actor in m_avatars)
{ {
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count); // m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
// if the values have changed and it was I who changed them, send an update /*
if (actor.SyncUpdated) lock (m_prims)
{ {
actor.SyncUpdated = false; foreach (PEPrim prim in m_prims)
actor.RequestPhysicsterseUpdate(); {
// if the values have changed and it was I who changed them, send an update
if (prim.ChangingActorID == RegionSyncServerModule.ActorID && prim.lastValues.Changed(prim))
{
SceneToPhysEngineSyncServer.RouteUpdate(prim);
}
}
}
*/
lock (m_avatars)
{
foreach (PECharacter actor in m_avatars)
{
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
// if the values have changed and it was I who changed them, send an update
if (actor.ChangingActorID == RegionSyncServerModule.ActorID && actor.lastValues.Changed(actor))
{
SceneToPhysEngineSyncServer.RouteUpdate(actor);
}
}
} }
} }
return 60f;
} }
/* /*
// code borrowed from BasicPhysics to do just avatar movement // code borrowed from BasicPhysics to do just avatar movement