physics messages sync'ing both ways. Value change not happening

dsg
Robert Adams 2010-12-14 15:31:00 -08:00
parent a036426f18
commit 7c6bca1668
17 changed files with 171 additions and 66 deletions

View File

@ -375,20 +375,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
uint localID = data["localID"].AsUInteger();
// m_log.DebugFormat("{0}: HandlPhysUpdateAttributes for {1}", LogHeader, localID);
SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(localID);
if (sop != null)
PhysicsActor pa = FindPhysicsActor(localID);
if (pa != null)
{
sop.PhysActor.Size = data["size"].AsVector3();
sop.PhysActor.Position = data["position"].AsVector3();
sop.PhysActor.Force = data["force"].AsVector3();
sop.PhysActor.Velocity = data["velocity"].AsVector3();
sop.PhysActor.Torque = data["torque"].AsVector3();
sop.PhysActor.Orientation = data["orientantion"].AsQuaternion();
sop.PhysActor.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
sop.PhysActor.Flying = data["flying"].AsBoolean(); // receive??
sop.PhysActor.Kinematic = data["kinematic"].AsBoolean(); // receive??
sop.PhysActor.Buoyancy = (float)(data["buoyancy"].AsReal());
sop.PhysActor.Shape = sop.Shape;
pa.Size = data["size"].AsVector3();
pa.Position = data["position"].AsVector3();
pa.Force = data["force"].AsVector3();
pa.Velocity = data["velocity"].AsVector3();
pa.Torque = data["torque"].AsVector3();
pa.Orientation = data["orientantion"].AsQuaternion();
pa.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
pa.Flying = data["flying"].AsBoolean(); // receive??
pa.Kinematic = data["kinematic"].AsBoolean(); // receive??
pa.Buoyancy = (float)(data["buoyancy"].AsReal());
SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(localID);
if (sop != null)
{
pa.Shape = sop.Shape;
}
}
else
{
@ -404,9 +408,25 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return;
}
// Find the physics actor whether it is an object or a scene presence
private PhysicsActor FindPhysicsActor(uint localID)
{
SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(localID);
if (sop != null)
{
return sop.PhysActor;
}
ScenePresence sp = m_validLocalScene.GetScenePresence(localID);
if (sp != null)
{
return sp.PhysicsActor;
}
return null;
}
public void SendPhysUpdateAttributes(PhysicsActor pa)
{
m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.LocalID);
// m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.LocalID);
OSDMap data = new OSDMap(9);
data["localID"] = OSD.FromUInteger(pa.LocalID);
data["size"] = OSD.FromVector3(pa.Size);

View File

@ -133,6 +133,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
InstallInterfaces();
SyncStart(null); // fake a 'phys start' to get things going
m_log.Warn(LogHeader + " Initialised");
// collect all the scenes for later routing
@ -198,15 +200,28 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
}
public static bool IsPhysEngineScene
bool IPhysEngineToSceneConnectorModule.IsPhysEngineActor()
{
get { return SceneToPhysEngineSyncServer.IsPhysEngineScene; }
return PhysEngineToSceneConnectorModule.IsPhysEngineActorS;
}
public static bool IsActivePhysEngineScene
bool IPhysEngineToSceneConnectorModule.IsPhysEngineScene()
{
get { return SceneToPhysEngineSyncServer.IsActivePhysEngineScene; }
return PhysEngineToSceneConnectorModule.IsPhysEngineSceneS;
}
public static bool IsPhysEngineActor
bool IPhysEngineToSceneConnectorModule.IsActivePhysEngineScene()
{
return PhysEngineToSceneConnectorModule.IsActivePhysEngineSceneS;
}
public static bool IsPhysEngineSceneS
{
get { return SceneToPhysEngineSyncServer.IsPhysEngineScene2S(); }
}
public static bool IsActivePhysEngineSceneS
{
get { return SceneToPhysEngineSyncServer.IsActivePhysEngineScene2S(); }
}
public static bool IsPhysEngineActorS
{
get { return (m_activeActors != 0); }
}
@ -249,7 +264,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
else
{
Console.WriteLine("RouteUpdate: no SOP found");
Console.WriteLine("RouteUpdate: no SOP found for {0}", pa.LocalID);
}
return;
}

View File

@ -307,6 +307,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//RegionSyncMessage.HandleSuccess(LogHeader, msg, String.Format("Object \"{0}\" ({1}) ({1}) updated.", sog.Name, sog.UUID.ToString(), sog.LocalId.ToString()));
//else
//RegionSyncMessage.HandleSuccess(LogHeader, msg, String.Format("Object \"{0}\" ({1}) ({1}) added.", sog.Name, sog.UUID.ToString(), sog.LocalId.ToString()));
sog.ScheduleGroupForFullUpdate();
return;
}
@ -351,6 +352,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
UUID agentID = data["agentID"].AsUUID();
string first = data["first"].AsString();
string last = data["last"].AsString();
uint localID = data["localID"].AsUInteger();
Vector3 startPos = data["startPos"].AsVector3();
if (agentID == null || agentID == UUID.Zero || first == null || last == null || startPos == null)
{
@ -384,6 +386,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
else
{
sp.IsSyncedAvatar = true;
m_log.DebugFormat("{0}: Setting avatar local ID to {1}", LogHeader, localID);
sp.LocalId = localID;
if (sp.PhysicsActor != null)
{
sp.PhysicsActor.LocalID = localID;
}
}
//RegionSyncMessage.HandlerDebug(LogHeader, msg, String.Format("Added new remote avatar \"{0}\" ({1})", first + " " + last, agentID));
RegionSyncMessage.HandleSuccess(LogHeader, msg, String.Format("Added new remote avatar \"{0}\" ({1})", first + " " + last, agentID));

View File

@ -331,6 +331,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// Let the client managers know about this avatar
OSDMap data = new OSDMap(1);
data["agentID"] = OSD.FromUUID(presence.ControllingClient.AgentId);
data["localID"] = OSD.FromUInteger(presence.LocalId);
data["first"] = OSD.FromString(presence.ControllingClient.FirstName);
data["last"] = OSD.FromString(presence.ControllingClient.LastName);
data["startPos"] = OSD.FromVector3(presence.ControllingClient.StartPos);

View File

@ -701,6 +701,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// Let the client managers know that a new agent has connected
OSDMap data = new OSDMap(1);
data["agentID"] = OSD.FromUUID(client.AgentId);
data["localID"] = OSD.FromUInteger(m_scene.GetScenePresence(client.AgentId).LocalId);
data["first"] = OSD.FromString(client.FirstName);
data["last"] = OSD.FromString(client.LastName);
data["startPos"] = OSD.FromVector3(client.StartPos);

View File

@ -318,20 +318,20 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
try
{
uint localID = data["localID"].AsUInteger();
m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, localID);
SceneObjectPart sop = m_scene.GetSceneObjectPart(localID);
if (sop != null)
// m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, localID);
PhysicsActor pa = FindPhysicsActor(localID);
if (pa != null)
{
sop.PhysActor.Size = data["size"].AsVector3();
sop.PhysActor.Position = data["position"].AsVector3();
sop.PhysActor.Force = data["force"].AsVector3();
sop.PhysActor.Velocity = data["velocity"].AsVector3();
sop.PhysActor.Torque = data["torque"].AsVector3();
sop.PhysActor.Orientation = data["orientantion"].AsQuaternion();
sop.PhysActor.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
sop.PhysActor.Flying = data["flying"].AsBoolean(); // receive??
sop.PhysActor.Kinematic = data["kinematic"].AsBoolean(); // receive??
sop.PhysActor.Buoyancy = (float)(data["buoyancy"].AsReal());
pa.Size = data["size"].AsVector3();
pa.Position = data["position"].AsVector3();
pa.Force = data["force"].AsVector3();
pa.Velocity = data["velocity"].AsVector3();
pa.Torque = data["torque"].AsVector3();
pa.Orientation = data["orientantion"].AsQuaternion();
pa.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
pa.Flying = data["flying"].AsBoolean(); // receive??
pa.Kinematic = data["kinematic"].AsBoolean(); // receive??
pa.Buoyancy = (float)(data["buoyancy"].AsReal());
}
else
{
@ -347,6 +347,22 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return;
}
// Find the physics actor whether it is an object or a scene presence
private PhysicsActor FindPhysicsActor(uint localID)
{
SceneObjectPart sop = m_scene.GetSceneObjectPart(localID);
if (sop != null)
{
return sop.PhysActor;
}
ScenePresence sp = m_scene.GetScenePresence(localID);
if (sp != null)
{
return sp.PhysicsActor;
}
return null;
}
public void SendPhysUpdateAttributes(PhysicsActor pa)
{
// m_log.DebugFormat("{0}: sending PhysUpdateAttributes for {1}", LogHeader, pa.LocalID);

View File

@ -182,19 +182,23 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
#endregion
// Check if any of the client views are in a connected state
public bool IsPhysEngineScene() { return SceneToPhysEngineSyncServer.IsPhysEngineScene2S(); }
public bool IsActivePhysEngineScene() { return SceneToPhysEngineSyncServer.IsActivePhysEngineScene2S(); }
public bool IsPhysEngineActor() { return SceneToPhysEngineSyncServer.IsPhysEngineActorS; }
public bool Synced
{
get { return (m_physEngineConnectors.Count > 0); }
}
public static bool IsPhysEngineScene
public static bool IsPhysEngineSceneS
{
get { return (SceneToPhysEngineSyncServer.m_syncServerInitialized > 0); }
}
public static bool IsPhysEngineScene2()
public static bool IsPhysEngineScene2S()
{
return (SceneToPhysEngineSyncServer.m_syncServerInitialized > 0);
}
public static bool IsActivePhysEngineScene
public static bool IsActivePhysEngineSceneS
{
get {
System.Console.WriteLine("IsActivePhysEngineScene: si={0} tc={1}",
@ -204,14 +208,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
&& SceneToPhysEngineSyncServer.m_totalConnections > 0);
}
}
public static bool IsActivePhysEngineScene2()
public static bool IsActivePhysEngineScene2S()
{
return (SceneToPhysEngineSyncServer.m_syncServerInitialized > 0
&& SceneToPhysEngineSyncServer.m_totalConnections > 0);
}
public static bool IsPhysEngineActor
public static bool IsPhysEngineActorS
{
get { return PhysEngineToSceneConnectorModule.IsPhysEngineActor; }
get { return PhysEngineToSceneConnectorModule.IsPhysEngineActorS; }
}
/// <summary>
@ -238,6 +242,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
s = ss;
break;
}
else
{
ScenePresence sp = ss.GetScenePresence(pa.LocalID);
if (sp != null)
{
s = ss;
break;
}
}
}
if (s != null)
{
@ -252,7 +265,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
else
{
Console.WriteLine("RouteUpdate: no SOP for update");
Console.WriteLine("RouteUpdate: no SOP for update of {0}", pa.LocalID);
}
return;
}

View File

@ -37,9 +37,9 @@ namespace OpenSim.Region.Framework.Interfaces
//the interface for Scene to sync with Script Engine
public interface IPhysEngineToSceneConnectorModule
{
// static bool IsPhysEngineScene { get; }
// static bool IsActivePhysEngineScene { get; }
// static bool IsPhysEngineActor { get; }
bool IsPhysEngineScene();
bool IsActivePhysEngineScene();
bool IsPhysEngineActor();
bool DebugWithViewer { get; }
void SendUpdate(PhysicsActor pa);
}

View File

@ -37,9 +37,9 @@ namespace OpenSim.Region.Framework.Interfaces
//the interface for Scene to sync with Script Engine
public interface ISceneToPhysEngineServer
{
// static bool IsPhysEngineScene { get; }
// static bool IsActivePhysEngineScene { get; }
// static bool IsPhysEngineActor { get; }
bool IsPhysEngineScene();
bool IsActivePhysEngineScene();
bool IsPhysEngineActor();
void SendUpdate(PhysicsActor pa);
}
}

View File

@ -427,6 +427,20 @@ namespace OpenSim.Region.Framework.Scenes
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;
}
///////////////////////////////////////////////////////////////////////////////////////////////
//This function should only be called by an actor who's local Scene is just a cache of the authorative Scene.
@ -1670,7 +1684,7 @@ namespace OpenSim.Region.Framework.Scenes
int tmpPhysicsMS2 = Util.EnvironmentTickCount();
// Do not simulate physics locally if this is a synced client
if (!IsSyncedClient())
if (!IsSyncedClient() || this.IsPhysEngineActor())
{
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
m_sceneGraph.UpdatePreparePhysics();
@ -1678,7 +1692,7 @@ namespace OpenSim.Region.Framework.Scenes
physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
// Do not simulate physics locally if this is a synced client
if (!IsSyncedClient())
if (!IsSyncedClient() || this.IsPhysEngineActor())
{
if (m_frame % m_update_entitymovement == 0)
m_sceneGraph.UpdateScenePresenceMovement();
@ -1686,7 +1700,7 @@ namespace OpenSim.Region.Framework.Scenes
int tmpPhysicsMS = Util.EnvironmentTickCount();
// Do not simulate physics locally if this is a synced client
if (!IsSyncedClient())
if (!IsSyncedClient() || this.IsPhysEngineActor())
{
if (m_frame % m_update_physics == 0)
{

View File

@ -121,6 +121,7 @@ namespace OpenSim.Region.Physics.Manager
/// </summary>
public struct PhysActorLastValues
{
public uint updateTime;
public uint localID;
public Vector3 size;
public Vector3 position;
@ -176,7 +177,11 @@ namespace OpenSim.Region.Physics.Manager
public abstract PrimitiveBaseShape Shape { set; }
// RA: used to be abstract but changed to allow 'get' without changing all the phys engines
public virtual uint LocalID { set { return; } get { return 0; } }
uint m_baseLocalID;
public virtual uint LocalID {
set { m_baseLocalID = value; }
get { return m_baseLocalID; }
}
public PhysActorLastValues lastValues;
public abstract bool Grabbed { set; }

View File

@ -205,7 +205,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void RequestPhysicsterseUpdate()
{
if (PhysEngineToSceneConnectorModule.IsPhysEngineActor)
if (PhysEngineToSceneConnectorModule.IsPhysEngineActorS)
{
m_log.DebugFormat("[ODE CHARACTER]: Sending terse update for {0}", LocalID);
PhysEngineToSceneConnectorModule.RouteUpdate(this);
@ -234,6 +234,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override uint LocalID
{
set { m_localID = value; }
get { return m_localID; }
}
public override bool Grabbed
@ -1153,7 +1154,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!m_lastUpdateSent)
{
m_lastUpdateSent = true;
//base.RequestPhysicsterseUpdate();
// base.RequestPhysicsterseUpdate();
}
}
@ -1191,6 +1192,11 @@ namespace OpenSim.Region.Physics.OdePlugin
m_hackSentFall = false;
}
}
if (!m_lastUpdateSent)
{
m_log.DebugFormat("[ODE CHARACTER] UpdatePositionAndVelocity");
this.RequestPhysicsterseUpdate();
}
}
/// <summary>
@ -1357,7 +1363,8 @@ namespace OpenSim.Region.Physics.OdePlugin
_position.Z = m_taintPosition.Z;
}
}
Console.WriteLine("ODECharacter: ProcessTaints: doing update");
this.RequestPhysicsterseUpdate();
}
internal void AddCollisionFrameTime(int p)

View File

@ -256,9 +256,10 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void RequestPhysicsterseUpdate()
{
if (PhysEngineToSceneConnectorModule.IsPhysEngineActor)
if (PhysEngineToSceneConnectorModule.IsPhysEngineActorS)
{
PhysEngineToSceneConnectorModule.RouteUpdate(this);
if (this.lastValues.Changed(this))
PhysEngineToSceneConnectorModule.RouteUpdate(this);
}
else
{
@ -283,6 +284,7 @@ namespace OpenSim.Region.Physics.OdePlugin
set {
//m_log.Info("[PHYSICS]: Setting TrackerID: " + value);
m_localID = value; }
get { return m_localID; }
}
public override bool Grabbed
@ -2655,7 +2657,7 @@ Console.WriteLine(" JointCreateFixed");
_position = l_position;
//_parent_scene.remActivePrim(this);
if (_parent == null)
RequestPhysicsterseUpdate();
this.RequestPhysicsterseUpdate();
return;
}
else
@ -2690,7 +2692,7 @@ Console.WriteLine(" JointCreateFixed");
m_rotationalVelocity.Z = 0;
if (_parent == null)
RequestPhysicsterseUpdate();
this.RequestPhysicsterseUpdate();
m_throttleUpdates = false;
throttleCounter = 0;
@ -2743,7 +2745,7 @@ Console.WriteLine(" JointCreateFixed");
if (_parent == null)
{
RequestPhysicsterseUpdate();
this.RequestPhysicsterseUpdate();
}
m_lastUpdateSent = true;
@ -2755,7 +2757,7 @@ Console.WriteLine(" JointCreateFixed");
{
if (_parent == null)
{
RequestPhysicsterseUpdate();
this.RequestPhysicsterseUpdate();
}
}
@ -2790,7 +2792,7 @@ Console.WriteLine(" JointCreateFixed");
{
if (_parent == null)
{
RequestPhysicsterseUpdate();
this.RequestPhysicsterseUpdate();
}
}
else

View File

@ -127,7 +127,7 @@ public sealed class PEPrim : PhysicsActor
public override Vector3 Position {
get { return _position; }
set { _position = value;
m_log.Debug("[RPE] PEPrim set Position");
// m_log.Debug("[RPE] PEPrim set Position");
Prop.Set(_localID, PropType.Position, _position);
}
}
@ -137,7 +137,7 @@ public sealed class PEPrim : PhysicsActor
public override Vector3 Force {
get { return _force; }
set { _force = value;
m_log.Debug("[RPE] PEPrim set Force");
// m_log.Debug("[RPE] PEPrim set Force");
Prop.Set(_localID, PropType.Force, _force);
}
}

View File

@ -101,9 +101,9 @@ public class PEScene : PhysicsScene
public override float Simulate(float timeStep)
{
// if we are a physics engine server, send update information
if (SceneToPhysEngineSyncServer.IsPhysEngineScene2())
if (SceneToPhysEngineSyncServer.IsPhysEngineScene2S())
{
if (SceneToPhysEngineSyncServer.IsActivePhysEngineScene2())
if (SceneToPhysEngineSyncServer.IsActivePhysEngineScene2S())
{
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
foreach (PEPrim prim in m_prims)
@ -115,8 +115,11 @@ public class PEScene : PhysicsScene
}
foreach (PECharacter actor in m_avatars)
{
m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
SceneToPhysEngineSyncServer.RouteUpdate(actor);
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
if (actor.lastValues.Changed(actor))
{
SceneToPhysEngineSyncServer.RouteUpdate(actor);
}
}
}
return 60f;

Binary file not shown.

Binary file not shown.