* 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).
0.6.5-rc1
Teravus Ovares 2009-03-30 14:10:24 +00:00
parent f88d755f96
commit 6522b4f5d4
3 changed files with 30 additions and 8 deletions

View File

@ -985,9 +985,11 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.geom_name_map[Shell] = m_name; _parent_scene.geom_name_map[Shell] = m_name;
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this; _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
_parent_scene.AddCharacter(this);
} }
else else
{ {
_parent_scene.RemoveCharacter(this);
// destroy avatar capsule and related ODE data // destroy avatar capsule and related ODE data
// Kill the Amotor // Kill the Amotor

View File

@ -1365,6 +1365,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Don't need to re-enable body.. it's done in SetMesh // 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); _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. // createmesh returns null when it's a shape that isn't a cube.
m_log.Debug(m_localID);
} }
} }

View File

@ -1339,18 +1339,37 @@ namespace OpenSim.Region.Physics.OdePlugin
OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun); OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun);
newAv.Flying = isFlying; newAv.Flying = isFlying;
newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset;
_characters.Add(newAv);
return newAv; return newAv;
} }
public void AddCharacter(OdeCharacter chr)
{
lock (_characters)
{
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) public override void RemoveAvatar(PhysicsActor actor)
{
lock (OdeLock)
{ {
//m_log.Debug("[PHYSICS]:ODELOCK"); //m_log.Debug("[PHYSICS]:ODELOCK");
((OdeCharacter) actor).Destroy(); ((OdeCharacter) actor).Destroy();
_characters.Remove((OdeCharacter) actor);
}
} }
private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation,