From 93fa9e89918f41db01229c61a228724d380552ac Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 1 Jun 2012 00:56:13 +0100 Subject: Add ODE avatar and prim collision numbers if extra stats collection is enabled. --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 39 ++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 25b3266..864cdc2 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -148,6 +148,16 @@ namespace OpenSim.Region.Physics.OdePlugin public const string ODENativeCollisionFrameMsStatName = "ODENativeCollisionFrameMS"; /// + /// Stat name for the number of avatar collisions with another entity. + /// + public const string ODEAvatarCollisionsStatName = "ODEAvatarCollisions"; + + /// + /// Stat name for the number of prim collisions with another entity. + /// + public const string ODEPrimCollisionsStatName = "ODEPrimCollisions"; + + /// /// Used to hold tick numbers for stat collection purposes. /// private int m_nativeCollisionTickRecorder; @@ -158,6 +168,12 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_inCollisionTiming; /// + /// A temporary holder for the number of avatar collisions in a frame, so we can work out how many object + /// collisions occured using the _perloopcontact if stats collection is enabled. + /// + private int m_tempAvatarCollisionsThisFrame; + + /// /// Used in calculating physics frame time dilation /// private int tickCountFrameRun; @@ -473,7 +489,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Initialize the mesh plugin public override void Initialise(IMesher meshmerizer, IConfigSource config) { - m_stats[ODENativeCollisionFrameMsStatName] = 0; + InitializeExtraStats(); mesher = meshmerizer; m_config = config; @@ -1455,7 +1471,7 @@ namespace OpenSim.Region.Physics.OdePlugin break; } } - //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth)); + //m_log.DebugFormat("[Collision]: 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)); } } @@ -1693,8 +1709,11 @@ namespace OpenSim.Region.Physics.OdePlugin //} } -// if (framecount % 55 == 0) -// m_log.DebugFormat("Processed {0} collisions", _perloopContact.Count); + if (CollectStats) + { + m_tempAvatarCollisionsThisFrame = _perloopContact.Count; + m_stats[ODEAvatarCollisionsStatName] += m_tempAvatarCollisionsThisFrame; + } List removeprims = null; foreach (OdePrim chr in _activeprims) @@ -1728,6 +1747,9 @@ namespace OpenSim.Region.Physics.OdePlugin } } + if (CollectStats) + m_stats[ODEPrimCollisionsStatName] += _perloopContact.Count - m_tempAvatarCollisionsThisFrame; + if (removeprims != null) { foreach (OdePrim chr in removeprims) @@ -4063,10 +4085,17 @@ namespace OpenSim.Region.Physics.OdePlugin { returnStats = new Dictionary(m_stats); - m_stats[ODENativeCollisionFrameMsStatName] = 0; + InitializeExtraStats(); } return returnStats; } + + private void InitializeExtraStats() + { + m_stats[ODENativeCollisionFrameMsStatName] = 0; + m_stats[ODEAvatarCollisionsStatName] = 0; + m_stats[ODEPrimCollisionsStatName] = 0; + } } } \ No newline at end of file -- cgit v1.1