aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
diff options
context:
space:
mode:
authorRobert Adams2015-11-30 20:51:12 -0800
committerRobert Adams2015-11-30 20:51:12 -0800
commite4d0ae4f6e89afaf5ce3f9b7783eb20a50dc758c (patch)
tree74eff09d032aeed18b5796df807ec4bc2120fcf0 /OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
parentReplaced ICSharpCode.SharpZipLib.dll for the same reason (diff)
downloadopensim-SC_OLD-e4d0ae4f6e89afaf5ce3f9b7783eb20a50dc758c.zip
opensim-SC_OLD-e4d0ae4f6e89afaf5ce3f9b7783eb20a50dc758c.tar.gz
opensim-SC_OLD-e4d0ae4f6e89afaf5ce3f9b7783eb20a50dc758c.tar.bz2
opensim-SC_OLD-e4d0ae4f6e89afaf5ce3f9b7783eb20a50dc758c.tar.xz
BulletSim: fix collision sound calculation. Modify some routines to make
collider and collidee clearer. Also fix (when did it break?) avatars not moving if standing on a moving object. Now friction will move avatars if standing on a disc or the top of a train.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs36
1 files changed, 22 insertions, 14 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
index 6adf219..0ad95c4 100755
--- a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
@@ -452,18 +452,20 @@ public abstract class BSPhysObject : PhysicsActor
452 private long CollisionsLastTickStep = -1; 452 private long CollisionsLastTickStep = -1;
453 453
454 // The simulation step is telling this object about a collision. 454 // The simulation step is telling this object about a collision.
455 // I'm the 'collider', the thing I'm colliding with is the 'collidee'.
455 // Return 'true' if a collision was processed and should be sent up. 456 // Return 'true' if a collision was processed and should be sent up.
456 // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. 457 // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision.
457 // Called at taint time from within the Step() function 458 // Called at taint time from within the Step() function
458 public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); 459 public virtual bool Collide(BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
459 public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
460 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
461 { 460 {
462 bool ret = false; 461 bool ret = false;
463 462
463 // if 'collidee' is null, that means it is terrain
464 uint collideeLocalID = (collidee == null) ? PhysScene.TerrainManager.HighestTerrainID : collidee.LocalID;
465
464 // The following lines make IsColliding(), CollidingGround() and CollidingObj work 466 // The following lines make IsColliding(), CollidingGround() and CollidingObj work
465 CollidingStep = PhysScene.SimulationStep; 467 CollidingStep = PhysScene.SimulationStep;
466 if (collidingWith <= PhysScene.TerrainManager.HighestTerrainID) 468 if (collideeLocalID <= PhysScene.TerrainManager.HighestTerrainID)
467 { 469 {
468 CollidingGroundStep = PhysScene.SimulationStep; 470 CollidingGroundStep = PhysScene.SimulationStep;
469 } 471 }
@@ -474,10 +476,13 @@ public abstract class BSPhysObject : PhysicsActor
474 476
475 CollisionAccumulation++; 477 CollisionAccumulation++;
476 478
477 // For movement tests, remember if we are colliding with an object that is moving. 479 // For movement tests, if the collider is me, remember if we are colliding with an object that is moving.
478 ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero) : false; 480 // Here the 'collider'/'collidee' thing gets messed up. In the larger context, when something is checking
481 // if the thing it is colliding with is moving, for instance, it asks if the its collider is moving.
482 ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero || collidee.RotationalVelocity != OMV.Vector3.Zero) : false;
479 ColliderIsVolumeDetect = collidee != null ? (collidee.IsVolumeDetect) : false; 483 ColliderIsVolumeDetect = collidee != null ? (collidee.IsVolumeDetect) : false;
480 484
485
481 // Make a collection of the collisions that happened the last simulation tick. 486 // Make a collection of the collisions that happened the last simulation tick.
482 // This is different than the collection created for sending up to the simulator as it is cleared every tick. 487 // This is different than the collection created for sending up to the simulator as it is cleared every tick.
483 if (CollisionsLastTickStep != PhysScene.SimulationStep) 488 if (CollisionsLastTickStep != PhysScene.SimulationStep)
@@ -485,23 +490,26 @@ public abstract class BSPhysObject : PhysicsActor
485 CollisionsLastTick = new CollisionEventUpdate(); 490 CollisionsLastTick = new CollisionEventUpdate();
486 CollisionsLastTickStep = PhysScene.SimulationStep; 491 CollisionsLastTickStep = PhysScene.SimulationStep;
487 } 492 }
488 493 CollisionsLastTick.AddCollider(collideeLocalID, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
489 CollisionsLastTick.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
490 494
491 // If someone has subscribed for collision events log the collision so it will be reported up 495 // If someone has subscribed for collision events log the collision so it will be reported up
492 if (SubscribedEvents()) { 496 if (SubscribedEvents()) {
493 ContactPoint newContact = new ContactPoint(contactPoint, contactNormal, pentrationDepth); 497 ContactPoint newContact = new ContactPoint(contactPoint, contactNormal, pentrationDepth);
494 498
495 // make collision sound work just setting a speed 499 // Collision sound requires a velocity to know it should happen. This is a lot of computation for a little used feature.
496 // see ubOde 500 OMV.Vector3 relvel = OMV.Vector3.Zero;
497 newContact.RelativeSpeed = 2.0f; 501 if (IsPhysical)
498 502 relvel = Velocity;
503 if (collidee != null && collidee.IsPhysical)
504 relvel -= collidee.Velocity;
505 newContact.RelativeSpeed = OMV.Vector3.Dot(relvel, contactNormal);
506
499 lock (PhysScene.CollisionLock) 507 lock (PhysScene.CollisionLock)
500 { 508 {
501 CollisionCollection.AddCollider(collidingWith, newContact); 509 CollisionCollection.AddCollider(collideeLocalID, newContact);
502 } 510 }
503 DetailLog("{0},{1}.Collision.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}", 511 DetailLog("{0},{1}.Collision.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}",
504 LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving); 512 LocalID, TypeName, collideeLocalID, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving);
505 513
506 ret = true; 514 ret = true;
507 } 515 }