From 4485007fce3578079d200d15e5988355772fa592 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 17:04:54 +0000
Subject: Instead of generating a new list for bad characters on every physics
 pass, keep reusing the same list.

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 43d852b..fe2b2b2 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -188,11 +188,20 @@ namespace OpenSim.Region.Physics.OdePlugin
         private d.NearCallback nearCallback;
         public d.TriCallback triCallback;
         public d.TriArrayCallback triArrayCallback;
+
         private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
         private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
         private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
 
         /// <summary>
+        /// Defects list to remove characters that no longer have finite positions due to some other bug.
+        /// </summary>
+        /// <remarks>
+        /// Used repeatedly in Simulate() but initialized once here.
+        /// </remarks>
+        private readonly List<OdeCharacter> defects = new List<OdeCharacter>();
+
+        /// <summary>
         /// Used to lock on manipulation of _taintedPrimL and _taintedPrimH
         /// </summary>
         private readonly Object _taintedPrimLock = new Object();
@@ -2773,18 +2782,18 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                         // Move characters
                         lock (_characters)
                         {
-                            List<OdeCharacter> defects = new List<OdeCharacter>();
                             foreach (OdeCharacter actor in _characters)
                             {
                                 if (actor != null)
                                     actor.Move(defects);
                             }
+                            
                             if (0 != defects.Count)
                             {
                                 foreach (OdeCharacter defect in defects)
-                                {
                                     RemoveCharacter(defect);
-                                }
+
+                                defects.Clear();
                             }
                         }
 
-- 
cgit v1.1


From e0887944a0fe1fa6d695a3dd7ca536ede9968de2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 17:47:30 +0000
Subject: Remove unused PhysicsActor.SOPDescription

---
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4e79311..d2b4fb2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -909,15 +909,7 @@ namespace OpenSim.Region.Framework.Scenes
         public string Description
         {
             get { return m_description; }
-            set 
-            {
-                m_description = value;
-                PhysicsActor actor = PhysActor;
-                if (actor != null)
-                {
-                    actor.SOPDescription = value;
-                }
-            }
+            set { m_description = value; }
         }
 
         /// <value>
@@ -1543,8 +1535,7 @@ namespace OpenSim.Region.Framework.Scenes
                     // Basic Physics returns null..  joy joy joy.
                     if (PhysActor != null)
                     {
-                        PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info
-                        PhysActor.SOPDescription = this.Description;
+                        PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
                         PhysActor.SetMaterial(Material);
                         DoPhysicsPropertyUpdate(RigidBody, true);
                         PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
-- 
cgit v1.1


From 58a114787096df901d7d8dbf1370089771f91cf3 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 17:51:38 +0000
Subject: refactor: Make SOP.Description an automatic property

---
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index d2b4fb2..b97efc4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -242,7 +242,6 @@ namespace OpenSim.Region.Framework.Scenes
         private byte[] m_TextureAnimation;
         private byte m_clickAction;
         private Color m_color = Color.Black;
-        private string m_description = String.Empty;
         private readonly List<uint> m_lastColliders = new List<uint>();
         private int m_linkNum;
         
@@ -323,6 +322,7 @@ namespace OpenSim.Region.Framework.Scenes
             m_TextureAnimation = Utils.EmptyBytes;
             m_particleSystem = Utils.EmptyBytes;
             Rezzed = DateTime.UtcNow;
+            Description = String.Empty;
             
             m_inventory = new SceneObjectPartInventory(this);
         }
@@ -342,6 +342,7 @@ namespace OpenSim.Region.Framework.Scenes
             m_name = "Primitive";
 
             Rezzed = DateTime.UtcNow;
+            Description = String.Empty;
             CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
             LastOwnerID = CreatorID = OwnerID = ownerID;
             UUID = UUID.Random();
@@ -906,11 +907,7 @@ namespace OpenSim.Region.Framework.Scenes
             set { m_acceleration = value; }
         }
 
-        public string Description
-        {
-            get { return m_description; }
-            set { m_description = value; }
-        }
+        public string Description { get; set; }
 
         /// <value>
         /// Text color.
-- 
cgit v1.1


From 39c1ae2408f0e93362894b3b45ebc8f965a6d7c5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 17:55:10 +0000
Subject: Chain SOP constructors together rather than having copy/paste code

---
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b97efc4..24322a1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -318,12 +318,14 @@ namespace OpenSim.Region.Framework.Scenes
         /// </summary>
         public SceneObjectPart()
         {
-            // It's not necessary to persist this
             m_TextureAnimation = Utils.EmptyBytes;
             m_particleSystem = Utils.EmptyBytes;
             Rezzed = DateTime.UtcNow;
             Description = String.Empty;
-            
+
+            // Prims currently only contain a single folder (Contents).  From looking at the Second Life protocol,
+            // this appears to have the same UUID (!) as the prim.  If this isn't the case, one can't drag items from
+            // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
             m_inventory = new SceneObjectPartInventory(this);
         }
 
@@ -337,12 +339,10 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="offsetPosition"></param>
         public SceneObjectPart(
             UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 
-            Quaternion rotationOffset, Vector3 offsetPosition)
+            Quaternion rotationOffset, Vector3 offsetPosition) : this()
         {
             m_name = "Primitive";
 
-            Rezzed = DateTime.UtcNow;
-            Description = String.Empty;
             CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
             LastOwnerID = CreatorID = OwnerID = ownerID;
             UUID = UUID.Random();
@@ -357,19 +357,10 @@ namespace OpenSim.Region.Framework.Scenes
             Velocity = Vector3.Zero;
             AngularVelocity = Vector3.Zero;
             Acceleration = Vector3.Zero;
-            m_TextureAnimation = Utils.EmptyBytes;
-            m_particleSystem = Utils.EmptyBytes;
-
-            // Prims currently only contain a single folder (Contents).  From looking at the Second Life protocol,
-            // this appears to have the same UUID (!) as the prim.  If this isn't the case, one can't drag items from
-            // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
-
             Flags = 0;
             CreateSelected = true;
 
             TrimPermissions();
-            
-            m_inventory = new SceneObjectPartInventory(this);
         }
 
         #endregion Constructors
-- 
cgit v1.1


From 4fdcfd79e4c8cdbc53fe9a2b46ef7d8511571681 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 17:55:54 +0000
Subject: Actually remove PhysicsActor.SOPDescription this time

---
 OpenSim/Region/Physics/Manager/PhysicsActor.cs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 798a0a4..c213e6a 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -160,8 +160,10 @@ namespace OpenSim.Region.Physics.Manager
 
         public abstract bool Selected { set; }
 
+        /// <summary>
+        /// This is being used by ODE joint code.
+        /// </summary>
         public string SOPName;
-        public string SOPDescription;
 
         public abstract void CrossingFailure();
 
-- 
cgit v1.1


From cead87005bbcb7a4f19440a3bb7876252a7b77ac Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 18:06:04 +0000
Subject: Have ODECharacter and ODEPrim both use PhysicsActor.Name instead of
 maintaining their own properties

---
 OpenSim/Region/Physics/Manager/PhysicsActor.cs   |  9 +++++++++
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 13 +++++--------
 OpenSim/Region/Physics/OdePlugin/ODEPrim.cs      |  1 -
 3 files changed, 14 insertions(+), 9 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index c213e6a..c2acf97 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -161,6 +161,15 @@ namespace OpenSim.Region.Physics.Manager
         public abstract bool Selected { set; }
 
         /// <summary>
+        /// Name of this actor.
+        /// </summary>
+        /// <remarks>
+        /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or
+        /// water.  This is not a problem due to the formatting of names given by prims and avatars.
+        /// </remarks>
+        public string Name { get; protected set; }
+
+        /// <summary>
         /// This is being used by ODE joint code.
         /// </summary>
         public string SOPName;
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index c37d588..20bc7f6 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -123,9 +123,6 @@ namespace OpenSim.Region.Physics.OdePlugin
         private float m_buoyancy = 0f;
 
         // private CollisionLocker ode;
-
-        private string m_name = String.Empty;
-
         private bool[] m_colliderarr = new bool[11];
         private bool[] m_colliderGroundarr = new bool[11];
 
@@ -212,7 +209,7 @@ namespace OpenSim.Region.Physics.OdePlugin
 
             _parent_scene.AddPhysicsActorTaint(this);
             
-            m_name = avName;
+            Name = avName;
         }
 
         public override int PhysicsActorType
@@ -1068,7 +1065,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 _parent_scene.BadCharacter(this);
                 newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
                 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
-                m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid);
+                m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", Name, m_uuid);
             }
 
             //  kluge to keep things in bounds.  ODE lets dead avatars drift away (they should be removed!)
@@ -1284,8 +1281,8 @@ namespace OpenSim.Region.Physics.OdePlugin
                     }
                     AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
                     
-                    _parent_scene.geom_name_map[Shell] = m_name;
-                    _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+                    _parent_scene.geom_name_map[Shell] = Name;
+                    _parent_scene.actor_name_map[Shell] = this;
                     _parent_scene.AddCharacter(this);
                 }
                 else
@@ -1320,7 +1317,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     // appear to stall initial region crossings when done here.  Being done for consistency.
 //                    Velocity = Vector3.Zero;
 
-                    _parent_scene.geom_name_map[Shell] = m_name;
+                    _parent_scene.geom_name_map[Shell] = Name;
                     _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
                 }
                 else
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 1ba7ef7..5f21c9d 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -184,7 +184,6 @@ namespace OpenSim.Region.Physics.OdePlugin
         private bool m_lastUpdateSent;
 
         public IntPtr Body = IntPtr.Zero;
-        public String Name { get; private set; }
         private Vector3 _target_velocity;
         private d.Mass pMass;
 
-- 
cgit v1.1


From 898904d83d371b69d001b669588f29c2befd6aa9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 18:27:41 +0000
Subject: When an ODECharacter is removed (e.g. when an avatar leaves a scene),
 remove the actor reference in OdeScene.actor_name_map rather than leaving it
 dangling.

This also largely centralizes adds/removes in OdeScene.AddCharacter()/RemoveCharacter()
---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 11 ++---------
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs     | 22 +++++++++++++++++++++-
 2 files changed, 23 insertions(+), 10 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 20bc7f6..3e7fadf 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -599,13 +599,11 @@ namespace OpenSim.Region.Physics.OdePlugin
                 d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
             }
 
-
             d.GeomSetRotation(Shell, ref m_caprot);
             d.BodySetRotation(Body, ref m_caprot);
 
             d.GeomSetBody(Shell, Body);
 
-
             // The purpose of the AMotor here is to keep the avatar's physical
             // surrogate from rotating while moving
             Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
@@ -660,7 +658,6 @@ namespace OpenSim.Region.Physics.OdePlugin
             //standupStraight();
         }
 
-        //
         /// <summary>
         /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
         /// This may be used in calculations in the scene/scenepresence
@@ -1162,14 +1159,12 @@ namespace OpenSim.Region.Physics.OdePlugin
             {
                 //kill the body
                 d.BodyDestroy(Body);
-
                 Body = IntPtr.Zero;
             }
 
             if (Shell != IntPtr.Zero)
             {
                 d.GeomDestroy(Shell);
-                _parent_scene.geom_name_map.Remove(Shell);
                 Shell = IntPtr.Zero;
             }
         }
@@ -1279,10 +1274,8 @@ namespace OpenSim.Region.Physics.OdePlugin
                             + (Body!=IntPtr.Zero ? "Body ":"")
                             + (Amotor!=IntPtr.Zero ? "Amotor ":""));
                     }
+
                     AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
-                    
-                    _parent_scene.geom_name_map[Shell] = Name;
-                    _parent_scene.actor_name_map[Shell] = this;
                     _parent_scene.AddCharacter(this);
                 }
                 else
@@ -1318,7 +1311,7 @@ namespace OpenSim.Region.Physics.OdePlugin
 //                    Velocity = Vector3.Zero;
 
                     _parent_scene.geom_name_map[Shell] = Name;
-                    _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+                    _parent_scene.actor_name_map[Shell] = this;
                 }
                 else
                 {
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index fe2b2b2..9dee07b 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -238,8 +238,23 @@ namespace OpenSim.Region.Physics.OdePlugin
         private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>();
         
         private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
+
+        /// <summary>
+        /// Maps a unique geometry id (a memory location) to a physics actor name.
+        /// </summary>
+        /// <remarks>
+        /// Only actors participating in collisions have geometries.
+        /// </remarks>
         public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
+
+        /// <summary>
+        /// Maps a unique geometry id (a memory location) to a physics actor.
+        /// </summary>
+        /// <remarks>
+        /// Only actors participating in collisions have geometries.
+        /// </remarks>
         public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
+
         private bool m_NINJA_physics_joints_enabled = false;
         //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
         private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
@@ -1699,8 +1714,11 @@ namespace OpenSim.Region.Physics.OdePlugin
                 if (!_characters.Contains(chr))
                 {
                     _characters.Add(chr);
+                    geom_name_map[chr.Shell] = Name;
+                    actor_name_map[chr.Shell] = chr;
+
                     if (chr.bad)
-                        m_log.DebugFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
+                        m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
                 }
             }
         }
@@ -1712,6 +1730,8 @@ namespace OpenSim.Region.Physics.OdePlugin
                 if (_characters.Contains(chr))
                 {
                     _characters.Remove(chr);
+                    geom_name_map.Remove(chr.Shell);
+                    actor_name_map.Remove(chr.Shell);
                 }
             }
         }
-- 
cgit v1.1


From 4faac1f090b668274e9a07356b8a093d1b662b7e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 19:06:53 +0000
Subject: When changing avatar size in ODE, remove the old actor from the name
 and actor maps

---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 18 +++++++++++-------
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs     |  4 +++-
 2 files changed, 14 insertions(+), 8 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 3e7fadf..efe3b7e 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -526,7 +526,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
             }
 
-
             // movementVector.Z is zero
 
             // calculate tilt components based on desired amount of tilt and current (snapped) heading.
@@ -1291,16 +1290,21 @@ namespace OpenSim.Region.Physics.OdePlugin
             {
                 if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero)
                 {
-//                    m_log.DebugFormat("[PHYSICS]: Changing capsule size");
+//                    m_log.DebugFormat(
+//                        "[ODE CHARACTER]: Changing capsule size from {0} to {1} for {2}",
+//                        CAPSULE_LENGTH, m_tainted_CAPSULE_LENGTH, Name);
                     
                     m_pidControllerActive = true;
+
+                    _parent_scene.geom_name_map.Remove(Shell);
+                    _parent_scene.actor_name_map.Remove(Shell);
+
                     // no lock needed on _parent_scene.OdeLock because we are called from within the thread lock in OdePlugin's simulate()
-                    d.JointDestroy(Amotor);
+                    DestroyOdeStructures();
+
                     float prevCapsule = CAPSULE_LENGTH;
                     CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH;
-                    //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
-                    d.BodyDestroy(Body);
-                    d.GeomDestroy(Shell);
+
                     AvatarGeomAndBodyCreation(
                         _position.X,
                         _position.Y,
@@ -1315,7 +1319,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
                 else
                 {
-                    m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - " 
+                    m_log.Warn("[ODE CHARACTER]: trying to change capsule size, but the following ODE data is missing - "
                         + (Shell==IntPtr.Zero ? "Shell ":"")
                         + (Body==IntPtr.Zero ? "Body ":"")
                         + (Amotor==IntPtr.Zero ? "Amotor ":""));
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 9dee07b..d5c3250 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -243,7 +243,9 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// Maps a unique geometry id (a memory location) to a physics actor name.
         /// </summary>
         /// <remarks>
-        /// Only actors participating in collisions have geometries.
+        /// Only actors participating in collisions have geometries.  This has to be maintained separately from
+        /// actor_name_map because terrain and water currently don't conceptually have a physics actor of their own
+        /// apart from the singleton PANull
         /// </remarks>
         public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
 
-- 
cgit v1.1


From 3becda919e0cb82e29742c50923f1b72c1a02241 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 19:30:21 +0000
Subject: move geom/actor map maintenance into
 DestroyODEStructures()/AvatarGeomAndBodyCreation().

This saves us having to do it separately when a character capsule size is changed
---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 17 +++++++++--------
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs     |  2 --
 2 files changed, 9 insertions(+), 10 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index efe3b7e..0f1a897 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -655,6 +655,9 @@ namespace OpenSim.Region.Physics.OdePlugin
             //
             //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
             //standupStraight();
+
+            _parent_scene.geom_name_map[Shell] = Name;
+            _parent_scene.actor_name_map[Shell] = this;
         }
 
         /// <summary>
@@ -896,7 +899,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             
             if (!localPos.IsFinite())
             {
-                m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
+                m_log.WarnFormat("[PHYSICS]: Avatar Position of {0} is non-finite!", Name);
 
                 defects.Add(this);
                 // _parent_scene.RemoveCharacter(this);
@@ -1059,9 +1062,10 @@ namespace OpenSim.Region.Physics.OdePlugin
             {
                 bad = true;
                 _parent_scene.BadCharacter(this);
+                DestroyOdeStructures();
                 newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
                 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
-                m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", Name, m_uuid);
+                m_log.WarnFormat("[ODE CHARACTER]: Avatar Null reference for Avatar {0}, physical actor {1}", Name, m_uuid);
             }
 
             //  kluge to keep things in bounds.  ODE lets dead avatars drift away (they should be removed!)
@@ -1164,6 +1168,9 @@ namespace OpenSim.Region.Physics.OdePlugin
             if (Shell != IntPtr.Zero)
             {
                 d.GeomDestroy(Shell);
+                _parent_scene.geom_name_map.Remove(Shell);
+                _parent_scene.actor_name_map.Remove(Shell);
+
                 Shell = IntPtr.Zero;
             }
         }
@@ -1296,9 +1303,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                     
                     m_pidControllerActive = true;
 
-                    _parent_scene.geom_name_map.Remove(Shell);
-                    _parent_scene.actor_name_map.Remove(Shell);
-
                     // no lock needed on _parent_scene.OdeLock because we are called from within the thread lock in OdePlugin's simulate()
                     DestroyOdeStructures();
 
@@ -1313,9 +1317,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                     // As with Size, we reset velocity.  However, this isn't strictly necessary since it doesn't
                     // appear to stall initial region crossings when done here.  Being done for consistency.
 //                    Velocity = Vector3.Zero;
-
-                    _parent_scene.geom_name_map[Shell] = Name;
-                    _parent_scene.actor_name_map[Shell] = this;
                 }
                 else
                 {
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index d5c3250..05455dc 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1716,8 +1716,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                 if (!_characters.Contains(chr))
                 {
                     _characters.Add(chr);
-                    geom_name_map[chr.Shell] = Name;
-                    actor_name_map[chr.Shell] = chr;
 
                     if (chr.bad)
                         m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
-- 
cgit v1.1


From 54789706f40d0800d1277eeb71afd61edcefd9ab Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 19:45:22 +0000
Subject: Reduce complexity of OdeScene.Simulate() by fully removing bad
 characters at point of detection rather than later on.

---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 57 ++++++++++++------------
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs     | 42 +----------------
 2 files changed, 29 insertions(+), 70 deletions(-)

(limited to 'OpenSim/Region')

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
                         parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
                 m_taintPosition = _position;
 
-                m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
+                m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName);
             }
 
             _parent_scene = parent_scene;
@@ -201,7 +201,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 m_colliderarr[i] = false;
             }
             CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
-            //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
+            //m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH.ToString());
             m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
 
             m_isPhysical = false; // current status: no ODE information exists
@@ -266,7 +266,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             set
             {
                 flying = value;
-//                m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
+//                m_log.DebugFormat("[ODE CHARACTER]: Set OdeCharacter Flying to {0}", flying);
             }
         }
 
@@ -437,7 +437,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     }
                     else
                     {
-                        m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character");
+                        m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Position from Scene on character {0}", Name);
                     }
                 }
             }
@@ -464,7 +464,7 @@ namespace OpenSim.Region.Physics.OdePlugin
 
                     Vector3 SetSize = value;
                     m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
-//                    m_log.Info("[SIZE]: " + CAPSULE_LENGTH);
+//                    m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH);
 
                     // If we reset velocity here, then an avatar stalls when it crosses a border for the first time
                     // (as the height of the new root agent is set).
@@ -474,7 +474,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
                 else
                 {
-                    m_log.Warn("[PHYSICS]: Got a NaN Size from Scene on a Character");
+                    m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size from Scene on {0}", Name);
                 }
             }
         }
@@ -533,7 +533,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             float xTiltComponent = -movementVector.X * m_tiltMagnitudeWhenProjectedOnXYPlane;
             float yTiltComponent = -movementVector.Y * m_tiltMagnitudeWhenProjectedOnXYPlane;
 
-            //m_log.Debug("[PHYSICS] changing avatar tilt");
+            //m_log.Debug("[ODE CHARACTER]: changing avatar tilt");
             d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, xTiltComponent);
             d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, xTiltComponent); // must be same as lowstop, else a different, spurious tilt is introduced
             d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, yTiltComponent);
@@ -560,17 +560,16 @@ namespace OpenSim.Region.Physics.OdePlugin
             _parent_scene.waitForSpaceUnlock(_parent_scene.space);
             if (CAPSULE_LENGTH <= 0)
             {
-                m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
+                m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
                 CAPSULE_LENGTH = 0.01f;
-
             }
 
             if (CAPSULE_RADIUS <= 0)
             {
-                m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
+                m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
                 CAPSULE_RADIUS = 0.01f;
-
             }
+
             Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
 
             d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
@@ -770,7 +769,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
                 else
                 {
-                    m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character");
+                    m_log.WarnFormat("[ODE CHARACTER]: Got a NaN velocity from Scene for {0}", Name);
                 }
 
 //                m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", m_taintTargetVelocity);
@@ -848,7 +847,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             }
             else
             {
-                m_log.Warn("[PHYSICS]: Got a NaN force applied to a Character");
+                m_log.WarnFormat("[ODE CHARACTER]: Got a NaN force applied to {0}", Name);
             }
             //m_lastUpdateSent = false;
         }
@@ -874,11 +873,11 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// Called from Simulate
         /// This is the avatar's movement control + PID Controller
         /// </summary>
-        /// <param name="defects">
-        /// If there is something wrong with the character (e.g. its position is non-finite)
-        /// then it is added to this list.  The ODE structures associated with it are also destroyed.
-        /// </param>
-        internal void Move(List<OdeCharacter> defects)
+        /// <remarks>
+        /// This routine will remove the character from the physics scene if it detects something wrong (non-finite
+        /// position or velocity).
+        /// </remarks>
+        internal void Move()
         {
             //  no lock; for now it's only called from within Simulate()
             
@@ -899,11 +898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
             
             if (!localPos.IsFinite())
             {
-                m_log.WarnFormat("[PHYSICS]: Avatar Position of {0} is non-finite!", Name);
-
-                defects.Add(this);
-                // _parent_scene.RemoveCharacter(this);
+                m_log.WarnFormat(
+                    "[ODE CHARACTER]: Avatar position of {0} for {1} is non-finite!  Removing from physics scene.",
+                    localPos, Name);
 
+                _parent_scene.RemoveCharacter(this);
                 DestroyOdeStructures();
 
                 return;
@@ -1038,11 +1037,11 @@ namespace OpenSim.Region.Physics.OdePlugin
             }
             else
             {
-                m_log.Warn("[PHYSICS]: Got a NaN force vector in Move()");
-                m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
-                defects.Add(this);
-                // _parent_scene.RemoveCharacter(this);
+                m_log.WarnFormat(
+                    "[ODE CHARACTER]: Got a NaN force vector {0} in Move() for {1}.  Removing character from physics scene.",
+                    vec, Name);
 
+                _parent_scene.RemoveCharacter(this);
                 DestroyOdeStructures();
             }
         }
@@ -1061,7 +1060,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             catch (NullReferenceException)
             {
                 bad = true;
-                _parent_scene.BadCharacter(this);
+                _parent_scene.RemoveCharacter(this);
                 DestroyOdeStructures();
                 newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
                 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
@@ -1275,7 +1274,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     // Create avatar capsule and related ODE data
                     if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
                     {
-                        m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - "
+                        m_log.Warn("[ODE CHARACTER]: re-creating the following avatar ODE data for " + Name + ", even though it already exists - "
                             + (Shell!=IntPtr.Zero ? "Shell ":"")
                             + (Body!=IntPtr.Zero ? "Body ":"")
                             + (Amotor!=IntPtr.Zero ? "Amotor ":""));
@@ -1320,7 +1319,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
                 else
                 {
-                    m_log.Warn("[ODE CHARACTER]: trying to change capsule size, but the following ODE data is missing - "
+                    m_log.Warn("[ODE CHARACTER]: trying to change capsule size for " + Name + ", but the following ODE data is missing - "
                         + (Shell==IntPtr.Zero ? "Shell ":"")
                         + (Body==IntPtr.Zero ? "Body ":"")
                         + (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
         private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
 
         /// <summary>
-        /// Defects list to remove characters that no longer have finite positions due to some other bug.
-        /// </summary>
-        /// <remarks>
-        /// Used repeatedly in Simulate() but initialized once here.
-        /// </remarks>
-        private readonly List<OdeCharacter> defects = new List<OdeCharacter>();
-
-        /// <summary>
         /// Used to lock on manipulation of _taintedPrimL and _taintedPrimH
         /// </summary>
         private readonly Object _taintedPrimLock = new Object();
@@ -236,8 +228,6 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// A dictionary of collision event changes that are waiting to be processed.
         /// </summary>
         private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>();
-        
-        private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
 
         /// <summary>
         /// Maps a unique geometry id (a memory location) to a physics actor name.
@@ -1736,15 +1726,6 @@ namespace OpenSim.Region.Physics.OdePlugin
             }
         }
 
-        internal void BadCharacter(OdeCharacter chr)
-        {
-            lock (_badCharacter)
-            {
-                if (!_badCharacter.Contains(chr))
-                    _badCharacter.Add(chr);
-            }
-        }
-
         private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
                                      PrimitiveBaseShape pbs, bool isphysical, uint localID)
         {
@@ -2805,15 +2786,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                             foreach (OdeCharacter actor in _characters)
                             {
                                 if (actor != null)
-                                    actor.Move(defects);
-                            }
-                            
-                            if (0 != defects.Count)
-                            {
-                                foreach (OdeCharacter defect in defects)
-                                    RemoveCharacter(defect);
-
-                                defects.Clear();
+                                    actor.Move();
                             }
                         }
 
@@ -2885,19 +2858,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                     }
                 }
 
-                lock (_badCharacter)
-                {
-                    if (_badCharacter.Count > 0)
-                    {
-                        foreach (OdeCharacter chr in _badCharacter)
-                        {
-                            RemoveCharacter(chr);
-                        }
-
-                        _badCharacter.Clear();
-                    }
-                }
-
                 lock (_activeprims)
                 {
                     //if (timeStep < 0.2f)
-- 
cgit v1.1


From 225b925f4ec6a0b7dfec27589d0aea40ce0a8e54 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 19:48:31 +0000
Subject: Comment out calls to OdeScene.waitForSpaceUnlock() since that method
 does nothing right now

---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs |  4 ++--
 OpenSim/Region/Physics/OdePlugin/ODEPrim.cs      | 18 ++++++++---------
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs     | 25 ++++++++++++------------
 3 files changed, 24 insertions(+), 23 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index c838587..af67407 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -557,7 +557,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             //CAPSULE_LENGTH = -5;
             //CAPSULE_RADIUS = -5;
             int dAMotorEuler = 1;
-            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+//            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
             if (CAPSULE_LENGTH <= 0)
             {
                 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
@@ -1155,7 +1155,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             }
 
             //kill the Geometry
-            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+//            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
 
             if (Body != IntPtr.Zero)
             {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 5f21c9d..fec4693 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -856,7 +856,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 m_MeshToTriMeshMap[mesh] = _triMeshData;
             }
 
-            _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//            _parent_scene.waitForSpaceUnlock(m_targetSpace);
             try
             {
                 if (prim_geom == IntPtr.Zero)
@@ -1379,7 +1379,7 @@ Console.WriteLine("CreateGeom:");
                     {
                         if (((_size.X / 2f) > 0f))
                         {
-                            _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                            _parent_scene.waitForSpaceUnlock(m_targetSpace);
                             try
                             {
 //Console.WriteLine(" CreateGeom 1");
@@ -1393,7 +1393,7 @@ Console.WriteLine("CreateGeom:");
                         }
                         else
                         {
-                            _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                            _parent_scene.waitForSpaceUnlock(m_targetSpace);
                             try
                             {
 //Console.WriteLine(" CreateGeom 2");
@@ -1408,7 +1408,7 @@ Console.WriteLine("CreateGeom:");
                     }
                     else
                     {
-                        _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                        _parent_scene.waitForSpaceUnlock(m_targetSpace);
                         try
                         {
 //Console.WriteLine("  CreateGeom 3");
@@ -1423,7 +1423,7 @@ Console.WriteLine("CreateGeom:");
                 }
                 else
                 {
-                    _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                    _parent_scene.waitForSpaceUnlock(m_targetSpace);
                     try
                     {
 //Console.WriteLine("  CreateGeom 4");
@@ -1576,17 +1576,17 @@ Console.WriteLine(" JointCreateFixed");
             {
                 // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position);
                 // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
-                _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                _parent_scene.waitForSpaceUnlock(m_targetSpace);
 
                 IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace);
                 m_targetSpace = tempspace;
 
-                _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                _parent_scene.waitForSpaceUnlock(m_targetSpace);
                 if (prim_geom != IntPtr.Zero)
                 {
                     d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
 
-                    _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                    _parent_scene.waitForSpaceUnlock(m_targetSpace);
                     d.SpaceAdd(m_targetSpace, prim_geom);
                 }
             }
@@ -1977,7 +1977,7 @@ Console.WriteLine(" JointCreateFixed");
 
             if (d.SpaceQuery(m_targetSpace, prim_geom))
             {
-                _parent_scene.waitForSpaceUnlock(m_targetSpace);
+//                _parent_scene.waitForSpaceUnlock(m_targetSpace);
                 d.SpaceRemove(m_targetSpace, prim_geom);
             }
 
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 9c3c077..b952b30 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -679,11 +679,11 @@ namespace OpenSim.Region.Physics.OdePlugin
             }
         }
 
-        internal void waitForSpaceUnlock(IntPtr space)
-        {
-            //if (space != IntPtr.Zero)
-                //while (d.SpaceLockQuery(space)) { } // Wait and do nothing
-        }
+//        internal void waitForSpaceUnlock(IntPtr space)
+//        {
+//            //if (space != IntPtr.Zero)
+//                //while (d.SpaceLockQuery(space)) { } // Wait and do nothing
+//        }
 
 //        /// <summary>
 //        /// Debug space message for printing the space that a prim/avatar is in.
@@ -2303,7 +2303,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 {
                     if (d.GeomIsSpace(currentspace))
                     {
-                        waitForSpaceUnlock(currentspace);
+//                        waitForSpaceUnlock(currentspace);
                         d.SpaceRemove(currentspace, geom);
                     }
                     else
@@ -2319,7 +2319,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     {
                         if (d.GeomIsSpace(currentspace))
                         {
-                            waitForSpaceUnlock(sGeomIsIn);
+//                            waitForSpaceUnlock(sGeomIsIn);
                             d.SpaceRemove(sGeomIsIn, geom);
                         }
                         else
@@ -2337,8 +2337,8 @@ namespace OpenSim.Region.Physics.OdePlugin
                     {
                         if (d.GeomIsSpace(currentspace))
                         {
-                            waitForSpaceUnlock(currentspace);
-                            waitForSpaceUnlock(space);
+//                            waitForSpaceUnlock(currentspace);
+//                            waitForSpaceUnlock(space);
                             d.SpaceRemove(space, currentspace);
                             // free up memory used by the space.
 
@@ -2362,7 +2362,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     {
                         if (d.GeomIsSpace(currentspace))
                         {
-                            waitForSpaceUnlock(currentspace);
+//                            waitForSpaceUnlock(currentspace);
                             d.SpaceRemove(currentspace, geom);
                         }
                         else
@@ -2378,7 +2378,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                         {
                             if (d.GeomIsSpace(sGeomIsIn))
                             {
-                                waitForSpaceUnlock(sGeomIsIn);
+//                                waitForSpaceUnlock(sGeomIsIn);
                                 d.SpaceRemove(sGeomIsIn, geom);
                             }
                             else
@@ -2417,9 +2417,10 @@ namespace OpenSim.Region.Physics.OdePlugin
             // creating a new space for prim and inserting it into main space.
             staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero);
             d.GeomSetCategoryBits(staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY], (int)CollisionCategories.Space);
-            waitForSpaceUnlock(space);
+//            waitForSpaceUnlock(space);
             d.SpaceSetSublevel(space, 1);
             d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]);
+            
             return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY];
         }
 
-- 
cgit v1.1


From 063f0f5d97d8b8d38a57c7a0601e9133d0054a26 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 19:58:37 +0000
Subject: refactor: Eliminate one line ODECharacter.doForce() method for code
 clarity

---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index af67407..afa8de5 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -70,7 +70,6 @@ namespace OpenSim.Region.Physics.OdePlugin
 
         private Vector3 _position;
         private d.Vector3 _zeroPosition;
-        // private d.Matrix3 m_StandUpRotation;
         private bool _zeroFlag = false;
         private bool m_lastUpdateSent = false;
         private Vector3 _velocity;
@@ -554,8 +553,6 @@ namespace OpenSim.Region.Physics.OdePlugin
         // place that is safe to call this routine AvatarGeomAndBodyCreation.
         private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor)
         {
-            //CAPSULE_LENGTH = -5;
-            //CAPSULE_RADIUS = -5;
             int dAMotorEuler = 1;
 //            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
             if (CAPSULE_LENGTH <= 0)
@@ -831,7 +828,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                     m_taintForce += force;
                     _parent_scene.AddPhysicsActorTaint(this);
 
-                    //doForce(force);
                     // If uncommented, things get pushed off world
                     //
                     // m_log.Debug("Push!");
@@ -856,15 +852,6 @@ namespace OpenSim.Region.Physics.OdePlugin
         {
         }
 
-        /// <summary>
-        /// After all of the forces add up with 'add force' we apply them with doForce
-        /// </summary>
-        /// <param name="force"></param>
-        public void doForce(Vector3 force)
-        {
-            d.BodyAddForce(Body, force.X, force.Y, force.Z);
-        }
-
         public override void SetMomentum(Vector3 momentum)
         {
         }
@@ -1030,7 +1017,8 @@ namespace OpenSim.Region.Physics.OdePlugin
 
             if (vec.IsFinite())
             {
-                doForce(vec);
+                // Apply the total force acting on this avatar
+                d.BodyAddForce(Body, vec.X, vec.Y, vec.Z);
 
                 if (!_zeroFlag)
                     AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
@@ -1258,7 +1246,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     // FIXME: This is not a good solution since it's subject to a race condition if a force is another
                     // thread sets a new force while we're in this loop (since it could be obliterated by
                     // m_taintForce = Vector3.Zero.  Need to lock ProcessTaints() when we set a new tainted force.
-                    doForce(m_taintForce);
+                    d.BodyAddForce(Body, m_taintForce.X, m_taintForce.Y, m_taintForce.Z);
                 }
 
                 m_taintForce = Vector3.Zero;
-- 
cgit v1.1


From e67ba0ad06a0ff54834892257d8e7bc39b4fc892 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 20:01:34 +0000
Subject: rename ODECharacter.AvatarGeomAndBodyCreation() ->
 CreateOdeStructures() to match existing DestroyOdeStructures()

---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index afa8de5..5a7626e 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -542,16 +542,18 @@ namespace OpenSim.Region.Physics.OdePlugin
         }
 
         /// <summary>
-        /// This creates the Avatar's physical Surrogate at the position supplied
+        /// This creates the Avatar's physical Surrogate in ODE at the position supplied
         /// </summary>
+        /// <remarks>
+        /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
+        /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
+        /// place that is safe to call this routine AvatarGeomAndBodyCreation.
+        /// </remarks>
         /// <param name="npositionX"></param>
         /// <param name="npositionY"></param>
         /// <param name="npositionZ"></param>
-
-        // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
-        // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only 
-        // place that is safe to call this routine AvatarGeomAndBodyCreation.
-        private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ, float tensor)
+        /// <param name="tensor"></param>
+        private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
         {
             int dAMotorEuler = 1;
 //            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
@@ -1268,7 +1270,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                             + (Amotor!=IntPtr.Zero ? "Amotor ":""));
                     }
 
-                    AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
+                    CreateOdeStructures(_position.X, _position.Y, _position.Z, m_tensor);
                     _parent_scene.AddCharacter(this);
                 }
                 else
@@ -1296,7 +1298,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     float prevCapsule = CAPSULE_LENGTH;
                     CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH;
 
-                    AvatarGeomAndBodyCreation(
+                    CreateOdeStructures(
                         _position.X,
                         _position.Y,
                         _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
-- 
cgit v1.1


From e33b0fa35bf6bef47849c82b1ef1f5f81420217e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 20:12:04 +0000
Subject: don't lock OdeScene.contacts since only ever accessed by a single
 thread

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 34 ++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 10 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index b952b30..92dd2dd 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -251,10 +251,27 @@ namespace OpenSim.Region.Physics.OdePlugin
         //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
         private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
         private d.ContactGeom[] contacts;
-        private readonly List<PhysicsJoint> requestedJointsToBeCreated = new List<PhysicsJoint>(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active
-        private readonly List<PhysicsJoint> pendingJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene.
-        private readonly List<PhysicsJoint> activeJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene.
-        private readonly List<string> requestedJointsToBeDeleted = new List<string>(); // lock only briefly. accessed by external code (to request deletion of joints) and by OdeScene.Simulate() to move those joints out of pending/active
+
+        /// <summary>
+        /// Lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active
+        /// </summary>
+        private readonly List<PhysicsJoint> requestedJointsToBeCreated = new List<PhysicsJoint>();
+
+        /// <summary>
+        /// can lock for longer. accessed only by OdeScene.
+        /// </summary>
+        private readonly List<PhysicsJoint> pendingJoints = new List<PhysicsJoint>();
+
+        /// <summary>
+        /// can lock for longer. accessed only by OdeScene.
+        /// </summary>
+        private readonly List<PhysicsJoint> activeJoints = new List<PhysicsJoint>();
+
+        /// <summary>
+        /// lock only briefly. accessed by external code (to request deletion of joints) and by OdeScene.Simulate() to move those joints out of pending/active
+        /// </summary>
+        private readonly List<string> requestedJointsToBeDeleted = new List<string>();
+
         private Object externalJointRequestsLock = new Object();
         private readonly Dictionary<String, PhysicsJoint> SOPName_to_activeJoint = new Dictionary<String, PhysicsJoint>();
         private readonly Dictionary<String, PhysicsJoint> SOPName_to_pendingJoint = new Dictionary<String, PhysicsJoint>();
@@ -776,12 +793,9 @@ namespace OpenSim.Region.Physics.OdePlugin
                 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
                     return;
 
-                lock (contacts)
-                {
-                    count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
-                    if (count > contacts.Length)
-                        m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
-                }
+                count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
+                if (count > contacts.Length)
+                    m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
             }
             catch (SEHException)
             {
-- 
cgit v1.1


From 25d9001de1225a7d1c938f440b43c37bcca0e69e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 20:17:36 +0000
Subject: don't bother locking OdeScene._perloopContact in single threaded code

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 89 +++++++++++++---------------
 1 file changed, 42 insertions(+), 47 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 92dd2dd..897ab82 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1247,69 +1247,64 @@ namespace OpenSim.Region.Physics.OdePlugin
 
         private bool checkDupe(d.ContactGeom contactGeom, int atype)
         {
-            bool result = false;
-            //return result;
             if (!m_filterCollisions)
                 return false;
+            
+            bool result = false;
 
             ActorTypes at = (ActorTypes)atype;
-            lock (_perloopContact)
+
+            foreach (d.ContactGeom contact in _perloopContact)
             {
-                foreach (d.ContactGeom contact in _perloopContact)
+                //if ((contact.g1 == contactGeom.g1 && contact.g2 == contactGeom.g2))
+                //{
+                    // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2)
+                if (at == ActorTypes.Agent)
                 {
-                    //if ((contact.g1 == contactGeom.g1 && contact.g2 == contactGeom.g2))
-                    //{
-                        // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2)
-                    if (at == ActorTypes.Agent)
-                    {
-                            if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+                        if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+                        {
+                            
+                            if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
                             {
-                                
-                                if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
-                                {
-                                    //contactGeom.depth *= .00005f;
-                                   //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
-                                    // m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
-                                    result = true;
-                                    break;
-                                }
-                                else
-                                {
-                                    //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
-                                }
+                                //contactGeom.depth *= .00005f;
+                               //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+                                // m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+                                result = true;
+                                break;
                             }
                             else
                             {
-                                //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
-                                //int i = 0;
+                                //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
                             }
-                    } 
-                    else if (at == ActorTypes.Prim)
-                    {
-                            //d.AABB aabb1 = new d.AABB();
-                            //d.AABB aabb2 = new d.AABB();
+                        }
+                        else
+                        {
+                            //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+                            //int i = 0;
+                        }
+                } 
+                else if (at == ActorTypes.Prim)
+                {
+                        //d.AABB aabb1 = new d.AABB();
+                        //d.AABB aabb2 = new d.AABB();
 
-                            //d.GeomGetAABB(contactGeom.g2, out aabb2);
-                            //d.GeomGetAABB(contactGeom.g1, out aabb1);
-                            //aabb1.
-                            if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+                        //d.GeomGetAABB(contactGeom.g2, out aabb2);
+                        //d.GeomGetAABB(contactGeom.g1, out aabb1);
+                        //aabb1.
+                        if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+                        {
+                            if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
                             {
-                                if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
+                                if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
                                 {
-                                    if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
-                                    {
-                                        result = true;
-                                        break;
-                                    }
+                                    result = true;
+                                    break;
                                 }
-                                //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
-                                //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
                             }
-                            
-                    }
-                    
-                    //}
-
+                            //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+                            //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+                        }
+                        
                 }
             }
 
-- 
cgit v1.1


From 546259b2ffdb7dfdc450dd5386ec6794bb06223d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 20:30:37 +0000
Subject: simplify operation of OdeScene._perloopContact

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 96 +++++++++++++++-------------
 1 file changed, 51 insertions(+), 45 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 897ab82..7db188f 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -216,7 +216,14 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// </remarks>
         private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>();
 
+        /// <summary>
+        /// Record a character that has taints to be processed.
+        /// </summary>
         private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>();
+
+        /// <summary>
+        /// Keep record of contacts in the physics loop so that we can remove duplicates.
+        /// </summary>
         private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
 
         /// <summary>
@@ -1059,6 +1066,8 @@ namespace OpenSim.Region.Physics.OdePlugin
 
                 if (!skipThisContact)
                 {
+                    _perloopContact.Add(curContact);
+
                     // If we're colliding against terrain
                     if (name1 == "Terrain" || name2 == "Terrain")
                     {
@@ -1068,7 +1077,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                         {
                             // Use the movement terrain contact
                             AvatarMovementTerrainContact.geom = curContact;
-                            _perloopContact.Add(curContact);
+
                             if (m_global_contactcount < maxContactsbeforedeath)
                             {
                                 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
@@ -1081,7 +1090,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                             {
                                 // Use the non moving terrain contact
                                 TerrainContact.geom = curContact;
-                                _perloopContact.Add(curContact);
+
                                 if (m_global_contactcount < maxContactsbeforedeath)
                                 {
                                     joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
@@ -1107,7 +1116,6 @@ namespace OpenSim.Region.Physics.OdePlugin
 
                                     //m_log.DebugFormat("Material: {0}", material);
                                     m_materialContacts[material, movintYN].geom = curContact;
-                                    _perloopContact.Add(curContact);
 
                                     if (m_global_contactcount < maxContactsbeforedeath)
                                     {
@@ -1128,9 +1136,9 @@ namespace OpenSim.Region.Physics.OdePlugin
 
                                     if (p2 is OdePrim)
                                         material = ((OdePrim)p2).m_material;
+
                                     //m_log.DebugFormat("Material: {0}", material);
                                     m_materialContacts[material, movintYN].geom = curContact;
-                                    _perloopContact.Add(curContact);
 
                                     if (m_global_contactcount < maxContactsbeforedeath)
                                     {
@@ -1163,8 +1171,9 @@ namespace OpenSim.Region.Physics.OdePlugin
                             //contact.normal = new d.Vector3(0, 0, 1);
                             //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f);
                         }
+
                         WaterContact.geom = curContact;
-                        _perloopContact.Add(curContact);
+
                         if (m_global_contactcount < maxContactsbeforedeath)
                         {
                             joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
@@ -1182,7 +1191,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                             {
                                 // Use the Movement prim contact
                                 AvatarMovementprimContact.geom = curContact;
-                                _perloopContact.Add(curContact);
+
                                 if (m_global_contactcount < maxContactsbeforedeath)
                                 {
                                     joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
@@ -1212,13 +1221,11 @@ namespace OpenSim.Region.Physics.OdePlugin
                             
                             //m_log.DebugFormat("Material: {0}", material);
                             m_materialContacts[material, 0].geom = curContact;
-                            _perloopContact.Add(curContact);
 
                             if (m_global_contactcount < maxContactsbeforedeath)
                             {
                                 joint = d.JointCreateContact(world, contactgroup, ref m_materialContacts[material, 0]);
                                 m_global_contactcount++;
-
                             }
                         }
                     }
@@ -1249,7 +1256,7 @@ namespace OpenSim.Region.Physics.OdePlugin
         {
             if (!m_filterCollisions)
                 return false;
-            
+
             bool result = false;
 
             ActorTypes at = (ActorTypes)atype;
@@ -1261,50 +1268,51 @@ namespace OpenSim.Region.Physics.OdePlugin
                     // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2)
                 if (at == ActorTypes.Agent)
                 {
-                        if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
-                        {
-                            
-                            if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
-                            {
-                                //contactGeom.depth *= .00005f;
-                               //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
-                                // m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
-                                result = true;
-                                break;
-                            }
-                            else
-                            {
-                                //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
-                            }
-                        }
-                        else
+                    if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f)
+                        && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f)
+                        && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f))
+                        && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+                    {
+                        if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f)
                         {
-                            //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
-                            //int i = 0;
+                            //contactGeom.depth *= .00005f;
+                           //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+                            // m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+                            result = true;
+                            break;
                         }
+//                        else
+//                        {
+//                            //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+//                        }
+                    }
+//                    else
+//                    {
+//                        //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+//                        //int i = 0;
+//                    }
                 } 
                 else if (at == ActorTypes.Prim)
                 {
-                        //d.AABB aabb1 = new d.AABB();
-                        //d.AABB aabb2 = new d.AABB();
+                    //d.AABB aabb1 = new d.AABB();
+                    //d.AABB aabb2 = new d.AABB();
 
-                        //d.GeomGetAABB(contactGeom.g2, out aabb2);
-                        //d.GeomGetAABB(contactGeom.g1, out aabb1);
-                        //aabb1.
-                        if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+                    //d.GeomGetAABB(contactGeom.g2, out aabb2);
+                    //d.GeomGetAABB(contactGeom.g1, out aabb1);
+                    //aabb1.
+                    if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
+                    {
+                        if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
                         {
-                            if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
+                            if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
                             {
-                                if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
-                                {
-                                    result = true;
-                                    break;
-                                }
+                                result = true;
+                                break;
                             }
-                            //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
-                            //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
                         }
-                        
+                        //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
+                        //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
+                    }
                 }
             }
 
@@ -1589,8 +1597,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                     }
                 }
             }
-
-            _perloopContact.Clear();
         }
 
         #endregion
-- 
cgit v1.1


From 7480f2fd0e5482d366890b34d4aca72c887e02c3 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 21:04:24 +0000
Subject: Restore defects list.  In hindsight, the reason for this is becuase
 we can't remove the character whilst iterating over the list.

This commit also removes locking on OdeScene._characters since code is single threaded
---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs |  27 ++--
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs     | 177 +++++++++++++----------
 2 files changed, 112 insertions(+), 92 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 5a7626e..cfe64f2 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -862,11 +862,10 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// Called from Simulate
         /// This is the avatar's movement control + PID Controller
         /// </summary>
-        /// <remarks>
-        /// This routine will remove the character from the physics scene if it detects something wrong (non-finite
+        /// <param name="defects">The character will be added to this list if there is something wrong (non-finite
         /// position or velocity).
-        /// </remarks>
-        internal void Move()
+        /// </param>
+        internal void Move(List<OdeCharacter> defects)
         {
             //  no lock; for now it's only called from within Simulate()
             
@@ -891,8 +890,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     "[ODE CHARACTER]: Avatar position of {0} for {1} is non-finite!  Removing from physics scene.",
                     localPos, Name);
 
-                _parent_scene.RemoveCharacter(this);
-                DestroyOdeStructures();
+                defects.Add(this);
 
                 return;
             }
@@ -1031,15 +1029,19 @@ namespace OpenSim.Region.Physics.OdePlugin
                     "[ODE CHARACTER]: Got a NaN force vector {0} in Move() for {1}.  Removing character from physics scene.",
                     vec, Name);
 
-                _parent_scene.RemoveCharacter(this);
-                DestroyOdeStructures();
+                defects.Add(this);
+
+                return;
             }
         }
 
         /// <summary>
         /// Updates the reported position and velocity.  This essentially sends the data up to ScenePresence.
         /// </summary>
-        internal void UpdatePositionAndVelocity()
+        /// <param name="defects">The character will be added to this list if there is something wrong (non-finite
+        /// position or velocity).
+        /// </param>
+        internal void UpdatePositionAndVelocity(List<OdeCharacter> defects)
         {
             //  no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
             d.Vector3 newPos;
@@ -1050,11 +1052,12 @@ namespace OpenSim.Region.Physics.OdePlugin
             catch (NullReferenceException)
             {
                 bad = true;
-                _parent_scene.RemoveCharacter(this);
-                DestroyOdeStructures();
+                defects.Add(this);
                 newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
                 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
                 m_log.WarnFormat("[ODE CHARACTER]: Avatar Null reference for Avatar {0}, physical actor {1}", Name, m_uuid);
+
+                return;
             }
 
             //  kluge to keep things in bounds.  ODE lets dead avatars drift away (they should be removed!)
@@ -1134,7 +1137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// <summary>
         /// Used internally to destroy the ODE structures associated with this character.
         /// </summary>
-        private void DestroyOdeStructures()
+        internal void DestroyOdeStructures()
         {
             // destroy avatar capsule and related ODE data
             if (Amotor != IntPtr.Zero)
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 7db188f..89568b6 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -189,7 +189,11 @@ namespace OpenSim.Region.Physics.OdePlugin
         public d.TriCallback triCallback;
         public d.TriArrayCallback triArrayCallback;
 
+        /// <summary>
+        /// Avatars in the physics scene.
+        /// </summary>
         private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
+        
         private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
         private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
 
@@ -254,6 +258,14 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// </remarks>
         public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
 
+        /// <summary>
+        /// Defects list to remove characters that no longer have finite positions due to some other bug.
+        /// </summary>
+        /// <remarks>
+        /// Used repeatedly in Simulate() but initialized once here.
+        /// </remarks>
+        private readonly List<OdeCharacter> defects = new List<OdeCharacter>();
+
         private bool m_NINJA_physics_joints_enabled = false;
         //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
         private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
@@ -1515,45 +1527,42 @@ namespace OpenSim.Region.Physics.OdePlugin
         {
             _perloopContact.Clear();
 
-            lock (_characters)
+            foreach (OdeCharacter chr in _characters)
             {
-                foreach (OdeCharacter chr in _characters)
+                // Reset the collision values to false
+                // since we don't know if we're colliding yet
+                
+                // For some reason this can happen. Don't ask...
+                //
+                if (chr == null)
+                    continue;
+                
+                if (chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero)
+                    continue;
+                
+                chr.IsColliding = false;
+                chr.CollidingGround = false;
+                chr.CollidingObj = false;
+                
+                // test the avatar's geometry for collision with the space
+                // This will return near and the space that they are the closest to
+                // And we'll run this again against the avatar and the space segment
+                // This will return with a bunch of possible objects in the space segment
+                // and we'll run it again on all of them.
+                try
                 {
-                    // Reset the collision values to false
-                    // since we don't know if we're colliding yet
-                    
-                    // For some reason this can happen. Don't ask...
-                    //
-                    if (chr == null)
-                        continue;
-                    
-                    if (chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero)
-                        continue;
-                    
-                    chr.IsColliding = false;
-                    chr.CollidingGround = false;
-                    chr.CollidingObj = false;
-                    
-                    // test the avatar's geometry for collision with the space
-                    // This will return near and the space that they are the closest to
-                    // And we'll run this again against the avatar and the space segment
-                    // This will return with a bunch of possible objects in the space segment
-                    // and we'll run it again on all of them.
-                    try
-                    {
-                        d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
-                    }
-                    catch (AccessViolationException)
-                    {
-                        m_log.Warn("[PHYSICS]: Unable to space collide");
-                    }
-                    //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
-                    //if (chr.Position.Z + (chr.Velocity.Z * timeStep) < terrainheight + 10)
-                    //{
-                    //chr.Position.Z = terrainheight + 10.0f;
-                    //forcedZ = true;
-                    //}
+                    d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
+                }
+                catch (AccessViolationException)
+                {
+                    m_log.Warn("[PHYSICS]: Unable to space collide");
                 }
+                //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
+                //if (chr.Position.Z + (chr.Velocity.Z * timeStep) < terrainheight + 10)
+                //{
+                //chr.Position.Z = terrainheight + 10.0f;
+                //forcedZ = true;
+                //}
             }
 
             lock (_activeprims)
@@ -1716,28 +1725,22 @@ namespace OpenSim.Region.Physics.OdePlugin
 
         internal void AddCharacter(OdeCharacter chr)
         {
-            lock (_characters)
+            if (!_characters.Contains(chr))
             {
-                if (!_characters.Contains(chr))
-                {
-                    _characters.Add(chr);
+                _characters.Add(chr);
 
-                    if (chr.bad)
-                        m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
-                }
+                if (chr.bad)
+                    m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
             }
         }
 
         internal void RemoveCharacter(OdeCharacter chr)
         {
-            lock (_characters)
+            if (_characters.Contains(chr))
             {
-                if (_characters.Contains(chr))
-                {
-                    _characters.Remove(chr);
-                    geom_name_map.Remove(chr.Shell);
-                    actor_name_map.Remove(chr.Shell);
-                }
+                _characters.Remove(chr);
+                geom_name_map.Remove(chr.Shell);
+                actor_name_map.Remove(chr.Shell);
             }
         }
 
@@ -2797,13 +2800,21 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                         }
 
                         // Move characters
-                        lock (_characters)
+                        foreach (OdeCharacter actor in _characters)
                         {
-                            foreach (OdeCharacter actor in _characters)
+                            if (actor != null)
+                                actor.Move(defects);
+                        }
+
+                        if (defects.Count != 0)
+                        {
+                            foreach (OdeCharacter actor in defects)
                             {
-                                if (actor != null)
-                                    actor.Move();
+                                RemoveCharacter(actor);
+                                actor.DestroyOdeStructures();
                             }
+
+                            defects.Clear();
                         }
 
                         // Move other active objects
@@ -2860,18 +2871,26 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                     timeLeft -= ODE_STEPSIZE;
                 }
 
-                lock (_characters)
+                foreach (OdeCharacter actor in _characters)
                 {
-                    foreach (OdeCharacter actor in _characters)
+                    if (actor != null)
                     {
-                        if (actor != null)
-                        {
-                            if (actor.bad)
-                                m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
+                        if (actor.bad)
+                            m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
 
-                            actor.UpdatePositionAndVelocity();
-                        }
+                        actor.UpdatePositionAndVelocity(defects);
+                    }
+                }
+
+                if (defects.Count != 0)
+                {
+                    foreach (OdeCharacter actor in defects)
+                    {
+                        RemoveCharacter(actor);
+                        actor.DestroyOdeStructures();
                     }
+
+                    defects.Clear();
                 }
 
                 lock (_activeprims)
@@ -3899,30 +3918,28 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                 }
             }
             ds.SetColor(1.0f, 0.0f, 0.0f);
-            lock (_characters)
+
+            foreach (OdeCharacter chr in _characters)
             {
-                foreach (OdeCharacter chr in _characters)
+                if (chr.Shell != IntPtr.Zero)
                 {
-                    if (chr.Shell != IntPtr.Zero)
-                    {
-                        IntPtr body = d.GeomGetBody(chr.Shell);
+                    IntPtr body = d.GeomGetBody(chr.Shell);
 
-                        d.Vector3 pos;
-                        d.GeomCopyPosition(chr.Shell, out pos);
-                        //d.BodyCopyPosition(body, out pos);
+                    d.Vector3 pos;
+                    d.GeomCopyPosition(chr.Shell, out pos);
+                    //d.BodyCopyPosition(body, out pos);
 
-                        d.Matrix3 R;
-                        d.GeomCopyRotation(chr.Shell, out R);
-                        //d.BodyCopyRotation(body, out R);
+                    d.Matrix3 R;
+                    d.GeomCopyRotation(chr.Shell, out R);
+                    //d.BodyCopyRotation(body, out R);
 
-                        ds.DrawCapsule(ref pos, ref R, chr.Size.Z, 0.35f);
-                        d.Vector3 sides = new d.Vector3();
-                        sides.X = 0.5f;
-                        sides.Y = 0.5f;
-                        sides.Z = 0.5f;
+                    ds.DrawCapsule(ref pos, ref R, chr.Size.Z, 0.35f);
+                    d.Vector3 sides = new d.Vector3();
+                    sides.X = 0.5f;
+                    sides.Y = 0.5f;
+                    sides.Z = 0.5f;
 
-                        ds.DrawBox(ref pos, ref R, ref sides);
-                    }
+                    ds.DrawBox(ref pos, ref R, ref sides);
                 }
             }
         }
-- 
cgit v1.1


From 82dc7886fc8e7517530077a593d352939f7a29d2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 21:15:15 +0000
Subject: remove unnecessary OdeScene._activeprims locking.  Code is
 single-threaded

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 99 +++++++++++++---------------
 1 file changed, 46 insertions(+), 53 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 89568b6..d1c1c25 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -193,8 +193,15 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// Avatars in the physics scene.
         /// </summary>
         private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
-        
+
+        /// <summary>
+        /// Prims in the physics scene.
+        /// </summary>
         private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
+
+        /// <summary>
+        /// Prims in the physics scene that are subject to physics, not just collisions.
+        /// </summary>
         private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
 
         /// <summary>
@@ -1565,45 +1572,42 @@ namespace OpenSim.Region.Physics.OdePlugin
                 //}
             }
 
-            lock (_activeprims)
+            List<OdePrim> removeprims = null;
+            foreach (OdePrim chr in _activeprims)
             {
-                List<OdePrim> removeprims = null;
-                foreach (OdePrim chr in _activeprims)
+                if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
                 {
-                    if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
+                    try
                     {
-                        try
+                        lock (chr)
                         {
-                            lock (chr)
+                            if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false)
                             {
-                                if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false)
-                                {
-                                    d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
-                                }
-                                else
+                                d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
+                            }
+                            else
+                            {
+                                if (removeprims == null)
                                 {
-                                    if (removeprims == null)
-                                    {
-                                        removeprims = new List<OdePrim>();
-                                    }
-                                    removeprims.Add(chr);
-                                    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!");
+                                    removeprims = new List<OdePrim>();
                                 }
+                                removeprims.Add(chr);
+                                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!");
                             }
                         }
-                        catch (AccessViolationException)
-                        {
-                            m_log.Warn("[PHYSICS]: Unable to space collide");
-                        }
+                    }
+                    catch (AccessViolationException)
+                    {
+                        m_log.Warn("[PHYSICS]: Unable to space collide");
                     }
                 }
+            }
 
-                if (removeprims != null)
+            if (removeprims != null)
+            {
+                foreach (OdePrim chr in removeprims)
                 {
-                    foreach (OdePrim chr in removeprims)
-                    {
-                        _activeprims.Remove(chr);
-                    }
+                    _activeprims.Remove(chr);
                 }
             }
         }
@@ -1770,13 +1774,10 @@ namespace OpenSim.Region.Physics.OdePlugin
         internal void ActivatePrim(OdePrim prim)
         {
             // adds active prim..   (ones that should be iterated over in collisions_optimized
-            lock (_activeprims)
-            {
-                if (!_activeprims.Contains(prim))
-                    _activeprims.Add(prim);
-                //else
-                  //  m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
-            }
+            if (!_activeprims.Contains(prim))
+                _activeprims.Add(prim);
+            //else
+              //  m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
         }
 
         public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
@@ -2150,8 +2151,7 @@ namespace OpenSim.Region.Physics.OdePlugin
         /// <param name="prim"></param>
         internal void DeactivatePrim(OdePrim prim)
         {
-            lock (_activeprims)
-                _activeprims.Remove(prim);
+            _activeprims.Remove(prim);
         }
 
         public override void RemovePrim(PhysicsActor prim)
@@ -2818,13 +2818,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                         }
 
                         // Move other active objects
-                        lock (_activeprims)
+                        foreach (OdePrim prim in _activeprims)
                         {
-                            foreach (OdePrim prim in _activeprims)
-                            {
-                                prim.m_collisionscore = 0;
-                                prim.Move(timeStep);
-                            }
+                            prim.m_collisionscore = 0;
+                            prim.Move(timeStep);
                         }
 
                         //if ((framecount % m_randomizeWater) == 0)
@@ -2893,20 +2890,16 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                     defects.Clear();
                 }
 
-                lock (_activeprims)
+                //if (timeStep < 0.2f)
+
+                foreach (OdePrim prim in _activeprims)
                 {
-                    //if (timeStep < 0.2f)
+                    if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag))
                     {
-                        foreach (OdePrim prim in _activeprims)
-                        {
-                            if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag))
-                            {
-                                prim.UpdatePositionAndVelocity();
+                        prim.UpdatePositionAndVelocity();
 
-                                if (SupportsNINJAJoints)
-                                    SimulateActorPendingJoints(prim);
-                            }
-                        }
+                        if (SupportsNINJAJoints)
+                            SimulateActorPendingJoints(prim);
                     }
                 }
 
-- 
cgit v1.1


From 4ddff7eb0ffbb1cc43eac2543296e241574e31be Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 21:29:56 +0000
Subject: Get rid of OdeCharacter != null checks since OdeScene._characters can
 never contain a null character.

Ignoring the ancient code glyphs not to do this....
---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index d1c1c25..e6cf915 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1538,12 +1538,6 @@ namespace OpenSim.Region.Physics.OdePlugin
             {
                 // Reset the collision values to false
                 // since we don't know if we're colliding yet
-                
-                // For some reason this can happen. Don't ask...
-                //
-                if (chr == null)
-                    continue;
-                
                 if (chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero)
                     continue;
                 
@@ -2056,7 +2050,6 @@ namespace OpenSim.Region.Physics.OdePlugin
             //m_log.Debug("RemoveAllJointsConnectedToActor: start");
             if (actor.SOPName != null && joints_connecting_actor.ContainsKey(actor.SOPName) && joints_connecting_actor[actor.SOPName] != null)
             {
-
                 List<PhysicsJoint> jointsToRemove = new List<PhysicsJoint>();
                 //TODO: merge these 2 loops (originally it was needed to avoid altering a list being iterated over, but it is no longer needed due to the joint request queue mechanism)
                 foreach (PhysicsJoint j in joints_connecting_actor[actor.SOPName])
@@ -2801,10 +2794,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
 
                         // Move characters
                         foreach (OdeCharacter actor in _characters)
-                        {
-                            if (actor != null)
-                                actor.Move(defects);
-                        }
+                            actor.Move(defects);
 
                         if (defects.Count != 0)
                         {
@@ -2870,13 +2860,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
 
                 foreach (OdeCharacter actor in _characters)
                 {
-                    if (actor != null)
-                    {
-                        if (actor.bad)
-                            m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
+                    if (actor.bad)
+                        m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
 
-                        actor.UpdatePositionAndVelocity(defects);
-                    }
+                    actor.UpdatePositionAndVelocity(defects);
                 }
 
                 if (defects.Count != 0)
-- 
cgit v1.1


From c4e4a29478c635bb5759fa5b815d86e39cb3a794 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 21 Nov 2011 21:31:26 +0000
Subject: Slightly improve "Unable to space collide" logging message, though I
 don't think I've ever seen this.

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index e6cf915..e219535 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1556,8 +1556,9 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
                 catch (AccessViolationException)
                 {
-                    m_log.Warn("[PHYSICS]: Unable to space collide");
+                    m_log.WarnFormat("[PHYSICS]: Unable to space collide {0}", Name);
                 }
+                
                 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
                 //if (chr.Position.Z + (chr.Velocity.Z * timeStep) < terrainheight + 10)
                 //{
-- 
cgit v1.1


From daf99f8c0ac874971c829b18a2372be1c4ee9541 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 22 Nov 2011 21:51:00 +0000
Subject: slightly simplify OdeScene.Simulate() by removing bool processtaints,
 since we can inspect count of taint lists instead.

also groups OdeCharacter.CreateOdeStructures() and DestroyOdeStructures() together
---
 OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 234 +++++++++++------------
 OpenSim/Region/Physics/OdePlugin/ODEPrim.cs      |   1 -
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs     |  34 ++--
 3 files changed, 128 insertions(+), 141 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index cfe64f2..489a23a 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -542,123 +542,6 @@ namespace OpenSim.Region.Physics.OdePlugin
         }
 
         /// <summary>
-        /// This creates the Avatar's physical Surrogate in ODE at the position supplied
-        /// </summary>
-        /// <remarks>
-        /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
-        /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
-        /// place that is safe to call this routine AvatarGeomAndBodyCreation.
-        /// </remarks>
-        /// <param name="npositionX"></param>
-        /// <param name="npositionY"></param>
-        /// <param name="npositionZ"></param>
-        /// <param name="tensor"></param>
-        private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
-        {
-            int dAMotorEuler = 1;
-//            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
-            if (CAPSULE_LENGTH <= 0)
-            {
-                m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
-                CAPSULE_LENGTH = 0.01f;
-            }
-
-            if (CAPSULE_RADIUS <= 0)
-            {
-                m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
-                CAPSULE_RADIUS = 0.01f;
-            }
-
-            Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
-
-            d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
-            d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
-
-            d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
-            Body = d.BodyCreate(_parent_scene.world);
-            d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
-
-            _position.X = npositionX;
-            _position.Y = npositionY;
-            _position.Z = npositionZ;
-
-            m_taintPosition = _position;
-
-            d.BodySetMass(Body, ref ShellMass);
-            d.Matrix3 m_caprot;
-            // 90 Stand up on the cap of the capped cyllinder
-            if (_parent_scene.IsAvCapsuleTilted)
-            {
-                d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2));
-            }
-            else
-            {
-                d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
-            }
-
-            d.GeomSetRotation(Shell, ref m_caprot);
-            d.BodySetRotation(Body, ref m_caprot);
-
-            d.GeomSetBody(Shell, Body);
-
-            // The purpose of the AMotor here is to keep the avatar's physical
-            // surrogate from rotating while moving
-            Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
-            d.JointAttach(Amotor, Body, IntPtr.Zero);
-            d.JointSetAMotorMode(Amotor, dAMotorEuler);
-            d.JointSetAMotorNumAxes(Amotor, 3);
-            d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
-            d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
-            d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
-            d.JointSetAMotorAngle(Amotor, 0, 0);
-            d.JointSetAMotorAngle(Amotor, 1, 0);
-            d.JointSetAMotorAngle(Amotor, 2, 0);
-
-            // These lowstops and high stops are effectively (no wiggle room)
-            if (_parent_scene.IsAvCapsuleTilted)
-            {
-                d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
-            }
-            else
-            {
-                #region Documentation of capsule motor LowStop and HighStop parameters
-                // Intentionally introduce some tilt into the capsule by setting
-                // the motor stops to small epsilon values. This small tilt prevents
-                // the capsule from falling into the terrain; a straight-up capsule
-                // (with -0..0 motor stops) falls into the terrain for reasons yet
-                // to be comprehended in their entirety.
-                #endregion
-                AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
-                d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
-                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop,  0.08f); // must be same as lowstop, else a different, spurious tilt is introduced
-                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
-                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop
-            }
-
-            // Fudge factor is 1f by default, we're setting it to 0.  We don't want it to Fudge or the
-            // capped cyllinder will fall over
-            d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
-            d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
-
-            //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
-            //d.QfromR(
-            //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
-            //
-            //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
-            //standupStraight();
-
-            _parent_scene.geom_name_map[Shell] = Name;
-            _parent_scene.actor_name_map[Shell] = this;
-        }
-
-        /// <summary>
         /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
         /// This may be used in calculations in the scene/scenepresence
         /// </summary>
@@ -1126,6 +1009,123 @@ namespace OpenSim.Region.Physics.OdePlugin
         }
 
         /// <summary>
+        /// This creates the Avatar's physical Surrogate in ODE at the position supplied
+        /// </summary>
+        /// <remarks>
+        /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
+        /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
+        /// place that is safe to call this routine AvatarGeomAndBodyCreation.
+        /// </remarks>
+        /// <param name="npositionX"></param>
+        /// <param name="npositionY"></param>
+        /// <param name="npositionZ"></param>
+        /// <param name="tensor"></param>
+        private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
+        {
+            int dAMotorEuler = 1;
+//            _parent_scene.waitForSpaceUnlock(_parent_scene.space);
+            if (CAPSULE_LENGTH <= 0)
+            {
+                m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
+                CAPSULE_LENGTH = 0.01f;
+            }
+
+            if (CAPSULE_RADIUS <= 0)
+            {
+                m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
+                CAPSULE_RADIUS = 0.01f;
+            }
+
+            Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
+
+            d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
+            d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
+
+            d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
+            Body = d.BodyCreate(_parent_scene.world);
+            d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
+
+            _position.X = npositionX;
+            _position.Y = npositionY;
+            _position.Z = npositionZ;
+
+            m_taintPosition = _position;
+
+            d.BodySetMass(Body, ref ShellMass);
+            d.Matrix3 m_caprot;
+            // 90 Stand up on the cap of the capped cyllinder
+            if (_parent_scene.IsAvCapsuleTilted)
+            {
+                d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2));
+            }
+            else
+            {
+                d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
+            }
+
+            d.GeomSetRotation(Shell, ref m_caprot);
+            d.BodySetRotation(Body, ref m_caprot);
+
+            d.GeomSetBody(Shell, Body);
+
+            // The purpose of the AMotor here is to keep the avatar's physical
+            // surrogate from rotating while moving
+            Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
+            d.JointAttach(Amotor, Body, IntPtr.Zero);
+            d.JointSetAMotorMode(Amotor, dAMotorEuler);
+            d.JointSetAMotorNumAxes(Amotor, 3);
+            d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
+            d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
+            d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
+            d.JointSetAMotorAngle(Amotor, 0, 0);
+            d.JointSetAMotorAngle(Amotor, 1, 0);
+            d.JointSetAMotorAngle(Amotor, 2, 0);
+
+            // These lowstops and high stops are effectively (no wiggle room)
+            if (_parent_scene.IsAvCapsuleTilted)
+            {
+                d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
+            }
+            else
+            {
+                #region Documentation of capsule motor LowStop and HighStop parameters
+                // Intentionally introduce some tilt into the capsule by setting
+                // the motor stops to small epsilon values. This small tilt prevents
+                // the capsule from falling into the terrain; a straight-up capsule
+                // (with -0..0 motor stops) falls into the terrain for reasons yet
+                // to be comprehended in their entirety.
+                #endregion
+                AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
+                d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
+                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop,  0.08f); // must be same as lowstop, else a different, spurious tilt is introduced
+                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
+                d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop
+            }
+
+            // Fudge factor is 1f by default, we're setting it to 0.  We don't want it to Fudge or the
+            // capped cyllinder will fall over
+            d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
+            d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
+
+            //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
+            //d.QfromR(
+            //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
+            //
+            //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
+            //standupStraight();
+
+            _parent_scene.geom_name_map[Shell] = Name;
+            _parent_scene.actor_name_map[Shell] = this;
+        }
+
+        /// <summary>
         /// Cleanup the things we use in the scene.
         /// </summary>
         internal void Destroy()
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index fec4693..94e6185 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -272,7 +272,6 @@ namespace OpenSim.Region.Physics.OdePlugin
 
             m_taintadd = true;
             _parent_scene.AddPhysicsActorTaint(this);
-            //  don't do .add() here; old geoms get recycled with the same hash
         }
 
         public override int PhysicsActorType
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index e219535..72e9ca0 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -2160,7 +2160,6 @@ namespace OpenSim.Region.Physics.OdePlugin
 
                     p.setPrimForRemoval();
                     AddPhysicsActorTaint(prim);
-                    //RemovePrimThreadLocked(p);
                 }
             }
         }
@@ -2607,15 +2606,17 @@ namespace OpenSim.Region.Physics.OdePlugin
 
         /// <summary>
         /// Called after our prim properties are set Scale, position etc.
+        /// </summary>
+        /// <remarks>
         /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex
         /// This assures us that we have no race conditions
-        /// </summary>
-        /// <param name="prim"></param>
-        public override void AddPhysicsActorTaint(PhysicsActor prim)
+        /// </remarks>
+        /// <param name="actor"></param>
+        public override void AddPhysicsActorTaint(PhysicsActor actor)
         {
-            if (prim is OdePrim)
+            if (actor is OdePrim)
             {
-                OdePrim taintedprim = ((OdePrim) prim);
+                OdePrim taintedprim = ((OdePrim)actor);
                 lock (_taintedPrimLock)
                 {
                     if (!(_taintedPrimH.Contains(taintedprim))) 
@@ -2627,11 +2628,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                         _taintedPrimL.Add(taintedprim);                    // List for ordered readout
                     }
                 }
-                return;
             }
-            else if (prim is OdeCharacter)
+            else if (actor is OdeCharacter)
             {
-                OdeCharacter taintedchar = ((OdeCharacter)prim);
+                OdeCharacter taintedchar = ((OdeCharacter)actor);
                 lock (_taintedActors)
                 {
                     if (!(_taintedActors.Contains(taintedchar)))
@@ -2734,29 +2734,18 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                 {
                     try
                     {
-                        // Insert, remove Characters
-                        bool processedtaints = false;
-
                         lock (_taintedActors)
                         {
                             if (_taintedActors.Count > 0)
                             {
                                 foreach (OdeCharacter character in _taintedActors)
-                                {
                                     character.ProcessTaints();
 
-                                    processedtaints = true;
-                                    //character.m_collisionscore = 0;
-                                }
-
-                                if (processedtaints)
+                                if (_taintedActors.Count > 0)
                                     _taintedActors.Clear();
                             }
                         }
 
-                        // Modify other objects in the scene.
-                        processedtaints = false;
-
                         lock (_taintedPrimLock)
                         {
                             foreach (OdePrim prim in _taintedPrimL)
@@ -2772,7 +2761,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                                     prim.ProcessTaints();
                                 }
 
-                                processedtaints = true;
                                 prim.m_collisionscore = 0;
 
                                 // This loop can block up the Heartbeat for a very long time on large regions.
@@ -2785,7 +2773,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                             if (SupportsNINJAJoints)
                                 SimulatePendingNINJAJoints();
 
-                            if (processedtaints)
+                            if (_taintedPrimL.Count > 0)
                             {
 //Console.WriteLine("Simulate calls Clear of _taintedPrim list");
                                 _taintedPrimH.Clear();
-- 
cgit v1.1


From b0fe0464af9a11dda184d3613eca734cd8c9f21e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 22 Nov 2011 22:13:57 +0000
Subject: Stop an exception being thrown and a teleport/border cross failing if
 the desintation sim has no active script engines.

This involves getting IScene.RequestModuleInterfaces() to return an empty array (as was stated in the method doc) rather than an array containing one null entry.
Callers adjusted to stop checking for the list reference being null (which never happened anyway)
---
 OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 13 +++--------
 OpenSim/Region/Framework/Scenes/SceneBase.cs       |  2 +-
 .../Framework/Scenes/SceneObjectPartInventory.cs   | 10 ++++-----
 OpenSim/Region/Framework/Scenes/ScenePresence.cs   | 26 +++++++++++-----------
 4 files changed, 22 insertions(+), 29 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 663aa22..26eb729 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -82,16 +82,9 @@ namespace OpenSim.Region.Framework.Scenes
             m_log.Info("[PRIM INVENTORY]: Starting scripts in scene");
 
             IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
-            if (engines != null)
-            {
-                foreach (IScriptModule engine in engines)
-                {
-                    if (engine != null)
-                    {
-                        engine.StartProcessing();
-                    }
-                }
-            }
+
+            foreach (IScriptModule engine in engines)
+                engine.StartProcessing();
         }
 
         public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index dee2ecb..0336fe5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -449,7 +449,7 @@ namespace OpenSim.Region.Framework.Scenes
             }
             else
             {
-                return new T[] { default(T) };
+                return new T[] {};
             }
         }
         
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 9446741..d80944b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -232,8 +232,6 @@ namespace OpenSim.Region.Framework.Scenes
             ArrayList ret = new ArrayList();
 
             IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
-            if (engines == null) // No engine at all
-                return ret;
 
             foreach (IScriptModule e in engines)
             {
@@ -329,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes
         private void RestoreSavedScriptState(UUID oldID, UUID newID)
         {
             IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
-            if (engines == null) // No engine at all
+            if (engines.Length == 0) // No engine at all
                 return;
 
             if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
@@ -369,6 +367,7 @@ namespace OpenSim.Region.Framework.Scenes
 
                     m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml;
                 }
+                
                 foreach (IScriptModule e in engines)
                 {
                     if (e != null)
@@ -377,6 +376,7 @@ namespace OpenSim.Region.Framework.Scenes
                             break;
                     }
                 }
+
                 m_part.ParentGroup.m_savedScriptState.Remove(oldID);
             }
         }
@@ -1129,7 +1129,7 @@ namespace OpenSim.Region.Framework.Scenes
             
             IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
             
-            if (engines == null) // No engine at all
+            if (engines.Length == 0) // No engine at all
                 return ret;
 
             List<TaskInventoryItem> scripts = GetInventoryScripts();
@@ -1157,7 +1157,7 @@ namespace OpenSim.Region.Framework.Scenes
         public void ResumeScripts()
         {
             IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
-            if (engines == null)
+            if (engines.Length == 0)
                 return;
 
             List<TaskInventoryItem> scripts = GetInventoryScripts();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7d901c9..c2d3501 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3525,23 +3525,23 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="args">The arguments for the event</param>
         public void SendScriptEventToAttachments(string eventName, Object[] args)
         {
-            if (m_scriptEngines != null)
+            if (m_scriptEngines.Length == 0)
+                return;
+
+            lock (m_attachments)
             {
-                lock (m_attachments)
+                foreach (SceneObjectGroup grp in m_attachments)
                 {
-                    foreach (SceneObjectGroup grp in m_attachments)
+                    // 16384 is CHANGED_ANIMATION
+                    //
+                    // Send this to all attachment root prims
+                    //
+                    foreach (IScriptModule m in m_scriptEngines)
                     {
-                        // 16384 is CHANGED_ANIMATION
-                        //
-                        // Send this to all attachment root prims
-                        //
-                        foreach (IScriptModule m in m_scriptEngines)
-                        {
-                            if (m == null) // No script engine loaded
-                                continue;
+                        if (m == null) // No script engine loaded
+                            continue;
 
-                            m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION });
-                        }
+                        m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION });
                     }
                 }
             }
-- 
cgit v1.1


From d639f7fdf3ddb4bbb825a08c5c153b5e93b27231 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 22 Nov 2011 22:16:09 +0000
Subject: minor: remove mono compiler warning

---
 OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
index 2a44360..23ef757 100755
--- a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
+++ b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
     public class PhysicsParameters : ISharedRegionModule
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-        private static string LogHeader = "[PHYSICS PARAMETERS]";
+//        private static string LogHeader = "[PHYSICS PARAMETERS]";
 
         private List<Scene> m_scenes = new List<Scene>();
         private static bool m_commandsLoaded = false;
-- 
cgit v1.1


From fcb066cb5f8d56f13cfbdd4cef9f51a854b95854 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 22 Nov 2011 22:23:52 +0000
Subject: Comment out unimplemented and uncalled
 RegionCombinerModule.UnCombineRegion()

---
 .../RegionCombinerModule/RegionCombinerModule.cs   | 54 +++++++++++-----------
 1 file changed, 27 insertions(+), 27 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
index 92cbbc6..3f9834c 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
@@ -841,33 +841,33 @@ namespace OpenSim.Region.RegionCombinerModule
         {
         }
         
-        /// <summary>
-        /// TODO:
-        /// </summary>
-        /// <param name="rdata"></param>
-        public void UnCombineRegion(RegionData rdata)
-        {
-            lock (m_regions)
-            {
-                if (m_regions.ContainsKey(rdata.RegionId))
-                {
-                    // uncombine root region and virtual regions
-                }
-                else
-                {
-                    foreach (RegionConnections r in m_regions.Values)
-                    {
-                        foreach (RegionData rd in r.ConnectedRegions)
-                        {
-                            if (rd.RegionId == rdata.RegionId)
-                            {
-                                // uncombine virtual region
-                            }
-                        }
-                    }
-                }
-            }
-        }
+//        /// <summary>
+//        /// TODO:
+//        /// </summary>
+//        /// <param name="rdata"></param>
+//        public void UnCombineRegion(RegionData rdata)
+//        {
+//            lock (m_regions)
+//            {
+//                if (m_regions.ContainsKey(rdata.RegionId))
+//                {
+//                    // uncombine root region and virtual regions
+//                }
+//                else
+//                {
+//                    foreach (RegionConnections r in m_regions.Values)
+//                    {
+//                        foreach (RegionData rd in r.ConnectedRegions)
+//                        {
+//                            if (rd.RegionId == rdata.RegionId)
+//                            {
+//                                // uncombine virtual region
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//        }
 
         // Create a set of infinite borders around the whole aabb of the combined island.
         private void AdjustLargeRegionBounds()
-- 
cgit v1.1


From af90b527314d6cf441dcd593886739ac77b68558 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 22 Nov 2011 22:28:46 +0000
Subject: Comment out uncalled OdeScene.UnCombine()

---
 OpenSim/Region/Physics/Manager/PhysicsScene.cs |  10 +--
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs   | 116 ++++++++++++-------------
 2 files changed, 60 insertions(+), 66 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index eaa1175..7ab295a 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -221,15 +221,9 @@ namespace OpenSim.Region.Physics.Manager
             return false;
         }
 
-        public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
-        {
-            return;
-        }
+        public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {}
 
-        public virtual void UnCombine(PhysicsScene pScene)
-        {
-            
-        }
+        public virtual void UnCombine(PhysicsScene pScene) {}
 
         /// <summary>
         /// Queue a raycast against the physics scene.
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 72e9ca0..b5436bd 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -3583,64 +3583,64 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
             return true;
         }
 
-        public override void UnCombine(PhysicsScene pScene)
-        {
-            IntPtr localGround = IntPtr.Zero;
-//            float[] localHeightfield;
-            bool proceed = false;
-            List<IntPtr> geomDestroyList = new List<IntPtr>();
-
-            lock (OdeLock)
-            {
-                if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround))
-                {
-                    foreach (IntPtr geom in TerrainHeightFieldHeights.Keys)
-                    {
-                        if (geom == localGround)
-                        {
-//                            localHeightfield = TerrainHeightFieldHeights[geom];
-                            proceed = true;
-                        }
-                        else
-                        {
-                            geomDestroyList.Add(geom);
-                        }
-                    }
-
-                    if (proceed)
-                    {
-                        m_worldOffset = Vector3.Zero;
-                        WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
-                        m_parentScene = null;
-
-                        foreach (IntPtr g in geomDestroyList)
-                        {
-                            // removingHeightField needs to be done or the garbage collector will
-                            // collect the terrain data before we tell ODE to destroy it causing 
-                            // memory corruption
-                            if (TerrainHeightFieldHeights.ContainsKey(g))
-                            {
-//                                float[] removingHeightField = TerrainHeightFieldHeights[g];
-                                TerrainHeightFieldHeights.Remove(g);
-
-                                if (RegionTerrain.ContainsKey(g))
-                                {
-                                    RegionTerrain.Remove(g);
-                                }
-
-                                d.GeomDestroy(g);
-                                //removingHeightField = new float[0];
-                            }
-                        }
-
-                    }
-                    else
-                    {
-                        m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine.  Region has inconsistant data.");
-                    }
-                }
-            }
-        }
+//        public override void UnCombine(PhysicsScene pScene)
+//        {
+//            IntPtr localGround = IntPtr.Zero;
+////            float[] localHeightfield;
+//            bool proceed = false;
+//            List<IntPtr> geomDestroyList = new List<IntPtr>();
+//
+//            lock (OdeLock)
+//            {
+//                if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround))
+//                {
+//                    foreach (IntPtr geom in TerrainHeightFieldHeights.Keys)
+//                    {
+//                        if (geom == localGround)
+//                        {
+////                            localHeightfield = TerrainHeightFieldHeights[geom];
+//                            proceed = true;
+//                        }
+//                        else
+//                        {
+//                            geomDestroyList.Add(geom);
+//                        }
+//                    }
+//
+//                    if (proceed)
+//                    {
+//                        m_worldOffset = Vector3.Zero;
+//                        WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
+//                        m_parentScene = null;
+//
+//                        foreach (IntPtr g in geomDestroyList)
+//                        {
+//                            // removingHeightField needs to be done or the garbage collector will
+//                            // collect the terrain data before we tell ODE to destroy it causing 
+//                            // memory corruption
+//                            if (TerrainHeightFieldHeights.ContainsKey(g))
+//                            {
+////                                float[] removingHeightField = TerrainHeightFieldHeights[g];
+//                                TerrainHeightFieldHeights.Remove(g);
+//
+//                                if (RegionTerrain.ContainsKey(g))
+//                                {
+//                                    RegionTerrain.Remove(g);
+//                                }
+//
+//                                d.GeomDestroy(g);
+//                                //removingHeightField = new float[0];
+//                            }
+//                        }
+//
+//                    }
+//                    else
+//                    {
+//                        m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine.  Region has inconsistant data.");
+//                    }
+//                }
+//            }
+//        }
 
         public override void SetWaterLevel(float baseheight)
         {
-- 
cgit v1.1


From ace4324e753435e317ec388b5b25a8e3ffd84db4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 22 Nov 2011 22:37:06 +0000
Subject: Stop removing actor from the hash maps in OdeScene.RemoveCharacter()
 since this is now being down in OdeCharacter.DestroyOdeStructures()

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index b5436bd..7b04bcf 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1735,12 +1735,7 @@ namespace OpenSim.Region.Physics.OdePlugin
 
         internal void RemoveCharacter(OdeCharacter chr)
         {
-            if (_characters.Contains(chr))
-            {
-                _characters.Remove(chr);
-                geom_name_map.Remove(chr.Shell);
-                actor_name_map.Remove(chr.Shell);
-            }
+            _characters.Remove(chr);
         }
 
         private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
-- 
cgit v1.1


From b56410285b1af7c5fc2b4a84d8c9c734d2238ff0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 22 Nov 2011 22:46:25 +0000
Subject: Log error if we attempt to add/remove an OdeCharacter from the
 _characters list inappropriately

---
 OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 56 ++++++++++++++++------------
 1 file changed, 33 insertions(+), 23 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 7b04bcf..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
         /// <param value="name">Name of the scene.  Useful in debug messages.</param>
         public OdeScene(string name)
         {
-            m_log 
-                = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
+            m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
 
             Name = name;
 
@@ -769,7 +768,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
                 catch (AccessViolationException)
                 {
-                    m_log.Warn("[PHYSICS]: Unable to collide test a space");
+                    m_log.Warn("[ODE SCENE]: Unable to collide test a space");
                     return;
                 }
                 //Colliding a space or a geom with a space or a geom. so drill down
@@ -821,17 +820,17 @@ namespace OpenSim.Region.Physics.OdePlugin
 
                 count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
                 if (count > contacts.Length)
-                    m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
+                    m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
             }
             catch (SEHException)
             {
                 m_log.Error(
-                    "[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.");
+                    "[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.");
                 base.TriggerPhysicsBasedRestart();
             }
             catch (Exception e)
             {
-                m_log.WarnFormat("[PHYSICS]: Unable to collide test an object: {0}", e.Message);
+                m_log.WarnFormat("[ODE SCENE]: Unable to collide test an object: {0}", e.Message);
                 return;
             }
 
@@ -1556,7 +1555,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                 }
                 catch (AccessViolationException)
                 {
-                    m_log.WarnFormat("[PHYSICS]: Unable to space collide {0}", Name);
+                    m_log.WarnFormat("[ODE SCENE]: Unable to space collide {0}", Name);
                 }
                 
                 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
@@ -1587,13 +1586,13 @@ namespace OpenSim.Region.Physics.OdePlugin
                                     removeprims = new List<OdePrim>();
                                 }
                                 removeprims.Add(chr);
-                                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!");
+                                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!");
                             }
                         }
                     }
                     catch (AccessViolationException)
                     {
-                        m_log.Warn("[PHYSICS]: Unable to space collide");
+                        m_log.Warn("[ODE SCENE]: Unable to space collide");
                     }
                 }
             }
@@ -1729,13 +1728,24 @@ namespace OpenSim.Region.Physics.OdePlugin
                 _characters.Add(chr);
 
                 if (chr.bad)
-                    m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
+                    m_log.ErrorFormat("[ODE SCENE]: Added BAD actor {0} to characters list", chr.m_uuid);
+            }
+            else
+            {
+                m_log.ErrorFormat(
+                    "[ODE SCENE]: Tried to add character {0} {1} but they are already in the set!",
+                    chr.Name, chr.LocalID);
             }
         }
 
         internal void RemoveCharacter(OdeCharacter chr)
         {
-            _characters.Remove(chr);
+            if (_characters.Contains(chr))
+                _characters.Remove(chr);
+            else
+                m_log.ErrorFormat(
+                    "[ODE SCENE]: Tried to remove character {0} {1} but they are not in the list!",
+                    chr.Name, chr.LocalID);
         }
 
         private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
@@ -2222,7 +2232,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     //m_log.Warn(prim.prim_geom);
 
                     if (!prim.RemoveGeom())
-                        m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene");
+                        m_log.Warn("[ODE SCENE]: Unable to remove prim from physics scene");
 
                     lock (_prims)
                         _prims.Remove(prim);
@@ -2314,7 +2324,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                     }
                     else
                     {
-                        m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + currentspace +
+                        m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + currentspace +
                                    " Geom:" + geom);
                     }
                 }
@@ -2330,7 +2340,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                         }
                         else
                         {
-                            m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+                            m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                        sGeomIsIn + " Geom:" + geom);
                         }
                     }
@@ -2353,7 +2363,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                         }
                         else
                         {
-                            m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+                            m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                        currentspace + " Geom:" + geom);
                         }
                     }
@@ -2373,7 +2383,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                         }
                         else
                         {
-                            m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+                            m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                        currentspace + " Geom:" + geom);
                         }
                     }
@@ -2389,7 +2399,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                             }
                             else
                             {
-                                m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
+                                m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                            sGeomIsIn + " Geom:" + geom);
                             }
                         }
@@ -2633,7 +2643,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                     {
                         _taintedActors.Add(taintedchar);
                         if (taintedchar.bad)
-                            m_log.DebugFormat("[PHYSICS]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid);
+                            m_log.DebugFormat("[ODE SCENE]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid);
                     }
                 }
             }
@@ -2836,7 +2846,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                     }
                     catch (Exception e)
                     {
-                        m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e);
+                        m_log.ErrorFormat("[ODE SCENE]: {0}, {1}, {2}", e.Message, e.TargetSite, e);
                     }
 
                     timeLeft -= ODE_STEPSIZE;
@@ -2845,7 +2855,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                 foreach (OdeCharacter actor in _characters)
                 {
                     if (actor.bad)
-                        m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
+                        m_log.WarnFormat("[ODE SCENE]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
 
                     actor.UpdatePositionAndVelocity(defects);
                 }
@@ -3405,7 +3415,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
                 {
                     if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x]))
                     {
-                        m_log.Warn("[PHYSICS]: Non finite heightfield element detected.  Setting it to 0");
+                        m_log.Warn("[ODE SCENE]: Non finite heightfield element detected.  Setting it to 0");
                         resultarr2[y, x] = 0;
                     }
                     returnarr[i] = resultarr2[y, x];
@@ -3436,7 +3446,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
         private void SetTerrain(float[] heightMap, Vector3 pOffset)
         {
             int startTime = Util.EnvironmentTickCount();
-            m_log.DebugFormat("[PHYSICS]: Setting terrain for {0}", Name);
+            m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0}", Name);
 
             // this._heightmap[i] = (double)heightMap[i];
             // dbm (danx0r) -- creating a buffer zone of one extra sample all around
@@ -3561,7 +3571,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
             }
 
             m_log.DebugFormat(
-                "[PHYSICS]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime));
+                "[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime));
         }
 
         public override void DeleteTerrain()
-- 
cgit v1.1


From d4e3a7fe81a155be841bc0d182aa7a14083ffa3e Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Sat, 19 Nov 2011 11:01:51 -0500
Subject: Shell Environment Variables in config

   Adding updated Nini and support to use shell environment variables in OpenSimulator configuration.

  Nini @ https://github.com/BlueWall/Nini-Dev
---
 OpenSim/Region/Application/ConfigurationLoader.cs | 20 +++++++++++++++++++-
 OpenSim/Region/Application/OpenSimBase.cs         |  9 ++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index d0f6ab7..4a7c8b0 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -70,7 +70,7 @@ namespace OpenSim
         /// <param name="networkInfo"></param>
         /// <returns>A configuration that gets passed to modules</returns>
         public OpenSimConfigSource LoadConfigSettings(
-                IConfigSource argvSource, out ConfigSettings configSettings,
+                IConfigSource argvSource, EnvConfigSource envConfigSource, out ConfigSettings configSettings,
                 out NetworkServersInfo networkInfo)
         {
             m_configSettings = configSettings = new ConfigSettings();
@@ -195,6 +195,24 @@ namespace OpenSim
             // Make sure command line options take precedence
             m_config.Source.Merge(argvSource);
 
+
+            IConfig enVars = m_config.Source.Configs["Environment"];
+
+            if( enVars != null )
+            {
+                string[] env_keys = enVars.GetKeys();
+
+                foreach ( string key in env_keys )
+                {
+                    envConfigSource.AddEnv(key, string.Empty);
+                }
+
+                envConfigSource.LoadEnv();
+                m_config.Source.Merge(envConfigSource);
+                m_config.Source.ExpandKeyValues();
+            }
+
+
             ReadConfigSettings();
 
             return m_config;
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 553786b..0a78df2 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -108,6 +108,13 @@ namespace OpenSim
             get { return m_clientServers; }
         }
 
+        protected EnvConfigSource m_EnvConfigSource = new EnvConfigSource();
+
+        public EnvConfigSource envConfigSource
+        {
+            get { return m_EnvConfigSource; }
+        }
+
         protected List<IClientNetworkServer> m_clientServers = new List<IClientNetworkServer>();
        
         public uint HttpServerPort
@@ -142,7 +149,7 @@ namespace OpenSim
         protected virtual void LoadConfigSettings(IConfigSource configSource)
         {
             m_configLoader = new ConfigurationLoader();
-            m_config = m_configLoader.LoadConfigSettings(configSource, out m_configSettings, out m_networkServersInfo);
+            m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
             ReadExtraConfigSettings();
         }
 
-- 
cgit v1.1


From 0cb33a539812c69a6686c1b028318601793051a8 Mon Sep 17 00:00:00 2001
From: Dan Lake
Date: Wed, 23 Nov 2011 16:09:11 -0800
Subject: Line endings

---
 .../World/AutoBackup/AutoBackupModuleState.cs      | 202 ++++++++++-----------
 1 file changed, 101 insertions(+), 101 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
index 2db718c..f9e118b 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
@@ -23,104 +23,104 @@
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-
-
-namespace OpenSim.Region.OptionalModules.World.AutoBackup
-{
-    /// <summary>AutoBackupModuleState: Auto-Backup state for one region (scene).
-    /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque.
-    /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation.
-    /// </summary>
-    /// 
-    public class AutoBackupModuleState
-    {
-        private Dictionary<Guid, string> m_liveRequests = null;
-
-        public AutoBackupModuleState()
-        {
-            this.Enabled = false;
-            this.BackupDir = ".";
-            this.BusyCheck = true;
-            this.Timer = null;
-            this.NamingType = NamingType.Time;
-            this.Script = null;
-        }
-
-        public Dictionary<Guid, string> LiveRequests
-        {
-            get {
-                return this.m_liveRequests ??
-                       (this.m_liveRequests = new Dictionary<Guid, string>(1));
-            }
-        }
-
-        public bool Enabled
-        {
-            get;
-            set;
-        }
-
-        public System.Timers.Timer Timer
-        {
-            get;
-            set;
-        }
-
-        public double IntervalMinutes
-        {
-            get
-            {
-                if (this.Timer == null)
-                {
-                    return -1.0;
-                }
-                else
-                {
-                    return this.Timer.Interval / 60000.0;
-                }
-            }
-        }
-
-        public bool BusyCheck
-        {
-            get;
-            set;
-        }
-
-        public string Script
-        {
-            get;
-            set;
-        }
-
-        public string BackupDir
-        {
-            get;
-            set;
-        }
-
-        public NamingType NamingType
-        {
-            get;
-            set;
-        }
-
-        public new string ToString()
-        {
-            string retval = "";
-
-            retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n";
-            retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n";
-            retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n";
-            retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n";
-            retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n";
-            retval += "[AUTO BACKUP]: Script: " + Script + "\n";
-            return retval;
-        }
-    }
-}
-
+ */
+
+using System;
+using System.Collections.Generic;
+
+
+namespace OpenSim.Region.OptionalModules.World.AutoBackup
+{
+    /// <summary>AutoBackupModuleState: Auto-Backup state for one region (scene).
+    /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque.
+    /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation.
+    /// </summary>
+    /// 
+    public class AutoBackupModuleState
+    {
+        private Dictionary<Guid, string> m_liveRequests = null;
+
+        public AutoBackupModuleState()
+        {
+            this.Enabled = false;
+            this.BackupDir = ".";
+            this.BusyCheck = true;
+            this.Timer = null;
+            this.NamingType = NamingType.Time;
+            this.Script = null;
+        }
+
+        public Dictionary<Guid, string> LiveRequests
+        {
+            get {
+                return this.m_liveRequests ??
+                       (this.m_liveRequests = new Dictionary<Guid, string>(1));
+            }
+        }
+
+        public bool Enabled
+        {
+            get;
+            set;
+        }
+
+        public System.Timers.Timer Timer
+        {
+            get;
+            set;
+        }
+
+        public double IntervalMinutes
+        {
+            get
+            {
+                if (this.Timer == null)
+                {
+                    return -1.0;
+                }
+                else
+                {
+                    return this.Timer.Interval / 60000.0;
+                }
+            }
+        }
+
+        public bool BusyCheck
+        {
+            get;
+            set;
+        }
+
+        public string Script
+        {
+            get;
+            set;
+        }
+
+        public string BackupDir
+        {
+            get;
+            set;
+        }
+
+        public NamingType NamingType
+        {
+            get;
+            set;
+        }
+
+        public new string ToString()
+        {
+            string retval = "";
+
+            retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n";
+            retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n";
+            retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n";
+            retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n";
+            retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n";
+            retval += "[AUTO BACKUP]: Script: " + Script + "\n";
+            return retval;
+        }
+    }
+}
+
-- 
cgit v1.1