aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs99
1 files changed, 46 insertions, 53 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 70f0785..fef0c4e 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -144,9 +144,9 @@ namespace OpenSim.Region.Physics.OdePlugin
144 //private int m_returncollisions = 10; 144 //private int m_returncollisions = 10;
145 145
146 private IntPtr contactgroup; 146 private IntPtr contactgroup;
147 private IntPtr LandGeom = (IntPtr) 0; 147 private IntPtr LandGeom;
148 148
149 private IntPtr WaterGeom = (IntPtr)0; 149 private IntPtr WaterGeom;
150 150
151 private float nmTerrainContactFriction = 255.0f; 151 private float nmTerrainContactFriction = 255.0f;
152 private float nmTerrainContactBounce = 0.1f; 152 private float nmTerrainContactBounce = 0.1f;
@@ -430,7 +430,7 @@ namespace OpenSim.Region.Physics.OdePlugin
430 430
431 internal void waitForSpaceUnlock(IntPtr space) 431 internal void waitForSpaceUnlock(IntPtr space)
432 { 432 {
433 //if (space != (IntPtr)0) 433 //if (space != IntPtr.Zero)
434 //while (d.SpaceLockQuery(space)) { } // Wait and do nothing 434 //while (d.SpaceLockQuery(space)) { } // Wait and do nothing
435 } 435 }
436 436
@@ -461,7 +461,7 @@ namespace OpenSim.Region.Physics.OdePlugin
461 461
462 if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) 462 if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
463 { 463 {
464 if (g1 == (IntPtr)0 || g2 == (IntPtr)0) 464 if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
465 return; 465 return;
466 // Separating static prim geometry spaces. 466 // Separating static prim geometry spaces.
467 // We'll be calling near recursivly if one 467 // We'll be calling near recursivly if one
@@ -484,7 +484,7 @@ namespace OpenSim.Region.Physics.OdePlugin
484 return; 484 return;
485 } 485 }
486 486
487 if (g1 == (IntPtr)0 || g2 == (IntPtr)0) 487 if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
488 return; 488 return;
489 489
490 IntPtr b1 = d.GeomGetBody(g1); 490 IntPtr b1 = d.GeomGetBody(g1);
@@ -1037,10 +1037,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1037 { 1037 {
1038 lock (chr) 1038 lock (chr)
1039 { 1039 {
1040 if (space != (IntPtr)0 && chr.prim_geom != (IntPtr)0 && chr.m_taintremove == false) 1040 if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false)
1041 {
1041 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback); 1042 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
1043 }
1042 else 1044 else
1045 {
1043 m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed"); 1046 m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed");
1047 }
1044 } 1048 }
1045 } 1049 }
1046 catch (AccessViolationException) 1050 catch (AccessViolationException)
@@ -1204,7 +1208,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1204 remCollisionEventReporting(prim); 1208 remCollisionEventReporting(prim);
1205 lock (ode) 1209 lock (ode)
1206 { 1210 {
1207 if (prim.prim_geom != (IntPtr)0) 1211 if (prim.prim_geom != IntPtr.Zero)
1208 { 1212 {
1209 prim.ResetTaints(); 1213 prim.ResetTaints();
1210 1214
@@ -1217,7 +1221,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1217 // If the geometry is in the targetspace, remove it from the target space 1221 // If the geometry is in the targetspace, remove it from the target space
1218 //m_log.Warn(prim.m_targetSpace); 1222 //m_log.Warn(prim.m_targetSpace);
1219 1223
1220 //if (prim.m_targetSpace != (IntPtr)0) 1224 //if (prim.m_targetSpace != IntPtr.Zero)
1221 //{ 1225 //{
1222 //if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) 1226 //if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
1223 //{ 1227 //{
@@ -1226,7 +1230,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1226 //{ 1230 //{
1227 //waitForSpaceUnlock(prim.m_targetSpace); 1231 //waitForSpaceUnlock(prim.m_targetSpace);
1228 //d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); 1232 //d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
1229 prim.m_targetSpace = (IntPtr)0; 1233 prim.m_targetSpace = IntPtr.Zero;
1230 //} 1234 //}
1231 //else 1235 //else
1232 //{ 1236 //{
@@ -1239,10 +1243,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1239 //m_log.Warn(prim.prim_geom); 1243 //m_log.Warn(prim.prim_geom);
1240 try 1244 try
1241 { 1245 {
1242 if (prim.prim_geom != (IntPtr)0) 1246 if (prim.prim_geom != IntPtr.Zero)
1243 { 1247 {
1244 d.GeomDestroy(prim.prim_geom); 1248 d.GeomDestroy(prim.prim_geom);
1245 prim.prim_geom = (IntPtr)0; 1249 prim.prim_geom = IntPtr.Zero;
1246 } 1250 }
1247 else 1251 else
1248 { 1252 {
@@ -1258,7 +1262,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1258 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 1262 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
1259 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) 1263 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
1260 //{ 1264 //{
1261 //if (!(prim.m_targetSpace.Equals(null))) 1265 //if (prim.m_targetSpace != null)
1262 //{ 1266 //{
1263 //if (d.GeomIsSpace(prim.m_targetSpace)) 1267 //if (d.GeomIsSpace(prim.m_targetSpace))
1264 //{ 1268 //{
@@ -1327,11 +1331,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1327 if (currentspace != space) 1331 if (currentspace != space)
1328 { 1332 {
1329 //m_log.Info("[SPACE]: C:" + currentspace.ToString() + " g:" + geom.ToString()); 1333 //m_log.Info("[SPACE]: C:" + currentspace.ToString() + " g:" + geom.ToString());
1330 //if (currentspace == (IntPtr) 0) 1334 //if (currentspace == IntPtr.Zero)
1331 //{ 1335 //{
1332 //int adfadf = 0; 1336 //int adfadf = 0;
1333 //} 1337 //}
1334 if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr) 0) 1338 if (d.SpaceQuery(currentspace, geom) && currentspace != IntPtr.Zero)
1335 { 1339 {
1336 if (d.GeomIsSpace(currentspace)) 1340 if (d.GeomIsSpace(currentspace))
1337 { 1341 {
@@ -1347,20 +1351,17 @@ namespace OpenSim.Region.Physics.OdePlugin
1347 else 1351 else
1348 { 1352 {
1349 IntPtr sGeomIsIn = d.GeomGetSpace(geom); 1353 IntPtr sGeomIsIn = d.GeomGetSpace(geom);
1350 if (!(sGeomIsIn.Equals(null))) 1354 if (sGeomIsIn != IntPtr.Zero)
1351 { 1355 {
1352 if (sGeomIsIn != (IntPtr) 0) 1356 if (d.GeomIsSpace(currentspace))
1353 { 1357 {
1354 if (d.GeomIsSpace(currentspace)) 1358 waitForSpaceUnlock(sGeomIsIn);
1355 { 1359 d.SpaceRemove(sGeomIsIn, geom);
1356 waitForSpaceUnlock(sGeomIsIn); 1360 }
1357 d.SpaceRemove(sGeomIsIn, geom); 1361 else
1358 } 1362 {
1359 else 1363 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
1360 { 1364 sGeomIsIn.ToString() + " Geom:" + geom.ToString());
1361 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
1362 sGeomIsIn.ToString() + " Geom:" + geom.ToString());
1363 }
1364 } 1365 }
1365 } 1366 }
1366 } 1367 }
@@ -1368,7 +1369,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1368 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 1369 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
1369 if (d.SpaceGetNumGeoms(currentspace) == 0) 1370 if (d.SpaceGetNumGeoms(currentspace) == 0)
1370 { 1371 {
1371 if (currentspace != (IntPtr) 0) 1372 if (currentspace != IntPtr.Zero)
1372 { 1373 {
1373 if (d.GeomIsSpace(currentspace)) 1374 if (d.GeomIsSpace(currentspace))
1374 { 1375 {
@@ -1391,7 +1392,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1391 else 1392 else
1392 { 1393 {
1393 // this is a physical object that got disabled. ;.; 1394 // this is a physical object that got disabled. ;.;
1394 if (currentspace != (IntPtr)0 && geom != (IntPtr)0) 1395 if (currentspace != IntPtr.Zero && geom != IntPtr.Zero)
1395 { 1396 {
1396 if (d.SpaceQuery(currentspace, geom)) 1397 if (d.SpaceQuery(currentspace, geom))
1397 { 1398 {
@@ -1409,20 +1410,17 @@ namespace OpenSim.Region.Physics.OdePlugin
1409 else 1410 else
1410 { 1411 {
1411 IntPtr sGeomIsIn = d.GeomGetSpace(geom); 1412 IntPtr sGeomIsIn = d.GeomGetSpace(geom);
1412 if (!(sGeomIsIn.Equals(null))) 1413 if (sGeomIsIn != IntPtr.Zero)
1413 { 1414 {
1414 if (sGeomIsIn != (IntPtr)0) 1415 if (d.GeomIsSpace(sGeomIsIn))
1415 { 1416 {
1416 if (d.GeomIsSpace(sGeomIsIn)) 1417 waitForSpaceUnlock(sGeomIsIn);
1417 { 1418 d.SpaceRemove(sGeomIsIn, geom);
1418 waitForSpaceUnlock(sGeomIsIn); 1419 }
1419 d.SpaceRemove(sGeomIsIn, geom); 1420 else
1420 } 1421 {
1421 else 1422 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
1422 { 1423 sGeomIsIn.ToString() + " Geom:" + geom.ToString());
1423 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
1424 sGeomIsIn.ToString() + " Geom:" + geom.ToString());
1425 }
1426 } 1424 }
1427 } 1425 }
1428 } 1426 }
@@ -1461,20 +1459,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1461 } 1459 }
1462 1460
1463 /// <summary> 1461 /// <summary>
1464 /// Calculates the space the prim should be in by it's position 1462 /// Calculates the space the prim should be in by its position
1465 /// </summary> 1463 /// </summary>
1466 /// <param name="pos"></param> 1464 /// <param name="pos"></param>
1467 /// <returns>a pointer to the space. This could be a new space or reused space.</returns> 1465 /// <returns>a pointer to the space. This could be a new space or reused space.</returns>
1468 public IntPtr calculateSpaceForGeom(PhysicsVector pos) 1466 public IntPtr calculateSpaceForGeom(PhysicsVector pos)
1469 { 1467 {
1470 IntPtr locationbasedspace =IntPtr.Zero; 1468 int[] xyspace = calculateSpaceArrayItemFromPos(pos);
1471 1469 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
1472 int[] xyspace = calculateSpaceArrayItemFromPos(pos); 1470 return staticPrimspace[xyspace[0], xyspace[1]];
1473 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
1474 locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]];
1475
1476 //locationbasedspace = space;
1477 return locationbasedspace;
1478 } 1471 }
1479 1472
1480 /// <summary> 1473 /// <summary>
@@ -2050,7 +2043,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2050 2043
2051 lock (OdeLock) 2044 lock (OdeLock)
2052 { 2045 {
2053 if (!(LandGeom == (IntPtr) 0)) 2046 if (LandGeom != IntPtr.Zero)
2054 { 2047 {
2055 d.SpaceRemove(space, LandGeom); 2048 d.SpaceRemove(space, LandGeom);
2056 } 2049 }
@@ -2060,7 +2053,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2060 offset, thickness, wrap); 2053 offset, thickness, wrap);
2061 d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); 2054 d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
2062 LandGeom = d.CreateHeightfield(space, HeightmapData, 1); 2055 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
2063 if (LandGeom != (IntPtr)0) 2056 if (LandGeom != IntPtr.Zero)
2064 { 2057 {
2065 d.GeomSetCategoryBits(LandGeom, (int)(CollisionCategories.Land)); 2058 d.GeomSetCategoryBits(LandGeom, (int)(CollisionCategories.Land));
2066 d.GeomSetCollideBits(LandGeom, (int)(CollisionCategories.Space)); 2059 d.GeomSetCollideBits(LandGeom, (int)(CollisionCategories.Space));
@@ -2115,7 +2108,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2115 2108
2116 lock (OdeLock) 2109 lock (OdeLock)
2117 { 2110 {
2118 if (!(WaterGeom == (IntPtr)0)) 2111 if (WaterGeom != IntPtr.Zero)
2119 { 2112 {
2120 d.SpaceRemove(space, WaterGeom); 2113 d.SpaceRemove(space, WaterGeom);
2121 } 2114 }
@@ -2125,7 +2118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2125 offset, thickness, wrap); 2118 offset, thickness, wrap);
2126 d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); 2119 d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
2127 WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); 2120 WaterGeom = d.CreateHeightfield(space, HeightmapData, 1);
2128 if (WaterGeom != (IntPtr)0) 2121 if (WaterGeom != IntPtr.Zero)
2129 { 2122 {
2130 d.GeomSetCategoryBits(WaterGeom, (int)(CollisionCategories.Water)); 2123 d.GeomSetCategoryBits(WaterGeom, (int)(CollisionCategories.Water));
2131 d.GeomSetCollideBits(WaterGeom, (int)(CollisionCategories.Space)); 2124 d.GeomSetCollideBits(WaterGeom, (int)(CollisionCategories.Space));