aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorTeravus Ovares2007-11-16 18:30:25 +0000
committerTeravus Ovares2007-11-16 18:30:25 +0000
commitb2243079eaef6bac4f718572f0fb3d2e38945bb8 (patch)
tree7b5c663f4d7626c5596fc2cbfd6c9415523e71f8 /OpenSim/Region/Physics/OdePlugin
parentMore cleaning up when deleting regions from a instance. NOTE: IGridServices.D... (diff)
downloadopensim-SC_OLD-b2243079eaef6bac4f718572f0fb3d2e38945bb8.zip
opensim-SC_OLD-b2243079eaef6bac4f718572f0fb3d2e38945bb8.tar.gz
opensim-SC_OLD-b2243079eaef6bac4f718572f0fb3d2e38945bb8.tar.bz2
opensim-SC_OLD-b2243079eaef6bac4f718572f0fb3d2e38945bb8.tar.xz
* Trying a space/collision optimization technique in ODE. Let me know if you see a difference.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs55
1 files changed, 39 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index bf9daa3..5388852 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Physics.OdePlugin
100 100
101 public IntPtr space; 101 public IntPtr space;
102 // split static geometry collision handling into spaces of 64 meters 102 // split static geometry collision handling into spaces of 64 meters
103 public IntPtr[] staticPrimspace = new IntPtr[64]; 103 public IntPtr[] staticPrimspace = new IntPtr[74];
104 104
105 public static Object OdeLock = new Object(); 105 public static Object OdeLock = new Object();
106 106
@@ -139,6 +139,7 @@ namespace OpenSim.Region.Physics.OdePlugin
139 { 139 {
140 world = d.WorldCreate(); 140 world = d.WorldCreate();
141 space = d.HashSpaceCreate(IntPtr.Zero); 141 space = d.HashSpaceCreate(IntPtr.Zero);
142 d.HashSpaceSetLevels(space, -4, 128);
142 contactgroup = d.JointGroupCreate(0); 143 contactgroup = d.JointGroupCreate(0);
143 //contactgroup 144 //contactgroup
144 145
@@ -151,16 +152,24 @@ namespace OpenSim.Region.Physics.OdePlugin
151 } 152 }
152 153
153 _heightmap = new double[258*258]; 154 _heightmap = new double[258*258];
155
156 for (int i = 0; i < staticPrimspace.Length; i++)
157 {
158 staticPrimspace[i] = IntPtr.Zero;
159 }
154 160
155 } 161 }
156 162
163
164
157 public override void Initialise(IMesher meshmerizer) 165 public override void Initialise(IMesher meshmerizer)
158 { 166 {
159 mesher = meshmerizer; 167 mesher = meshmerizer;
168
160 } 169 }
161 170
162 171
163 172
164 private void near(IntPtr space, IntPtr g1, IntPtr g2) 173 private void near(IntPtr space, IntPtr g1, IntPtr g2)
165 { 174 {
166 // no lock here! It's invoked from within Simulate(), which is thread-locked 175 // no lock here! It's invoked from within Simulate(), which is thread-locked
@@ -175,8 +184,8 @@ namespace OpenSim.Region.Physics.OdePlugin
175 //Colliding a space or a geom with a space or a geom. 184 //Colliding a space or a geom with a space or a geom.
176 185
177 //Collide all geoms in each space.. 186 //Collide all geoms in each space..
178 if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); 187 //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback);
179 if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); 188 //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback);
180 189
181 } 190 }
182 else 191 else
@@ -317,7 +326,7 @@ namespace OpenSim.Region.Physics.OdePlugin
317 { 326 {
318 327
319 328
320 d.SpaceCollide2(chr.Shell, ch2.Shell, IntPtr.Zero, nearCallback); 329 //d.SpaceCollide2(chr.Shell, ch2.Shell, IntPtr.Zero, nearCallback);
321 } 330 }
322 331
323 } 332 }
@@ -388,9 +397,11 @@ namespace OpenSim.Region.Physics.OdePlugin
388 // If the geometry is in the targetspace, remove it from the target space 397 // If the geometry is in the targetspace, remove it from the target space
389 if (d.SpaceQuery(((OdePrim)prim).m_targetSpace, ((OdePrim)prim).prim_geom)) 398 if (d.SpaceQuery(((OdePrim)prim).m_targetSpace, ((OdePrim)prim).prim_geom))
390 { 399 {
391 d.SpaceRemove(space, ((OdePrim)prim).prim_geom); 400 d.SpaceRemove(((OdePrim)prim).m_targetSpace, ((OdePrim)prim).prim_geom);
392 } 401 }
393 402
403
404
394 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 405 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
395 if (d.SpaceGetNumGeoms(((OdePrim)prim).m_targetSpace) == 0) 406 if (d.SpaceGetNumGeoms(((OdePrim)prim).m_targetSpace) == 0)
396 { 407 {
@@ -400,8 +411,8 @@ namespace OpenSim.Region.Physics.OdePlugin
400 resetSpaceArrayItemToZero(calculateSpaceArrayItemFromPos(((OdePrim)prim).Position)); 411 resetSpaceArrayItemToZero(calculateSpaceArrayItemFromPos(((OdePrim)prim).Position));
401 } 412 }
402 } 413 }
403 414
404 d.GeomDestroy(((OdePrim)prim).prim_geom); 415 d.GeomDestroy(((OdePrim)prim).prim_geom);
405 416
406 _prims.Remove((OdePrim)prim); 417 _prims.Remove((OdePrim)prim);
407 418
@@ -434,7 +445,7 @@ namespace OpenSim.Region.Physics.OdePlugin
434 { 445 {
435 if (d.SpaceQuery(currentspace, geom)) 446 if (d.SpaceQuery(currentspace, geom))
436 { 447 {
437 d.SpaceRemove(space, geom); 448 d.SpaceRemove(currentspace, geom);
438 } 449 }
439 450
440 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 451 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
@@ -454,8 +465,11 @@ namespace OpenSim.Region.Physics.OdePlugin
454 int iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); 465 int iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos);
455 IntPtr newspace = calculateSpaceForGeom(pos); 466 IntPtr newspace = calculateSpaceForGeom(pos);
456 467
457 if (newspace == IntPtr.Zero) 468 if (newspace == IntPtr.Zero)
469 {
458 newspace = createprimspace(iprimspaceArrItem); 470 newspace = createprimspace(iprimspaceArrItem);
471 d.HashSpaceSetLevels(newspace, -4, 66);
472 }
459 473
460 return newspace; 474 return newspace;
461 } 475 }
@@ -469,12 +483,14 @@ namespace OpenSim.Region.Physics.OdePlugin
469 483
470 public IntPtr calculateSpaceForGeom(PhysicsVector pos) 484 public IntPtr calculateSpaceForGeom(PhysicsVector pos)
471 { 485 {
472 486 IntPtr locationbasedspace = staticPrimspace[calculateSpaceArrayItemFromPos(pos)];
473 return space; 487 //locationbasedspace = space;
488 return locationbasedspace;
474 } 489 }
475 public int calculateSpaceArrayItemFromPos(PhysicsVector pos) 490 public int calculateSpaceArrayItemFromPos(PhysicsVector pos)
476 { 491 {
477 return 0; 492 int returnint = ((int)((pos.X + pos.Y)/8.6f));
493 return returnint;
478 } 494 }
479 495
480 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 496 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation,
@@ -1494,6 +1510,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1494 { 1510 {
1495 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1511 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1496 m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); 1512 m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
1513 d.SpaceAdd(m_targetSpace, prim_geom);
1497 } 1514 }
1498 1515
1499 } 1516 }
@@ -1520,11 +1537,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1520 { 1537 {
1521 disableBody(); 1538 disableBody();
1522 } 1539 }
1540 if (d.SpaceQuery(m_targetSpace,prim_geom)) {
1541 d.SpaceRemove(m_targetSpace,prim_geom);
1542 }
1523 d.GeomDestroy(prim_geom); 1543 d.GeomDestroy(prim_geom);
1544
1545 // we don't need to do space calculation because the client sends a position update also.
1524 1546
1525 // Recalculate which space this geometry should be in. 1547 // Construction of new prim
1526 m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
1527 // Construction of new prim
1528 if (this._parent_scene.needsMeshing(_pbs)) 1548 if (this._parent_scene.needsMeshing(_pbs))
1529 { 1549 {
1530 1550
@@ -1543,6 +1563,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1543 } else { 1563 } else {
1544 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); 1564 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1545 1565
1566
1567 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1546 if (IsPhysical && Body == (IntPtr)0) 1568 if (IsPhysical && Body == (IntPtr)0)
1547 { 1569 {
1548 // Re creates body on size. 1570 // Re creates body on size.
@@ -1688,6 +1710,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1688 1710
1689 public void UpdatePositionAndVelocity() { 1711 public void UpdatePositionAndVelocity() {
1690 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1712 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1713
1691 if (Body != (IntPtr)0) 1714 if (Body != (IntPtr)0)
1692 { 1715 {
1693 d.Vector3 vec = d.BodyGetPosition(Body); 1716 d.Vector3 vec = d.BodyGetPosition(Body);