diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 98eb4ca..309d004 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -96,7 +96,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
96 | SetMaterial((int)MaterialAttributes.Material.Wood); | 96 | SetMaterial((int)MaterialAttributes.Material.Wood); |
97 | 97 | ||
98 | CollisionCollection = new CollisionEventUpdate(); | 98 | CollisionCollection = new CollisionEventUpdate(); |
99 | CollisionsLastTick = CollisionCollection; | 99 | CollisionsLastReported = CollisionCollection; |
100 | SubscribedEventsMs = 0; | 100 | SubscribedEventsMs = 0; |
101 | CollidingStep = 0; | 101 | CollidingStep = 0; |
102 | CollidingGroundStep = 0; | 102 | CollidingGroundStep = 0; |
@@ -368,11 +368,14 @@ public abstract class BSPhysObject : PhysicsActor | |||
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | // The collisions that have been collected this tick | 371 | // The collisions that have been collected for the next collision reporting (throttled by subscription) |
372 | protected CollisionEventUpdate CollisionCollection; | 372 | protected CollisionEventUpdate CollisionCollection; |
373 | // Remember collisions from last tick for fancy collision based actions | 373 | // This is the collision collection last reported to the Simulator. |
374 | public CollisionEventUpdate CollisionsLastReported; | ||
375 | // Remember the collisions recorded in the last tick for fancy collision checking | ||
374 | // (like a BSCharacter walking up stairs). | 376 | // (like a BSCharacter walking up stairs). |
375 | public CollisionEventUpdate CollisionsLastTick; | 377 | public CollisionEventUpdate CollisionsLastTick; |
378 | private long CollisionsLastTickStep = -1; | ||
376 | 379 | ||
377 | // The simulation step is telling this object about a collision. | 380 | // The simulation step is telling this object about a collision. |
378 | // Return 'true' if a collision was processed and should be sent up. | 381 | // Return 'true' if a collision was processed and should be sent up. |
@@ -399,6 +402,15 @@ public abstract class BSPhysObject : PhysicsActor | |||
399 | // For movement tests, remember if we are colliding with an object that is moving. | 402 | // For movement tests, remember if we are colliding with an object that is moving. |
400 | ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero) : false; | 403 | ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero) : false; |
401 | 404 | ||
405 | // Make a collection of the collisions that happened the last simulation tick. | ||
406 | // This is different than the collection created for sending up to the simulator as it is cleared every tick. | ||
407 | if (CollisionsLastTickStep != PhysicsScene.SimulationStep) | ||
408 | { | ||
409 | CollisionsLastTick = new CollisionEventUpdate(); | ||
410 | CollisionsLastTickStep = PhysicsScene.SimulationStep; | ||
411 | } | ||
412 | CollisionsLastTick.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | ||
413 | |||
402 | // If someone has subscribed for collision events log the collision so it will be reported up | 414 | // If someone has subscribed for collision events log the collision so it will be reported up |
403 | if (SubscribedEvents()) { | 415 | if (SubscribedEvents()) { |
404 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 416 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
@@ -419,7 +431,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
419 | bool ret = true; | 431 | bool ret = true; |
420 | 432 | ||
421 | // If the 'no collision' call, force it to happen right now so quick collision_end | 433 | // If the 'no collision' call, force it to happen right now so quick collision_end |
422 | bool force = (CollisionCollection.Count == 0 && CollisionsLastTick.Count != 0); | 434 | bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0); |
423 | 435 | ||
424 | // throttle the collisions to the number of milliseconds specified in the subscription | 436 | // throttle the collisions to the number of milliseconds specified in the subscription |
425 | if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime)) | 437 | if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime)) |
@@ -438,7 +450,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
438 | base.SendCollisionUpdate(CollisionCollection); | 450 | base.SendCollisionUpdate(CollisionCollection); |
439 | 451 | ||
440 | // Remember the collisions from this tick for some collision specific processing. | 452 | // Remember the collisions from this tick for some collision specific processing. |
441 | CollisionsLastTick = CollisionCollection; | 453 | CollisionsLastReported = CollisionCollection; |
442 | 454 | ||
443 | // The CollisionCollection instance is passed around in the simulator. | 455 | // The CollisionCollection instance is passed around in the simulator. |
444 | // Make sure we don't have a handle to that one and that a new one is used for next time. | 456 | // Make sure we don't have a handle to that one and that a new one is used for next time. |