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.
remove-scene-viewer
Justin Clark-Casey (justincc) 2011-11-04 23:12:01 +00:00
parent b8d50b10fb
commit ccca6ba935
1 changed files with 25 additions and 2 deletions

View File

@ -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;
/// <summary>
/// Hold set forces so we can process them outside physics calculations. This prevents race conditions if we set force
/// while calculatios are going on
/// </summary>
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;