diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 5be2b1b..1c6d476 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -271,7 +271,7 @@ public sealed class BSPrim : BSPhysObject | |||
271 | _position = BulletSimAPI.GetPosition2(BSBody.ptr); | 271 | _position = BulletSimAPI.GetPosition2(BSBody.ptr); |
272 | 272 | ||
273 | // don't do the GetObjectPosition for root elements because this function is called a zillion times | 273 | // don't do the GetObjectPosition for root elements because this function is called a zillion times |
274 | // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, LocalID); | 274 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); |
275 | return _position; | 275 | return _position; |
276 | } | 276 | } |
277 | set { | 277 | set { |
@@ -432,7 +432,7 @@ public sealed class BSPrim : BSPhysObject | |||
432 | // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint? | 432 | // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint? |
433 | PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() | 433 | PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() |
434 | { | 434 | { |
435 | // _position = BulletSimAPI.GetObjectPosition(Scene.WorldID, LocalID); | 435 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); |
436 | DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 436 | DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
437 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 437 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); |
438 | }); | 438 | }); |
@@ -492,7 +492,8 @@ public sealed class BSPrim : BSPhysObject | |||
492 | { | 492 | { |
493 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape); | 493 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape); |
494 | 494 | ||
495 | // Mangling all the physical properties requires the object to be out of the physical world | 495 | // Mangling all the physical properties requires the object to be out of the physical world. |
496 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). | ||
496 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 497 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr); |
497 | 498 | ||
498 | #if !CSHARP_BODY_MANAGEMENT | 499 | #if !CSHARP_BODY_MANAGEMENT |
@@ -517,6 +518,14 @@ public sealed class BSPrim : BSPhysObject | |||
517 | // Rebuild its shape | 518 | // Rebuild its shape |
518 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); | 519 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); |
519 | 520 | ||
521 | // Collision filter can be set only when the object is in the world | ||
522 | if (BSBody.collisionFilter != 0 || BSBody.collisionMask != 0) | ||
523 | { | ||
524 | BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, (uint)BSBody.collisionFilter, (uint)BSBody.collisionMask); | ||
525 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,setCollisionFilterMask,filter={1},mask={2}", | ||
526 | LocalID, BSBody.collisionFilter.ToString("X"), BSBody.collisionMask.ToString("X")); | ||
527 | } | ||
528 | |||
520 | // Recompute any linkset parameters. | 529 | // Recompute any linkset parameters. |
521 | // When going from non-physical to physical, this re-enables the constraints that | 530 | // When going from non-physical to physical, this re-enables the constraints that |
522 | // had been automatically disabled when the mass was set to zero. | 531 | // had been automatically disabled when the mass was set to zero. |
@@ -548,8 +557,11 @@ public sealed class BSPrim : BSPhysObject | |||
548 | // There can be special things needed for implementing linksets | 557 | // There can be special things needed for implementing linksets |
549 | Linkset.MakeStatic(this); | 558 | Linkset.MakeStatic(this); |
550 | // The activation state is 'sleeping' so Bullet will not try to act on it | 559 | // The activation state is 'sleeping' so Bullet will not try to act on it |
551 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING); | 560 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING); |
552 | // BulletSimAPI.ForceActivationState2(BSBody.Ptr, ActivationState.DISABLE_SIMULATION); | 561 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_SIMULATION); |
562 | |||
563 | BSBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter; | ||
564 | BSBody.collisionMask = CollisionFilterGroups.StaticObjectMask; | ||
553 | } | 565 | } |
554 | else | 566 | else |
555 | { | 567 | { |
@@ -582,6 +594,9 @@ public sealed class BSPrim : BSPhysObject | |||
582 | 594 | ||
583 | // Force activation of the object so Bullet will act on it. | 595 | // Force activation of the object so Bullet will act on it. |
584 | BulletSimAPI.Activate2(BSBody.ptr, true); | 596 | BulletSimAPI.Activate2(BSBody.ptr, true); |
597 | |||
598 | BSBody.collisionFilter = CollisionFilterGroups.ObjectFilter; | ||
599 | BSBody.collisionMask = CollisionFilterGroups.ObjectMask; | ||
585 | } | 600 | } |
586 | } | 601 | } |
587 | 602 | ||
@@ -609,6 +624,8 @@ public sealed class BSPrim : BSPhysObject | |||
609 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); | 624 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); |
610 | } | 625 | } |
611 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 626 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
627 | BSBody.collisionFilter = CollisionFilterGroups.VolumeDetectFilter; | ||
628 | BSBody.collisionMask = CollisionFilterGroups.VolumeDetectMask; | ||
612 | } | 629 | } |
613 | #else | 630 | #else |
614 | // If doing the body management in C#, all this logic is in CSShapeCollection.CreateObject(). | 631 | // If doing the body management in C#, all this logic is in CSShapeCollection.CreateObject(). |
@@ -745,7 +762,6 @@ public sealed class BSPrim : BSPhysObject | |||
745 | // Buoyancy is faked by changing the gravity applied to the object | 762 | // Buoyancy is faked by changing the gravity applied to the object |
746 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | 763 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); |
747 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); | 764 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); |
748 | // BulletSimAPI.SetObjectBuoyancy(Scene.WorldID, LocalID, _buoyancy); | ||
749 | }); | 765 | }); |
750 | } | 766 | } |
751 | } | 767 | } |