aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorTeravus Ovares2007-11-19 04:15:18 +0000
committerTeravus Ovares2007-11-19 04:15:18 +0000
commitaaab1448f7b55e9e4d0d7936ecb5de01ac95a5dc (patch)
tree0ec9047dd5ab171d06bd50df46487bd567fdad75 /OpenSim/Region/Physics
parentAdded medium debug information to Verbose mode of the console about Prim/spac... (diff)
downloadopensim-SC-aaab1448f7b55e9e4d0d7936ecb5de01ac95a5dc.zip
opensim-SC-aaab1448f7b55e9e4d0d7936ecb5de01ac95a5dc.tar.gz
opensim-SC-aaab1448f7b55e9e4d0d7936ecb5de01ac95a5dc.tar.bz2
opensim-SC-aaab1448f7b55e9e4d0d7936ecb5de01ac95a5dc.tar.xz
* Split space array structure into a two dimentional array instead of a single one. Once again. Should help debugging space/copy issues.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs65
1 files changed, 38 insertions, 27 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index bac45eb..9d5b6e7 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Region.Physics.OdePlugin
75 { 75 {
76 private static float ODE_STEPSIZE = 0.004f; 76 private static float ODE_STEPSIZE = 0.004f;
77 private static bool RENDER_FLAG = false; 77 private static bool RENDER_FLAG = false;
78 private static float metersInSpace = 29.9f;
78 private IntPtr contactgroup; 79 private IntPtr contactgroup;
79 private IntPtr LandGeom = (IntPtr) 0; 80 private IntPtr LandGeom = (IntPtr) 0;
80 private double[] _heightmap; 81 private double[] _heightmap;
@@ -99,8 +100,8 @@ namespace OpenSim.Region.Physics.OdePlugin
99 public IntPtr world; 100 public IntPtr world;
100 101
101 public IntPtr space; 102 public IntPtr space;
102 // split static geometry collision handling into spaces of 64 meters 103 // split static geometry collision handling into spaces of 30 meters
103 public IntPtr[] staticPrimspace = new IntPtr[74]; 104 public IntPtr[,] staticPrimspace = new IntPtr[(int)(257/metersInSpace),(int)(257/metersInSpace)];
104 105
105 public static Object OdeLock = new Object(); 106 public static Object OdeLock = new Object();
106 107
@@ -153,9 +154,12 @@ namespace OpenSim.Region.Physics.OdePlugin
153 154
154 _heightmap = new double[258*258]; 155 _heightmap = new double[258*258];
155 156
156 for (int i = 0; i < staticPrimspace.Length; i++) 157 for (int i = 0; i < staticPrimspace.GetLength(0); i++)
157 { 158 {
158 staticPrimspace[i] = IntPtr.Zero; 159 for (int j = 0; j < staticPrimspace.GetLength(1); j++)
160 {
161 staticPrimspace[i,j] = IntPtr.Zero;
162 }
159 } 163 }
160 164
161 } 165 }
@@ -437,7 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin
437 d.SpaceRemove(space, ((OdePrim)prim).m_targetSpace); 441 d.SpaceRemove(space, ((OdePrim)prim).m_targetSpace);
438 // free up memory used by the space. 442 // free up memory used by the space.
439 d.SpaceDestroy(((OdePrim)prim).m_targetSpace); 443 d.SpaceDestroy(((OdePrim)prim).m_targetSpace);
440 resetSpaceArrayItemToZero(calculateSpaceArrayItemFromPos(((OdePrim)prim).Position)); 444 int[] xyspace = calculateSpaceArrayItemFromPos(((OdePrim)prim).Position);
445 resetSpaceArrayItemToZero(xyspace[0],xyspace[1]);
441 } 446 }
442 else 447 else
443 { 448 {
@@ -456,15 +461,18 @@ namespace OpenSim.Region.Physics.OdePlugin
456 } 461 }
457 public void resetSpaceArrayItemToZero(IntPtr space) 462 public void resetSpaceArrayItemToZero(IntPtr space)
458 { 463 {
459 for (int i = 0; i < staticPrimspace.Length; i++) 464 for (int x = 0; x < staticPrimspace.GetLength(0); x++)
460 { 465 {
461 if (staticPrimspace[i] == space) 466 for (int y = 0; y < staticPrimspace.GetLength(1); y++)
462 staticPrimspace[i] = IntPtr.Zero; 467 {
468 if (staticPrimspace[x, y] == space)
469 staticPrimspace[x, y] = IntPtr.Zero;
470 }
463 } 471 }
464 } 472 }
465 public void resetSpaceArrayItemToZero(int arrayitem) 473 public void resetSpaceArrayItemToZero(int arrayitemX,int arrayitemY)
466 { 474 {
467 staticPrimspace[arrayitem] = IntPtr.Zero; 475 staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero;
468 } 476 }
469 477
470 public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) 478 public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace)
@@ -569,34 +577,37 @@ namespace OpenSim.Region.Physics.OdePlugin
569 // The routines in the Position and Size sections do the 'inserting' into the space, 577 // The routines in the Position and Size sections do the 'inserting' into the space,
570 // so all we have to do is make sure that the space that we're putting the prim into 578 // so all we have to do is make sure that the space that we're putting the prim into
571 // is in the 'main' space. 579 // is in the 'main' space.
572 int iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); 580 int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos);
573 IntPtr newspace = calculateSpaceForGeom(pos); 581 IntPtr newspace = calculateSpaceForGeom(pos);
574 582
575 if (newspace == IntPtr.Zero) 583 if (newspace == IntPtr.Zero)
576 { 584 {
577 newspace = createprimspace(iprimspaceArrItem); 585 newspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]);
578 d.HashSpaceSetLevels(newspace, -4, 66); 586 d.HashSpaceSetLevels(newspace, -4, 66);
579 } 587 }
580 588
581 return newspace; 589 return newspace;
582 } 590 }
583 591
584 public IntPtr createprimspace(int iprimspaceArrItem) { 592 public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) {
585 // creating a new space for prim and inserting it into main space. 593 // creating a new space for prim and inserting it into main space.
586 staticPrimspace[iprimspaceArrItem] = d.HashSpaceCreate(IntPtr.Zero); 594 staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero);
587 d.SpaceAdd(space, staticPrimspace[iprimspaceArrItem]); 595 d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX,iprimspaceArrItemY]);
588 return staticPrimspace[iprimspaceArrItem]; 596 return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY];
589 } 597 }
590 598
591 public IntPtr calculateSpaceForGeom(PhysicsVector pos) 599 public IntPtr calculateSpaceForGeom(PhysicsVector pos)
592 { 600 {
593 IntPtr locationbasedspace = staticPrimspace[calculateSpaceArrayItemFromPos(pos)]; 601 int[] xyspace = calculateSpaceArrayItemFromPos(pos);
602 IntPtr locationbasedspace = staticPrimspace[xyspace[0],xyspace[1]];
594 //locationbasedspace = space; 603 //locationbasedspace = space;
595 return locationbasedspace; 604 return locationbasedspace;
596 } 605 }
597 public int calculateSpaceArrayItemFromPos(PhysicsVector pos) 606 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos)
598 { 607 {
599 int returnint = ((int)((pos.X + pos.Y)/8.6f)); 608 int[] returnint = new int[2];
609 returnint[0] = (int)(pos.X / metersInSpace);
610 returnint[1] = (int)(pos.Y / metersInSpace);
600 return returnint; 611 return returnint;
601 } 612 }
602 613
@@ -619,11 +630,11 @@ namespace OpenSim.Region.Physics.OdePlugin
619 rot.z = rotation.z; 630 rot.z = rotation.z;
620 631
621 632
622 int iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); 633 int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos);
623 IntPtr targetspace = calculateSpaceForGeom(pos); 634 IntPtr targetspace = calculateSpaceForGeom(pos);
624 635
625 if (targetspace == IntPtr.Zero) 636 if (targetspace == IntPtr.Zero)
626 targetspace = createprimspace(iprimspaceArrItem); 637 targetspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]);
627 638
628 OdePrim newPrim; 639 OdePrim newPrim;
629 lock (OdeLock) 640 lock (OdeLock)
@@ -1326,14 +1337,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1326 m_lastUpdateSent = true; 1337 m_lastUpdateSent = true;
1327 base.RequestPhysicsterseUpdate(); 1338 base.RequestPhysicsterseUpdate();
1328 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); 1339 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
1329 int arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); 1340 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
1330 if (primScenAvatarIn == "0") 1341 if (primScenAvatarIn == "0")
1331 { 1342 {
1332 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem.ToString()); 1343 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1333 } 1344 }
1334 else 1345 else
1335 { 1346 {
1336 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem.ToString()); 1347 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1337 } 1348 }
1338 1349
1339 } 1350 }
@@ -1628,14 +1639,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1628 else 1639 else
1629 { 1640 {
1630 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); 1641 string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
1631 int arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); 1642 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
1632 if (primScenAvatarIn == "0") 1643 if (primScenAvatarIn == "0")
1633 { 1644 {
1634 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in space with no prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + " . Arr:': " + arrayitem.ToString()); 1645 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in space with no prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + " . Arr:': " + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1635 } 1646 }
1636 else 1647 else
1637 { 1648 {
1638 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in Prim space with prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + ". Arr:" + arrayitem.ToString()); 1649 OpenSim.Framework.Console.MainLog.Instance.Verbose("Physics", "Prim " + m_primName + " in Prim space with prim: " + primScenAvatarIn + ". Expected to be at: " + m_targetSpace.ToString() + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
1639 } 1650 }
1640 m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); 1651 m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
1641 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1652 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);