Rewrite collision dictionary handling, cleans up deleted obects/avs. Fixes occasional collision event failure. ChOde only.

avinationmerge
Kitto Flora 2010-07-13 20:37:13 +00:00
parent 5f4105d48c
commit 7ab103c96f
4 changed files with 106 additions and 60 deletions

3
.gitignore vendored
View File

@ -1,5 +1,6 @@
.project .project
.settings .settings
.gitignore
*.csproj *.csproj
*.csproj.user *.csproj.user
*.build *.build
@ -10,6 +11,7 @@
*.pidb *.pidb
*.dll.build *.dll.build
*.dll *.dll
*.log
*.VisualState.xml *.VisualState.xml
*/*/obj */*/obj
*/*/*/obj */*/*/obj
@ -23,6 +25,7 @@
*/*/*/*/*/bin */*/*/*/*/bin
*/*/*/*/*/*/bin */*/*/*/*/*/bin
*/*/*/*/*/*/*/bin */*/*/*/*/*/*/bin
addon-modules/
bin/Debug/*.dll bin/Debug/*.dll
bin/*.dll.mdb bin/*.dll.mdb
bin/*.db bin/*.db

View File

@ -565,7 +565,29 @@ namespace OpenSim.Region.Physics.OdePlugin
CAPSULE_RADIUS = 0.01f; CAPSULE_RADIUS = 0.01f;
} }
if(Shell != IntPtr.Zero)
{
try
{
d.GeomDestroy(Shell);
}
catch (System.AccessViolationException)
{
m_log.Error("[PHYSICS]: PrimGeom dead");
}
// Remove any old entries
//string tShell;
//_parent_scene.geom_name_map.TryGetValue(Shell, out tShell);
//Console.WriteLine("**** Remove {0}", tShell);
if(_parent_scene.geom_name_map.ContainsKey(Shell)) _parent_scene.geom_name_map.Remove(Shell);
if(_parent_scene.actor_name_map.ContainsKey(Shell)) _parent_scene.actor_name_map.Remove(Shell);
}
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
_parent_scene.geom_name_map[Shell] = m_name;
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
//Console.WriteLine("**** Create {2} Dicts: actor={0} name={1}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, m_name);
d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
d.GeomSetCollideBits(Shell, (int)m_collisionFlags); d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
@ -931,10 +953,23 @@ namespace OpenSim.Region.Physics.OdePlugin
Body = IntPtr.Zero; Body = IntPtr.Zero;
} }
if (Shell != IntPtr.Zero) if(Shell != IntPtr.Zero)
{ {
d.GeomDestroy(Shell); try
_parent_scene.geom_name_map.Remove(Shell); {
d.GeomDestroy(Shell);
}
catch (System.AccessViolationException)
{
m_log.Error("[PHYSICS]: PrimGeom dead");
}
// Remove any old entries
//string tShell;
//_parent_scene.geom_name_map.TryGetValue(Shell, out tShell);
//Console.WriteLine("**** Remove {0}", tShell);
if(_parent_scene.geom_name_map.ContainsKey(Shell)) _parent_scene.geom_name_map.Remove(Shell);
if(_parent_scene.actor_name_map.ContainsKey(Shell)) _parent_scene.actor_name_map.Remove(Shell);
Shell = IntPtr.Zero; Shell = IntPtr.Zero;
} }
@ -1098,10 +1133,23 @@ namespace OpenSim.Region.Physics.OdePlugin
Body = IntPtr.Zero; Body = IntPtr.Zero;
} }
if (Shell != IntPtr.Zero) if(Shell != IntPtr.Zero)
{ {
d.GeomDestroy(Shell); try
_parent_scene.geom_name_map.Remove(Shell); {
d.GeomDestroy(Shell);
}
catch (System.AccessViolationException)
{
m_log.Error("[PHYSICS]: PrimGeom dead");
}
// Remove any old entries
//string tShell;
//_parent_scene.geom_name_map.TryGetValue(Shell, out tShell);
//Console.WriteLine("**** Remove {0}", tShell);
if(_parent_scene.geom_name_map.ContainsKey(Shell)) _parent_scene.geom_name_map.Remove(Shell);
if(_parent_scene.actor_name_map.ContainsKey(Shell)) _parent_scene.actor_name_map.Remove(Shell);
Shell = IntPtr.Zero; Shell = IntPtr.Zero;
} }
} }
@ -1277,9 +1325,6 @@ namespace OpenSim.Region.Physics.OdePlugin
+ (Amotor!=IntPtr.Zero ? "Amotor ":"")); + (Amotor!=IntPtr.Zero ? "Amotor ":""));
} }
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor); 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); _parent_scene.AddCharacter(this);
} }
else else
@ -1299,17 +1344,28 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
//kill the body //kill the body
d.BodyDestroy(Body); d.BodyDestroy(Body);
Body = IntPtr.Zero; Body = IntPtr.Zero;
} }
if (Shell != IntPtr.Zero) if(Shell != IntPtr.Zero)
{ {
d.GeomDestroy(Shell); try
_parent_scene.geom_name_map.Remove(Shell); {
d.GeomDestroy(Shell);
}
catch (System.AccessViolationException)
{
m_log.Error("[PHYSICS]: PrimGeom dead");
}
// Remove any old entries
//string tShell;
//_parent_scene.geom_name_map.TryGetValue(Shell, out tShell);
//Console.WriteLine("**** Remove {0}", tShell);
if(_parent_scene.geom_name_map.ContainsKey(Shell)) _parent_scene.geom_name_map.Remove(Shell);
if(_parent_scene.actor_name_map.ContainsKey(Shell)) _parent_scene.actor_name_map.Remove(Shell);
Shell = IntPtr.Zero; Shell = IntPtr.Zero;
} }
} }
m_isPhysical = m_tainted_isPhysical; m_isPhysical = m_tainted_isPhysical;
@ -1327,13 +1383,9 @@ namespace OpenSim.Region.Physics.OdePlugin
CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH; CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH;
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
d.BodyDestroy(Body); d.BodyDestroy(Body);
d.GeomDestroy(Shell);
AvatarGeomAndBodyCreation(_position.X, _position.Y, AvatarGeomAndBodyCreation(_position.X, _position.Y,
_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
Velocity = Vector3.Zero; Velocity = Vector3.Zero;
_parent_scene.geom_name_map[Shell] = m_name;
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
} }
else else
{ {

View File

@ -142,7 +142,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private OdeScene _parent_scene; private OdeScene _parent_scene;
public IntPtr m_targetSpace = IntPtr.Zero; public IntPtr m_targetSpace = IntPtr.Zero;
public IntPtr prim_geom; public IntPtr prim_geom;
public IntPtr prev_geom; // public IntPtr prev_geom;
public IntPtr _triMeshData; public IntPtr _triMeshData;
private IntPtr _linkJointGroup = IntPtr.Zero; private IntPtr _linkJointGroup = IntPtr.Zero;
@ -274,7 +274,7 @@ namespace OpenSim.Region.Physics.OdePlugin
prim_geom = IntPtr.Zero; prim_geom = IntPtr.Zero;
prev_geom = IntPtr.Zero; // prev_geom = IntPtr.Zero;
if (!pos.IsFinite()) if (!pos.IsFinite())
{ {
@ -776,13 +776,26 @@ namespace OpenSim.Region.Physics.OdePlugin
public void SetGeom(IntPtr geom) public void SetGeom(IntPtr geom)
{ {
prev_geom = prim_geom; if(prim_geom != IntPtr.Zero)
{
// Remove any old entries
//string tPA;
//_parent_scene.geom_name_map.TryGetValue(prim_geom, out tPA);
//Console.WriteLine("**** Remove {0}", tPA);
if(_parent_scene.geom_name_map.ContainsKey(prim_geom)) _parent_scene.geom_name_map.Remove(prim_geom);
if(_parent_scene.actor_name_map.ContainsKey(prim_geom)) _parent_scene.actor_name_map.Remove(prim_geom);
d.GeomDestroy(prim_geom);
}
prim_geom = geom; prim_geom = geom;
//Console.WriteLine("SetGeom to " + prim_geom + " for " + m_primName); //Console.WriteLine("SetGeom to " + prim_geom + " for " + m_primName);
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
{ {
_parent_scene.geom_name_map[prim_geom] = this.m_primName;
_parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
//Console.WriteLine("**** Create {2} Dicts: actor={0} name={1}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, this.m_primName);
} }
if (childPrim) if (childPrim)
@ -1774,17 +1787,17 @@ namespace OpenSim.Region.Physics.OdePlugin
public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
{ {
//Console.WriteLine("CreateGeom:"); //Console.WriteLine("CreateGeom:");
if (_mesh != null) if (_mesh != null) // Special - make mesh
{ {
setMesh(_parent_scene, _mesh); setMesh(_parent_scene, _mesh);
} }
else else // not a mesh
{ {
if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) // special profile??
{ {
if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) // Equi-size
{ {
if (((_size.X / 2f) > 0f)) if (((_size.X / 2f) > 0f)) // Has size
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace); _parent_scene.waitForSpaceUnlock(m_targetSpace);
try try
@ -1815,7 +1828,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
} }
else else // not equi-size
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace); _parent_scene.waitForSpaceUnlock(m_targetSpace);
try try
@ -1832,7 +1845,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
else else // not special profile
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace); _parent_scene.waitForSpaceUnlock(m_targetSpace);
try try
@ -1894,9 +1907,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
_parent_scene.geom_name_map[prim_geom] = this.m_primName;
_parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
changeSelectedStatus(timestep); changeSelectedStatus(timestep);
m_taintadd = false; m_taintadd = false;
@ -2045,22 +2055,7 @@ Console.WriteLine(" JointCreateFixed");
{ {
if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
{ {
_mesh = null;
if (prim_geom != IntPtr.Zero)
{
try
{
d.GeomDestroy(prim_geom);
prim_geom = IntPtr.Zero;
_mesh = null;
}
catch (System.AccessViolationException)
{
prim_geom = IntPtr.Zero;
m_log.Error("[PHYSICS]: PrimGeom dead");
}
}
//Console.WriteLine("changePhysicsStatus for " + m_primName ); //Console.WriteLine("changePhysicsStatus for " + m_primName );
changeadd(2f); changeadd(2f);
} }
@ -2120,8 +2115,6 @@ Console.WriteLine(" JointCreateFixed");
_parent_scene.waitForSpaceUnlock(m_targetSpace); _parent_scene.waitForSpaceUnlock(m_targetSpace);
d.SpaceRemove(m_targetSpace, prim_geom); d.SpaceRemove(m_targetSpace, prim_geom);
} }
d.GeomDestroy(prim_geom);
prim_geom = IntPtr.Zero;
// we don't need to do space calculation because the client sends a position update also. // we don't need to do space calculation because the client sends a position update also.
// Construction of new prim // Construction of new prim
@ -2223,16 +2216,8 @@ Console.WriteLine(" JointCreateFixed");
disableBody(); disableBody();
} }
} }
try
{
d.GeomDestroy(prim_geom);
}
catch (System.AccessViolationException)
{
prim_geom = IntPtr.Zero;
m_log.Error("[PHYSICS]: PrimGeom dead");
}
prim_geom = IntPtr.Zero;
// we don't need to do space calculation because the client sends a position update also. // we don't need to do space calculation because the client sends a position update also.
if (_size.X <= 0) _size.X = 0.01f; if (_size.X <= 0) _size.X = 0.01f;
if (_size.Y <= 0) _size.Y = 0.01f; if (_size.Y <= 0) _size.Y = 0.01f;

View File

@ -2206,6 +2206,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (prim.prim_geom != IntPtr.Zero) if (prim.prim_geom != IntPtr.Zero)
{ {
//string tPA;
//geom_name_map.TryGetValue(prim.prim_geom, out tPA);
//Console.WriteLine("**** Remove {0}", tPA);
if(geom_name_map.ContainsKey(prim.prim_geom)) geom_name_map.Remove(prim.prim_geom);
if(actor_name_map.ContainsKey(prim.prim_geom)) actor_name_map.Remove(prim.prim_geom);
d.GeomDestroy(prim.prim_geom); d.GeomDestroy(prim.prim_geom);
prim.prim_geom = IntPtr.Zero; prim.prim_geom = IntPtr.Zero;
} }