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') 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 From d7815ace4a502926a06f4fb5ed20b0d05db42591 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Nov 2011 23:24:22 +0000 Subject: On standup, trigger the changed link script event after the avatar has been fully changed. This was meant to help with the script in http://opensimulator.org/mantis/view.php?id=5772 but it doesn't work. Probably the event is fired before the physics actor has been set up again for the stood avatar. Fixing that would be much more complicated, but processing the event last of all seems like a good idea in any case. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f6df3c3..89e511f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1864,8 +1864,6 @@ namespace OpenSim.Region.Framework.Scenes if (part.SitTargetAvatar == UUID) part.SitTargetAvatar = UUID.Zero; - part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); - ParentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); } @@ -1881,6 +1879,9 @@ namespace OpenSim.Region.Framework.Scenes ParentID = 0; SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; + + if (part != null) + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } Animator.TrySetMovementAnimation("STAND"); -- cgit v1.1