From 5f68b5b82e6410c2079c304c6c5872ebf7c990ba Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 16 Jul 2009 00:05:07 +0000 Subject: There was possible a locking issue in revision 9951 so reverting that revision until further testing can be done. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 39 +++++++++++++----------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 296c554..ada81b5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -89,8 +89,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_updateflag; private byte m_movementflag; - //private readonly List m_forcesList = new List(); - private NewForce m_nextVelocity = new NewForce(); + private readonly List m_forcesList = new List(); private short m_updateCount; private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID = UUID.Zero; @@ -139,7 +138,7 @@ namespace OpenSim.Region.Framework.Scenes public string JID = string.Empty; // Agent moves with a PID controller causing a force to be exerted. - private bool m_newMovement; + private bool m_newForce; private bool m_newCoarseLocations = true; private float m_health = 100f; @@ -2227,6 +2226,7 @@ namespace OpenSim.Region.Framework.Scenes m_perfMonMS = Environment.TickCount; m_rotation = rotation; + NewForce newVelocity = new NewForce(); Vector3 direc = vec * rotation; direc.Normalize(); @@ -2261,12 +2261,10 @@ namespace OpenSim.Region.Framework.Scenes } } - lock (m_nextVelocity) - { - m_nextVelocity.X = direc.X; - m_nextVelocity.Y = direc.Y; - m_nextVelocity.Z = direc.Z; - } + newVelocity.X = direc.X; + newVelocity.Y = direc.Y; + newVelocity.Z = direc.Z; + m_forcesList.Add(newVelocity); m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); } @@ -2287,11 +2285,10 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { - if (m_newMovement) // user movement 'forces' (ie commands to move) + if (m_newForce) // user movement 'forces' (ie commands to move) { SendTerseUpdateToAllClients(); m_updateCount = 0; - m_newMovement = false; } else if (m_movementflag != 0) // scripted movement (?) { @@ -3139,17 +3136,20 @@ namespace OpenSim.Region.Framework.Scenes /// public override void UpdateMovement() { - // m_newMovement = false; - if ((m_nextVelocity.X != movementvector.X) || (m_nextVelocity.Y != movementvector.Y) || (m_nextVelocity.Z != movementvector.Z)) + m_newForce = false; + lock (m_forcesList) { - lock (m_nextVelocity) + if (m_forcesList.Count > 0) { + //we are only interested in the last velocity added to the list [Although they are called forces, they are actually velocities] + NewForce force = m_forcesList[m_forcesList.Count - 1]; + m_updateflag = true; try { - movementvector.X = m_nextVelocity.X; - movementvector.Y = m_nextVelocity.Y; - movementvector.Z = m_nextVelocity.Z; + movementvector.X = force.X; + movementvector.Y = force.Y; + movementvector.Z = force.Z; Velocity = movementvector; } catch (NullReferenceException) @@ -3158,7 +3158,9 @@ namespace OpenSim.Region.Framework.Scenes // Ignoring this causes no movement to be sent to the physics engine... // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! } - m_newMovement = true; + m_newForce = true; + + m_forcesList.Clear(); } } } @@ -3265,6 +3267,7 @@ namespace OpenSim.Region.Framework.Scenes public void Close() { + lock (m_attachments) { // Delete attachments from scene -- cgit v1.1