Merge branch 'master' into vehicles

This commit is contained in:
Melanie
2009-10-19 21:58:51 +01:00
24 changed files with 218 additions and 76 deletions

View File

@@ -1105,7 +1105,19 @@ namespace OpenSim.Region.Physics.OdePlugin
public void UpdatePositionAndVelocity()
{
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
d.Vector3 vec = d.BodyGetPosition(Body);
d.Vector3 vec;
try
{
vec = d.BodyGetPosition(Body);
}
catch (NullReferenceException)
{
_parent_scene.BadCharacter(this);
vec = 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}", m_name);
}
// 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;
@@ -1137,7 +1149,16 @@ namespace OpenSim.Region.Physics.OdePlugin
else
{
m_lastUpdateSent = false;
vec = d.BodyGetLinearVel(Body);
try
{
vec = d.BodyGetLinearVel(Body);
}
catch (NullReferenceException)
{
vec.X = _velocity.X;
vec.Y = _velocity.Y;
vec.Z = _velocity.Z;
}
_velocity.X = (vec.X);
_velocity.Y = (vec.Y);

View File

@@ -827,8 +827,8 @@ namespace OpenSim.Region.Physics.OdePlugin
IntPtr vertices, indices;
int vertexCount, indexCount;
int vertexStride, triStride;
mesh.getVertexListAsPtrToFloatArray( out vertices, out vertexStride, out vertexCount ); // Note, that vertices are fixed in unmanaged heap
mesh.getIndexListAsPtrToIntArray( out indices, out triStride, out indexCount ); // Also fixed, needs release after usage
mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap
mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
mesh.releaseSourceMeshData(); // free up the original mesh data to save memory

View File

@@ -243,6 +243,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>();
private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
private bool m_NINJA_physics_joints_enabled = false;
@@ -1678,6 +1679,14 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
}
public void BadCharacter(OdeCharacter chr)
{
lock (_badCharacter)
{
if (!_badCharacter.Contains(chr))
_badCharacter.Add(chr);
}
}
public override void RemoveAvatar(PhysicsActor actor)
{
@@ -2987,6 +2996,18 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
lock (_badCharacter)
{
if (_badCharacter.Count > 0)
{
foreach (OdeCharacter chr in _badCharacter)
{
RemoveCharacter(chr);
}
_badCharacter.Clear();
}
}
lock (_activeprims)
{
//if (timeStep < 0.2f)
@@ -3792,7 +3813,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
public void start(int unused)
{
{
ds.SetViewpoint(ref xyz, ref hpr);
}
#endif