diff options
author | Robert Adams | 2012-12-30 10:21:47 -0800 |
---|---|---|
committer | Robert Adams | 2012-12-31 19:57:22 -0800 |
commit | 9218748321519ed04da5cdffa1f29e69030171b5 (patch) | |
tree | 7516cfbea32d716651430bc3124dbdd4cb772105 /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |
parent | BulletSim: add the implementation files for the two versions of Bullet: (diff) | |
download | opensim-SC_OLD-9218748321519ed04da5cdffa1f29e69030171b5.zip opensim-SC_OLD-9218748321519ed04da5cdffa1f29e69030171b5.tar.gz opensim-SC_OLD-9218748321519ed04da5cdffa1f29e69030171b5.tar.bz2 opensim-SC_OLD-9218748321519ed04da5cdffa1f29e69030171b5.tar.xz |
BulletSim: another round of conversion: dynamics world and collision object functions.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index cf09be2..613606f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -120,7 +120,7 @@ public sealed class BSPrim : BSPhysObject | |||
120 | { | 120 | { |
121 | CreateGeomAndObject(true); | 121 | CreateGeomAndObject(true); |
122 | 122 | ||
123 | CurrentCollisionFlags = BulletSimAPI.GetCollisionFlags2(PhysBody.ptr); | 123 | CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody); |
124 | }); | 124 | }); |
125 | } | 125 | } |
126 | 126 | ||
@@ -265,7 +265,7 @@ public sealed class BSPrim : BSPhysObject | |||
265 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); | 265 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); |
266 | if (PhysBody.HasPhysicalBody) | 266 | if (PhysBody.HasPhysicalBody) |
267 | { | 267 | { |
268 | BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 268 | PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); |
269 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 269 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); |
270 | } | 270 | } |
271 | }); | 271 | }); |
@@ -318,14 +318,14 @@ public sealed class BSPrim : BSPhysObject | |||
318 | } | 318 | } |
319 | public override OMV.Vector3 ForcePosition { | 319 | public override OMV.Vector3 ForcePosition { |
320 | get { | 320 | get { |
321 | _position = BulletSimAPI.GetPosition2(PhysBody.ptr); | 321 | _position = PhysicsScene.PE.GetPosition(PhysBody); |
322 | return _position; | 322 | return _position; |
323 | } | 323 | } |
324 | set { | 324 | set { |
325 | _position = value; | 325 | _position = value; |
326 | if (PhysBody.HasPhysicalBody) | 326 | if (PhysBody.HasPhysicalBody) |
327 | { | 327 | { |
328 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 328 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
329 | ActivateIfPhysical(false); | 329 | ActivateIfPhysical(false); |
330 | } | 330 | } |
331 | } | 331 | } |
@@ -419,7 +419,7 @@ public sealed class BSPrim : BSPhysObject | |||
419 | // Changing interesting properties doesn't change proxy and collision cache | 419 | // Changing interesting properties doesn't change proxy and collision cache |
420 | // 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 |
421 | // after parameters are changed. | 421 | // after parameters are changed. |
422 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 422 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); |
423 | } | 423 | } |
424 | 424 | ||
425 | // 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. |
@@ -649,9 +649,9 @@ public sealed class BSPrim : BSPhysObject | |||
649 | { | 649 | { |
650 | if (PhysBody.HasPhysicalBody) | 650 | if (PhysBody.HasPhysicalBody) |
651 | { | 651 | { |
652 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 652 | // _position = PhysicsScene.PE.GetObjectPosition(PhysicsScene.World, BSBody); |
653 | // 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); |
654 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 654 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
655 | } | 655 | } |
656 | }); | 656 | }); |
657 | } | 657 | } |
@@ -661,13 +661,13 @@ public sealed class BSPrim : BSPhysObject | |||
661 | { | 661 | { |
662 | get | 662 | get |
663 | { | 663 | { |
664 | _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); | 664 | _orientation = PhysicsScene.PE.GetOrientation(PhysBody); |
665 | return _orientation; | 665 | return _orientation; |
666 | } | 666 | } |
667 | set | 667 | set |
668 | { | 668 | { |
669 | _orientation = value; | 669 | _orientation = value; |
670 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 670 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
671 | } | 671 | } |
672 | } | 672 | } |
673 | public override int PhysicsActorType { | 673 | public override int PhysicsActorType { |
@@ -723,7 +723,7 @@ public sealed class BSPrim : BSPhysObject | |||
723 | 723 | ||
724 | // 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. |
725 | // 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). |
726 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 726 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); |
727 | 727 | ||
728 | // 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) |
729 | MakeDynamic(IsStatic); | 729 | MakeDynamic(IsStatic); |
@@ -740,7 +740,7 @@ public sealed class BSPrim : BSPhysObject | |||
740 | AddObjectToPhysicalWorld(); | 740 | AddObjectToPhysicalWorld(); |
741 | 741 | ||
742 | // Rebuild its shape | 742 | // Rebuild its shape |
743 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); | 743 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); |
744 | 744 | ||
745 | // Recompute any linkset parameters. | 745 | // Recompute any linkset parameters. |
746 | // 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 |
@@ -762,28 +762,28 @@ public sealed class BSPrim : BSPhysObject | |||
762 | if (makeStatic) | 762 | if (makeStatic) |
763 | { | 763 | { |
764 | // Become a Bullet 'static' object type | 764 | // Become a Bullet 'static' object type |
765 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 765 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
766 | // Stop all movement | 766 | // Stop all movement |
767 | ZeroMotion(true); | 767 | ZeroMotion(true); |
768 | 768 | ||
769 | // Set various physical properties so other object interact properly | 769 | // Set various physical properties so other object interact properly |
770 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); | 770 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); |
771 | BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); | 771 | PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction); |
772 | BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); | 772 | PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution); |
773 | 773 | ||
774 | // 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 |
775 | UpdatePhysicalMassProperties(0f, false); | 775 | UpdatePhysicalMassProperties(0f, false); |
776 | // Set collision detection parameters | 776 | // Set collision detection parameters |
777 | if (BSParam.CcdMotionThreshold > 0f) | 777 | if (BSParam.CcdMotionThreshold > 0f) |
778 | { | 778 | { |
779 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); | 779 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
780 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); | 780 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
781 | } | 781 | } |
782 | 782 | ||
783 | // 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. |
784 | // BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_SIMULATION); | 784 | // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION); |
785 | // Start it out sleeping and physical actions could wake it up. | 785 | // Start it out sleeping and physical actions could wake it up. |
786 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING); | 786 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING); |
787 | 787 | ||
788 | // This collides like a static object | 788 | // This collides like a static object |
789 | PhysBody.collisionType = CollisionType.Static; | 789 | PhysBody.collisionType = CollisionType.Static; |
@@ -794,22 +794,22 @@ public sealed class BSPrim : BSPhysObject | |||
794 | else | 794 | else |
795 | { | 795 | { |
796 | // Not a Bullet static object | 796 | // Not a Bullet static object |
797 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 797 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
798 | 798 | ||
799 | // Set various physical properties so other object interact properly | 799 | // Set various physical properties so other object interact properly |
800 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true); | 800 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true); |
801 | BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); | 801 | PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction); |
802 | BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); | 802 | PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution); |
803 | 803 | ||
804 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 | 804 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 |
805 | // 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 |
806 | // BulletSimAPI.ClearAllForces2(BSBody.ptr); | 806 | // PhysicsScene.PE.ClearAllForces(BSBody); |
807 | 807 | ||
808 | // 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 |
809 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 809 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
810 | 810 | ||
811 | // Center of mass is at the center of the object | 811 | // Center of mass is at the center of the object |
812 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody.ptr, _position, _orientation); | 812 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody, _position, _orientation); |
813 | 813 | ||
814 | // A dynamic object has mass | 814 | // A dynamic object has mass |
815 | UpdatePhysicalMassProperties(RawMass, false); | 815 | UpdatePhysicalMassProperties(RawMass, false); |
@@ -817,22 +817,22 @@ public sealed class BSPrim : BSPhysObject | |||
817 | // Set collision detection parameters | 817 | // Set collision detection parameters |
818 | if (BSParam.CcdMotionThreshold > 0f) | 818 | if (BSParam.CcdMotionThreshold > 0f) |
819 | { | 819 | { |
820 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); | 820 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
821 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); | 821 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
822 | } | 822 | } |
823 | 823 | ||
824 | // Various values for simulation limits | 824 | // Various values for simulation limits |
825 | BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping); | 825 | BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping); |
826 | BulletSimAPI.SetDeactivationTime2(PhysBody.ptr, BSParam.DeactivationTime); | 826 | PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime); |
827 | BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); | 827 | BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); |
828 | BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, BSParam.ContactProcessingThreshold); | 828 | PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); |
829 | 829 | ||
830 | // This collides like an object. | 830 | // This collides like an object. |
831 | PhysBody.collisionType = CollisionType.Dynamic; | 831 | PhysBody.collisionType = CollisionType.Dynamic; |
832 | 832 | ||
833 | // Force activation of the object so Bullet will act on it. | 833 | // Force activation of the object so Bullet will act on it. |
834 | // 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. |
835 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ACTIVE_TAG); | 835 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); |
836 | 836 | ||
837 | // There might be special things needed for implementing linksets. | 837 | // There might be special things needed for implementing linksets. |
838 | Linkset.MakeDynamic(this); | 838 | Linkset.MakeDynamic(this); |
@@ -853,7 +853,7 @@ public sealed class BSPrim : BSPhysObject | |||
853 | { | 853 | { |
854 | 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); |
855 | } | 855 | } |
856 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 856 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
857 | } | 857 | } |
858 | else | 858 | else |
859 | { | 859 | { |
@@ -861,7 +861,7 @@ public sealed class BSPrim : BSPhysObject | |||
861 | { | 861 | { |
862 | 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); |
863 | } | 863 | } |
864 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 864 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
865 | 865 | ||
866 | // 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 |
867 | PhysBody.collisionType = CollisionType.VolumeDetect; | 867 | PhysBody.collisionType = CollisionType.VolumeDetect; |
@@ -874,7 +874,7 @@ public sealed class BSPrim : BSPhysObject | |||
874 | private void ActivateIfPhysical(bool forceIt) | 874 | private void ActivateIfPhysical(bool forceIt) |
875 | { | 875 | { |
876 | if (IsPhysical && PhysBody.HasPhysicalBody) | 876 | if (IsPhysical && PhysBody.HasPhysicalBody) |
877 | BulletSimAPI.Activate2(PhysBody.ptr, forceIt); | 877 | PhysicsScene.PE.Activate(PhysBody, forceIt); |
878 | } | 878 | } |
879 | 879 | ||
880 | // 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. |
@@ -882,11 +882,11 @@ public sealed class BSPrim : BSPhysObject | |||
882 | { | 882 | { |
883 | if (wantsCollisionEvents) | 883 | if (wantsCollisionEvents) |
884 | { | 884 | { |
885 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 885 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
886 | } | 886 | } |
887 | else | 887 | else |
888 | { | 888 | { |
889 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 889 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
890 | } | 890 | } |
891 | } | 891 | } |
892 | 892 | ||
@@ -897,7 +897,7 @@ public sealed class BSPrim : BSPhysObject | |||
897 | { | 897 | { |
898 | if (PhysBody.HasPhysicalBody) | 898 | if (PhysBody.HasPhysicalBody) |
899 | { | 899 | { |
900 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 900 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); |
901 | 901 | ||
902 | // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. | 902 | // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. |
903 | // Replace this when the new AddObjectToWorld function is complete. | 903 | // Replace this when the new AddObjectToWorld function is complete. |
@@ -941,9 +941,9 @@ public sealed class BSPrim : BSPhysObject | |||
941 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() | 941 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() |
942 | { | 942 | { |
943 | if (_floatOnWater) | 943 | if (_floatOnWater) |
944 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 944 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
945 | else | 945 | else |
946 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 946 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
947 | }); | 947 | }); |
948 | } | 948 | } |
949 | } | 949 | } |