* Cleaned up some locking on the ODEPlugin to make it more developer friendly

* Expect the occasional deadlock?
0.6.0-stable
Teravus Ovares 2008-03-09 15:43:01 +00:00
parent 7981c45750
commit 081b2ac34e
2 changed files with 534 additions and 543 deletions

View File

@ -293,6 +293,8 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.addActivePrim(this); _parent_scene.addActivePrim(this);
} }
#region Mass Calculation
private float CalculateMass() private float CalculateMass()
{ {
float volume = 0; float volume = 0;
@ -598,6 +600,9 @@ namespace OpenSim.Region.Physics.OdePlugin
return returnMass; return returnMass;
} }
#endregion
public void setMass() public void setMass()
{ {
if (Body != (IntPtr) 0) if (Body != (IntPtr) 0)
@ -734,10 +739,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changelink(float timestep) private void changelink(float timestep)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
if (_parent == null && m_taintparent != null) if (_parent == null && m_taintparent != null)
{ {
@ -763,17 +764,13 @@ namespace OpenSim.Region.Physics.OdePlugin
m_linkJoint = (IntPtr)0; m_linkJoint = (IntPtr)0;
} }
ode.dunlock(_parent_scene.world);
_parent = m_taintparent; _parent = m_taintparent;
} }
private void changeSelectedStatus(float timestep) private void changeSelectedStatus(float timestep)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
if (m_taintselected) if (m_taintselected)
{ {
@ -831,7 +828,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
ode.dunlock(_parent_scene.world);
resetCollisionAccounting(); resetCollisionAccounting();
m_isSelected = m_taintselected; m_isSelected = m_taintselected;
} }
@ -860,10 +857,8 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
public void changeadd(float timestep) public void changeadd(float timestep)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position);
@ -992,7 +987,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
ode.dunlock(_parent_scene.world);
_parent_scene.geom_name_map[prim_geom] = this.m_primName; _parent_scene.geom_name_map[prim_geom] = this.m_primName;
_parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
@ -1004,10 +999,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
public void Move(float timestep) public void Move(float timestep)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
if (m_isphysical) if (m_isphysical)
@ -1057,7 +1049,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.SpaceAdd(m_targetSpace, prim_geom); d.SpaceAdd(m_targetSpace, prim_geom);
} }
} }
ode.dunlock(_parent_scene.world);
changeSelectedStatus(timestep); changeSelectedStatus(timestep);
@ -1067,10 +1059,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void rotate(float timestep) public void rotate(float timestep)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
d.Quaternion myrot = new d.Quaternion(); d.Quaternion myrot = new d.Quaternion();
myrot.W = _orientation.w; myrot.W = _orientation.w;
@ -1083,8 +1072,6 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetQuaternion(Body, ref myrot); d.BodySetQuaternion(Body, ref myrot);
} }
ode.dunlock(_parent_scene.world);
resetCollisionAccounting(); resetCollisionAccounting();
m_taintrot = _orientation; m_taintrot = _orientation;
} }
@ -1098,46 +1085,35 @@ namespace OpenSim.Region.Physics.OdePlugin
public void changedisable(float timestep) public void changedisable(float timestep)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
m_disabled = true; m_disabled = true;
if (Body != (IntPtr)0) if (Body != (IntPtr)0)
{ {
d.BodyDisable(Body); d.BodyDisable(Body);
Body = (IntPtr)0; Body = (IntPtr)0;
} }
ode.dunlock(_parent_scene.world);
m_taintdisable = false; m_taintdisable = false;
} }
public void changePhysicsStatus(float timestep) public void changePhysicsStatus(float timestep)
{ {
lock (ode)
if (m_isphysical == true)
{ {
while (ode.lockquery()) if (Body == (IntPtr)0)
{ {
enableBody();
} }
ode.dlock(_parent_scene.world); }
else
if (m_isphysical == true) {
if (Body != (IntPtr)0)
{ {
if (Body == (IntPtr)0) disableBody();
{
enableBody();
}
} }
else
{
if (Body != (IntPtr)0)
{
disableBody();
}
}
ode.dunlock(_parent_scene.world);
} }
changeSelectedStatus(timestep); changeSelectedStatus(timestep);
@ -1148,10 +1124,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void changesize(float timestamp) public void changesize(float timestamp)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
//if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom))
//{ //{
// m_taintsize = _size; // m_taintsize = _size;
@ -1311,8 +1284,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.geom_name_map[prim_geom] = oldname; _parent_scene.geom_name_map[prim_geom] = oldname;
ode.dunlock(_parent_scene.world);
changeSelectedStatus(timestamp); changeSelectedStatus(timestamp);
resetCollisionAccounting(); resetCollisionAccounting();
@ -1321,11 +1292,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public void changeshape(float timestamp) public void changeshape(float timestamp)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
string oldname = _parent_scene.geom_name_map[prim_geom]; string oldname = _parent_scene.geom_name_map[prim_geom];
@ -1471,8 +1437,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.geom_name_map[prim_geom] = oldname; _parent_scene.geom_name_map[prim_geom] = oldname;
ode.dunlock(_parent_scene.world);
changeSelectedStatus(timestamp); changeSelectedStatus(timestamp);
resetCollisionAccounting(); resetCollisionAccounting();
@ -1483,10 +1447,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (!m_isSelected) if (!m_isSelected)
{ {
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
lock (m_forcelist) lock (m_forcelist)
@ -1505,7 +1466,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_forcelist.Clear(); m_forcelist.Clear();
} }
ode.dunlock(_parent_scene.world);
m_collisionscore = 0; m_collisionscore = 0;
m_interpenetrationcount = 0; m_interpenetrationcount = 0;
@ -1517,24 +1477,17 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (!m_isSelected) if (!m_isSelected)
{ {
lock (ode)
System.Threading.Thread.Sleep(20);
if (IsPhysical)
{ {
while (ode.lockquery()) if (Body != (IntPtr)0)
{ {
d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
} }
ode.dlock(_parent_scene.world);
System.Threading.Thread.Sleep(20);
if (IsPhysical)
{
if (Body != (IntPtr)0)
{
d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
}
}
ode.dunlock(_parent_scene.world);
} }
//resetCollisionAccounting(); //resetCollisionAccounting();
} }
m_taintVelocity = PhysicsVector.Zero; m_taintVelocity = PhysicsVector.Zero;
@ -1763,12 +1716,16 @@ namespace OpenSim.Region.Physics.OdePlugin
if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f) if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f)
{ {
base.RaiseOutOfBounds(_position); base.RaiseOutOfBounds(_position);
//if (m_crossingfailures < 5)
//{
//base.RequestPhysicsterseUpdate();
//}
//else
//{
//base.RaiseOutOfBounds(_position);
//}
} }
//if (m_crossingfailures < 5)
//{
//base.RequestPhysicsterseUpdate();
//}
//}
if (l_position.Z < 0) if (l_position.Z < 0)
{ {

File diff suppressed because it is too large Load Diff