* Experimental ODE Update to make ODE more stable

* WARNING: This update will break *nix support. Will be restored in the next revision
ThreadPoolClientBranch
Teravus Ovares 2008-01-30 07:09:58 +00:00
parent 8aa796595c
commit fc9b3ec5a8
5 changed files with 50 additions and 4 deletions

View File

@ -359,6 +359,9 @@ namespace OpenSim.Region.Physics.OdePlugin
CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.52f))); // subtract 43% of the size CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.52f))); // subtract 43% of the size
OpenSim.Framework.Console.MainLog.Instance.Verbose("SIZE", CAPSULE_LENGTH.ToString()); OpenSim.Framework.Console.MainLog.Instance.Verbose("SIZE", CAPSULE_LENGTH.ToString());
d.BodyDestroy(Body); d.BodyDestroy(Body);
_parent_scene.waitForSpaceUnlock(_parent_scene.space);
d.GeomDestroy(Shell); 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);
@ -389,6 +392,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
int dAMotorEuler = 1; int dAMotorEuler = 1;
_parent_scene.waitForSpaceUnlock(_parent_scene.space);
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
Body = d.BodyCreate(_parent_scene.world); Body = d.BodyCreate(_parent_scene.world);
@ -781,6 +785,8 @@ namespace OpenSim.Region.Physics.OdePlugin
d.JointDestroy(Amotor); d.JointDestroy(Amotor);
//kill the Geometry //kill the Geometry
_parent_scene.waitForSpaceUnlock(_parent_scene.space);
d.GeomDestroy(Shell); d.GeomDestroy(Shell);
_parent_scene.geom_name_map.Remove(Shell); _parent_scene.geom_name_map.Remove(Shell);

View File

@ -140,15 +140,20 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (((_size.X / 2f) > 0f)) if (((_size.X / 2f) > 0f))
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2); prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2);
} }
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
} }
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
} }
@ -166,7 +171,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//} //}
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
} }
@ -190,6 +195,12 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
/// <summary>
/// Nasty, however without this you get
/// 'invalid operation for locked space' when things are really loaded down
/// </summary>
/// <param name="space"></param>
public override int PhysicsActorType public override int PhysicsActorType
{ {
get { return (int) ActorTypes.Prim; } get { return (int) ActorTypes.Prim; }
@ -375,6 +386,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3*sizeof (int)); 3*sizeof (int));
d.GeomTriMeshDataPreprocess(_triMeshData); d.GeomTriMeshDataPreprocess(_triMeshData);
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null); prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null);
if (IsPhysical && Body == (IntPtr) 0) if (IsPhysical && Body == (IntPtr) 0)
@ -427,6 +439,8 @@ namespace OpenSim.Region.Physics.OdePlugin
int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
_parent_scene.waitForSpaceUnlock(m_targetSpace);
d.SpaceAdd(m_targetSpace, prim_geom); d.SpaceAdd(m_targetSpace, prim_geom);
} }
@ -486,6 +500,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
if (d.SpaceQuery(m_targetSpace, prim_geom)) if (d.SpaceQuery(m_targetSpace, prim_geom))
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
d.SpaceRemove(m_targetSpace, prim_geom); d.SpaceRemove(m_targetSpace, prim_geom);
} }
d.GeomDestroy(prim_geom); d.GeomDestroy(prim_geom);
@ -510,17 +525,20 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000)) if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000))
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2); prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2);
} }
else else
{ {
OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Failed to load a sphere bad size"); OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Failed to load a sphere bad size");
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
} }
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
} }
@ -538,7 +556,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//} //}
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
//prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
@ -557,10 +575,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
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)
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2); prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2);
} }
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
} }
@ -578,7 +598,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//} //}
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
@ -630,11 +650,13 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
} }
else else
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
if (IsPhysical && Body == (IntPtr) 0) if (IsPhysical && Body == (IntPtr) 0)

View File

@ -206,6 +206,13 @@ namespace OpenSim.Region.Physics.OdePlugin
mesher = meshmerizer; mesher = meshmerizer;
} }
internal void waitForSpaceUnlock(IntPtr space)
{
while (d.SpaceLockQuery(space))
{
}
}
/// <summary> /// <summary>
/// Debug space message for printing the space that a prim/avatar is in. /// Debug space message for printing the space that a prim/avatar is in.
/// </summary> /// </summary>
@ -635,8 +642,10 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (!(prim.m_targetSpace.Equals(null))) if (!(prim.m_targetSpace.Equals(null)))
{ {
if (d.GeomIsSpace(prim.m_targetSpace)) if (d.GeomIsSpace(prim.m_targetSpace))
{ {
waitForSpaceUnlock(prim.m_targetSpace);
d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
} }
else else
@ -656,6 +665,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (d.GeomIsSpace(prim.m_targetSpace)) if (d.GeomIsSpace(prim.m_targetSpace))
{ {
waitForSpaceUnlock(prim.m_targetSpace);
d.SpaceRemove(space, prim.m_targetSpace); d.SpaceRemove(space, prim.m_targetSpace);
// free up memory used by the space. // free up memory used by the space.
d.SpaceDestroy(prim.m_targetSpace); d.SpaceDestroy(prim.m_targetSpace);
@ -723,6 +733,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (d.GeomIsSpace(currentspace)) if (d.GeomIsSpace(currentspace))
{ {
waitForSpaceUnlock(currentspace);
d.SpaceRemove(currentspace, geom); d.SpaceRemove(currentspace, geom);
} }
else else
@ -741,6 +752,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (d.GeomIsSpace(currentspace)) if (d.GeomIsSpace(currentspace))
{ {
waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom); d.SpaceRemove(sGeomIsIn, geom);
} }
else else
@ -761,8 +773,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (d.GeomIsSpace(currentspace)) if (d.GeomIsSpace(currentspace))
{ {
waitForSpaceUnlock(currentspace);
waitForSpaceUnlock(space);
d.SpaceRemove(space, currentspace); d.SpaceRemove(space, currentspace);
// free up memory used by the space. // free up memory used by the space.
d.SpaceDestroy(currentspace); d.SpaceDestroy(currentspace);
resetSpaceArrayItemToZero(currentspace); resetSpaceArrayItemToZero(currentspace);
} }
@ -783,6 +798,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (currentspace != (IntPtr) 0) if (currentspace != (IntPtr) 0)
if (d.GeomIsSpace(currentspace)) if (d.GeomIsSpace(currentspace))
{ {
waitForSpaceUnlock(currentspace);
d.SpaceRemove(currentspace, geom); d.SpaceRemove(currentspace, geom);
} }
else else
@ -801,6 +817,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (d.GeomIsSpace(sGeomIsIn)) if (d.GeomIsSpace(sGeomIsIn))
{ {
waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom); d.SpaceRemove(sGeomIsIn, geom);
} }
else else
@ -840,6 +857,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// creating a new space for prim and inserting it into main space. // creating a new space for prim and inserting it into main space.
staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero);
waitForSpaceUnlock(space);
d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]);
return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY];
} }

Binary file not shown.

Binary file not shown.