From 5ae8de3c00cdf5d200b3158116a1e1fd9a404229 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 29 Oct 2011 01:39:48 +0100 Subject: Stop setting _position as well as m_taint_position in ODECharacter.Position setting position at the same time as taint appears to undermine the whole purpose of taint testing doesn't reveal any obvious regressions in doing this --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index c22d27f..5ad7616 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -431,13 +431,10 @@ namespace OpenSim.Region.Physics.OdePlugin value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; } - _position.X = value.X; - _position.Y = value.Y; - _position.Z = value.Z; - m_taintPosition.X = value.X; m_taintPosition.Y = value.Y; m_taintPosition.Z = value.Z; + _parent_scene.AddPhysicsActorTaint(this); } else -- cgit v1.1 From a5ea9f883092ca7b54aeb1c6e3abb8a5ebed1dc7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 29 Oct 2011 01:46:22 +0100 Subject: Move position set from taint to logically better position at top of ODECharacter.ProcessTaints() though this makes no practical difference --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 5ad7616..ca8fef9 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1250,6 +1250,18 @@ namespace OpenSim.Region.Physics.OdePlugin internal void ProcessTaints() { + if (m_taintPosition != _position) + { + if (Body != IntPtr.Zero) + { + d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); + + _position.X = m_taintPosition.X; + _position.Y = m_taintPosition.Y; + _position.Z = m_taintPosition.Z; + } + } + if (m_tainted_isPhysical != m_isPhysical) { if (m_tainted_isPhysical) @@ -1309,18 +1321,6 @@ namespace OpenSim.Region.Physics.OdePlugin + (Amotor==IntPtr.Zero ? "Amotor ":"")); } } - - if (!m_taintPosition.ApproxEquals(_position, 0.05f)) - { - if (Body != IntPtr.Zero) - { - d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); - - _position.X = m_taintPosition.X; - _position.Y = m_taintPosition.Y; - _position.Z = m_taintPosition.Z; - } - } } internal void AddCollisionFrameTime(int p) -- cgit v1.1 From ef8370fb8e527ca20c13d18aad1cbf7f8a44c70a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 29 Oct 2011 02:07:28 +0100 Subject: tidy up OdeCharacter so that we just use OpenMetaverse.Vector3 assignment directly where possible, instead of transferring X, Y and Z components separately some of this is probably a hold over from using ODE.Vector3, which is still necessary in some places. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 90 ++++++++++-------------- 1 file changed, 39 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index ca8fef9..09581c3 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -161,17 +161,19 @@ namespace OpenSim.Region.Physics.OdePlugin { pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; } + _position = pos; - m_taintPosition.X = pos.X; - m_taintPosition.Y = pos.Y; - m_taintPosition.Z = pos.Z; + m_taintPosition = pos; } else { - _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f); - m_taintPosition.X = _position.X; - m_taintPosition.Y = _position.Y; - m_taintPosition.Z = _position.Z; + _position + = new Vector3( + (float)_parent_scene.WorldExtents.X * 0.5f, + (float)_parent_scene.WorldExtents.Y * 0.5f, + parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f); + m_taintPosition = _position; + m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); } @@ -431,10 +433,7 @@ namespace OpenSim.Region.Physics.OdePlugin value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; } - m_taintPosition.X = value.X; - m_taintPosition.Y = value.Y; - m_taintPosition.Z = value.Z; - + m_taintPosition = value; _parent_scene.AddPhysicsActorTaint(this); } else @@ -582,15 +581,12 @@ namespace OpenSim.Region.Physics.OdePlugin d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); Body = d.BodyCreate(_parent_scene.world); d.BodySetPosition(Body, npositionX, npositionY, npositionZ); - + _position.X = npositionX; _position.Y = npositionY; _position.Z = npositionZ; - - m_taintPosition.X = npositionX; - m_taintPosition.Y = npositionY; - m_taintPosition.Z = npositionZ; + m_taintPosition = _position; d.BodySetMass(Body, ref ShellMass); d.Matrix3 m_caprot; @@ -845,9 +841,7 @@ namespace OpenSim.Region.Physics.OdePlugin else { m_pidControllerActive = true; - _target_velocity.X += force.X; - _target_velocity.Y += force.Y; - _target_velocity.Z += force.Z; + _target_velocity += force; } } else @@ -868,8 +862,6 @@ namespace OpenSim.Region.Physics.OdePlugin public void doForce(Vector3 force) { d.BodyAddForce(Body, force.X, force.Y, force.Z); - //d.BodySetRotation(Body, ref m_StandUpRotation); - //standupStraight(); } public override void SetMomentum(Vector3 momentum) @@ -1059,69 +1051,66 @@ namespace OpenSim.Region.Physics.OdePlugin internal void UpdatePositionAndVelocity() { // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! - d.Vector3 vec; + d.Vector3 newPos; try { - vec = d.BodyGetPosition(Body); + newPos = d.BodyGetPosition(Body); } catch (NullReferenceException) { bad = true; _parent_scene.BadCharacter(this); - vec = new d.Vector3(_position.X, _position.Y, _position.Z); + newPos = new d.Vector3(_position.X, _position.Y, _position.Z); base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid); } // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) - if (vec.X < 0.0f) vec.X = 0.0f; - if (vec.Y < 0.0f) vec.Y = 0.0f; - if (vec.X > (int)_parent_scene.WorldExtents.X - 0.05f) vec.X = (int)_parent_scene.WorldExtents.X - 0.05f; - if (vec.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) vec.Y = (int)_parent_scene.WorldExtents.Y - 0.05f; + if (newPos.X < 0.0f) newPos.X = 0.0f; + if (newPos.Y < 0.0f) newPos.Y = 0.0f; + if (newPos.X > (int)_parent_scene.WorldExtents.X - 0.05f) newPos.X = (int)_parent_scene.WorldExtents.X - 0.05f; + if (newPos.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) newPos.Y = (int)_parent_scene.WorldExtents.Y - 0.05f; - _position.X = vec.X; - _position.Y = vec.Y; - _position.Z = vec.Z; + _position.X = newPos.X; + _position.Y = newPos.Y; + _position.Z = newPos.Z; // I think we need to update the taintPosition too -- Diva 12/24/10 - m_taintPosition.X = vec.X; - m_taintPosition.Y = vec.Y; - m_taintPosition.Z = vec.Z; + m_taintPosition = _position; // Did we move last? = zeroflag // This helps keep us from sliding all over if (_zeroFlag) { - _velocity.X = 0.0f; - _velocity.Y = 0.0f; - _velocity.Z = 0.0f; + _velocity = Vector3.Zero; // Did we send out the 'stopped' message? if (!m_lastUpdateSent) { m_lastUpdateSent = true; //base.RequestPhysicsterseUpdate(); - } } else { m_lastUpdateSent = false; + d.Vector3 newVelocity; + try { - vec = d.BodyGetLinearVel(Body); + newVelocity = d.BodyGetLinearVel(Body); } catch (NullReferenceException) { - vec.X = _velocity.X; - vec.Y = _velocity.Y; - vec.Z = _velocity.Z; + newVelocity.X = _velocity.X; + newVelocity.Y = _velocity.Y; + newVelocity.Z = _velocity.Z; } - _velocity.X = (vec.X); - _velocity.Y = (vec.Y); - _velocity.Z = (vec.Z); + _velocity.X = newVelocity.X; + _velocity.Y = newVelocity.Y; + _velocity.Z = newVelocity.Z; if (_velocity.Z < -6 && !m_hackSentFall) { @@ -1255,10 +1244,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (Body != IntPtr.Zero) { d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); - - _position.X = m_taintPosition.X; - _position.Y = m_taintPosition.Y; - _position.Z = m_taintPosition.Z; + _position = m_taintPosition; } } @@ -1303,8 +1289,10 @@ namespace OpenSim.Region.Physics.OdePlugin //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); d.BodyDestroy(Body); d.GeomDestroy(Shell); - AvatarGeomAndBodyCreation(_position.X, _position.Y, - _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); + AvatarGeomAndBodyCreation( + _position.X, + _position.Y, + _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); // As with Size, we reset velocity. However, this isn't strictly necessary since it doesn't // appear to stall initial region crossings when done here. Being done for consistency. -- cgit v1.1 From 9fdd1753fa535ea710afc18753529aa3d12a09c6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 29 Oct 2011 02:30:33 +0100 Subject: Add taint target velocity for ODECharacters as is already done for ODECharacter position and position and velocity for ODEPrims. This is to help stop surprises if the velocity is set in the middle of physics calculations, though this probably isn't a huge problem. It's more for consistency and for the next step of removing some scene locks --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 09581c3..f93d7ba 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -74,6 +74,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool _zeroFlag = false; private bool m_lastUpdateSent = false; private Vector3 _velocity; + private Vector3 m_taintTargetVelocity; private Vector3 _target_velocity; private Vector3 _acceleration; private Vector3 m_rotationalVelocity; @@ -701,7 +702,7 @@ namespace OpenSim.Region.Physics.OdePlugin // d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); // d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); // //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); -// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); +// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyFArotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); // } public override Vector3 Force @@ -767,14 +768,15 @@ namespace OpenSim.Region.Physics.OdePlugin if (value.IsFinite()) { m_pidControllerActive = true; - _target_velocity = value; + m_taintTargetVelocity = value; + _parent_scene.AddPhysicsActorTaint(this); } else { m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character"); } -// m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", _target_velocity); +// m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", m_taintTargetVelocity); } } @@ -834,14 +836,14 @@ namespace OpenSim.Region.Physics.OdePlugin // If uncommented, things get pushed off world // // m_log.Debug("Push!"); - // _target_velocity.X += force.X; - // _target_velocity.Y += force.Y; - // _target_velocity.Z += force.Z; + // m_taintTargetVelocity.X += force.X; + // m_taintTargetVelocity.Y += force.Y; + // m_taintTargetVelocity.Z += force.Z; } else { m_pidControllerActive = true; - _target_velocity += force; + m_taintTargetVelocity += force; } } else @@ -1248,6 +1250,9 @@ namespace OpenSim.Region.Physics.OdePlugin } } + if (m_taintTargetVelocity != _target_velocity) + _target_velocity = m_taintTargetVelocity; + if (m_tainted_isPhysical != m_isPhysical) { if (m_tainted_isPhysical) -- cgit v1.1