BulletSim: remove all the debug printing of pointer formatting (.ToString(X)) and replace it with a method on BulletBody, BulletShape, ...

0.7.5-pf-bulletsim
Robert Adams 2012-12-30 10:37:37 -08:00
parent 9218748321
commit 5379d6d112
7 changed files with 58 additions and 25 deletions

View File

@ -65,8 +65,8 @@ public abstract class BSConstraint : IDisposable
bool success = PhysicsScene.PE.DestroyConstraint(m_world, m_constraint); 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}", m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}",
BSScene.DetailLogZero, BSScene.DetailLogZero,
m_body1.ID, m_body1.ptr.ToString("X"), m_body1.ID, m_body1.AddrString,
m_body2.ID, m_body2.ptr.ToString("X"), m_body2.ID, m_body2.AddrString,
success); success);
m_constraint.Clear(); m_constraint.Clear();
} }

View File

@ -54,7 +54,7 @@ public sealed class BSConstraint6Dof : BSConstraint
m_enabled = true; m_enabled = true;
world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
BSScene.DetailLogZero, world.worldID, 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, 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}", world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
BSScene.DetailLogZero, world.worldID, 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}", 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; m_enabled = false;
} }
else else
@ -79,8 +79,8 @@ public sealed class BSConstraint6Dof : BSConstraint
joinPoint, joinPoint,
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
PhysicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", 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"), BSScene.DetailLogZero, world.worldID, m_constraint.AddrString,
obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
if (!m_constraint.HasPhysicalConstraint) if (!m_constraint.HasPhysicalConstraint)
{ {
world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}",

View File

@ -196,7 +196,7 @@ public sealed class BSLinksetCompound : BSLinkset
bool ret = false; bool ret = false;
DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", 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)) 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}", DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}",
child.LocalID, child.LocalID,
LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString,
child.LocalID, child.PhysBody.ptr.ToString("X")); child.LocalID, child.PhysBody.AddrString);
// Cause the child's body to be rebuilt and thus restored to normal operation // Cause the child's body to be rebuilt and thus restored to normal operation
RecomputeChildWorldPosition(child, false); RecomputeChildWorldPosition(child, false);

View File

@ -98,7 +98,7 @@ public sealed class BSLinksetConstraints : BSLinkset
bool ret = false; bool ret = false;
DetailLog("{0},BSLinksetConstraint.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", 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) 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}", DetailLog("{0},BSLinksetConstraints.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}",
childx.LocalID, childx.LocalID,
rootx.LocalID, rootx.PhysBody.ptr.ToString("X"), rootx.LocalID, rootx.PhysBody.AddrString,
childx.LocalID, childx.PhysBody.ptr.ToString("X")); childx.LocalID, childx.PhysBody.AddrString);
PhysicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() 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}", DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}",
rootPrim.LocalID, rootPrim.LocalID,
rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"), rootPrim.LocalID, rootPrim.PhysBody.AddrString,
childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X"), childPrim.LocalID, childPrim.PhysBody.AddrString,
rootPrim.Position, childPrim.Position, midPoint); rootPrim.Position, childPrim.Position, midPoint);
// create a constraint that allows no freedom of movement between the two objects // 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; bool ret = false;
DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}", DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}",
rootPrim.LocalID, rootPrim.LocalID,
rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"), rootPrim.LocalID, rootPrim.PhysBody.AddrString,
childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X")); childPrim.LocalID, childPrim.PhysBody.AddrString);
// Find the constraint for this link and get rid of it from the overall collection and from my list // 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)) if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody))
@ -290,7 +290,7 @@ public sealed class BSLinksetConstraints : BSLinkset
// BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr,
// (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", 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) foreach (BSPhysObject child in m_children)
{ {

View File

@ -259,7 +259,7 @@ public sealed class BSShapeCollection : IDisposable
{ {
// Native shapes are not tracked and are released immediately // Native shapes are not tracked and are released immediately
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}", 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); if (shapeCallback != null) shapeCallback(shape);
PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape); PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape);
} }
@ -336,9 +336,9 @@ public sealed class BSShapeCollection : IDisposable
{ {
// Failed the sanity check!! // Failed the sanity check!!
PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}", 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}", 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; return;
} }
@ -400,7 +400,7 @@ public sealed class BSShapeCollection : IDisposable
else else
{ {
PhysicsScene.Logger.ErrorFormat("{0} Could not decypher shape type. Region={1}, addr={2}", PhysicsScene.Logger.ErrorFormat("{0} Could not decypher shape type. Region={1}, addr={2}",
LogHeader, PhysicsScene.RegionName, cShape.ToString("X")); LogHeader, PhysicsScene.RegionName, shapeInfo.AddrString);
} }
} }

View File

@ -91,11 +91,17 @@ public abstract class BSShape
// All shapes have a static call to get a reference to the physical shape // All shapes have a static call to get a reference to the physical shape
// protected abstract static BSShape GetReference(); // 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() public override string ToString()
{ {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
buff.Append("<p="); buff.Append("<p=");
buff.Append(ptr.ToString("X")); buff.Append(AddrString);
buff.Append(",s="); buff.Append(",s=");
buff.Append(type.ToString()); buff.Append(type.ToString());
buff.Append(",k="); buff.Append(",k=");

View File

@ -82,13 +82,22 @@ public class BulletBody
BulletSimData.CollisionTypeMasks[collisionType].mask); 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() public override string ToString()
{ {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
buff.Append("<id="); buff.Append("<id=");
buff.Append(ID.ToString()); buff.Append(ID.ToString());
buff.Append(",p="); buff.Append(",p=");
buff.Append(ptr.ToString("X")); buff.Append(AddrString);
buff.Append(",c="); buff.Append(",c=");
buff.Append(collisionType); buff.Append(collisionType);
buff.Append(">"); buff.Append(">");
@ -124,11 +133,20 @@ public class BulletShape
} }
public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } } 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() public override string ToString()
{ {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
buff.Append("<p="); buff.Append("<p=");
buff.Append(ptr.ToString("X")); buff.Append(AddrString);
buff.Append(",s="); buff.Append(",s=");
buff.Append(type.ToString()); buff.Append(type.ToString());
buff.Append(",k="); buff.Append(",k=");
@ -154,6 +172,15 @@ public class BulletConstraint
ptr = IntPtr.Zero; ptr = IntPtr.Zero;
} }
public bool HasPhysicalConstraint { get { return 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. // An allocated HeightMapThing which holds various heightmap info.