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++;
//Get sync server info for Physics Engine actors
// string peServerAddr = scene.RegionInfo.RegionName + "_SceneToPESyncServerIP";
// m_peSyncServeraddr = syncConfig.GetString(peServerAddr, "127.0.0.1");
// string peServerPort = scene.RegionInfo.RegionName + "_SceneToPESyncServerPort";
// m_peSyncServerport = syncConfig.GetInt(peServerPort, DefaultPort);
// DefaultPort++;
string peServerAddr = scene.RegionInfo.RegionName + "_SceneToPESyncServerIP";
m_peSyncServeraddr = syncConfig.GetString(peServerAddr, "127.0.0.1");
string peServerPort = scene.RegionInfo.RegionName + "_SceneToPESyncServerPort";
m_peSyncServerport = syncConfig.GetInt(peServerPort, DefaultPort);
DefaultPort++;
// m_symsync = syncConfig.GetBoolean("SymSync", false);
@ -190,7 +190,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_sceneToSESyncServer.Start();
}
/*
m_peSyncServeraddr = m_scene.RegionInfo.PhysicsSyncServerAddress;
m_peSyncServerport = m_scene.RegionInfo.PhysicsSyncServerPort;
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.Start();
}
*/
//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_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()
@ -522,6 +520,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private int m_seSyncServerport;
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
//private bool m_symsync = false;

View File

@ -496,27 +496,27 @@ 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<ISceneToPhysEngineServer>();
}
return m_sceneToPhysEngineSyncServer;
}
set { m_sceneToPhysEngineSyncServer = value; }
}
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; }
}
protected bool IsPhysEngineActor()
{
@ -1505,8 +1505,8 @@ namespace OpenSim.Region.Framework.Scenes
//REGION SYNC
RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>();
RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>();
ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>();
PhysEngineToSceneConnectorModule = RequestModuleInterface<IPhysEngineToSceneConnectorModule>();
ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>();
PhysEngineToSceneConnectorModule = RequestModuleInterface<IPhysEngineToSceneConnectorModule>();
SceneToPhysEngineSyncServer = RequestModuleInterface<ISceneToPhysEngineServer>();
//////////////////////////////////////////////////////////////////////
//SYMMETRIC SYNC (KittyL: started 12/23/2010)

View File

@ -2443,14 +2443,8 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart localPart = GetSceneObjectPart(partUUID);
if (localPart == null)
{
// 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;
m_log.Warn("No SOP found: UUID -- " + partUUID);
return Scene.ObjectUpdateResult.Unchanged;
}
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>();
// 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 ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
@ -2456,14 +2448,10 @@ namespace OpenSim.Region.Framework.Scenes
if (m_scene.IsSyncedServer())
{
m_scene.RegionSyncServerModule.QueuePresenceForTerseUpdate(this);
}
if (m_scene.RegionSyncModule.Active)
{
m_sop.PhysicsRequestingTerseUpdate();
m_scene.RegionSyncModule.QueueSceneObjectPartForUpdate(m_sop);
}
if (m_scene.IsSyncedServer() || m_scene.RegionSyncModule.Active)
// this.PhysicsRequestingTerseUpdate();
// m_scene.RegionSyncModule.QueueSceneObjectPartForUpdate(this);
return;
}
m_perfMonMS = Util.EnvironmentTickCount();
@ -3391,20 +3379,6 @@ 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(),
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)

View File

@ -199,7 +199,7 @@ namespace OpenSim.Region.Physics.Manager
get { return m_UUID; }
}
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";
// set to true of prim is updated
public bool SyncUpdated;
@ -219,7 +219,7 @@ namespace OpenSim.Region.Physics.Manager
public abstract void LockAngularMotion(Vector3 axis);
public void RequestPhysicsterseUpdate()
public virtual void RequestPhysicsterseUpdate()
{
// Make a temporary copy of the event to avoid possibility of
// a race condition if the last subscriber unsubscribes

View File

@ -203,6 +203,23 @@ namespace OpenSim.Region.Physics.OdePlugin
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
{
get { return (int) ActorTypes.Agent; }
@ -410,6 +427,7 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return _position; }
set
{
base.ChangingActorID = RegionSyncServerModule.ActorID;
if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
{
if (value.IsFinite())
@ -455,6 +473,7 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
set
{
base.ChangingActorID = RegionSyncServerModule.ActorID;
if (value.IsFinite())
{
m_pidControllerActive = true;
@ -776,6 +795,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_pidControllerActive = true;
_target_velocity = value;
base.ChangingActorID = RegionSyncServerModule.ActorID;
}
else
{
@ -833,6 +853,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (force.IsFinite())
{
base.ChangingActorID = RegionSyncServerModule.ActorID;
if (pushforce)
{
m_pidControllerActive = false;

View File

@ -121,7 +121,6 @@ public class PECharacter : PhysicsActor
public override Vector3 Position {
get { return _position; }
set { _position = value;
SyncUpdated = true;
}
}
public override float Mass {
@ -134,7 +133,6 @@ public class PECharacter : PhysicsActor
public override Vector3 Force {
get { return _force; }
set { _force = value;
SyncUpdated = true;
}
}
@ -155,19 +153,16 @@ 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 {

View File

@ -96,38 +96,43 @@ public class PEScene : PhysicsScene
return prim;
}
public override void AddPhysicsActorTaint(PhysicsActor prim)
{
prim.SyncUpdated = true;
}
public override void AddPhysicsActorTaint(PhysicsActor prim) { }
public override float Simulate(float timeStep)
{
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
lock (m_prims)
// if we are a physics engine server, send update information
if (SceneToPhysEngineSyncServer.IsPhysEngineScene2S())
{
foreach (PEPrim prim in m_prims)
{
// 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)
if (SceneToPhysEngineSyncServer.IsActivePhysEngineScene2S())
{
// 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;
actor.RequestPhysicsterseUpdate();
foreach (PEPrim prim in m_prims)
{
// 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