aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs207
1 files changed, 100 insertions, 107 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index e219535..0456f56 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -377,8 +377,7 @@ namespace OpenSim.Region.Physics.OdePlugin
377 /// <param value="name">Name of the scene. Useful in debug messages.</param> 377 /// <param value="name">Name of the scene. Useful in debug messages.</param>
378 public OdeScene(string name) 378 public OdeScene(string name)
379 { 379 {
380 m_log 380 m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
381 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
382 381
383 Name = name; 382 Name = name;
384 383
@@ -769,7 +768,7 @@ namespace OpenSim.Region.Physics.OdePlugin
769 } 768 }
770 catch (AccessViolationException) 769 catch (AccessViolationException)
771 { 770 {
772 m_log.Warn("[PHYSICS]: Unable to collide test a space"); 771 m_log.Warn("[ODE SCENE]: Unable to collide test a space");
773 return; 772 return;
774 } 773 }
775 //Colliding a space or a geom with a space or a geom. so drill down 774 //Colliding a space or a geom with a space or a geom. so drill down
@@ -821,17 +820,17 @@ namespace OpenSim.Region.Physics.OdePlugin
821 820
822 count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); 821 count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
823 if (count > contacts.Length) 822 if (count > contacts.Length)
824 m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); 823 m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
825 } 824 }
826 catch (SEHException) 825 catch (SEHException)
827 { 826 {
828 m_log.Error( 827 m_log.Error(
829 "[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); 828 "[ODE SCENE]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
830 base.TriggerPhysicsBasedRestart(); 829 base.TriggerPhysicsBasedRestart();
831 } 830 }
832 catch (Exception e) 831 catch (Exception e)
833 { 832 {
834 m_log.WarnFormat("[PHYSICS]: Unable to collide test an object: {0}", e.Message); 833 m_log.WarnFormat("[ODE SCENE]: Unable to collide test an object: {0}", e.Message);
835 return; 834 return;
836 } 835 }
837 836
@@ -1556,7 +1555,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1556 } 1555 }
1557 catch (AccessViolationException) 1556 catch (AccessViolationException)
1558 { 1557 {
1559 m_log.WarnFormat("[PHYSICS]: Unable to space collide {0}", Name); 1558 m_log.WarnFormat("[ODE SCENE]: Unable to space collide {0}", Name);
1560 } 1559 }
1561 1560
1562 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); 1561 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
@@ -1587,13 +1586,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1587 removeprims = new List<OdePrim>(); 1586 removeprims = new List<OdePrim>();
1588 } 1587 }
1589 removeprims.Add(chr); 1588 removeprims.Add(chr);
1590 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. Removed it from the active prim list. This needs to be fixed!"); 1589 m_log.Debug("[ODE SCENE]: 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. Removed it from the active prim list. This needs to be fixed!");
1591 } 1590 }
1592 } 1591 }
1593 } 1592 }
1594 catch (AccessViolationException) 1593 catch (AccessViolationException)
1595 { 1594 {
1596 m_log.Warn("[PHYSICS]: Unable to space collide"); 1595 m_log.Warn("[ODE SCENE]: Unable to space collide");
1597 } 1596 }
1598 } 1597 }
1599 } 1598 }
@@ -1729,18 +1728,24 @@ namespace OpenSim.Region.Physics.OdePlugin
1729 _characters.Add(chr); 1728 _characters.Add(chr);
1730 1729
1731 if (chr.bad) 1730 if (chr.bad)
1732 m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid); 1731 m_log.ErrorFormat("[ODE SCENE]: Added BAD actor {0} to characters list", chr.m_uuid);
1732 }
1733 else
1734 {
1735 m_log.ErrorFormat(
1736 "[ODE SCENE]: Tried to add character {0} {1} but they are already in the set!",
1737 chr.Name, chr.LocalID);
1733 } 1738 }
1734 } 1739 }
1735 1740
1736 internal void RemoveCharacter(OdeCharacter chr) 1741 internal void RemoveCharacter(OdeCharacter chr)
1737 { 1742 {
1738 if (_characters.Contains(chr)) 1743 if (_characters.Contains(chr))
1739 {
1740 _characters.Remove(chr); 1744 _characters.Remove(chr);
1741 geom_name_map.Remove(chr.Shell); 1745 else
1742 actor_name_map.Remove(chr.Shell); 1746 m_log.ErrorFormat(
1743 } 1747 "[ODE SCENE]: Tried to remove character {0} {1} but they are not in the list!",
1748 chr.Name, chr.LocalID);
1744 } 1749 }
1745 1750
1746 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, 1751 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
@@ -2160,7 +2165,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2160 2165
2161 p.setPrimForRemoval(); 2166 p.setPrimForRemoval();
2162 AddPhysicsActorTaint(prim); 2167 AddPhysicsActorTaint(prim);
2163 //RemovePrimThreadLocked(p);
2164 } 2168 }
2165 } 2169 }
2166 } 2170 }
@@ -2228,7 +2232,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2228 //m_log.Warn(prim.prim_geom); 2232 //m_log.Warn(prim.prim_geom);
2229 2233
2230 if (!prim.RemoveGeom()) 2234 if (!prim.RemoveGeom())
2231 m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene"); 2235 m_log.Warn("[ODE SCENE]: Unable to remove prim from physics scene");
2232 2236
2233 lock (_prims) 2237 lock (_prims)
2234 _prims.Remove(prim); 2238 _prims.Remove(prim);
@@ -2320,7 +2324,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2320 } 2324 }
2321 else 2325 else
2322 { 2326 {
2323 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + currentspace + 2327 m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + currentspace +
2324 " Geom:" + geom); 2328 " Geom:" + geom);
2325 } 2329 }
2326 } 2330 }
@@ -2336,7 +2340,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2336 } 2340 }
2337 else 2341 else
2338 { 2342 {
2339 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + 2343 m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
2340 sGeomIsIn + " Geom:" + geom); 2344 sGeomIsIn + " Geom:" + geom);
2341 } 2345 }
2342 } 2346 }
@@ -2359,7 +2363,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2359 } 2363 }
2360 else 2364 else
2361 { 2365 {
2362 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + 2366 m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
2363 currentspace + " Geom:" + geom); 2367 currentspace + " Geom:" + geom);
2364 } 2368 }
2365 } 2369 }
@@ -2379,7 +2383,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2379 } 2383 }
2380 else 2384 else
2381 { 2385 {
2382 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + 2386 m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
2383 currentspace + " Geom:" + geom); 2387 currentspace + " Geom:" + geom);
2384 } 2388 }
2385 } 2389 }
@@ -2395,7 +2399,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2395 } 2399 }
2396 else 2400 else
2397 { 2401 {
2398 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + 2402 m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
2399 sGeomIsIn + " Geom:" + geom); 2403 sGeomIsIn + " Geom:" + geom);
2400 } 2404 }
2401 } 2405 }
@@ -2607,15 +2611,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2607 2611
2608 /// <summary> 2612 /// <summary>
2609 /// Called after our prim properties are set Scale, position etc. 2613 /// Called after our prim properties are set Scale, position etc.
2614 /// </summary>
2615 /// <remarks>
2610 /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex 2616 /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex
2611 /// This assures us that we have no race conditions 2617 /// This assures us that we have no race conditions
2612 /// </summary> 2618 /// </remarks>
2613 /// <param name="prim"></param> 2619 /// <param name="actor"></param>
2614 public override void AddPhysicsActorTaint(PhysicsActor prim) 2620 public override void AddPhysicsActorTaint(PhysicsActor actor)
2615 { 2621 {
2616 if (prim is OdePrim) 2622 if (actor is OdePrim)
2617 { 2623 {
2618 OdePrim taintedprim = ((OdePrim) prim); 2624 OdePrim taintedprim = ((OdePrim)actor);
2619 lock (_taintedPrimLock) 2625 lock (_taintedPrimLock)
2620 { 2626 {
2621 if (!(_taintedPrimH.Contains(taintedprim))) 2627 if (!(_taintedPrimH.Contains(taintedprim)))
@@ -2627,18 +2633,17 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2627 _taintedPrimL.Add(taintedprim); // List for ordered readout 2633 _taintedPrimL.Add(taintedprim); // List for ordered readout
2628 } 2634 }
2629 } 2635 }
2630 return;
2631 } 2636 }
2632 else if (prim is OdeCharacter) 2637 else if (actor is OdeCharacter)
2633 { 2638 {
2634 OdeCharacter taintedchar = ((OdeCharacter)prim); 2639 OdeCharacter taintedchar = ((OdeCharacter)actor);
2635 lock (_taintedActors) 2640 lock (_taintedActors)
2636 { 2641 {
2637 if (!(_taintedActors.Contains(taintedchar))) 2642 if (!(_taintedActors.Contains(taintedchar)))
2638 { 2643 {
2639 _taintedActors.Add(taintedchar); 2644 _taintedActors.Add(taintedchar);
2640 if (taintedchar.bad) 2645 if (taintedchar.bad)
2641 m_log.DebugFormat("[PHYSICS]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid); 2646 m_log.DebugFormat("[ODE SCENE]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid);
2642 } 2647 }
2643 } 2648 }
2644 } 2649 }
@@ -2734,29 +2739,18 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2734 { 2739 {
2735 try 2740 try
2736 { 2741 {
2737 // Insert, remove Characters
2738 bool processedtaints = false;
2739
2740 lock (_taintedActors) 2742 lock (_taintedActors)
2741 { 2743 {
2742 if (_taintedActors.Count > 0) 2744 if (_taintedActors.Count > 0)
2743 { 2745 {
2744 foreach (OdeCharacter character in _taintedActors) 2746 foreach (OdeCharacter character in _taintedActors)
2745 {
2746 character.ProcessTaints(); 2747 character.ProcessTaints();
2747 2748
2748 processedtaints = true; 2749 if (_taintedActors.Count > 0)
2749 //character.m_collisionscore = 0;
2750 }
2751
2752 if (processedtaints)
2753 _taintedActors.Clear(); 2750 _taintedActors.Clear();
2754 } 2751 }
2755 } 2752 }
2756 2753
2757 // Modify other objects in the scene.
2758 processedtaints = false;
2759
2760 lock (_taintedPrimLock) 2754 lock (_taintedPrimLock)
2761 { 2755 {
2762 foreach (OdePrim prim in _taintedPrimL) 2756 foreach (OdePrim prim in _taintedPrimL)
@@ -2772,7 +2766,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2772 prim.ProcessTaints(); 2766 prim.ProcessTaints();
2773 } 2767 }
2774 2768
2775 processedtaints = true;
2776 prim.m_collisionscore = 0; 2769 prim.m_collisionscore = 0;
2777 2770
2778 // This loop can block up the Heartbeat for a very long time on large regions. 2771 // This loop can block up the Heartbeat for a very long time on large regions.
@@ -2785,7 +2778,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2785 if (SupportsNINJAJoints) 2778 if (SupportsNINJAJoints)
2786 SimulatePendingNINJAJoints(); 2779 SimulatePendingNINJAJoints();
2787 2780
2788 if (processedtaints) 2781 if (_taintedPrimL.Count > 0)
2789 { 2782 {
2790//Console.WriteLine("Simulate calls Clear of _taintedPrim list"); 2783//Console.WriteLine("Simulate calls Clear of _taintedPrim list");
2791 _taintedPrimH.Clear(); 2784 _taintedPrimH.Clear();
@@ -2853,7 +2846,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2853 } 2846 }
2854 catch (Exception e) 2847 catch (Exception e)
2855 { 2848 {
2856 m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e); 2849 m_log.ErrorFormat("[ODE SCENE]: {0}, {1}, {2}", e.Message, e.TargetSite, e);
2857 } 2850 }
2858 2851
2859 timeLeft -= ODE_STEPSIZE; 2852 timeLeft -= ODE_STEPSIZE;
@@ -2862,7 +2855,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2862 foreach (OdeCharacter actor in _characters) 2855 foreach (OdeCharacter actor in _characters)
2863 { 2856 {
2864 if (actor.bad) 2857 if (actor.bad)
2865 m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); 2858 m_log.WarnFormat("[ODE SCENE]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
2866 2859
2867 actor.UpdatePositionAndVelocity(defects); 2860 actor.UpdatePositionAndVelocity(defects);
2868 } 2861 }
@@ -3422,7 +3415,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
3422 { 3415 {
3423 if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x])) 3416 if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x]))
3424 { 3417 {
3425 m_log.Warn("[PHYSICS]: Non finite heightfield element detected. Setting it to 0"); 3418 m_log.Warn("[ODE SCENE]: Non finite heightfield element detected. Setting it to 0");
3426 resultarr2[y, x] = 0; 3419 resultarr2[y, x] = 0;
3427 } 3420 }
3428 returnarr[i] = resultarr2[y, x]; 3421 returnarr[i] = resultarr2[y, x];
@@ -3453,7 +3446,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
3453 private void SetTerrain(float[] heightMap, Vector3 pOffset) 3446 private void SetTerrain(float[] heightMap, Vector3 pOffset)
3454 { 3447 {
3455 int startTime = Util.EnvironmentTickCount(); 3448 int startTime = Util.EnvironmentTickCount();
3456 m_log.DebugFormat("[PHYSICS]: Setting terrain for {0}", Name); 3449 m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0}", Name);
3457 3450
3458 // this._heightmap[i] = (double)heightMap[i]; 3451 // this._heightmap[i] = (double)heightMap[i];
3459 // dbm (danx0r) -- creating a buffer zone of one extra sample all around 3452 // dbm (danx0r) -- creating a buffer zone of one extra sample all around
@@ -3578,7 +3571,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
3578 } 3571 }
3579 3572
3580 m_log.DebugFormat( 3573 m_log.DebugFormat(
3581 "[PHYSICS]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime)); 3574 "[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime));
3582 } 3575 }
3583 3576
3584 public override void DeleteTerrain() 3577 public override void DeleteTerrain()
@@ -3595,64 +3588,64 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
3595 return true; 3588 return true;
3596 } 3589 }
3597 3590
3598 public override void UnCombine(PhysicsScene pScene) 3591// public override void UnCombine(PhysicsScene pScene)
3599 { 3592// {
3600 IntPtr localGround = IntPtr.Zero; 3593// IntPtr localGround = IntPtr.Zero;
3601// float[] localHeightfield; 3594//// float[] localHeightfield;
3602 bool proceed = false; 3595// bool proceed = false;
3603 List<IntPtr> geomDestroyList = new List<IntPtr>(); 3596// List<IntPtr> geomDestroyList = new List<IntPtr>();
3604 3597//
3605 lock (OdeLock) 3598// lock (OdeLock)
3606 { 3599// {
3607 if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround)) 3600// if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround))
3608 { 3601// {
3609 foreach (IntPtr geom in TerrainHeightFieldHeights.Keys) 3602// foreach (IntPtr geom in TerrainHeightFieldHeights.Keys)
3610 { 3603// {
3611 if (geom == localGround) 3604// if (geom == localGround)
3612 { 3605// {
3613// localHeightfield = TerrainHeightFieldHeights[geom]; 3606//// localHeightfield = TerrainHeightFieldHeights[geom];
3614 proceed = true; 3607// proceed = true;
3615 } 3608// }
3616 else 3609// else
3617 { 3610// {
3618 geomDestroyList.Add(geom); 3611// geomDestroyList.Add(geom);
3619 } 3612// }
3620 } 3613// }
3621 3614//
3622 if (proceed) 3615// if (proceed)
3623 { 3616// {
3624 m_worldOffset = Vector3.Zero; 3617// m_worldOffset = Vector3.Zero;
3625 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); 3618// WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
3626 m_parentScene = null; 3619// m_parentScene = null;
3627 3620//
3628 foreach (IntPtr g in geomDestroyList) 3621// foreach (IntPtr g in geomDestroyList)
3629 { 3622// {
3630 // removingHeightField needs to be done or the garbage collector will 3623// // removingHeightField needs to be done or the garbage collector will
3631 // collect the terrain data before we tell ODE to destroy it causing 3624// // collect the terrain data before we tell ODE to destroy it causing
3632 // memory corruption 3625// // memory corruption
3633 if (TerrainHeightFieldHeights.ContainsKey(g)) 3626// if (TerrainHeightFieldHeights.ContainsKey(g))
3634 { 3627// {
3635// float[] removingHeightField = TerrainHeightFieldHeights[g]; 3628//// float[] removingHeightField = TerrainHeightFieldHeights[g];
3636 TerrainHeightFieldHeights.Remove(g); 3629// TerrainHeightFieldHeights.Remove(g);
3637 3630//
3638 if (RegionTerrain.ContainsKey(g)) 3631// if (RegionTerrain.ContainsKey(g))
3639 { 3632// {
3640 RegionTerrain.Remove(g); 3633// RegionTerrain.Remove(g);
3641 } 3634// }
3642 3635//
3643 d.GeomDestroy(g); 3636// d.GeomDestroy(g);
3644 //removingHeightField = new float[0]; 3637// //removingHeightField = new float[0];
3645 } 3638// }
3646 } 3639// }
3647 3640//
3648 } 3641// }
3649 else 3642// else
3650 { 3643// {
3651 m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); 3644// m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data.");
3652 } 3645// }
3653 } 3646// }
3654 } 3647// }
3655 } 3648// }
3656 3649
3657 public override void SetWaterLevel(float baseheight) 3650 public override void SetWaterLevel(float baseheight)
3658 { 3651 {