aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin
diff options
context:
space:
mode:
authorUbitUmarov2012-07-09 13:25:17 +0100
committerUbitUmarov2012-07-09 13:25:17 +0100
commitfb8e8dcbce6b2ecbb8fbfe8278657260ac55e823 (patch)
treec0527c8f5a51c2c053e2c77576ac075cda465657 /OpenSim/Region/Physics/UbitOdePlugin
parentMerge branch 'avination' into ubitwork (diff)
downloadopensim-SC_OLD-fb8e8dcbce6b2ecbb8fbfe8278657260ac55e823.zip
opensim-SC_OLD-fb8e8dcbce6b2ecbb8fbfe8278657260ac55e823.tar.gz
opensim-SC_OLD-fb8e8dcbce6b2ecbb8fbfe8278657260ac55e823.tar.bz2
opensim-SC_OLD-fb8e8dcbce6b2ecbb8fbfe8278657260ac55e823.tar.xz
fix ODE dispose plus minor clean. On regions restart ode.dispose seems
to be called with scene still calling simulation, that should be changed, for now added a check for a valid world in ode simulation
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs58
1 files changed, 43 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 4552f3f..5920838 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -268,7 +268,7 @@ namespace OpenSim.Region.Physics.OdePlugin
268 268
269 public ContactData[] m_materialContactsData = new ContactData[8]; 269 public ContactData[] m_materialContactsData = new ContactData[8];
270 270
271 private readonly DoubleDictionary<Vector3, IntPtr, IntPtr> RegionTerrain = new DoubleDictionary<Vector3, IntPtr, IntPtr>(); 271 private readonly Dictionary<Vector3, IntPtr> RegionTerrain = new Dictionary<Vector3, IntPtr>();
272 private readonly Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>(); 272 private readonly Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
273 private readonly Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>(); 273 private readonly Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
274 274
@@ -1892,18 +1892,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1892 lock (SimulationLock) 1892 lock (SimulationLock)
1893 lock(OdeLock) 1893 lock(OdeLock)
1894 { 1894 {
1895 if (world == IntPtr.Zero)
1896 return 0;
1897
1895 // adjust number of iterations per step 1898 // adjust number of iterations per step
1896 try 1899
1897 { 1900// try
1901// {
1898 d.WorldSetQuickStepNumIterations(world, curphysiteractions); 1902 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1899 } 1903/* }
1900 catch (StackOverflowException) 1904 catch (StackOverflowException)
1901 { 1905 {
1902 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); 1906 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
1903// ode.drelease(world); 1907// ode.drelease(world);
1904 base.TriggerPhysicsBasedRestart(); 1908 base.TriggerPhysicsBasedRestart();
1905 } 1909 }
1906 1910*/
1907 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever 1911 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
1908 { 1912 {
1909 try 1913 try
@@ -2383,11 +2387,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2383 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 2387 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
2384 d.GeomSetRotation(GroundGeom, ref R); 2388 d.GeomSetRotation(GroundGeom, ref R);
2385 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2389 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2386 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2390 RegionTerrain.Add(pOffset, GroundGeom);
2387// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
2388 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2391 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2389 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2392 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2390
2391 } 2393 }
2392 } 2394 }
2393 2395
@@ -2486,8 +2488,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2486 geom_name_map[GroundGeom] = "Terrain"; 2488 geom_name_map[GroundGeom] = "Terrain";
2487 2489
2488 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2490 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2489 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2491 RegionTerrain.Add(pOffset, GroundGeom);
2490 // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
2491 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2492 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2492 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2493 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2493 } 2494 }
@@ -2649,19 +2650,42 @@ namespace OpenSim.Region.Physics.OdePlugin
2649 2650
2650 public override void Dispose() 2651 public override void Dispose()
2651 { 2652 {
2652 m_rayCastManager.Dispose();
2653 m_rayCastManager = null;
2654
2655 lock (OdeLock) 2653 lock (OdeLock)
2656 { 2654 {
2655 m_rayCastManager.Dispose();
2656 m_rayCastManager = null;
2657
2657 lock (_prims) 2658 lock (_prims)
2658 { 2659 {
2660 ChangesQueue.Clear();
2659 foreach (OdePrim prm in _prims) 2661 foreach (OdePrim prm in _prims)
2660 { 2662 {
2661 RemovePrim(prm); 2663 prm.DoAChange(changes.Remove, null);
2664 _collisionEventPrim.Remove(prm);
2662 } 2665 }
2666 _prims.Clear();
2663 } 2667 }
2664 2668
2669 OdeCharacter[] chtorem;
2670 lock (_characters)
2671 {
2672 chtorem = new OdeCharacter[_characters.Count];
2673 _characters.CopyTo(chtorem);
2674 }
2675
2676 ChangesQueue.Clear();
2677 foreach (OdeCharacter ch in chtorem)
2678 ch.DoAChange(changes.Remove, null);
2679
2680
2681 foreach (IntPtr GroundGeom in RegionTerrain.Values)
2682 {
2683 if (GroundGeom != IntPtr.Zero)
2684 d.GeomDestroy(GroundGeom);
2685 }
2686
2687 RegionTerrain.Clear();
2688
2665 if (TerrainHeightFieldHeightsHandlers.Count > 0) 2689 if (TerrainHeightFieldHeightsHandlers.Count > 0)
2666 { 2690 {
2667 foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values) 2691 foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values)
@@ -2671,6 +2695,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2671 } 2695 }
2672 } 2696 }
2673 2697
2698 TerrainHeightFieldHeightsHandlers.Clear();
2699 TerrainHeightFieldHeights.Clear();
2700
2674 if (WaterGeom != IntPtr.Zero) 2701 if (WaterGeom != IntPtr.Zero)
2675 { 2702 {
2676 d.GeomDestroy(WaterGeom); 2703 d.GeomDestroy(WaterGeom);
@@ -2691,6 +2718,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2691 2718
2692 2719
2693 d.WorldDestroy(world); 2720 d.WorldDestroy(world);
2721 world = IntPtr.Zero;
2694 //d.CloseODE(); 2722 //d.CloseODE();
2695 } 2723 }
2696 } 2724 }