From 6522b4f5d4167f5f92683758f7959f70a3e73dd2 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 30 Mar 2009 14:10:24 +0000 Subject: * Fixing thread safety of avatar adding and removing from the Physics Scene in the ODEPlugin * This may help one of the symptoms or mantis 3363 , however it probably won't solve the occasional NonFinite Avatar Position detected.. issues that some people see. That is probably an entirely different issue(NaN). --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 4 ++- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 1 + OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 31 +++++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 1808fa0..bf8ca0e 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -982,12 +982,14 @@ namespace OpenSim.Region.Physics.OdePlugin + (Amotor!=IntPtr.Zero ? "Amotor ":"") ); } AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor); - + _parent_scene.geom_name_map[Shell] = m_name; _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; + _parent_scene.AddCharacter(this); } else { + _parent_scene.RemoveCharacter(this); // destroy avatar capsule and related ODE data // Kill the Amotor diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index e42c711..9e65dd8 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -1365,6 +1365,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Don't need to re-enable body.. it's done in SetMesh _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); // createmesh returns null when it's a shape that isn't a cube. + m_log.Debug(m_localID); } } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 732d99b..e3ac668 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -1339,20 +1339,39 @@ namespace OpenSim.Region.Physics.OdePlugin OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun); newAv.Flying = isFlying; newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; - _characters.Add(newAv); + return newAv; } - public override void RemoveAvatar(PhysicsActor actor) + public void AddCharacter(OdeCharacter chr) { - lock (OdeLock) + lock (_characters) { - //m_log.Debug("[PHYSICS]:ODELOCK"); - ((OdeCharacter) actor).Destroy(); - _characters.Remove((OdeCharacter) actor); + if (!_characters.Contains(chr)) + { + _characters.Add(chr); + } } } + public void RemoveCharacter(OdeCharacter chr) + { + lock (_characters) + { + if (_characters.Contains(chr)) + { + _characters.Remove(chr); + } + } + } + + public override void RemoveAvatar(PhysicsActor actor) + { + //m_log.Debug("[PHYSICS]:ODELOCK"); + ((OdeCharacter) actor).Destroy(); + + } + private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) { -- cgit v1.1