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/BSScene.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 581d540..94a0ccf 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -78,6 +78,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters private Dictionary m_avatars = new Dictionary(); private Dictionary m_prims = new Dictionary(); + private HashSet m_avatarsWithCollisions = new HashSet(); + private HashSet m_primsWithCollisions = new HashSet(); private List m_vehicles = new List(); private float[] m_heightMap; private float m_waterLevel; @@ -435,6 +437,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters } } + // The SendCollision's batch up the collisions on the objects. Now push the collisions into the simulator. + foreach (BSPrim bsp in m_primsWithCollisions) + bsp.SendCollisions(); + m_primsWithCollisions.Clear(); + // foreach (BSCharacter bsc in m_avatarsWithCollisions) + // bsc.SendCollisions(); + // This is a kludge to get avatar movement updated. ODE sends collisions even if there isn't any + foreach (KeyValuePair kvp in m_avatars) + kvp.Value.SendCollisions(); + m_avatarsWithCollisions.Clear(); + // If any of the objects had updated properties, tell the object it has been changed by the physics engine if (updatedEntityCount > 0) { @@ -485,11 +498,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters BSPrim prim; if (m_prims.TryGetValue(localID, out prim)) { prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration); + m_primsWithCollisions.Add(prim); return; } BSCharacter actor; if (m_avatars.TryGetValue(localID, out actor)) { actor.Collide(collidingWith, type, collidePoint, collideNormal, penitration); + m_avatarsWithCollisions.Add(actor); return; } return; -- cgit v1.1