simplify operation of OdeScene._perloopContact

iar_mods
Justin Clark-Casey (justincc) 2011-11-21 20:30:37 +00:00
parent 25d9001de1
commit 546259b2ff
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>
@ -1059,6 +1066,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")
{ {
@ -1068,7 +1077,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);
@ -1081,7 +1090,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);
@ -1107,7 +1116,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)
{ {
@ -1128,9 +1136,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)
{ {
@ -1163,8 +1171,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);
@ -1182,7 +1191,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);
@ -1212,13 +1221,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++;
} }
} }
} }
@ -1261,9 +1268,11 @@ 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) if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
{ {
//contactGeom.depth *= .00005f; //contactGeom.depth *= .00005f;
@ -1272,16 +1281,16 @@ namespace OpenSim.Region.Physics.OdePlugin
result = true; result = true;
break; break;
} }
else // else
{ // {
//m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth)); // //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("[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)
{ {
@ -1304,7 +1313,6 @@ namespace OpenSim.Region.Physics.OdePlugin
//m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth)); //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("[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));
} }
} }
} }
@ -1589,8 +1597,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
} }
_perloopContact.Clear();
} }
#endregion #endregion