aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2012-03-26 17:36:33 -0700
committerRobert Adams2012-03-26 17:36:33 -0700
commit872d513daaa68b94b78f71bd2a2d9a0f117ff727 (patch)
tree3f526fbad3394fa41a86e4aa6aa0a934c9119f3b /OpenSim/Region
parentBulletSim: update BulletSim binaries and configuration fixing a crash which h... (diff)
downloadopensim-SC-872d513daaa68b94b78f71bd2a2d9a0f117ff727.zip
opensim-SC-872d513daaa68b94b78f71bd2a2d9a0f117ff727.tar.gz
opensim-SC-872d513daaa68b94b78f71bd2a2d9a0f117ff727.tar.bz2
opensim-SC-872d513daaa68b94b78f71bd2a2d9a0f117ff727.tar.xz
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.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs24
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs18
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs15
3 files changed, 48 insertions, 9 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 20708d9..b08d5db 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -426,6 +426,8 @@ public class BSCharacter : PhysicsActor
426 } 426 }
427 } 427 }
428 428
429 // Called by the scene when a collision with this object is reported
430 CollisionEventUpdate collisionCollection = null;
429 public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) 431 public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth)
430 { 432 {
431 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); 433 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
@@ -443,10 +445,24 @@ public class BSCharacter : PhysicsActor
443 if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return; 445 if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return;
444 _lastCollisionTime = nowTime; 446 _lastCollisionTime = nowTime;
445 447
446 Dictionary<uint, ContactPoint> contactPoints = new Dictionary<uint, ContactPoint>(); 448 if (collisionCollection == null)
447 contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); 449 collisionCollection = new CollisionEventUpdate();
448 CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); 450 collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
449 base.SendCollisionUpdate(args); 451 }
452
453 public void SendCollisions()
454 {
455 // if (collisionCollection != null)
456 // {
457 // base.SendCollisionUpdate(collisionCollection);
458 // collisionCollection = null;
459 // }
460 // Kludge to make a collision call even if there are no collisions.
461 // This causes the avatar animation to get updated.
462 if (collisionCollection == null)
463 collisionCollection = new CollisionEventUpdate();
464 base.SendCollisionUpdate(collisionCollection);
465 collisionCollection = null;
450 } 466 }
451 467
452} 468}
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
1326 } 1326 }
1327 1327
1328 // I've collided with something 1328 // I've collided with something
1329 CollisionEventUpdate collisionCollection = null;
1329 public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 1330 public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
1330 { 1331 {
1331 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); 1332 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
@@ -1343,11 +1344,18 @@ public sealed class BSPrim : PhysicsActor
1343 if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return; 1344 if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return;
1344 _lastCollisionTime = nowTime; 1345 _lastCollisionTime = nowTime;
1345 1346
1346 // create the event for the collision 1347 if (collisionCollection == null)
1347 Dictionary<uint, ContactPoint> contactPoints = new Dictionary<uint, ContactPoint>(); 1348 collisionCollection = new CollisionEventUpdate();
1348 contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); 1349 collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
1349 CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); 1350 }
1350 base.SendCollisionUpdate(args); 1351
1352 public void SendCollisions()
1353 {
1354 if (collisionCollection != null)
1355 {
1356 base.SendCollisionUpdate(collisionCollection);
1357 collisionCollection = null;
1358 }
1351 } 1359 }
1352} 1360}
1353} 1361}
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
78 78
79 private Dictionary<uint, BSCharacter> m_avatars = new Dictionary<uint, BSCharacter>(); 79 private Dictionary<uint, BSCharacter> m_avatars = new Dictionary<uint, BSCharacter>();
80 private Dictionary<uint, BSPrim> m_prims = new Dictionary<uint, BSPrim>(); 80 private Dictionary<uint, BSPrim> m_prims = new Dictionary<uint, BSPrim>();
81 private HashSet<BSCharacter> m_avatarsWithCollisions = new HashSet<BSCharacter>();
82 private HashSet<BSPrim> m_primsWithCollisions = new HashSet<BSPrim>();
81 private List<BSPrim> m_vehicles = new List<BSPrim>(); 83 private List<BSPrim> m_vehicles = new List<BSPrim>();
82 private float[] m_heightMap; 84 private float[] m_heightMap;
83 private float m_waterLevel; 85 private float m_waterLevel;
@@ -435,6 +437,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters
435 } 437 }
436 } 438 }
437 439
440 // The SendCollision's batch up the collisions on the objects. Now push the collisions into the simulator.
441 foreach (BSPrim bsp in m_primsWithCollisions)
442 bsp.SendCollisions();
443 m_primsWithCollisions.Clear();
444 // foreach (BSCharacter bsc in m_avatarsWithCollisions)
445 // bsc.SendCollisions();
446 // This is a kludge to get avatar movement updated. ODE sends collisions even if there isn't any
447 foreach (KeyValuePair<uint, BSCharacter> kvp in m_avatars)
448 kvp.Value.SendCollisions();
449 m_avatarsWithCollisions.Clear();
450
438 // If any of the objects had updated properties, tell the object it has been changed by the physics engine 451 // If any of the objects had updated properties, tell the object it has been changed by the physics engine
439 if (updatedEntityCount > 0) 452 if (updatedEntityCount > 0)
440 { 453 {
@@ -485,11 +498,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters
485 BSPrim prim; 498 BSPrim prim;
486 if (m_prims.TryGetValue(localID, out prim)) { 499 if (m_prims.TryGetValue(localID, out prim)) {
487 prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration); 500 prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration);
501 m_primsWithCollisions.Add(prim);
488 return; 502 return;
489 } 503 }
490 BSCharacter actor; 504 BSCharacter actor;
491 if (m_avatars.TryGetValue(localID, out actor)) { 505 if (m_avatars.TryGetValue(localID, out actor)) {
492 actor.Collide(collidingWith, type, collidePoint, collideNormal, penitration); 506 actor.Collide(collidingWith, type, collidePoint, collideNormal, penitration);
507 m_avatarsWithCollisions.Add(actor);
493 return; 508 return;
494 } 509 }
495 return; 510 return;