aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-21 19:45:22 +0000
committerJustin Clark-Casey (justincc)2011-11-21 19:45:22 +0000
commit54789706f40d0800d1277eeb71afd61edcefd9ab (patch)
tree1b486ad115731aeb117aa6a0da1f601b3147573e /OpenSim/Region
parentmove geom/actor map maintenance into DestroyODEStructures()/AvatarGeomAndBody... (diff)
downloadopensim-SC_OLD-54789706f40d0800d1277eeb71afd61edcefd9ab.zip
opensim-SC_OLD-54789706f40d0800d1277eeb71afd61edcefd9ab.tar.gz
opensim-SC_OLD-54789706f40d0800d1277eeb71afd61edcefd9ab.tar.bz2
opensim-SC_OLD-54789706f40d0800d1277eeb71afd61edcefd9ab.tar.xz
Reduce complexity of OdeScene.Simulate() by fully removing bad characters at point of detection rather than later on.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs57
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs42
2 files changed, 29 insertions, 70 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 0f1a897..c838587 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -178,7 +178,7 @@ namespace OpenSim.Region.Physics.OdePlugin
178 parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f); 178 parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
179 m_taintPosition = _position; 179 m_taintPosition = _position;
180 180
181 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); 181 m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName);
182 } 182 }
183 183
184 _parent_scene = parent_scene; 184 _parent_scene = parent_scene;
@@ -201,7 +201,7 @@ namespace OpenSim.Region.Physics.OdePlugin
201 m_colliderarr[i] = false; 201 m_colliderarr[i] = false;
202 } 202 }
203 CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; 203 CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
204 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 204 //m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH.ToString());
205 m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH; 205 m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
206 206
207 m_isPhysical = false; // current status: no ODE information exists 207 m_isPhysical = false; // current status: no ODE information exists
@@ -266,7 +266,7 @@ namespace OpenSim.Region.Physics.OdePlugin
266 set 266 set
267 { 267 {
268 flying = value; 268 flying = value;
269// m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); 269// m_log.DebugFormat("[ODE CHARACTER]: Set OdeCharacter Flying to {0}", flying);
270 } 270 }
271 } 271 }
272 272
@@ -437,7 +437,7 @@ namespace OpenSim.Region.Physics.OdePlugin
437 } 437 }
438 else 438 else
439 { 439 {
440 m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character"); 440 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Position from Scene on character {0}", Name);
441 } 441 }
442 } 442 }
443 } 443 }
@@ -464,7 +464,7 @@ namespace OpenSim.Region.Physics.OdePlugin
464 464
465 Vector3 SetSize = value; 465 Vector3 SetSize = value;
466 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; 466 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
467// m_log.Info("[SIZE]: " + CAPSULE_LENGTH); 467// m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH);
468 468
469 // If we reset velocity here, then an avatar stalls when it crosses a border for the first time 469 // If we reset velocity here, then an avatar stalls when it crosses a border for the first time
470 // (as the height of the new root agent is set). 470 // (as the height of the new root agent is set).
@@ -474,7 +474,7 @@ namespace OpenSim.Region.Physics.OdePlugin
474 } 474 }
475 else 475 else
476 { 476 {
477 m_log.Warn("[PHYSICS]: Got a NaN Size from Scene on a Character"); 477 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size from Scene on {0}", Name);
478 } 478 }
479 } 479 }
480 } 480 }
@@ -533,7 +533,7 @@ namespace OpenSim.Region.Physics.OdePlugin
533 float xTiltComponent = -movementVector.X * m_tiltMagnitudeWhenProjectedOnXYPlane; 533 float xTiltComponent = -movementVector.X * m_tiltMagnitudeWhenProjectedOnXYPlane;
534 float yTiltComponent = -movementVector.Y * m_tiltMagnitudeWhenProjectedOnXYPlane; 534 float yTiltComponent = -movementVector.Y * m_tiltMagnitudeWhenProjectedOnXYPlane;
535 535
536 //m_log.Debug("[PHYSICS] changing avatar tilt"); 536 //m_log.Debug("[ODE CHARACTER]: changing avatar tilt");
537 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, xTiltComponent); 537 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, xTiltComponent);
538 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, xTiltComponent); // must be same as lowstop, else a different, spurious tilt is introduced 538 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, xTiltComponent); // must be same as lowstop, else a different, spurious tilt is introduced
539 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, yTiltComponent); 539 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, yTiltComponent);
@@ -560,17 +560,16 @@ namespace OpenSim.Region.Physics.OdePlugin
560 _parent_scene.waitForSpaceUnlock(_parent_scene.space); 560 _parent_scene.waitForSpaceUnlock(_parent_scene.space);
561 if (CAPSULE_LENGTH <= 0) 561 if (CAPSULE_LENGTH <= 0)
562 { 562 {
563 m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); 563 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
564 CAPSULE_LENGTH = 0.01f; 564 CAPSULE_LENGTH = 0.01f;
565
566 } 565 }
567 566
568 if (CAPSULE_RADIUS <= 0) 567 if (CAPSULE_RADIUS <= 0)
569 { 568 {
570 m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); 569 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
571 CAPSULE_RADIUS = 0.01f; 570 CAPSULE_RADIUS = 0.01f;
572
573 } 571 }
572
574 Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); 573 Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
575 574
576 d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); 575 d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
@@ -770,7 +769,7 @@ namespace OpenSim.Region.Physics.OdePlugin
770 } 769 }
771 else 770 else
772 { 771 {
773 m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character"); 772 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN velocity from Scene for {0}", Name);
774 } 773 }
775 774
776// m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", m_taintTargetVelocity); 775// m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", m_taintTargetVelocity);
@@ -848,7 +847,7 @@ namespace OpenSim.Region.Physics.OdePlugin
848 } 847 }
849 else 848 else
850 { 849 {
851 m_log.Warn("[PHYSICS]: Got a NaN force applied to a Character"); 850 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN force applied to {0}", Name);
852 } 851 }
853 //m_lastUpdateSent = false; 852 //m_lastUpdateSent = false;
854 } 853 }
@@ -874,11 +873,11 @@ namespace OpenSim.Region.Physics.OdePlugin
874 /// Called from Simulate 873 /// Called from Simulate
875 /// This is the avatar's movement control + PID Controller 874 /// This is the avatar's movement control + PID Controller
876 /// </summary> 875 /// </summary>
877 /// <param name="defects"> 876 /// <remarks>
878 /// If there is something wrong with the character (e.g. its position is non-finite) 877 /// This routine will remove the character from the physics scene if it detects something wrong (non-finite
879 /// then it is added to this list. The ODE structures associated with it are also destroyed. 878 /// position or velocity).
880 /// </param> 879 /// </remarks>
881 internal void Move(List<OdeCharacter> defects) 880 internal void Move()
882 { 881 {
883 // no lock; for now it's only called from within Simulate() 882 // no lock; for now it's only called from within Simulate()
884 883
@@ -899,11 +898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
899 898
900 if (!localPos.IsFinite()) 899 if (!localPos.IsFinite())
901 { 900 {
902 m_log.WarnFormat("[PHYSICS]: Avatar Position of {0} is non-finite!", Name); 901 m_log.WarnFormat(
903 902 "[ODE CHARACTER]: Avatar position of {0} for {1} is non-finite! Removing from physics scene.",
904 defects.Add(this); 903 localPos, Name);
905 // _parent_scene.RemoveCharacter(this);
906 904
905 _parent_scene.RemoveCharacter(this);
907 DestroyOdeStructures(); 906 DestroyOdeStructures();
908 907
909 return; 908 return;
@@ -1038,11 +1037,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1038 } 1037 }
1039 else 1038 else
1040 { 1039 {
1041 m_log.Warn("[PHYSICS]: Got a NaN force vector in Move()"); 1040 m_log.WarnFormat(
1042 m_log.Warn("[PHYSICS]: Avatar Position is non-finite!"); 1041 "[ODE CHARACTER]: Got a NaN force vector {0} in Move() for {1}. Removing character from physics scene.",
1043 defects.Add(this); 1042 vec, Name);
1044 // _parent_scene.RemoveCharacter(this);
1045 1043
1044 _parent_scene.RemoveCharacter(this);
1046 DestroyOdeStructures(); 1045 DestroyOdeStructures();
1047 } 1046 }
1048 } 1047 }
@@ -1061,7 +1060,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1061 catch (NullReferenceException) 1060 catch (NullReferenceException)
1062 { 1061 {
1063 bad = true; 1062 bad = true;
1064 _parent_scene.BadCharacter(this); 1063 _parent_scene.RemoveCharacter(this);
1065 DestroyOdeStructures(); 1064 DestroyOdeStructures();
1066 newPos = new d.Vector3(_position.X, _position.Y, _position.Z); 1065 newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
1067 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! 1066 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
@@ -1275,7 +1274,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1275 // Create avatar capsule and related ODE data 1274 // Create avatar capsule and related ODE data
1276 if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero)) 1275 if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
1277 { 1276 {
1278 m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - " 1277 m_log.Warn("[ODE CHARACTER]: re-creating the following avatar ODE data for " + Name + ", even though it already exists - "
1279 + (Shell!=IntPtr.Zero ? "Shell ":"") 1278 + (Shell!=IntPtr.Zero ? "Shell ":"")
1280 + (Body!=IntPtr.Zero ? "Body ":"") 1279 + (Body!=IntPtr.Zero ? "Body ":"")
1281 + (Amotor!=IntPtr.Zero ? "Amotor ":"")); 1280 + (Amotor!=IntPtr.Zero ? "Amotor ":""));
@@ -1320,7 +1319,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1320 } 1319 }
1321 else 1320 else
1322 { 1321 {
1323 m_log.Warn("[ODE CHARACTER]: trying to change capsule size, but the following ODE data is missing - " 1322 m_log.Warn("[ODE CHARACTER]: trying to change capsule size for " + Name + ", but the following ODE data is missing - "
1324 + (Shell==IntPtr.Zero ? "Shell ":"") 1323 + (Shell==IntPtr.Zero ? "Shell ":"")
1325 + (Body==IntPtr.Zero ? "Body ":"") 1324 + (Body==IntPtr.Zero ? "Body ":"")
1326 + (Amotor==IntPtr.Zero ? "Amotor ":"")); 1325 + (Amotor==IntPtr.Zero ? "Amotor ":""));
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 05455dc..9c3c077 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -194,14 +194,6 @@ namespace OpenSim.Region.Physics.OdePlugin
194 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 194 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
195 195
196 /// <summary> 196 /// <summary>
197 /// Defects list to remove characters that no longer have finite positions due to some other bug.
198 /// </summary>
199 /// <remarks>
200 /// Used repeatedly in Simulate() but initialized once here.
201 /// </remarks>
202 private readonly List<OdeCharacter> defects = new List<OdeCharacter>();
203
204 /// <summary>
205 /// Used to lock on manipulation of _taintedPrimL and _taintedPrimH 197 /// Used to lock on manipulation of _taintedPrimL and _taintedPrimH
206 /// </summary> 198 /// </summary>
207 private readonly Object _taintedPrimLock = new Object(); 199 private readonly Object _taintedPrimLock = new Object();
@@ -236,8 +228,6 @@ namespace OpenSim.Region.Physics.OdePlugin
236 /// A dictionary of collision event changes that are waiting to be processed. 228 /// A dictionary of collision event changes that are waiting to be processed.
237 /// </summary> 229 /// </summary>
238 private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>(); 230 private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>();
239
240 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
241 231
242 /// <summary> 232 /// <summary>
243 /// Maps a unique geometry id (a memory location) to a physics actor name. 233 /// Maps a unique geometry id (a memory location) to a physics actor name.
@@ -1736,15 +1726,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1736 } 1726 }
1737 } 1727 }
1738 1728
1739 internal void BadCharacter(OdeCharacter chr)
1740 {
1741 lock (_badCharacter)
1742 {
1743 if (!_badCharacter.Contains(chr))
1744 _badCharacter.Add(chr);
1745 }
1746 }
1747
1748 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, 1729 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1749 PrimitiveBaseShape pbs, bool isphysical, uint localID) 1730 PrimitiveBaseShape pbs, bool isphysical, uint localID)
1750 { 1731 {
@@ -2805,15 +2786,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2805 foreach (OdeCharacter actor in _characters) 2786 foreach (OdeCharacter actor in _characters)
2806 { 2787 {
2807 if (actor != null) 2788 if (actor != null)
2808 actor.Move(defects); 2789 actor.Move();
2809 }
2810
2811 if (0 != defects.Count)
2812 {
2813 foreach (OdeCharacter defect in defects)
2814 RemoveCharacter(defect);
2815
2816 defects.Clear();
2817 } 2790 }
2818 } 2791 }
2819 2792
@@ -2885,19 +2858,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2885 } 2858 }
2886 } 2859 }
2887 2860
2888 lock (_badCharacter)
2889 {
2890 if (_badCharacter.Count > 0)
2891 {
2892 foreach (OdeCharacter chr in _badCharacter)
2893 {
2894 RemoveCharacter(chr);
2895 }
2896
2897 _badCharacter.Clear();
2898 }
2899 }
2900
2901 lock (_activeprims) 2861 lock (_activeprims)
2902 { 2862 {
2903 //if (timeStep < 0.2f) 2863 //if (timeStep < 0.2f)