diff options
author | Robert Adams | 2015-11-30 20:51:12 -0800 |
---|---|---|
committer | Robert Adams | 2015-11-30 20:51:12 -0800 |
commit | e4d0ae4f6e89afaf5ce3f9b7783eb20a50dc758c (patch) | |
tree | 74eff09d032aeed18b5796df807ec4bc2120fcf0 /OpenSim/Region/PhysicsModules/BulletS | |
parent | Replaced ICSharpCode.SharpZipLib.dll for the same reason (diff) | |
download | opensim-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 'OpenSim/Region/PhysicsModules/BulletS')
4 files changed, 27 insertions, 20 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSLinkset.cs b/OpenSim/Region/PhysicsModules/BulletS/BSLinkset.cs index 8312239..e73f0e8 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSLinkset.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSLinkset.cs | |||
@@ -257,7 +257,7 @@ public abstract class BSLinkset | |||
257 | // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have | 257 | // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have |
258 | // anything to add for the collision and it should be passed through normal processing. | 258 | // anything to add for the collision and it should be passed through normal processing. |
259 | // Default processing for a linkset. | 259 | // Default processing for a linkset. |
260 | public virtual bool HandleCollide(uint collidingWith, BSPhysObject collidee, | 260 | public virtual bool HandleCollide(BSPhysObject collider, BSPhysObject collidee, |
261 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) | 261 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) |
262 | { | 262 | { |
263 | bool ret = false; | 263 | bool ret = false; |
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 | } |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPrimLinkable.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrimLinkable.cs index 55b5da0..563dcfa 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPrimLinkable.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrimLinkable.cs | |||
@@ -203,15 +203,14 @@ public class BSPrimLinkable : BSPrimDisplaced | |||
203 | // Called after a simulation step to post a collision with this object. | 203 | // Called after a simulation step to post a collision with this object. |
204 | // This returns 'true' if the collision has been queued and the SendCollisions call must | 204 | // This returns 'true' if the collision has been queued and the SendCollisions call must |
205 | // be made at the end of the simulation step. | 205 | // be made at the end of the simulation step. |
206 | public override bool Collide(uint collidingWith, BSPhysObject collidee, | 206 | public override bool Collide(BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) |
207 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) | ||
208 | { | 207 | { |
209 | bool ret = false; | 208 | bool ret = false; |
210 | // Ask the linkset if it wants to handle the collision | 209 | // Ask the linkset if it wants to handle the collision |
211 | if (!Linkset.HandleCollide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth)) | 210 | if (!Linkset.HandleCollide(this, collidee, contactPoint, contactNormal, pentrationDepth)) |
212 | { | 211 | { |
213 | // The linkset didn't handle it so pass the collision through normal processing | 212 | // The linkset didn't handle it so pass the collision through normal processing |
214 | ret = base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); | 213 | ret = base.Collide(collidee, contactPoint, contactNormal, pentrationDepth); |
215 | } | 214 | } |
216 | return ret; | 215 | return ret; |
217 | } | 216 | } |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs index b2d5e47..f02104c 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs | |||
@@ -880,7 +880,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
880 | 880 | ||
881 | if (collider.IsInitialized) | 881 | if (collider.IsInitialized) |
882 | { | 882 | { |
883 | if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration)) | 883 | if (collider.Collide(collidee, collidePoint, collideNormal, penetration)) |
884 | { | 884 | { |
885 | // If a collision was 'good', remember to send it to the simulator | 885 | // If a collision was 'good', remember to send it to the simulator |
886 | lock (CollisionLock) | 886 | lock (CollisionLock) |