From ccca6ba93527d5a7a9a2a95324f3abc26e161f31 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Nov 2011 23:12:01 +0000 Subject: Stop llPushObject() from causing problems by adding force via a taint rather than directly. This isn't a perfect solution since there can be a race between the taint processing and taint setting, as force needs to be reset after processing. Needs careful locking in the future. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin/ODECharacter.cs') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index f93d7ba..19d87c2 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -100,7 +100,14 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_hackSentFall = false; private bool m_hackSentFly = false; private int m_requestedUpdateFrequency = 0; - private Vector3 m_taintPosition = Vector3.Zero; + private Vector3 m_taintPosition; + + /// + /// Hold set forces so we can process them outside physics calculations. This prevents race conditions if we set force + /// while calculatios are going on + /// + private Vector3 m_taintForce; + internal uint m_localID = 0; // taints and their non-tainted counterparts private bool m_isPhysical = false; // the current physical status @@ -832,7 +839,10 @@ namespace OpenSim.Region.Physics.OdePlugin { m_pidControllerActive = false; force *= 100f; - doForce(force); + m_taintForce += force; + _parent_scene.AddPhysicsActorTaint(this); + + //doForce(force); // If uncommented, things get pushed off world // // m_log.Debug("Push!"); @@ -1250,6 +1260,19 @@ namespace OpenSim.Region.Physics.OdePlugin } } + if (m_taintForce != Vector3.Zero) + { + if (Body != IntPtr.Zero) + { + // FIXME: This is not a good solution since it's subject to a race condition if a force is another + // thread sets a new force while we're in this loop (since it could be obliterated by + // m_taintForce = Vector3.Zero. Need to lock ProcessTaints() when we set a new tainted force. + doForce(m_taintForce); + } + + m_taintForce = Vector3.Zero; + } + if (m_taintTargetVelocity != _target_velocity) _target_velocity = m_taintTargetVelocity; -- cgit v1.1