* Various ODE Cleanups
parent
89349a3810
commit
f80a534eb0
|
@ -672,15 +672,19 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
ode.dlock(_parent_scene.world);
|
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;
|
||||||
|
}
|
||||||
ode.dunlock(_parent_scene.world);
|
ode.dunlock(_parent_scene.world);
|
||||||
|
|
||||||
m_taintdisable = false;
|
m_taintdisable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePhysicsStatus(float timestap)
|
public void changePhysicsStatus(float timestap)
|
||||||
|
{
|
||||||
|
lock (ode)
|
||||||
{
|
{
|
||||||
while (ode.lockquery())
|
while (ode.lockquery())
|
||||||
{
|
{
|
||||||
|
@ -689,20 +693,21 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (m_isphysical == true)
|
if (m_isphysical == true)
|
||||||
{
|
{
|
||||||
if (Body == (IntPtr) 0)
|
if (Body == (IntPtr)0)
|
||||||
{
|
{
|
||||||
enableBody();
|
enableBody();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Body != (IntPtr) 0)
|
if (Body != (IntPtr)0)
|
||||||
{
|
{
|
||||||
disableBody();
|
disableBody();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ode.dunlock(_parent_scene.world);
|
ode.dunlock(_parent_scene.world);
|
||||||
|
}
|
||||||
|
|
||||||
resetCollisionAccounting();
|
resetCollisionAccounting();
|
||||||
m_taintPhysics = m_isphysical;
|
m_taintPhysics = m_isphysical;
|
||||||
|
@ -1279,18 +1284,21 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
|
|
||||||
// kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
|
// 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;
|
//if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
|
||||||
//if (vec.Y < 0.0f) vec.Y = 0.0f;
|
//if (vec.Y < 0.0f) { vec.Y = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
|
||||||
//if (vec.X > 255.95f) vec.X = 255.95f;
|
//if (vec.X > 255.95f) { vec.X = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
|
||||||
//if (vec.Y > 255.95f) vec.Y = 255.95f;
|
//if (vec.Y > 255.95f) { vec.Y = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
|
||||||
|
|
||||||
m_lastposition = _position;
|
m_lastposition = _position;
|
||||||
|
|
||||||
l_position.X = vec.X;
|
l_position.X = vec.X;
|
||||||
l_position.Y = vec.Y;
|
l_position.Y = vec.Y;
|
||||||
l_position.Z = vec.Z;
|
l_position.Z = vec.Z;
|
||||||
|
|
||||||
//if (l_position.X > 257f || l_position.X < -1f || l_position.Y > 257f || l_position.Y < -1f)
|
if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f)
|
||||||
//{
|
{
|
||||||
|
base.RaiseOutOfBounds(_position);
|
||||||
|
}
|
||||||
//if (m_crossingfailures < 5)
|
//if (m_crossingfailures < 5)
|
||||||
//{
|
//{
|
||||||
//base.RequestPhysicsterseUpdate();
|
//base.RequestPhysicsterseUpdate();
|
||||||
|
@ -1385,6 +1393,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_lastUpdateSent = false;
|
m_lastUpdateSent = false;
|
||||||
if (!m_throttleUpdates || throttleCounter > 15)
|
if (!m_throttleUpdates || throttleCounter > 15)
|
||||||
{
|
{
|
||||||
|
|
||||||
base.RequestPhysicsterseUpdate();
|
base.RequestPhysicsterseUpdate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -269,6 +269,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
|
if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
|
||||||
{
|
{
|
||||||
|
if (g1 == (IntPtr)0 || g2 == (IntPtr)0)
|
||||||
|
return;
|
||||||
// Separating static prim geometry spaces.
|
// Separating static prim geometry spaces.
|
||||||
// We'll be calling near recursivly if one
|
// We'll be calling near recursivly if one
|
||||||
// of them is a space to find all of the
|
// of them is a space to find all of the
|
||||||
|
@ -280,6 +282,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
catch (System.AccessViolationException)
|
catch (System.AccessViolationException)
|
||||||
{
|
{
|
||||||
m_log.Warn("[PHYSICS]: Unable to collide test a space");
|
m_log.Warn("[PHYSICS]: Unable to collide test a space");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
//Colliding a space or a geom with a space or a geom. so drill down
|
//Colliding a space or a geom with a space or a geom. so drill down
|
||||||
|
|
||||||
|
@ -291,6 +294,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
// Colliding Geom To Geom
|
// Colliding Geom To Geom
|
||||||
// This portion of the function 'was' blatantly ripped off from BoxStack.cs
|
// This portion of the function 'was' blatantly ripped off from BoxStack.cs
|
||||||
|
if (g1 == (IntPtr)0 || g2 == (IntPtr)0)
|
||||||
|
return;
|
||||||
|
|
||||||
IntPtr b1 = d.GeomGetBody(g1);
|
IntPtr b1 = d.GeomGetBody(g1);
|
||||||
IntPtr b2 = d.GeomGetBody(g2);
|
IntPtr b2 = d.GeomGetBody(g2);
|
||||||
|
@ -301,6 +306,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
|
if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
d.GeomClassID id = d.GeomGetClass(g1);
|
d.GeomClassID id = d.GeomGetClass(g1);
|
||||||
|
|
||||||
String name1 = null;
|
String name1 = null;
|
||||||
|
@ -325,6 +332,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
int count = 0;
|
int count = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//m_log.Warn(g1.ToString() + "|" + g2.ToString());
|
||||||
count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
|
count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
|
||||||
}
|
}
|
||||||
catch (SEHException)
|
catch (SEHException)
|
||||||
|
@ -335,7 +343,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
catch (System.AccessViolationException)
|
catch (System.AccessViolationException)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_log.Warn("[PHYSICS]: Unable to collide test an object");
|
m_log.Warn("[PHYSICS]: Unable to collide test an object");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsActor p1;
|
PhysicsActor p1;
|
||||||
|
@ -438,48 +448,48 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// If you interpenetrate a prim with another prim
|
// If you interpenetrate a prim with another prim
|
||||||
if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim)
|
if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim)
|
||||||
{
|
{
|
||||||
OdePrim op1 = (OdePrim)p1;
|
//OdePrim op1 = (OdePrim)p1;
|
||||||
OdePrim op2 = (OdePrim)p2;
|
//OdePrim op2 = (OdePrim)p2;
|
||||||
op1.m_collisionscore++;
|
//op1.m_collisionscore++;
|
||||||
op2.m_collisionscore++;
|
//op2.m_collisionscore++;
|
||||||
|
|
||||||
|
|
||||||
if (op1.m_collisionscore > 80 || op2.m_collisionscore > 80)
|
//if (op1.m_collisionscore > 8000 || op2.m_collisionscore > 8000)
|
||||||
{
|
//{
|
||||||
op1.m_taintdisable = true;
|
//op1.m_taintdisable = true;
|
||||||
AddPhysicsActorTaint(p1);
|
//AddPhysicsActorTaint(p1);
|
||||||
op2.m_taintdisable = true;
|
//op2.m_taintdisable = true;
|
||||||
AddPhysicsActorTaint(p2);
|
//AddPhysicsActorTaint(p2);
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (contacts[i].depth >= 0.25f)
|
//if (contacts[i].depth >= 0.25f)
|
||||||
{
|
//{
|
||||||
// Don't collide, one or both prim will expld.
|
// Don't collide, one or both prim will expld.
|
||||||
|
|
||||||
|
|
||||||
op1.m_interpenetrationcount++;
|
//op1.m_interpenetrationcount++;
|
||||||
op2.m_interpenetrationcount++;
|
//op2.m_interpenetrationcount++;
|
||||||
interpenetrations_before_disable = 20;
|
//interpenetrations_before_disable = 200;
|
||||||
if (op1.m_interpenetrationcount >= interpenetrations_before_disable)
|
//if (op1.m_interpenetrationcount >= interpenetrations_before_disable)
|
||||||
{
|
//{
|
||||||
op1.m_taintdisable = true;
|
//op1.m_taintdisable = true;
|
||||||
AddPhysicsActorTaint(p1);
|
//AddPhysicsActorTaint(p1);
|
||||||
}
|
//}
|
||||||
if (op2.m_interpenetrationcount >= interpenetrations_before_disable)
|
//if (op2.m_interpenetrationcount >= interpenetrations_before_disable)
|
||||||
{
|
//{
|
||||||
op2.m_taintdisable = true;
|
// op2.m_taintdisable = true;
|
||||||
AddPhysicsActorTaint(p2);
|
//AddPhysicsActorTaint(p2);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//contacts[i].depth = contacts[i].depth / 8f;
|
//contacts[i].depth = contacts[i].depth / 8f;
|
||||||
//contacts[i].normal = new d.Vector3(0, 0, 1);
|
//contacts[i].normal = new d.Vector3(0, 0, 1);
|
||||||
}
|
//}
|
||||||
if (op1.m_disabled || op2.m_disabled)
|
//if (op1.m_disabled || op2.m_disabled)
|
||||||
{
|
//{
|
||||||
//Manually disabled objects stay disabled
|
//Manually disabled objects stay disabled
|
||||||
contacts[i].depth = 0f;
|
//contacts[i].depth = 0f;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
if (contacts[i].depth >= 1.00f)
|
if (contacts[i].depth >= 1.00f)
|
||||||
{
|
{
|
||||||
|
@ -720,9 +730,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
OdePrim p = (OdePrim) prim;
|
OdePrim p = (OdePrim) prim;
|
||||||
|
|
||||||
//p.setPrimForRemoval();
|
p.setPrimForRemoval();
|
||||||
//AddPhysicsActorTaint(prim);
|
AddPhysicsActorTaint(prim);
|
||||||
RemovePrimThreadLocked(p);
|
//RemovePrimThreadLocked(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -760,8 +770,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
//m_log.Warn(prim.m_targetSpace);
|
//m_log.Warn(prim.m_targetSpace);
|
||||||
|
|
||||||
|
|
||||||
if (prim.m_targetSpace != (IntPtr)0)
|
//if (prim.m_targetSpace != (IntPtr)0)
|
||||||
{
|
//{
|
||||||
if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
|
if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -769,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
waitForSpaceUnlock(prim.m_targetSpace);
|
waitForSpaceUnlock(prim.m_targetSpace);
|
||||||
d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
|
d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
|
||||||
prim.m_targetSpace = space;
|
prim.m_targetSpace = (IntPtr) 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -778,7 +788,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
//m_log.Warn(prim.prim_geom);
|
//m_log.Warn(prim.prim_geom);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1309,10 +1319,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
bool processedtaints = false;
|
bool processedtaints = false;
|
||||||
foreach (OdePrim prim in _taintedPrim)
|
foreach (OdePrim prim in _taintedPrim)
|
||||||
{
|
{
|
||||||
//if (prim.m_taintremove)
|
if (prim.m_taintremove)
|
||||||
//{
|
{
|
||||||
//RemovePrimThreadLocked(prim);
|
RemovePrimThreadLocked(prim);
|
||||||
//}
|
}
|
||||||
|
|
||||||
prim.ProcessTaints(timeStep);
|
prim.ProcessTaints(timeStep);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue