diff options
author | Robert Adams | 2013-01-25 16:00:17 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-27 12:50:05 -0800 |
commit | ddef8f16e58471d19baa63f14134b25309cf2570 (patch) | |
tree | f7f520bf8613ff818701392958572f73f4b2b91e /OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |
parent | BulletSim: parameterize several vehicle debugging values: physical linear and... (diff) | |
download | opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.zip opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.tar.gz opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.tar.bz2 opensim-SC_OLD-ddef8f16e58471d19baa63f14134b25309cf2570.tar.xz |
BulletSim: first attempt at reporting top colliders
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 285d4a2..5e8143c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -95,6 +95,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
95 | SubscribedEventsMs = 0; | 95 | SubscribedEventsMs = 0; |
96 | CollidingStep = 0; | 96 | CollidingStep = 0; |
97 | CollidingGroundStep = 0; | 97 | CollidingGroundStep = 0; |
98 | CollisionAccumulation = 0; | ||
99 | CollisionScore = 0; | ||
98 | } | 100 | } |
99 | 101 | ||
100 | // Tell the object to clean up. | 102 | // Tell the object to clean up. |
@@ -239,6 +241,9 @@ public abstract class BSPhysObject : PhysicsActor | |||
239 | // The collision flags we think are set in Bullet | 241 | // The collision flags we think are set in Bullet |
240 | protected CollisionFlags CurrentCollisionFlags { get; set; } | 242 | protected CollisionFlags CurrentCollisionFlags { get; set; } |
241 | 243 | ||
244 | // Count of collisions for this object | ||
245 | protected long CollisionAccumulation { get; set; } | ||
246 | |||
242 | public override bool IsColliding { | 247 | public override bool IsColliding { |
243 | get { return (CollidingStep == PhysicsScene.SimulationStep); } | 248 | get { return (CollidingStep == PhysicsScene.SimulationStep); } |
244 | set { | 249 | set { |
@@ -300,6 +305,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
300 | return ret; | 305 | return ret; |
301 | } | 306 | } |
302 | 307 | ||
308 | CollisionAccumulation++; | ||
309 | |||
303 | // if someone has subscribed for collision events.... | 310 | // if someone has subscribed for collision events.... |
304 | if (SubscribedEvents()) { | 311 | if (SubscribedEvents()) { |
305 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 312 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
@@ -386,6 +393,16 @@ public abstract class BSPhysObject : PhysicsActor | |||
386 | public override bool SubscribedEvents() { | 393 | public override bool SubscribedEvents() { |
387 | return (SubscribedEventsMs > 0); | 394 | return (SubscribedEventsMs > 0); |
388 | } | 395 | } |
396 | // Because 'CollisionScore' is calls many times while sorting it should not be recomputed | ||
397 | // each time called. So this is built to be light weight for each collision and to do | ||
398 | // all the processing when the user asks for the info. | ||
399 | public void ComputeCollisionScore() | ||
400 | { | ||
401 | // Scale the collision count by the time since the last collision | ||
402 | long timeAgo = PhysicsScene.SimulationStep - CollidingStep + 1; | ||
403 | CollisionScore = CollisionAccumulation / timeAgo; | ||
404 | } | ||
405 | public override float CollisionScore { get; set; } | ||
389 | 406 | ||
390 | #endregion // Collisions | 407 | #endregion // Collisions |
391 | 408 | ||