When an ODECharacter is removed (e.g. when an avatar leaves a scene), remove the actor reference in OdeScene.actor_name_map rather than leaving it dangling.
This also largely centralizes adds/removes in OdeScene.AddCharacter()/RemoveCharacter()0.7.2-post-fixes
parent
5cd33f5e21
commit
1850b778e2
|
@ -598,13 +598,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
|
||||
}
|
||||
|
||||
|
||||
d.GeomSetRotation(Shell, ref m_caprot);
|
||||
d.BodySetRotation(Body, ref m_caprot);
|
||||
|
||||
d.GeomSetBody(Shell, Body);
|
||||
|
||||
|
||||
// The purpose of the AMotor here is to keep the avatar's physical
|
||||
// surrogate from rotating while moving
|
||||
Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
|
||||
|
@ -659,7 +657,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
//standupStraight();
|
||||
}
|
||||
|
||||
//
|
||||
/// <summary>
|
||||
/// Uses the capped cyllinder volume formula to calculate the avatar's mass.
|
||||
/// This may be used in calculations in the scene/scenepresence
|
||||
|
@ -1158,14 +1155,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
{
|
||||
//kill the body
|
||||
d.BodyDestroy(Body);
|
||||
|
||||
Body = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (Shell != IntPtr.Zero)
|
||||
{
|
||||
d.GeomDestroy(Shell);
|
||||
_parent_scene.geom_name_map.Remove(Shell);
|
||||
Shell = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
@ -1262,10 +1257,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
+ (Body!=IntPtr.Zero ? "Body ":"")
|
||||
+ (Amotor!=IntPtr.Zero ? "Amotor ":""));
|
||||
}
|
||||
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
|
||||
|
||||
_parent_scene.geom_name_map[Shell] = Name;
|
||||
_parent_scene.actor_name_map[Shell] = this;
|
||||
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
|
||||
_parent_scene.AddCharacter(this);
|
||||
}
|
||||
else
|
||||
|
@ -1301,7 +1294,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
// Velocity = Vector3.Zero;
|
||||
|
||||
_parent_scene.geom_name_map[Shell] = Name;
|
||||
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
|
||||
_parent_scene.actor_name_map[Shell] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -233,8 +233,23 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
|
||||
|
||||
private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
|
||||
|
||||
/// <summary>
|
||||
/// Maps a unique geometry id (a memory location) to a physics actor name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only actors participating in collisions have geometries.
|
||||
/// </remarks>
|
||||
public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
|
||||
|
||||
/// <summary>
|
||||
/// Maps a unique geometry id (a memory location) to a physics actor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only actors participating in collisions have geometries.
|
||||
/// </remarks>
|
||||
public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
|
||||
|
||||
private bool m_NINJA_physics_joints_enabled = false;
|
||||
//private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
|
||||
private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
|
||||
|
@ -1697,8 +1712,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (!_characters.Contains(chr))
|
||||
{
|
||||
_characters.Add(chr);
|
||||
geom_name_map[chr.Shell] = Name;
|
||||
actor_name_map[chr.Shell] = chr;
|
||||
|
||||
if (chr.bad)
|
||||
m_log.DebugFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
|
||||
m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1710,6 +1728,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (_characters.Contains(chr))
|
||||
{
|
||||
_characters.Remove(chr);
|
||||
geom_name_map.Remove(chr.Shell);
|
||||
actor_name_map.Remove(chr.Shell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue