diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index fa22c78..526dbad 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -131,8 +131,6 @@ public class BSCharacter : BSPhysObject | |||
131 | BulletSimAPI.SetObjectBuoyancy(Scene.WorldID, LocalID, _buoyancy); | 131 | BulletSimAPI.SetObjectBuoyancy(Scene.WorldID, LocalID, _buoyancy); |
132 | 132 | ||
133 | BSBody = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(Scene.World.Ptr, LocalID)); | 133 | BSBody = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(Scene.World.Ptr, LocalID)); |
134 | // avatars get all collisions no matter what (makes walking on ground and such work) | ||
135 | BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
136 | }); | 134 | }); |
137 | 135 | ||
138 | return; | 136 | return; |
@@ -480,11 +478,10 @@ public class BSCharacter : BSPhysObject | |||
480 | // Stop collision events | 478 | // Stop collision events |
481 | public override void UnSubscribeEvents() { | 479 | public override void UnSubscribeEvents() { |
482 | _subscribedEventsMs = 0; | 480 | _subscribedEventsMs = 0; |
483 | // Avatars get all their collision events | 481 | Scene.TaintedObject("BSCharacter.UnSubscribeEvents", delegate() |
484 | // Scene.TaintedObject("BSCharacter.UnSubscribeEvents", delegate() | 482 | { |
485 | // { | 483 | BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
486 | // BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 484 | }); |
487 | // }); | ||
488 | } | 485 | } |
489 | // Return 'true' if someone has subscribed to events | 486 | // Return 'true' if someone has subscribed to events |
490 | public override bool SubscribedEvents() { | 487 | public override bool SubscribedEvents() { |
@@ -532,20 +529,20 @@ public class BSCharacter : BSPhysObject | |||
532 | // The collision, if it should be reported to the character, is placed in a collection | 529 | // The collision, if it should be reported to the character, is placed in a collection |
533 | // that will later be sent to the simulator when SendCollisions() is called. | 530 | // that will later be sent to the simulator when SendCollisions() is called. |
534 | CollisionEventUpdate collisionCollection = null; | 531 | CollisionEventUpdate collisionCollection = null; |
535 | public override void Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) | 532 | public override bool Collide(uint collidingWith, BSPhysObject collidee, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) |
536 | { | 533 | { |
537 | // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); | 534 | bool ret = false; |
538 | 535 | ||
539 | // The following makes IsColliding() and IsCollidingGround() work | 536 | // The following makes IsColliding() and IsCollidingGround() work |
540 | _collidingStep = Scene.SimulationStep; | 537 | _collidingStep = Scene.SimulationStep; |
541 | if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID) | 538 | if (collidingWith <= Scene.TerrainManager.HighestTerrainID) |
542 | { | 539 | { |
543 | _collidingGroundStep = Scene.SimulationStep; | 540 | _collidingGroundStep = Scene.SimulationStep; |
544 | } | 541 | } |
545 | // DetailLog("{0},BSCharacter.Collison,call,with={1}", LocalID, collidingWith); | 542 | // DetailLog("{0},BSCharacter.Collison,call,with={1}", LocalID, collidingWith); |
546 | 543 | ||
547 | // throttle collisions to the rate specified in the subscription | 544 | // throttle collisions to the rate specified in the subscription |
548 | if (_subscribedEventsMs != 0) { | 545 | if (SubscribedEvents()) { |
549 | int nowTime = Scene.SimulationNowTime; | 546 | int nowTime = Scene.SimulationNowTime; |
550 | if (nowTime >= _nextCollisionOkTime) { | 547 | if (nowTime >= _nextCollisionOkTime) { |
551 | _nextCollisionOkTime = nowTime + _subscribedEventsMs; | 548 | _nextCollisionOkTime = nowTime + _subscribedEventsMs; |
@@ -553,8 +550,10 @@ public class BSCharacter : BSPhysObject | |||
553 | if (collisionCollection == null) | 550 | if (collisionCollection == null) |
554 | collisionCollection = new CollisionEventUpdate(); | 551 | collisionCollection = new CollisionEventUpdate(); |
555 | collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 552 | collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
553 | ret = true; | ||
556 | } | 554 | } |
557 | } | 555 | } |
556 | return ret; | ||
558 | } | 557 | } |
559 | 558 | ||
560 | public override void SendCollisions() | 559 | public override void SendCollisions() |