simplify operation of OdeScene._perloopContact

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2011-11-21 20:30:37 +00:00
parent 4b2b0d4a05
commit 5c305494ae
1 changed files with 51 additions and 45 deletions

View File

@ -216,7 +216,14 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </remarks> /// </remarks>
private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>(); private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>();
/// <summary>
/// Record a character that has taints to be processed.
/// </summary>
private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>(); private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>();
/// <summary>
/// Keep record of contacts in the physics loop so that we can remove duplicates.
/// </summary>
private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>(); private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
/// <summary> /// <summary>
@ -1056,6 +1063,8 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!skipThisContact) if (!skipThisContact)
{ {
_perloopContact.Add(curContact);
// If we're colliding against terrain // If we're colliding against terrain
if (name1 == "Terrain" || name2 == "Terrain") if (name1 == "Terrain" || name2 == "Terrain")
{ {
@ -1065,7 +1074,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// Use the movement terrain contact // Use the movement terrain contact
AvatarMovementTerrainContact.geom = curContact; AvatarMovementTerrainContact.geom = curContact;
_perloopContact.Add(curContact);
if (m_global_contactcount < maxContactsbeforedeath) if (m_global_contactcount < maxContactsbeforedeath)
{ {
joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
@ -1078,7 +1087,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// Use the non moving terrain contact // Use the non moving terrain contact
TerrainContact.geom = curContact; TerrainContact.geom = curContact;
_perloopContact.Add(curContact);
if (m_global_contactcount < maxContactsbeforedeath) if (m_global_contactcount < maxContactsbeforedeath)
{ {
joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
@ -1104,7 +1113,6 @@ namespace OpenSim.Region.Physics.OdePlugin
//m_log.DebugFormat("Material: {0}", material); //m_log.DebugFormat("Material: {0}", material);
m_materialContacts[material, movintYN].geom = curContact; m_materialContacts[material, movintYN].geom = curContact;
_perloopContact.Add(curContact);
if (m_global_contactcount < maxContactsbeforedeath) if (m_global_contactcount < maxContactsbeforedeath)
{ {
@ -1125,9 +1133,9 @@ namespace OpenSim.Region.Physics.OdePlugin
if (p2 is OdePrim) if (p2 is OdePrim)
material = ((OdePrim)p2).m_material; material = ((OdePrim)p2).m_material;
//m_log.DebugFormat("Material: {0}", material); //m_log.DebugFormat("Material: {0}", material);
m_materialContacts[material, movintYN].geom = curContact; m_materialContacts[material, movintYN].geom = curContact;
_perloopContact.Add(curContact);
if (m_global_contactcount < maxContactsbeforedeath) if (m_global_contactcount < maxContactsbeforedeath)
{ {
@ -1160,8 +1168,9 @@ namespace OpenSim.Region.Physics.OdePlugin
//contact.normal = new d.Vector3(0, 0, 1); //contact.normal = new d.Vector3(0, 0, 1);
//contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f); //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f);
} }
WaterContact.geom = curContact; WaterContact.geom = curContact;
_perloopContact.Add(curContact);
if (m_global_contactcount < maxContactsbeforedeath) if (m_global_contactcount < maxContactsbeforedeath)
{ {
joint = d.JointCreateContact(world, contactgroup, ref WaterContact); joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
@ -1179,7 +1188,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// Use the Movement prim contact // Use the Movement prim contact
AvatarMovementprimContact.geom = curContact; AvatarMovementprimContact.geom = curContact;
_perloopContact.Add(curContact);
if (m_global_contactcount < maxContactsbeforedeath) if (m_global_contactcount < maxContactsbeforedeath)
{ {
joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
@ -1209,13 +1218,11 @@ namespace OpenSim.Region.Physics.OdePlugin
//m_log.DebugFormat("Material: {0}", material); //m_log.DebugFormat("Material: {0}", material);
m_materialContacts[material, 0].geom = curContact; m_materialContacts[material, 0].geom = curContact;
_perloopContact.Add(curContact);
if (m_global_contactcount < maxContactsbeforedeath) if (m_global_contactcount < maxContactsbeforedeath)
{ {
joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]); joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]);
m_global_contactcount++; m_global_contactcount++;
} }
} }
} }
@ -1258,50 +1265,51 @@ namespace OpenSim.Region.Physics.OdePlugin
// || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2) // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2)
if (at == ActorTypes.Agent) if (at == ActorTypes.Agent)
{ {
if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom) if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f)
&& (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f)
&& (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f))
&& contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
{
if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
{ {
//contactGeom.depth *= .00005f;
if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f) //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
{ // m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
//contactGeom.depth *= .00005f; result = true;
//m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth)); break;
// m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
result = true;
break;
}
else
{
//m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
}
}
else
{
//m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
//int i = 0;
} }
// else
// {
// //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
// }
}
// else
// {
// //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
// //int i = 0;
// }
} }
else if (at == ActorTypes.Prim) else if (at == ActorTypes.Prim)
{ {
//d.AABB aabb1 = new d.AABB(); //d.AABB aabb1 = new d.AABB();
//d.AABB aabb2 = new d.AABB(); //d.AABB aabb2 = new d.AABB();
//d.GeomGetAABB(contactGeom.g2, out aabb2); //d.GeomGetAABB(contactGeom.g2, out aabb2);
//d.GeomGetAABB(contactGeom.g1, out aabb1); //d.GeomGetAABB(contactGeom.g1, out aabb1);
//aabb1. //aabb1.
if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom) if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
{
if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
{ {
if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z) if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
{ {
if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f) result = true;
{ break;
result = true;
break;
}
} }
//m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
//m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
} }
//m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
//m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
}
} }
} }
@ -1586,8 +1594,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
} }
_perloopContact.Clear();
} }
#endregion #endregion