diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 139 |
1 files changed, 65 insertions, 74 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 5f3f0d1..826261c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -111,10 +111,7 @@ public sealed class BSPrim : BSPhysObject | |||
111 | 111 | ||
112 | _mass = CalculateMass(); | 112 | _mass = CalculateMass(); |
113 | 113 | ||
114 | // No body or shape yet | 114 | // Cause linkset variables to be initialized (like mass) |
115 | PhysBody = new BulletBody(LocalID); | ||
116 | PhysShape = new BulletShape(); | ||
117 | |||
118 | Linkset.Refresh(this); | 115 | Linkset.Refresh(this); |
119 | 116 | ||
120 | DetailLog("{0},BSPrim.constructor,call", LocalID); | 117 | DetailLog("{0},BSPrim.constructor,call", LocalID); |
@@ -123,7 +120,7 @@ public sealed class BSPrim : BSPhysObject | |||
123 | { | 120 | { |
124 | CreateGeomAndObject(true); | 121 | CreateGeomAndObject(true); |
125 | 122 | ||
126 | CurrentCollisionFlags = BulletSimAPI.GetCollisionFlags2(PhysBody.ptr); | 123 | CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody); |
127 | }); | 124 | }); |
128 | } | 125 | } |
129 | 126 | ||
@@ -256,7 +253,7 @@ public sealed class BSPrim : BSPhysObject | |||
256 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() | 253 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() |
257 | { | 254 | { |
258 | if (PhysBody.HasPhysicalBody) | 255 | if (PhysBody.HasPhysicalBody) |
259 | BulletSimAPI.ClearAllForces2(PhysBody.ptr); | 256 | PhysicsScene.PE.ClearAllForces(PhysBody); |
260 | }); | 257 | }); |
261 | } | 258 | } |
262 | public override void ZeroAngularMotion(bool inTaintTime) | 259 | public override void ZeroAngularMotion(bool inTaintTime) |
@@ -268,8 +265,8 @@ public sealed class BSPrim : BSPhysObject | |||
268 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); | 265 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); |
269 | if (PhysBody.HasPhysicalBody) | 266 | if (PhysBody.HasPhysicalBody) |
270 | { | 267 | { |
271 | BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 268 | PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); |
272 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 269 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); |
273 | } | 270 | } |
274 | }); | 271 | }); |
275 | } | 272 | } |
@@ -295,7 +292,7 @@ public sealed class BSPrim : BSPhysObject | |||
295 | */ | 292 | */ |
296 | 293 | ||
297 | // don't do the GetObjectPosition for root elements because this function is called a zillion times. | 294 | // don't do the GetObjectPosition for root elements because this function is called a zillion times. |
298 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 295 | // _position = PhysicsScene.PE.GetObjectPosition2(PhysicsScene.World, BSBody); |
299 | return _position; | 296 | return _position; |
300 | } | 297 | } |
301 | set { | 298 | set { |
@@ -303,7 +300,7 @@ public sealed class BSPrim : BSPhysObject | |||
303 | // All positions are given in world positions. | 300 | // All positions are given in world positions. |
304 | if (_position == value) | 301 | if (_position == value) |
305 | { | 302 | { |
306 | DetailLog("{0},BSPrim.setPosition,taint,positionNotChanging,pos={1},orient={2}", LocalID, _position, _orientation); | 303 | DetailLog("{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, _position, _orientation); |
307 | return; | 304 | return; |
308 | } | 305 | } |
309 | _position = value; | 306 | _position = value; |
@@ -321,14 +318,14 @@ public sealed class BSPrim : BSPhysObject | |||
321 | } | 318 | } |
322 | public override OMV.Vector3 ForcePosition { | 319 | public override OMV.Vector3 ForcePosition { |
323 | get { | 320 | get { |
324 | _position = BulletSimAPI.GetPosition2(PhysBody.ptr); | 321 | _position = PhysicsScene.PE.GetPosition(PhysBody); |
325 | return _position; | 322 | return _position; |
326 | } | 323 | } |
327 | set { | 324 | set { |
328 | _position = value; | 325 | _position = value; |
329 | if (PhysBody.HasPhysicalBody) | 326 | if (PhysBody.HasPhysicalBody) |
330 | { | 327 | { |
331 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 328 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
332 | ActivateIfPhysical(false); | 329 | ActivateIfPhysical(false); |
333 | } | 330 | } |
334 | } | 331 | } |
@@ -408,10 +405,10 @@ public sealed class BSPrim : BSPhysObject | |||
408 | { | 405 | { |
409 | if (IsStatic) | 406 | if (IsStatic) |
410 | { | 407 | { |
411 | BulletSimAPI.SetGravity2(PhysBody.ptr, PhysicsScene.DefaultGravity); | 408 | PhysicsScene.PE.SetGravity(PhysBody, PhysicsScene.DefaultGravity); |
412 | Inertia = OMV.Vector3.Zero; | 409 | Inertia = OMV.Vector3.Zero; |
413 | BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia); | 410 | PhysicsScene.PE.SetMassProps(PhysBody, 0f, Inertia); |
414 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | 411 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); |
415 | } | 412 | } |
416 | else | 413 | else |
417 | { | 414 | { |
@@ -422,18 +419,18 @@ public sealed class BSPrim : BSPhysObject | |||
422 | // Changing interesting properties doesn't change proxy and collision cache | 419 | // Changing interesting properties doesn't change proxy and collision cache |
423 | // information. The Bullet solution is to re-add the object to the world | 420 | // information. The Bullet solution is to re-add the object to the world |
424 | // after parameters are changed. | 421 | // after parameters are changed. |
425 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 422 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); |
426 | } | 423 | } |
427 | 424 | ||
428 | // The computation of mass props requires gravity to be set on the object. | 425 | // The computation of mass props requires gravity to be set on the object. |
429 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); | 426 | PhysicsScene.PE.SetGravity(PhysBody, grav); |
430 | 427 | ||
431 | Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); | 428 | Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass); |
432 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); | 429 | PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia); |
433 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | 430 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); |
434 | 431 | ||
435 | // center of mass is at the zero of the object | 432 | // center of mass is at the zero of the object |
436 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); | 433 | // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(PhysBody, ForcePosition, ForceOrientation); |
437 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld); | 434 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld); |
438 | 435 | ||
439 | if (inWorld) | 436 | if (inWorld) |
@@ -443,7 +440,7 @@ public sealed class BSPrim : BSPhysObject | |||
443 | 440 | ||
444 | // Must set gravity after it has been added to the world because, for unknown reasons, | 441 | // Must set gravity after it has been added to the world because, for unknown reasons, |
445 | // adding the object resets the object's gravity to world gravity | 442 | // adding the object resets the object's gravity to world gravity |
446 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); | 443 | PhysicsScene.PE.SetGravity(PhysBody, grav); |
447 | 444 | ||
448 | } | 445 | } |
449 | } | 446 | } |
@@ -486,7 +483,7 @@ public sealed class BSPrim : BSPhysObject | |||
486 | DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); | 483 | DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); |
487 | if (PhysBody.HasPhysicalBody) | 484 | if (PhysBody.HasPhysicalBody) |
488 | { | 485 | { |
489 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, _force); | 486 | PhysicsScene.PE.ApplyCentralForce(PhysBody, _force); |
490 | ActivateIfPhysical(false); | 487 | ActivateIfPhysical(false); |
491 | } | 488 | } |
492 | } | 489 | } |
@@ -586,7 +583,7 @@ public sealed class BSPrim : BSPhysObject | |||
586 | _velocity = value; | 583 | _velocity = value; |
587 | if (PhysBody.HasPhysicalBody) | 584 | if (PhysBody.HasPhysicalBody) |
588 | { | 585 | { |
589 | BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); | 586 | PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity); |
590 | ActivateIfPhysical(false); | 587 | ActivateIfPhysical(false); |
591 | } | 588 | } |
592 | } | 589 | } |
@@ -652,9 +649,9 @@ public sealed class BSPrim : BSPhysObject | |||
652 | { | 649 | { |
653 | if (PhysBody.HasPhysicalBody) | 650 | if (PhysBody.HasPhysicalBody) |
654 | { | 651 | { |
655 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 652 | // _position = PhysicsScene.PE.GetObjectPosition(PhysicsScene.World, BSBody); |
656 | // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 653 | // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
657 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 654 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
658 | } | 655 | } |
659 | }); | 656 | }); |
660 | } | 657 | } |
@@ -664,13 +661,13 @@ public sealed class BSPrim : BSPhysObject | |||
664 | { | 661 | { |
665 | get | 662 | get |
666 | { | 663 | { |
667 | _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); | 664 | _orientation = PhysicsScene.PE.GetOrientation(PhysBody); |
668 | return _orientation; | 665 | return _orientation; |
669 | } | 666 | } |
670 | set | 667 | set |
671 | { | 668 | { |
672 | _orientation = value; | 669 | _orientation = value; |
673 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 670 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
674 | } | 671 | } |
675 | } | 672 | } |
676 | public override int PhysicsActorType { | 673 | public override int PhysicsActorType { |
@@ -726,7 +723,7 @@ public sealed class BSPrim : BSPhysObject | |||
726 | 723 | ||
727 | // Mangling all the physical properties requires the object not be in the physical world. | 724 | // Mangling all the physical properties requires the object not be in the physical world. |
728 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). | 725 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). |
729 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 726 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); |
730 | 727 | ||
731 | // Set up the object physicalness (does gravity and collisions move this object) | 728 | // Set up the object physicalness (does gravity and collisions move this object) |
732 | MakeDynamic(IsStatic); | 729 | MakeDynamic(IsStatic); |
@@ -743,7 +740,7 @@ public sealed class BSPrim : BSPhysObject | |||
743 | AddObjectToPhysicalWorld(); | 740 | AddObjectToPhysicalWorld(); |
744 | 741 | ||
745 | // Rebuild its shape | 742 | // Rebuild its shape |
746 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); | 743 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); |
747 | 744 | ||
748 | // Recompute any linkset parameters. | 745 | // Recompute any linkset parameters. |
749 | // When going from non-physical to physical, this re-enables the constraints that | 746 | // When going from non-physical to physical, this re-enables the constraints that |
@@ -765,28 +762,28 @@ public sealed class BSPrim : BSPhysObject | |||
765 | if (makeStatic) | 762 | if (makeStatic) |
766 | { | 763 | { |
767 | // Become a Bullet 'static' object type | 764 | // Become a Bullet 'static' object type |
768 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 765 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
769 | // Stop all movement | 766 | // Stop all movement |
770 | ZeroMotion(true); | 767 | ZeroMotion(true); |
771 | 768 | ||
772 | // Set various physical properties so other object interact properly | 769 | // Set various physical properties so other object interact properly |
773 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); | 770 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); |
774 | BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); | 771 | PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction); |
775 | BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); | 772 | PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution); |
776 | 773 | ||
777 | // Mass is zero which disables a bunch of physics stuff in Bullet | 774 | // Mass is zero which disables a bunch of physics stuff in Bullet |
778 | UpdatePhysicalMassProperties(0f, false); | 775 | UpdatePhysicalMassProperties(0f, false); |
779 | // Set collision detection parameters | 776 | // Set collision detection parameters |
780 | if (BSParam.CcdMotionThreshold > 0f) | 777 | if (BSParam.CcdMotionThreshold > 0f) |
781 | { | 778 | { |
782 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); | 779 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
783 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); | 780 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
784 | } | 781 | } |
785 | 782 | ||
786 | // The activation state is 'disabled' so Bullet will not try to act on it. | 783 | // The activation state is 'disabled' so Bullet will not try to act on it. |
787 | // BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_SIMULATION); | 784 | // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION); |
788 | // Start it out sleeping and physical actions could wake it up. | 785 | // Start it out sleeping and physical actions could wake it up. |
789 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING); | 786 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING); |
790 | 787 | ||
791 | // This collides like a static object | 788 | // This collides like a static object |
792 | PhysBody.collisionType = CollisionType.Static; | 789 | PhysBody.collisionType = CollisionType.Static; |
@@ -797,22 +794,22 @@ public sealed class BSPrim : BSPhysObject | |||
797 | else | 794 | else |
798 | { | 795 | { |
799 | // Not a Bullet static object | 796 | // Not a Bullet static object |
800 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 797 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
801 | 798 | ||
802 | // Set various physical properties so other object interact properly | 799 | // Set various physical properties so other object interact properly |
803 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true); | 800 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true); |
804 | BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); | 801 | PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction); |
805 | BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); | 802 | PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution); |
806 | 803 | ||
807 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 | 804 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 |
808 | // Since this can be called multiple times, only zero forces when becoming physical | 805 | // Since this can be called multiple times, only zero forces when becoming physical |
809 | // BulletSimAPI.ClearAllForces2(BSBody.ptr); | 806 | // PhysicsScene.PE.ClearAllForces(BSBody); |
810 | 807 | ||
811 | // For good measure, make sure the transform is set through to the motion state | 808 | // For good measure, make sure the transform is set through to the motion state |
812 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 809 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
813 | 810 | ||
814 | // Center of mass is at the center of the object | 811 | // Center of mass is at the center of the object |
815 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody.ptr, _position, _orientation); | 812 | // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(Linkset.LinksetRoot.PhysBody, _position, _orientation); |
816 | 813 | ||
817 | // A dynamic object has mass | 814 | // A dynamic object has mass |
818 | UpdatePhysicalMassProperties(RawMass, false); | 815 | UpdatePhysicalMassProperties(RawMass, false); |
@@ -820,22 +817,22 @@ public sealed class BSPrim : BSPhysObject | |||
820 | // Set collision detection parameters | 817 | // Set collision detection parameters |
821 | if (BSParam.CcdMotionThreshold > 0f) | 818 | if (BSParam.CcdMotionThreshold > 0f) |
822 | { | 819 | { |
823 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); | 820 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
824 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); | 821 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
825 | } | 822 | } |
826 | 823 | ||
827 | // Various values for simulation limits | 824 | // Various values for simulation limits |
828 | BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping); | 825 | PhysicsScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping); |
829 | BulletSimAPI.SetDeactivationTime2(PhysBody.ptr, BSParam.DeactivationTime); | 826 | PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime); |
830 | BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); | 827 | PhysicsScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); |
831 | BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, BSParam.ContactProcessingThreshold); | 828 | PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); |
832 | 829 | ||
833 | // This collides like an object. | 830 | // This collides like an object. |
834 | PhysBody.collisionType = CollisionType.Dynamic; | 831 | PhysBody.collisionType = CollisionType.Dynamic; |
835 | 832 | ||
836 | // Force activation of the object so Bullet will act on it. | 833 | // Force activation of the object so Bullet will act on it. |
837 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. | 834 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. |
838 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ACTIVE_TAG); | 835 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); |
839 | 836 | ||
840 | // There might be special things needed for implementing linksets. | 837 | // There might be special things needed for implementing linksets. |
841 | Linkset.MakeDynamic(this); | 838 | Linkset.MakeDynamic(this); |
@@ -848,7 +845,7 @@ public sealed class BSPrim : BSPhysObject | |||
848 | // the functions after this one set up the state of a possibly newly created collision body. | 845 | // the functions after this one set up the state of a possibly newly created collision body. |
849 | private void MakeSolid(bool makeSolid) | 846 | private void MakeSolid(bool makeSolid) |
850 | { | 847 | { |
851 | CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(PhysBody.ptr); | 848 | CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(PhysBody); |
852 | if (makeSolid) | 849 | if (makeSolid) |
853 | { | 850 | { |
854 | // Verify the previous code created the correct shape for this type of thing. | 851 | // Verify the previous code created the correct shape for this type of thing. |
@@ -856,7 +853,7 @@ public sealed class BSPrim : BSPhysObject | |||
856 | { | 853 | { |
857 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); | 854 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); |
858 | } | 855 | } |
859 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 856 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
860 | } | 857 | } |
861 | else | 858 | else |
862 | { | 859 | { |
@@ -864,7 +861,7 @@ public sealed class BSPrim : BSPhysObject | |||
864 | { | 861 | { |
865 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); | 862 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); |
866 | } | 863 | } |
867 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 864 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
868 | 865 | ||
869 | // Change collision info from a static object to a ghosty collision object | 866 | // Change collision info from a static object to a ghosty collision object |
870 | PhysBody.collisionType = CollisionType.VolumeDetect; | 867 | PhysBody.collisionType = CollisionType.VolumeDetect; |
@@ -877,7 +874,7 @@ public sealed class BSPrim : BSPhysObject | |||
877 | private void ActivateIfPhysical(bool forceIt) | 874 | private void ActivateIfPhysical(bool forceIt) |
878 | { | 875 | { |
879 | if (IsPhysical && PhysBody.HasPhysicalBody) | 876 | if (IsPhysical && PhysBody.HasPhysicalBody) |
880 | BulletSimAPI.Activate2(PhysBody.ptr, forceIt); | 877 | PhysicsScene.PE.Activate(PhysBody, forceIt); |
881 | } | 878 | } |
882 | 879 | ||
883 | // Turn on or off the flag controlling whether collision events are returned to the simulator. | 880 | // Turn on or off the flag controlling whether collision events are returned to the simulator. |
@@ -885,11 +882,11 @@ public sealed class BSPrim : BSPhysObject | |||
885 | { | 882 | { |
886 | if (wantsCollisionEvents) | 883 | if (wantsCollisionEvents) |
887 | { | 884 | { |
888 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 885 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
889 | } | 886 | } |
890 | else | 887 | else |
891 | { | 888 | { |
892 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 889 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
893 | } | 890 | } |
894 | } | 891 | } |
895 | 892 | ||
@@ -900,18 +897,12 @@ public sealed class BSPrim : BSPhysObject | |||
900 | { | 897 | { |
901 | if (PhysBody.HasPhysicalBody) | 898 | if (PhysBody.HasPhysicalBody) |
902 | { | 899 | { |
903 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 900 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); |
904 | 901 | } | |
905 | // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. | 902 | else |
906 | // Replace this when the new AddObjectToWorld function is complete. | 903 | { |
907 | BulletSimAPI.SetGravity2(PhysBody.ptr, ComputeGravity()); | 904 | m_log.ErrorFormat("{0} Attempt to add physical object without body. id={1}", LogHeader, LocalID); |
908 | 905 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,addObjectWithoutBody,cType={1}", LocalID, PhysBody.collisionType); | |
909 | // Collision filter can be set only when the object is in the world | ||
910 | if (!PhysBody.ApplyCollisionMask()) | ||
911 | { | ||
912 | m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID); | ||
913 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType); | ||
914 | } | ||
915 | } | 906 | } |
916 | } | 907 | } |
917 | 908 | ||
@@ -944,9 +935,9 @@ public sealed class BSPrim : BSPhysObject | |||
944 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() | 935 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() |
945 | { | 936 | { |
946 | if (_floatOnWater) | 937 | if (_floatOnWater) |
947 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 938 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
948 | else | 939 | else |
949 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 940 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
950 | }); | 941 | }); |
951 | } | 942 | } |
952 | } | 943 | } |
@@ -972,7 +963,7 @@ public sealed class BSPrim : BSPhysObject | |||
972 | _rotationalVelocity = value; | 963 | _rotationalVelocity = value; |
973 | if (PhysBody.HasPhysicalBody) | 964 | if (PhysBody.HasPhysicalBody) |
974 | { | 965 | { |
975 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 966 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); |
976 | ActivateIfPhysical(false); | 967 | ActivateIfPhysical(false); |
977 | } | 968 | } |
978 | } | 969 | } |
@@ -1064,7 +1055,7 @@ public sealed class BSPrim : BSPhysObject | |||
1064 | DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); | 1055 | DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); |
1065 | if (PhysBody.HasPhysicalBody) | 1056 | if (PhysBody.HasPhysicalBody) |
1066 | { | 1057 | { |
1067 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce); | 1058 | PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce); |
1068 | ActivateIfPhysical(false); | 1059 | ActivateIfPhysical(false); |
1069 | } | 1060 | } |
1070 | }); | 1061 | }); |
@@ -1088,7 +1079,7 @@ public sealed class BSPrim : BSPhysObject | |||
1088 | { | 1079 | { |
1089 | if (PhysBody.HasPhysicalBody) | 1080 | if (PhysBody.HasPhysicalBody) |
1090 | { | 1081 | { |
1091 | BulletSimAPI.ApplyTorque2(PhysBody.ptr, angForce); | 1082 | PhysicsScene.PE.ApplyTorque(PhysBody, angForce); |
1092 | ActivateIfPhysical(false); | 1083 | ActivateIfPhysical(false); |
1093 | } | 1084 | } |
1094 | }); | 1085 | }); |
@@ -1111,7 +1102,7 @@ public sealed class BSPrim : BSPhysObject | |||
1111 | { | 1102 | { |
1112 | if (PhysBody.HasPhysicalBody) | 1103 | if (PhysBody.HasPhysicalBody) |
1113 | { | 1104 | { |
1114 | BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse); | 1105 | PhysicsScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse); |
1115 | ActivateIfPhysical(false); | 1106 | ActivateIfPhysical(false); |
1116 | } | 1107 | } |
1117 | }); | 1108 | }); |