From fc9b3ec5a8c65f9b97e81f0e41abe4a9f45d4b3a Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Wed, 30 Jan 2008 07:09:58 +0000
Subject: * Experimental ODE Update to make ODE more stable * WARNING: This
update will break *nix support. Will be restored in the next revision
---
OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 6 +++++
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 28 +++++++++++++++++++++---
OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 20 ++++++++++++++++-
3 files changed, 50 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Physics/OdePlugin')
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 3f63477..a21b7eb 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -359,6 +359,9 @@ namespace OpenSim.Region.Physics.OdePlugin
CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.52f))); // subtract 43% of the size
OpenSim.Framework.Console.MainLog.Instance.Verbose("SIZE", CAPSULE_LENGTH.ToString());
d.BodyDestroy(Body);
+
+ _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+
d.GeomDestroy(Shell);
AvatarGeomAndBodyCreation(_position.X, _position.Y,
_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
@@ -389,6 +392,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
int dAMotorEuler = 1;
+ _parent_scene.waitForSpaceUnlock(_parent_scene.space);
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
Body = d.BodyCreate(_parent_scene.world);
@@ -781,6 +785,8 @@ namespace OpenSim.Region.Physics.OdePlugin
d.JointDestroy(Amotor);
//kill the Geometry
+ _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+
d.GeomDestroy(Shell);
_parent_scene.geom_name_map.Remove(Shell);
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index d70819e..93ba29e 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -140,15 +140,20 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (((_size.X / 2f) > 0f))
{
+
+
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2);
}
else
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
}
else
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
}
@@ -166,7 +171,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//}
else
{
-
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
}
@@ -190,6 +195,12 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
+ ///
+ /// Nasty, however without this you get
+ /// 'invalid operation for locked space' when things are really loaded down
+ ///
+ ///
+
public override int PhysicsActorType
{
get { return (int) ActorTypes.Prim; }
@@ -375,6 +386,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3*sizeof (int));
d.GeomTriMeshDataPreprocess(_triMeshData);
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null);
if (IsPhysical && Body == (IntPtr) 0)
@@ -427,6 +439,8 @@ namespace OpenSim.Region.Physics.OdePlugin
int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
+
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
d.SpaceAdd(m_targetSpace, prim_geom);
}
@@ -486,6 +500,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
if (d.SpaceQuery(m_targetSpace, prim_geom))
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
d.SpaceRemove(m_targetSpace, prim_geom);
}
d.GeomDestroy(prim_geom);
@@ -510,17 +525,20 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000))
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2);
}
else
{
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);
}
}
else
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
}
@@ -538,7 +556,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//}
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);
@@ -557,10 +575,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{
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);
}
else
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
}
@@ -578,7 +598,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//}
else
{
-
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
@@ -630,11 +650,13 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
}
else
{
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
}
if (IsPhysical && Body == (IntPtr) 0)
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 4175978..4c3dcd3 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -206,6 +206,13 @@ namespace OpenSim.Region.Physics.OdePlugin
mesher = meshmerizer;
}
+ internal void waitForSpaceUnlock(IntPtr space)
+ {
+ while (d.SpaceLockQuery(space))
+ {
+
+ }
+ }
///
/// Debug space message for printing the space that a prim/avatar is in.
///
@@ -635,8 +642,10 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (!(prim.m_targetSpace.Equals(null)))
{
+
if (d.GeomIsSpace(prim.m_targetSpace))
- {
+ {
+ waitForSpaceUnlock(prim.m_targetSpace);
d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
}
else
@@ -656,6 +665,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (d.GeomIsSpace(prim.m_targetSpace))
{
+ waitForSpaceUnlock(prim.m_targetSpace);
d.SpaceRemove(space, prim.m_targetSpace);
// free up memory used by the space.
d.SpaceDestroy(prim.m_targetSpace);
@@ -723,6 +733,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (d.GeomIsSpace(currentspace))
{
+ waitForSpaceUnlock(currentspace);
d.SpaceRemove(currentspace, geom);
}
else
@@ -741,6 +752,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (d.GeomIsSpace(currentspace))
{
+ waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom);
}
else
@@ -761,8 +773,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (d.GeomIsSpace(currentspace))
{
+ waitForSpaceUnlock(currentspace);
+ waitForSpaceUnlock(space);
d.SpaceRemove(space, currentspace);
// free up memory used by the space.
+
d.SpaceDestroy(currentspace);
resetSpaceArrayItemToZero(currentspace);
}
@@ -783,6 +798,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (currentspace != (IntPtr) 0)
if (d.GeomIsSpace(currentspace))
{
+ waitForSpaceUnlock(currentspace);
d.SpaceRemove(currentspace, geom);
}
else
@@ -801,6 +817,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (d.GeomIsSpace(sGeomIsIn))
{
+ waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom);
}
else
@@ -840,6 +857,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// creating a new space for prim and inserting it into main space.
staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero);
+ waitForSpaceUnlock(space);
d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]);
return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY];
}
--
cgit v1.1