From 5379d6d112a8027c8f0f62ba77303e8b69e24332 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Sun, 30 Dec 2012 10:37:37 -0800
Subject: BulletSim: remove all the debug printing of pointer formatting
 (.ToString(X)) and replace it with a method on BulletBody, BulletShape, ...

---
 .../Region/Physics/BulletSPlugin/BSConstraint.cs   |  4 +--
 .../Physics/BulletSPlugin/BSConstraint6Dof.cs      | 10 +++----
 .../Physics/BulletSPlugin/BSLinksetCompound.cs     |  6 ++---
 .../Physics/BulletSPlugin/BSLinksetConstraints.cs  | 16 +++++------
 .../Physics/BulletSPlugin/BSShapeCollection.cs     |  8 +++---
 OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs   |  8 +++++-
 .../Region/Physics/BulletSPlugin/BulletSimData.cs  | 31 ++++++++++++++++++++--
 7 files changed, 58 insertions(+), 25 deletions(-)

(limited to 'OpenSim/Region/Physics')

diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
index c9c7c2e..b813974 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
@@ -65,8 +65,8 @@ public abstract class BSConstraint : IDisposable
                 bool success = PhysicsScene.PE.DestroyConstraint(m_world, m_constraint);
                 m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}",
                                     BSScene.DetailLogZero,
-                                    m_body1.ID, m_body1.ptr.ToString("X"),
-                                    m_body2.ID, m_body2.ptr.ToString("X"),
+                                    m_body1.ID, m_body1.AddrString,
+                                    m_body2.ID, m_body2.AddrString,
                                     success);
                 m_constraint.Clear();
             }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs
index aee93c9..ecb1b32 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs
@@ -54,7 +54,7 @@ public sealed class BSConstraint6Dof : BSConstraint
         m_enabled = true;
         world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
                             BSScene.DetailLogZero, world.worldID,
-                            obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
+                            obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
     }
 
     public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2,
@@ -68,9 +68,9 @@ public sealed class BSConstraint6Dof : BSConstraint
         {
             world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
                             BSScene.DetailLogZero, world.worldID,
-                            obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
+                            obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
             world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
-                            LogHeader, world.worldID, obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
+                            LogHeader, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
             m_enabled = false;
         }
         else
@@ -79,8 +79,8 @@ public sealed class BSConstraint6Dof : BSConstraint
                                     joinPoint,
                                     useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
             PhysicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
-                                BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"),
-                                obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X"));
+                                BSScene.DetailLogZero, world.worldID, m_constraint.AddrString,
+                                obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
             if (!m_constraint.HasPhysicalConstraint)
             {
                 world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}",
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 3c99ca7..143c60c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -196,7 +196,7 @@ public sealed class BSLinksetCompound : BSLinkset
         bool ret = false;
 
         DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}",
-                        child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), IsRoot(child));
+                        child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, IsRoot(child));
 
         if (!IsRoot(child))
         {
@@ -280,8 +280,8 @@ public sealed class BSLinksetCompound : BSLinkset
         {
             DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}",
                             child.LocalID,
-                            LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"),
-                            child.LocalID, child.PhysBody.ptr.ToString("X"));
+                            LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString,
+                            child.LocalID, child.PhysBody.AddrString);
 
             // Cause the child's body to be rebuilt and thus restored to normal operation
             RecomputeChildWorldPosition(child, false);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index 86c29c7..629bc72 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -98,7 +98,7 @@ public sealed class BSLinksetConstraints : BSLinkset
         bool ret = false;
 
         DetailLog("{0},BSLinksetConstraint.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}",
-                                    child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"));
+                                    child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString);
 
         lock (m_linksetActivityLock)
         {
@@ -147,8 +147,8 @@ public sealed class BSLinksetConstraints : BSLinkset
 
             DetailLog("{0},BSLinksetConstraints.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}",
                             childx.LocalID,
-                            rootx.LocalID, rootx.PhysBody.ptr.ToString("X"),
-                            childx.LocalID, childx.PhysBody.ptr.ToString("X"));
+                            rootx.LocalID, rootx.PhysBody.AddrString,
+                            childx.LocalID, childx.PhysBody.AddrString);
 
             PhysicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate()
             {
@@ -187,8 +187,8 @@ public sealed class BSLinksetConstraints : BSLinkset
 
         DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}",
                                         rootPrim.LocalID,
-                                        rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"),
-                                        childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X"),
+                                        rootPrim.LocalID, rootPrim.PhysBody.AddrString,
+                                        childPrim.LocalID, childPrim.PhysBody.AddrString,
                                         rootPrim.Position, childPrim.Position, midPoint);
 
         // create a constraint that allows no freedom of movement between the two objects
@@ -252,8 +252,8 @@ public sealed class BSLinksetConstraints : BSLinkset
         bool ret = false;
         DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}",
                             rootPrim.LocalID,
-                            rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"),
-                            childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X"));
+                            rootPrim.LocalID, rootPrim.PhysBody.AddrString,
+                            childPrim.LocalID, childPrim.PhysBody.AddrString);
 
         // Find the constraint for this link and get rid of it from the overall collection and from my list
         if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody))
@@ -290,7 +290,7 @@ public sealed class BSLinksetConstraints : BSLinkset
         // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, 
         //                     (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
         DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}",
-                            LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), linksetMass);
+                            LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass);
 
         foreach (BSPhysObject child in m_children)
         {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 6f819d8..d59e455 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -259,7 +259,7 @@ public sealed class BSShapeCollection : IDisposable
                 {
                     // Native shapes are not tracked and are released immediately
                     if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}",
-                                    BSScene.DetailLogZero, shape.ptr.ToString("X"), inTaintTime);
+                                    BSScene.DetailLogZero, shape.AddrString, inTaintTime);
                     if (shapeCallback != null) shapeCallback(shape);
                     PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape);
                 }
@@ -336,9 +336,9 @@ public sealed class BSShapeCollection : IDisposable
         {
             // Failed the sanity check!!
             PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}",
-                                        LogHeader, shape.type, shape.ptr.ToString("X"));
+                                        LogHeader, shape.type, shape.AddrString);
             if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,notACompoundShape,type={1},ptr={2}",
-                                        BSScene.DetailLogZero, shape.type, shape.ptr.ToString("X"));
+                                        BSScene.DetailLogZero, shape.type, shape.AddrString);
             return;
         }
 
@@ -400,7 +400,7 @@ public sealed class BSShapeCollection : IDisposable
         else
         {
             PhysicsScene.Logger.ErrorFormat("{0} Could not decypher shape type. Region={1}, addr={2}",
-                                    LogHeader, PhysicsScene.RegionName, cShape.ToString("X"));
+                                    LogHeader, PhysicsScene.RegionName, shapeInfo.AddrString);
         }
     }
 
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
index cdaa869..423e700 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
@@ -91,11 +91,17 @@ public abstract class BSShape
     // All shapes have a static call to get a reference to the physical shape
     // protected abstract static BSShape GetReference();
 
+    // Returns a string for debugging that uniquily identifies the memory used by this instance
+    public string AddrString
+    {
+        get { return ptr.ToString("X"); }
+    }
+
     public override string ToString()
     {
         StringBuilder buff = new StringBuilder();
         buff.Append("<p=");
-        buff.Append(ptr.ToString("X"));
+        buff.Append(AddrString);
         buff.Append(",s=");
         buff.Append(type.ToString());
         buff.Append(",k=");
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
index cd5d170..c10d75e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
@@ -82,13 +82,22 @@ public class BulletBody
                                 BulletSimData.CollisionTypeMasks[collisionType].mask);
     }
 
+    // Used for log messages for a unique display of the memory/object allocated to this instance
+    public string AddrString
+    {
+        get
+        {
+            return ptr.ToString("X");
+        }
+    }
+
     public override string ToString()
     {
         StringBuilder buff = new StringBuilder();
         buff.Append("<id=");
         buff.Append(ID.ToString());
         buff.Append(",p=");
-        buff.Append(ptr.ToString("X"));
+        buff.Append(AddrString);
         buff.Append(",c=");
         buff.Append(collisionType);
         buff.Append(">");
@@ -124,11 +133,20 @@ public class BulletShape
     }
     public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } }
 
+    // Used for log messages for a unique display of the memory/object allocated to this instance
+    public string AddrString
+    {
+        get
+        {
+            return ptr.ToString("X");
+        }
+    }
+
     public override string ToString()
     {
         StringBuilder buff = new StringBuilder();
         buff.Append("<p=");
-        buff.Append(ptr.ToString("X"));
+        buff.Append(AddrString);
         buff.Append(",s=");
         buff.Append(type.ToString());
         buff.Append(",k=");
@@ -154,6 +172,15 @@ public class BulletConstraint
         ptr = IntPtr.Zero;
     }
     public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } }
+
+    // Used for log messages for a unique display of the memory/object allocated to this instance
+    public string AddrString
+    {
+        get
+        {
+            return ptr.ToString("X");
+        }
+    }
 }
 
 // An allocated HeightMapThing which holds various heightmap info.
-- 
cgit v1.1