aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-21 20:30:37 +0000
committerJustin Clark-Casey (justincc)2011-11-21 20:30:37 +0000
commit546259b2ffdb7dfdc450dd5386ec6794bb06223d (patch)
tree51f068a6dc94b96dfe2d45b492f3eb4d7bf3bc28
parentdon't bother locking OdeScene._perloopContact in single threaded code (diff)
downloadopensim-SC_OLD-546259b2ffdb7dfdc450dd5386ec6794bb06223d.zip
opensim-SC_OLD-546259b2ffdb7dfdc450dd5386ec6794bb06223d.tar.gz
opensim-SC_OLD-546259b2ffdb7dfdc450dd5386ec6794bb06223d.tar.bz2
opensim-SC_OLD-546259b2ffdb7dfdc450dd5386ec6794bb06223d.tar.xz
simplify operation of OdeScene._perloopContact
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs96
1 files changed, 51 insertions, 45 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 897ab82..7db188f 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -216,7 +216,14 @@ namespace OpenSim.Region.Physics.OdePlugin
216 /// </remarks> 216 /// </remarks>
217 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>(); 217 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>();
218 218
219 /// <summary>
220 /// Record a character that has taints to be processed.
221 /// </summary>
219 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>(); 222 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>();
223
224 /// <summary>
225 /// Keep record of contacts in the physics loop so that we can remove duplicates.
226 /// </summary>
220 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>(); 227 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
221 228
222 /// <summary> 229 /// <summary>
@@ -1059,6 +1066,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1059 1066
1060 if (!skipThisContact) 1067 if (!skipThisContact)
1061 { 1068 {
1069 _perloopContact.Add(curContact);
1070
1062 // If we're colliding against terrain 1071 // If we're colliding against terrain
1063 if (name1 == "Terrain" || name2 == "Terrain") 1072 if (name1 == "Terrain" || name2 == "Terrain")
1064 { 1073 {
@@ -1068,7 +1077,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1068 { 1077 {
1069 // Use the movement terrain contact 1078 // Use the movement terrain contact
1070 AvatarMovementTerrainContact.geom = curContact; 1079 AvatarMovementTerrainContact.geom = curContact;
1071 _perloopContact.Add(curContact); 1080
1072 if (m_global_contactcount < maxContactsbeforedeath) 1081 if (m_global_contactcount < maxContactsbeforedeath)
1073 { 1082 {
1074 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); 1083 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
@@ -1081,7 +1090,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1081 { 1090 {
1082 // Use the non moving terrain contact 1091 // Use the non moving terrain contact
1083 TerrainContact.geom = curContact; 1092 TerrainContact.geom = curContact;
1084 _perloopContact.Add(curContact); 1093
1085 if (m_global_contactcount < maxContactsbeforedeath) 1094 if (m_global_contactcount < maxContactsbeforedeath)
1086 { 1095 {
1087 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); 1096 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
@@ -1107,7 +1116,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1107 1116
1108 //m_log.DebugFormat("Material: {0}", material); 1117 //m_log.DebugFormat("Material: {0}", material);
1109 m_materialContacts[material, movintYN].geom = curContact; 1118 m_materialContacts[material, movintYN].geom = curContact;
1110 _perloopContact.Add(curContact);
1111 1119
1112 if (m_global_contactcount < maxContactsbeforedeath) 1120 if (m_global_contactcount < maxContactsbeforedeath)
1113 { 1121 {
@@ -1128,9 +1136,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1128 1136
1129 if (p2 is OdePrim) 1137 if (p2 is OdePrim)
1130 material = ((OdePrim)p2).m_material; 1138 material = ((OdePrim)p2).m_material;
1139
1131 //m_log.DebugFormat("Material: {0}", material); 1140 //m_log.DebugFormat("Material: {0}", material);
1132 m_materialContacts[material, movintYN].geom = curContact; 1141 m_materialContacts[material, movintYN].geom = curContact;
1133 _perloopContact.Add(curContact);
1134 1142
1135 if (m_global_contactcount < maxContactsbeforedeath) 1143 if (m_global_contactcount < maxContactsbeforedeath)
1136 { 1144 {
@@ -1163,8 +1171,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1163 //contact.normal = new d.Vector3(0, 0, 1); 1171 //contact.normal = new d.Vector3(0, 0, 1);
1164 //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f); 1172 //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f);
1165 } 1173 }
1174
1166 WaterContact.geom = curContact; 1175 WaterContact.geom = curContact;
1167 _perloopContact.Add(curContact); 1176
1168 if (m_global_contactcount < maxContactsbeforedeath) 1177 if (m_global_contactcount < maxContactsbeforedeath)
1169 { 1178 {
1170 joint = d.JointCreateContact(world, contactgroup, ref WaterContact); 1179 joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
@@ -1182,7 +1191,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1182 { 1191 {
1183 // Use the Movement prim contact 1192 // Use the Movement prim contact
1184 AvatarMovementprimContact.geom = curContact; 1193 AvatarMovementprimContact.geom = curContact;
1185 _perloopContact.Add(curContact); 1194
1186 if (m_global_contactcount < maxContactsbeforedeath) 1195 if (m_global_contactcount < maxContactsbeforedeath)
1187 { 1196 {
1188 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); 1197 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
@@ -1212,13 +1221,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1212 1221
1213 //m_log.DebugFormat("Material: {0}", material); 1222 //m_log.DebugFormat("Material: {0}", material);
1214 m_materialContacts[material, 0].geom = curContact; 1223 m_materialContacts[material, 0].geom = curContact;
1215 _perloopContact.Add(curContact);
1216 1224
1217 if (m_global_contactcount < maxContactsbeforedeath) 1225 if (m_global_contactcount < maxContactsbeforedeath)
1218 { 1226 {
1219 joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]); 1227 joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]);
1220 m_global_contactcount++; 1228 m_global_contactcount++;
1221
1222 } 1229 }
1223 } 1230 }
1224 } 1231 }
@@ -1249,7 +1256,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1249 { 1256 {
1250 if (!m_filterCollisions) 1257 if (!m_filterCollisions)
1251 return false; 1258 return false;
1252 1259
1253 bool result = false; 1260 bool result = false;
1254 1261
1255 ActorTypes at = (ActorTypes)atype; 1262 ActorTypes at = (ActorTypes)atype;
@@ -1261,50 +1268,51 @@ namespace OpenSim.Region.Physics.OdePlugin
1261 // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2) 1268 // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2)
1262 if (at == ActorTypes.Agent) 1269 if (at == ActorTypes.Agent)
1263 { 1270 {
1264 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) 1271 if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f)
1265 { 1272 && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f)
1266 1273 && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f))
1267 if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f) 1274 && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
1268 { 1275 {
1269 //contactGeom.depth *= .00005f; 1276 if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
1270 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
1271 // 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));
1272 result = true;
1273 break;
1274 }
1275 else
1276 {
1277 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
1278 }
1279 }
1280 else
1281 { 1277 {
1282 //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)); 1278 //contactGeom.depth *= .00005f;
1283 //int i = 0; 1279 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
1280 // 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));
1281 result = true;
1282 break;
1284 } 1283 }
1284// else
1285// {
1286// //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
1287// }
1288 }
1289// else
1290// {
1291// //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));
1292// //int i = 0;
1293// }
1285 } 1294 }
1286 else if (at == ActorTypes.Prim) 1295 else if (at == ActorTypes.Prim)
1287 { 1296 {
1288 //d.AABB aabb1 = new d.AABB(); 1297 //d.AABB aabb1 = new d.AABB();
1289 //d.AABB aabb2 = new d.AABB(); 1298 //d.AABB aabb2 = new d.AABB();
1290 1299
1291 //d.GeomGetAABB(contactGeom.g2, out aabb2); 1300 //d.GeomGetAABB(contactGeom.g2, out aabb2);
1292 //d.GeomGetAABB(contactGeom.g1, out aabb1); 1301 //d.GeomGetAABB(contactGeom.g1, out aabb1);
1293 //aabb1. 1302 //aabb1.
1294 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) 1303 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)
1304 {
1305 if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
1295 { 1306 {
1296 if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z) 1307 if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
1297 { 1308 {
1298 if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f) 1309 result = true;
1299 { 1310 break;
1300 result = true;
1301 break;
1302 }
1303 } 1311 }
1304 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
1305 //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));
1306 } 1312 }
1307 1313 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
1314 //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));
1315 }
1308 } 1316 }
1309 } 1317 }
1310 1318
@@ -1589,8 +1597,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1589 } 1597 }
1590 } 1598 }
1591 } 1599 }
1592
1593 _perloopContact.Clear();
1594 } 1600 }
1595 1601
1596 #endregion 1602 #endregion