From bfb1068ecaf32b847738ef73376eea442d392f9c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 31 May 2011 17:14:24 -0700 Subject: [PATCH 1/3] Fix for avatar jiggling in place and scooting after stop --- .../PhysEngineToSceneConnector.cs | 2 ++ .../RegionSyncModule/RegionSyncClient.cs | 32 +++++++++++-------- .../Region/Physics/OdePlugin/ODECharacter.cs | 17 ++++++++-- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs index 6bb3e3187d..48f5cafdfc 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs @@ -353,6 +353,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // pa.Size = data["size"].AsVector3(); pa.Position = data["position"].AsVector3(); pa.Force = data["force"].AsVector3(); + // m_log.DebugFormat("{0}: HandlePhysUpdateAttributes: receiving velocity = {1}", LogHeader, data["velocity"].AsVector3()); pa.Velocity = data["velocity"].AsVector3(); pa.RotationalVelocity = data["rotationalVelocity"].AsVector3(); pa.Acceleration = data["acceleration"].AsVector3(); @@ -416,6 +417,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["position"] = OSD.FromVector3(pa.Position); data["force"] = OSD.FromVector3(pa.Force); data["velocity"] = OSD.FromVector3(pa.Velocity); + // m_log.DebugFormat("{0}: HandlePhysUpdateAttributes: sending velocity = {1}", LogHeader, data["velocity"].AsVector3()); data["rotationalVelocity"] = OSD.FromVector3(pa.RotationalVelocity); data["acceleration"] = OSD.FromVector3(pa.Acceleration); data["torque"] = OSD.FromVector3(pa.Torque); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index 592bc003de..cafd53ffd1 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -460,21 +460,25 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule */ try { - presence.AgentControlFlags = flags; - presence.AbsolutePosition = pos; - presence.Velocity = vel; - presence.Rotation = rot; - // It seems the physics scene can drop an avatar if the avatar makes it angry - if (presence.PhysicsActor != null) + if (!PhysEngineToSceneConnectorModule.IsPhysEngineActorS) { - presence.PhysicsActor.Flying = flying; - presence.PhysicsActor.CollidingGround = !flying; - } - if (doFullUpdate) - { - presence.CollisionPlane = collisionPlane; - presence.OffsetPosition = offsetPosition; - presence.ParentID = parentID; + presence.AgentControlFlags = flags; + presence.AbsolutePosition = pos; + m_log.DebugFormat("{0}: UpdateAvatar. Setting vel={1}", LogHeader(), vel); + presence.Velocity = vel; + presence.Rotation = rot; + // It seems the physics scene can drop an avatar if the avatar makes it angry + if (presence.PhysicsActor != null) + { + presence.PhysicsActor.Flying = flying; + presence.PhysicsActor.CollidingGround = !flying; + } + if (doFullUpdate) + { + presence.CollisionPlane = collisionPlane; + presence.OffsetPosition = offsetPosition; + presence.ParentID = parentID; + } } } catch(Exception e) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index b59a65691d..d47a948ca9 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -208,9 +208,11 @@ namespace OpenSim.Region.Physics.OdePlugin 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) + // if (this.lastValues.Changed(this) && ChangingActorID == RegionSyncServerModule.ActorID) + if (ChangingActorID == RegionSyncServerModule.ActorID) { // m_log.DebugFormat("[ODE CHARACTER]: Sending terse update for {0}", LocalID); + ChangingActorID = "XXX"; // it's been sent. I am not changing it. PhysEngineToSceneConnectorModule.RouteUpdate(this); } } @@ -795,6 +797,12 @@ namespace OpenSim.Region.Physics.OdePlugin { m_pidControllerActive = true; _target_velocity = value; + if (_target_velocity.X == 0 && _target_velocity.Y == 0 && _target_velocity.Z == 0) + { + // if stopping, force real velocity to zero + _velocity = Vector3.Zero; + // m_log.DebugFormat("{0}: Set velocity {1}", "[PHYSICS]", _target_velocity); // RADEBUG + } base.ChangingActorID = RegionSyncServerModule.ActorID; } else @@ -983,10 +991,12 @@ namespace OpenSim.Region.Physics.OdePlugin if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f && m_iscolliding) { // keep track of where we stopped. No more slippin' & slidin' + // m_log.DebugFormat("[PHYSICS]: Move setting zero. zeroFlag={0}, pidControllerActive={1}", _zeroFlag, m_pidControllerActive); // RADEBUG if (!_zeroFlag) { _zeroFlag = true; _zeroPosition = d.BodyGetPosition(Body); + _velocity = _target_velocity; } if (m_pidControllerActive) { @@ -1164,13 +1174,15 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity.Y = 0.0f; _velocity.Z = 0.0f; + /* // Did we send out the 'stopped' message? if (!m_lastUpdateSent) { m_lastUpdateSent = true; - // base.RequestPhysicsterseUpdate(); + this.RequestPhysicsterseUpdate(); } + */ } else { @@ -1208,6 +1220,7 @@ namespace OpenSim.Region.Physics.OdePlugin } if (!m_lastUpdateSent) { + m_lastUpdateSent = true; ChangingActorID = RegionSyncServerModule.ActorID; this.RequestPhysicsterseUpdate(); } From b3efab2bbdc71b201c1c2fb641f54de0b189f9ef Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 31 May 2011 17:48:37 -0700 Subject: [PATCH 2/3] Add ChangingActorID setting for value changes from physics engine. Works much better distributed --- addon-modules/BulletSPlugin/BSCharacter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addon-modules/BulletSPlugin/BSCharacter.cs b/addon-modules/BulletSPlugin/BSCharacter.cs index 8c7a1d6269..fa9fc8d4b9 100644 --- a/addon-modules/BulletSPlugin/BSCharacter.cs +++ b/addon-modules/BulletSPlugin/BSCharacter.cs @@ -127,7 +127,8 @@ public class BSCharacter : PhysicsActor 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) + // if (this.lastValues.Changed(this) && ChangingActorID == RegionSyncServerModule.ActorID) + if (ChangingActorID == RegionSyncServerModule.ActorID) { // m_log.DebugFormat("{0}: Sending terse update for {1}", LogHeader, LocalID); PhysEngineToSceneConnectorModule.RouteUpdate(this); @@ -193,6 +194,7 @@ public class BSCharacter : PhysicsActor get { return _force; } set { _force = value; + base.ChangingActorID = RegionSyncServerModule.ActorID; // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); _scene.TaintedObject(delegate() { @@ -404,6 +406,7 @@ public class BSCharacter : PhysicsActor } if (changed) { + base.ChangingActorID = RegionSyncServerModule.ActorID; this.RequestPhysicsterseUpdate(); } } From 3a582a4cec749d5e2d7ef2e01c742c068a96d330 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Wed, 1 Jun 2011 10:01:04 -0700 Subject: [PATCH 3/3] TEMP: commented out agent limits in scene as a workaround for DSG demos --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index cd29a7d646..d0ff495340 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4357,11 +4357,13 @@ namespace OpenSim.Region.Framework.Scenes int num = m_sceneGraph.GetNumberOfScenePresences(); - if (num >= RegionInfo.RegionSettings.AgentLimit) + // TEMP WORKAROUND for DSG DEMO + // REGION SYNC + /*if (num >= RegionInfo.RegionSettings.AgentLimit) { if (!Permissions.IsAdministrator(cAgentData.AgentID)) return false; - } + }*/ ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); @@ -5729,14 +5731,16 @@ namespace OpenSim.Region.Framework.Scenes { int num = m_sceneGraph.GetNumberOfScenePresences(); - if (num >= RegionInfo.RegionSettings.AgentLimit) + // TEMP WORKAROUND for DSG DEMO + // REGION SYNC + /*if (num >= RegionInfo.RegionSettings.AgentLimit) { if (!Permissions.IsAdministrator(agentID)) { reason = "The region is full"; return false; } - } + }*/ reason = String.Empty; return true;