From 872d513daaa68b94b78f71bd2a2d9a0f117ff727 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 26 Mar 2012 17:36:33 -0700 Subject: BulletSim: make avatar animations update properly. It seems that ODE calls the avatar collision handling routine even if there are no collisions. This causes the animation to be updated. So, for instance, going from HOVER to FLY is caused by the physics engine calling the collision routine each frame with 0 collisions. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index f122df9..248d1f2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -1326,6 +1326,7 @@ public sealed class BSPrim : PhysicsActor } // I've collided with something + CollisionEventUpdate collisionCollection = null; public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); @@ -1343,11 +1344,18 @@ public sealed class BSPrim : PhysicsActor if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return; _lastCollisionTime = nowTime; - // create the event for the collision - Dictionary contactPoints = new Dictionary(); - contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); - base.SendCollisionUpdate(args); + if (collisionCollection == null) + collisionCollection = new CollisionEventUpdate(); + collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); + } + + public void SendCollisions() + { + if (collisionCollection != null) + { + base.SendCollisionUpdate(collisionCollection); + collisionCollection = null; + } } } } -- cgit v1.1