diff options
Merge branch 'ubitwork' into avination
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 4552f3f..d5938f4 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
175 | 175 | ||
176 | const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; | 176 | const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; |
177 | const float MaxERP = 0.8f; | 177 | const float MaxERP = 0.8f; |
178 | const float minERP = 0.1f; | 178 | const float minERP = 0.2f; |
179 | const float comumContactCFM = 0.0001f; | 179 | const float comumContactCFM = 0.0001f; |
180 | 180 | ||
181 | float frictionMovementMult = 0.8f; | 181 | float frictionMovementMult = 0.8f; |
@@ -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 | ||
@@ -408,8 +408,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
408 | // checkThread(); | 408 | // checkThread(); |
409 | mesher = meshmerizer; | 409 | mesher = meshmerizer; |
410 | m_config = config; | 410 | m_config = config; |
411 | /* | 411 | |
412 | string ode_config = d.GetConfiguration("ODE"); | 412 | string ode_config = d.GetConfiguration(); |
413 | if (ode_config != null && ode_config != "") | 413 | if (ode_config != null && ode_config != "") |
414 | { | 414 | { |
415 | m_log.WarnFormat("ODE configuration: {0}", ode_config); | 415 | m_log.WarnFormat("ODE configuration: {0}", ode_config); |
@@ -419,7 +419,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
419 | OdeUbitLib = true; | 419 | OdeUbitLib = true; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | */ | 422 | |
423 | /* | 423 | /* |
424 | if (region != null) | 424 | if (region != null) |
425 | { | 425 | { |
@@ -921,6 +921,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
921 | cfm = 0.0001f / cfm; | 921 | cfm = 0.0001f / cfm; |
922 | if (cfm > 0.01f) | 922 | if (cfm > 0.01f) |
923 | cfm = 0.01f; | 923 | cfm = 0.01f; |
924 | else if (cfm < 0.0001f) | ||
925 | cfm = 0.0001f; | ||
924 | 926 | ||
925 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) | 927 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) |
926 | mu *= frictionMovementMult; | 928 | mu *= frictionMovementMult; |
@@ -947,6 +949,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
947 | cfm = 0.0001f / cfm; | 949 | cfm = 0.0001f / cfm; |
948 | if (cfm > 0.01f) | 950 | if (cfm > 0.01f) |
949 | cfm = 0.01f; | 951 | cfm = 0.01f; |
952 | else if (cfm < 0.0001f) | ||
953 | cfm = 0.0001f; | ||
950 | 954 | ||
951 | if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) | 955 | if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) |
952 | { | 956 | { |
@@ -1892,18 +1896,22 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1892 | lock (SimulationLock) | 1896 | lock (SimulationLock) |
1893 | lock(OdeLock) | 1897 | lock(OdeLock) |
1894 | { | 1898 | { |
1899 | if (world == IntPtr.Zero) | ||
1900 | return 0; | ||
1901 | |||
1895 | // adjust number of iterations per step | 1902 | // adjust number of iterations per step |
1896 | try | 1903 | |
1897 | { | 1904 | // try |
1905 | // { | ||
1898 | d.WorldSetQuickStepNumIterations(world, curphysiteractions); | 1906 | d.WorldSetQuickStepNumIterations(world, curphysiteractions); |
1899 | } | 1907 | /* } |
1900 | catch (StackOverflowException) | 1908 | catch (StackOverflowException) |
1901 | { | 1909 | { |
1902 | m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); | 1910 | m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); |
1903 | // ode.drelease(world); | 1911 | // ode.drelease(world); |
1904 | base.TriggerPhysicsBasedRestart(); | 1912 | base.TriggerPhysicsBasedRestart(); |
1905 | } | 1913 | } |
1906 | 1914 | */ | |
1907 | while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever | 1915 | while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever |
1908 | { | 1916 | { |
1909 | try | 1917 | try |
@@ -2383,11 +2391,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2383 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 2391 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
2384 | d.GeomSetRotation(GroundGeom, ref R); | 2392 | d.GeomSetRotation(GroundGeom, ref R); |
2385 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); | 2393 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); |
2386 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); | 2394 | RegionTerrain.Add(pOffset, GroundGeom); |
2387 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); | ||
2388 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2395 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |
2389 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); | 2396 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); |
2390 | |||
2391 | } | 2397 | } |
2392 | } | 2398 | } |
2393 | 2399 | ||
@@ -2486,8 +2492,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2486 | geom_name_map[GroundGeom] = "Terrain"; | 2492 | geom_name_map[GroundGeom] = "Terrain"; |
2487 | 2493 | ||
2488 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); | 2494 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); |
2489 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); | 2495 | RegionTerrain.Add(pOffset, GroundGeom); |
2490 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); | ||
2491 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2496 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |
2492 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); | 2497 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); |
2493 | } | 2498 | } |
@@ -2649,19 +2654,42 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2649 | 2654 | ||
2650 | public override void Dispose() | 2655 | public override void Dispose() |
2651 | { | 2656 | { |
2652 | m_rayCastManager.Dispose(); | ||
2653 | m_rayCastManager = null; | ||
2654 | |||
2655 | lock (OdeLock) | 2657 | lock (OdeLock) |
2656 | { | 2658 | { |
2659 | m_rayCastManager.Dispose(); | ||
2660 | m_rayCastManager = null; | ||
2661 | |||
2657 | lock (_prims) | 2662 | lock (_prims) |
2658 | { | 2663 | { |
2664 | ChangesQueue.Clear(); | ||
2659 | foreach (OdePrim prm in _prims) | 2665 | foreach (OdePrim prm in _prims) |
2660 | { | 2666 | { |
2661 | RemovePrim(prm); | 2667 | prm.DoAChange(changes.Remove, null); |
2668 | _collisionEventPrim.Remove(prm); | ||
2662 | } | 2669 | } |
2670 | _prims.Clear(); | ||
2671 | } | ||
2672 | |||
2673 | OdeCharacter[] chtorem; | ||
2674 | lock (_characters) | ||
2675 | { | ||
2676 | chtorem = new OdeCharacter[_characters.Count]; | ||
2677 | _characters.CopyTo(chtorem); | ||
2678 | } | ||
2679 | |||
2680 | ChangesQueue.Clear(); | ||
2681 | foreach (OdeCharacter ch in chtorem) | ||
2682 | ch.DoAChange(changes.Remove, null); | ||
2683 | |||
2684 | |||
2685 | foreach (IntPtr GroundGeom in RegionTerrain.Values) | ||
2686 | { | ||
2687 | if (GroundGeom != IntPtr.Zero) | ||
2688 | d.GeomDestroy(GroundGeom); | ||
2663 | } | 2689 | } |
2664 | 2690 | ||
2691 | RegionTerrain.Clear(); | ||
2692 | |||
2665 | if (TerrainHeightFieldHeightsHandlers.Count > 0) | 2693 | if (TerrainHeightFieldHeightsHandlers.Count > 0) |
2666 | { | 2694 | { |
2667 | foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values) | 2695 | foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values) |
@@ -2671,6 +2699,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2671 | } | 2699 | } |
2672 | } | 2700 | } |
2673 | 2701 | ||
2702 | TerrainHeightFieldHeightsHandlers.Clear(); | ||
2703 | TerrainHeightFieldHeights.Clear(); | ||
2704 | |||
2674 | if (WaterGeom != IntPtr.Zero) | 2705 | if (WaterGeom != IntPtr.Zero) |
2675 | { | 2706 | { |
2676 | d.GeomDestroy(WaterGeom); | 2707 | d.GeomDestroy(WaterGeom); |
@@ -2691,6 +2722,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2691 | 2722 | ||
2692 | 2723 | ||
2693 | d.WorldDestroy(world); | 2724 | d.WorldDestroy(world); |
2725 | world = IntPtr.Zero; | ||
2694 | //d.CloseODE(); | 2726 | //d.CloseODE(); |
2695 | } | 2727 | } |
2696 | } | 2728 | } |