aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-08-07 10:15:28 -0700
committerJustin Clark-Casey (justincc)2013-09-20 21:01:58 +0100
commit785171109efda38f6ab973bfde51ba378450abaa (patch)
treee2f335531282db4ba22e538ab23add72f5ed51d8 /OpenSim
parentBulletSim: complete linkage of spring constraint into linkset constraint. (diff)
downloadopensim-SC_OLD-785171109efda38f6ab973bfde51ba378450abaa.zip
opensim-SC_OLD-785171109efda38f6ab973bfde51ba378450abaa.tar.gz
opensim-SC_OLD-785171109efda38f6ab973bfde51ba378450abaa.tar.bz2
opensim-SC_OLD-785171109efda38f6ab973bfde51ba378450abaa.tar.xz
BulletSim: add unmanaged and XNA functions for hinge, slider and spring constraints.
Diffstat (limited to 'OpenSim')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs45
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs174
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs24
3 files changed, 241 insertions, 2 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
index 6c36485..8dfb01c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
@@ -596,6 +596,12 @@ public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, flo
596 return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold); 596 return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold);
597} 597}
598 598
599public override bool HingeSetLimits(BulletConstraint constrain, float low, float high, float softness, float bias, float relaxation)
600{
601 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
602 return BSAPICPP.HingeSetLimits2(constrainu.ptr, low, high, softness, bias, relaxation);
603}
604
599public override bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse) 605public override bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse)
600{ 606{
601 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; 607 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
@@ -620,6 +626,30 @@ public override bool SpringSetDamping(BulletConstraint constrain, int index, flo
620 return BSAPICPP.ConstraintSpringSetDamping2(constrainu.ptr, index, damping); 626 return BSAPICPP.ConstraintSpringSetDamping2(constrainu.ptr, index, damping);
621} 627}
622 628
629public override bool SliderSetLimits(BulletConstraint constrain, int lowerUpper, int linAng, float val)
630{
631 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
632 return BSAPICPP.SliderSetLimits2(constrainu.ptr, lowerUpper, linAng, val);
633}
634
635public override bool SliderSet(BulletConstraint constrain, int softRestDamp, int dirLimOrtho, int linAng, float val)
636{
637 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
638 return BSAPICPP.SliderSet2(constrainu.ptr, softRestDamp, dirLimOrtho, linAng, val);
639}
640
641public override bool SliderMotorEnable(BulletConstraint constrain, int linAng, float numericTrueFalse)
642{
643 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
644 return BSAPICPP.SliderMotorEnable2(constrainu.ptr, linAng, numericTrueFalse);
645}
646
647public override bool SliderMotor(BulletConstraint constrain, int forceVel, int linAng, float val)
648{
649 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
650 return BSAPICPP.SliderMotor2(constrainu.ptr, forceVel, linAng, val);
651}
652
623public override bool CalculateTransforms(BulletConstraint constrain) 653public override bool CalculateTransforms(BulletConstraint constrain)
624{ 654{
625 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; 655 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
@@ -1625,6 +1655,9 @@ public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enabl
1625public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold); 1655public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold);
1626 1656
1627[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1657[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1658public static extern bool HingeSetLimits2(IntPtr constrain, float low, float high, float softness, float bias, float relaxation);
1659
1660[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1628public static extern bool ConstraintSpringEnable2(IntPtr constrain, int index, float numericTrueFalse); 1661public static extern bool ConstraintSpringEnable2(IntPtr constrain, int index, float numericTrueFalse);
1629 1662
1630[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1663[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -1637,6 +1670,18 @@ public static extern bool ConstraintSpringSetStiffness2(IntPtr constrain, int in
1637public static extern bool ConstraintSpringSetDamping2(IntPtr constrain, int index, float damping); 1670public static extern bool ConstraintSpringSetDamping2(IntPtr constrain, int index, float damping);
1638 1671
1639[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1672[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1673public static extern bool SliderSetLimits2(IntPtr constrain, int lowerUpper, int linAng, float val);
1674
1675[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1676public static extern bool SliderSet2(IntPtr constrain, int softRestDamp, int dirLimOrtho, int linAng, float val);
1677
1678[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1679public static extern bool SliderMotorEnable2(IntPtr constrain, int linAng, float numericTrueFalse);
1680
1681[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1682public static extern bool SliderMotor2(IntPtr constrain, int forceVel, int linAng, float val);
1683
1684[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1640public static extern bool CalculateTransforms2(IntPtr constrain); 1685public static extern bool CalculateTransforms2(IntPtr constrain);
1641 1686
1642[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1687[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
index 9ad12a9..ff2b497 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
@@ -752,6 +752,15 @@ private sealed class BulletConstraintXNA : BulletConstraint
752 constraint.SetBreakingImpulseThreshold(threshold); 752 constraint.SetBreakingImpulseThreshold(threshold);
753 return true; 753 return true;
754 } 754 }
755 public override bool HingeSetLimits(BulletConstraint pConstraint, float low, float high, float softness, float bias, float relaxation)
756 {
757 HingeConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as HingeConstraint;
758 if (softness == HINGE_NOT_SPECIFIED)
759 constraint.SetLimit(low, high);
760 else
761 constraint.SetLimit(low, high, softness, bias, relaxation);
762 return true;
763 }
755 public override bool SpringEnable(BulletConstraint pConstraint, int index, float numericTrueFalse) 764 public override bool SpringEnable(BulletConstraint pConstraint, int index, float numericTrueFalse)
756 { 765 {
757 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; 766 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
@@ -762,13 +771,13 @@ private sealed class BulletConstraintXNA : BulletConstraint
762 public override bool SpringSetEquilibriumPoint(BulletConstraint pConstraint, int index, float equilibriumPoint) 771 public override bool SpringSetEquilibriumPoint(BulletConstraint pConstraint, int index, float equilibriumPoint)
763 { 772 {
764 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint; 773 Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
765 if (index == -1) 774 if (index == SPRING_NOT_SPECIFIED)
766 { 775 {
767 constraint.SetEquilibriumPoint(); 776 constraint.SetEquilibriumPoint();
768 } 777 }
769 else 778 else
770 { 779 {
771 if (equilibriumPoint == -1) 780 if (equilibriumPoint == SPRING_NOT_SPECIFIED)
772 constraint.SetEquilibriumPoint(index); 781 constraint.SetEquilibriumPoint(index);
773 else 782 else
774 constraint.SetEquilibriumPoint(index, equilibriumPoint); 783 constraint.SetEquilibriumPoint(index, equilibriumPoint);
@@ -790,6 +799,167 @@ private sealed class BulletConstraintXNA : BulletConstraint
790 return true; 799 return true;
791 } 800 }
792 801
802 public override bool SliderSetLimits(BulletConstraint pConstraint, int lowerUpper, int linAng, float val)
803 {
804 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
805 switch (lowerUpper)
806 {
807 case SLIDER_LOWER_LIMIT:
808 switch (linAng)
809 {
810 case SLIDER_LINEAR:
811 constraint.SetLowerLinLimit(val);
812 break;
813 case SLIDER_ANGULAR:
814 constraint.SetLowerAngLimit(val);
815 break;
816 }
817 break;
818 case SLIDER_UPPER_LIMIT:
819 switch (linAng)
820 {
821 case SLIDER_LINEAR:
822 constraint.SetUpperLinLimit(val);
823 break;
824 case SLIDER_ANGULAR:
825 constraint.SetUpperAngLimit(val);
826 break;
827 }
828 break;
829 }
830 return true;
831 }
832 public override bool SliderSet(BulletConstraint pConstraint, int softRestDamp, int dirLimOrtho, int linAng, float val)
833 {
834 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
835 switch (softRestDamp)
836 {
837 case SLIDER_SET_SOFTNESS:
838 switch (dirLimOrtho)
839 {
840 case SLIDER_SET_DIRECTION:
841 switch (linAng)
842 {
843 case SLIDER_LINEAR: constraint.SetSoftnessDirLin(val); break;
844 case SLIDER_ANGULAR: constraint.SetSoftnessDirAng(val); break;
845 }
846 break;
847 case SLIDER_SET_LIMIT:
848 switch (linAng)
849 {
850 case SLIDER_LINEAR: constraint.SetSoftnessLimLin(val); break;
851 case SLIDER_ANGULAR: constraint.SetSoftnessLimAng(val); break;
852 }
853 break;
854 case SLIDER_SET_ORTHO:
855 switch (linAng)
856 {
857 case SLIDER_LINEAR: constraint.SetSoftnessOrthoLin(val); break;
858 case SLIDER_ANGULAR: constraint.SetSoftnessOrthoAng(val); break;
859 }
860 break;
861 }
862 break;
863 case SLIDER_SET_RESTITUTION:
864 switch (dirLimOrtho)
865 {
866 case SLIDER_SET_DIRECTION:
867 switch (linAng)
868 {
869 case SLIDER_LINEAR: constraint.SetRestitutionDirLin(val); break;
870 case SLIDER_ANGULAR: constraint.SetRestitutionDirAng(val); break;
871 }
872 break;
873 case SLIDER_SET_LIMIT:
874 switch (linAng)
875 {
876 case SLIDER_LINEAR: constraint.SetRestitutionLimLin(val); break;
877 case SLIDER_ANGULAR: constraint.SetRestitutionLimAng(val); break;
878 }
879 break;
880 case SLIDER_SET_ORTHO:
881 switch (linAng)
882 {
883 case SLIDER_LINEAR: constraint.SetRestitutionOrthoLin(val); break;
884 case SLIDER_ANGULAR: constraint.SetRestitutionOrthoAng(val); break;
885 }
886 break;
887 }
888 break;
889 case SLIDER_SET_DAMPING:
890 switch (dirLimOrtho)
891 {
892 case SLIDER_SET_DIRECTION:
893 switch (linAng)
894 {
895 case SLIDER_LINEAR: constraint.SetDampingDirLin(val); break;
896 case SLIDER_ANGULAR: constraint.SetDampingDirAng(val); break;
897 }
898 break;
899 case SLIDER_SET_LIMIT:
900 switch (linAng)
901 {
902 case SLIDER_LINEAR: constraint.SetDampingLimLin(val); break;
903 case SLIDER_ANGULAR: constraint.SetDampingLimAng(val); break;
904 }
905 break;
906 case SLIDER_SET_ORTHO:
907 switch (linAng)
908 {
909 case SLIDER_LINEAR: constraint.SetDampingOrthoLin(val); break;
910 case SLIDER_ANGULAR: constraint.SetDampingOrthoAng(val); break;
911 }
912 break;
913 }
914 break;
915 }
916 return true;
917 }
918 public override bool SliderMotorEnable(BulletConstraint pConstraint, int linAng, float numericTrueFalse)
919 {
920 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
921 switch (linAng)
922 {
923 case SLIDER_LINEAR:
924 constraint.SetPoweredLinMotor(numericTrueFalse == 0.0 ? false : true);
925 break;
926 case SLIDER_ANGULAR:
927 constraint.SetPoweredAngMotor(numericTrueFalse == 0.0 ? false : true);
928 break;
929 }
930 return true;
931 }
932 public override bool SliderMotor(BulletConstraint pConstraint, int forceVel, int linAng, float val)
933 {
934 SliderConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as SliderConstraint;
935 switch (forceVel)
936 {
937 case SLIDER_MOTOR_VELOCITY:
938 switch (linAng)
939 {
940 case SLIDER_LINEAR:
941 constraint.SetTargetLinMotorVelocity(val);
942 break;
943 case SLIDER_ANGULAR:
944 constraint.SetTargetAngMotorVelocity(val);
945 break;
946 }
947 break;
948 case SLIDER_MAX_MOTOR_FORCE:
949 switch (linAng)
950 {
951 case SLIDER_LINEAR:
952 constraint.SetMaxLinMotorForce(val);
953 break;
954 case SLIDER_ANGULAR:
955 constraint.SetMaxAngMotorForce(val);
956 break;
957 }
958 break;
959 }
960 return true;
961 }
962
793 //BulletSimAPI.SetAngularDamping(Prim.PhysBody.ptr, angularDamping); 963 //BulletSimAPI.SetAngularDamping(Prim.PhysBody.ptr, angularDamping);
794 public override void SetAngularDamping(BulletBody pBody, float angularDamping) 964 public override void SetAngularDamping(BulletBody pBody, float angularDamping)
795 { 965 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
index 8cca29f..b241059 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
@@ -441,14 +441,38 @@ public abstract bool TranslationalLimitMotor(BulletConstraint constrain, float e
441 441
442public abstract bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold); 442public abstract bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold);
443 443
444public const int HINGE_NOT_SPECIFIED = -1;
445public abstract bool HingeSetLimits(BulletConstraint constrain, float low, float high, float softness, float bias, float relaxation);
446
444public abstract bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse); 447public abstract bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse);
445 448
449public const int SPRING_NOT_SPECIFIED = -1;
446public abstract bool SpringSetEquilibriumPoint(BulletConstraint constrain, int index, float equilibriumPoint); 450public abstract bool SpringSetEquilibriumPoint(BulletConstraint constrain, int index, float equilibriumPoint);
447 451
448public abstract bool SpringSetStiffness(BulletConstraint constrain, int index, float stiffnesss); 452public abstract bool SpringSetStiffness(BulletConstraint constrain, int index, float stiffnesss);
449 453
450public abstract bool SpringSetDamping(BulletConstraint constrain, int index, float damping); 454public abstract bool SpringSetDamping(BulletConstraint constrain, int index, float damping);
451 455
456public const int SLIDER_LOWER_LIMIT = 0;
457public const int SLIDER_UPPER_LIMIT = 1;
458public const int SLIDER_LINEAR = 2;
459public const int SLIDER_ANGULAR = 3;
460public abstract bool SliderSetLimits(BulletConstraint constrain, int lowerUpper, int linAng, float val);
461
462public const int SLIDER_SET_SOFTNESS = 4;
463public const int SLIDER_SET_RESTITUTION = 5;
464public const int SLIDER_SET_DAMPING = 6;
465public const int SLIDER_SET_DIRECTION = 7;
466public const int SLIDER_SET_LIMIT = 8;
467public const int SLIDER_SET_ORTHO = 9;
468public abstract bool SliderSet(BulletConstraint constrain, int softRestDamp, int dirLimOrtho, int linAng, float val);
469
470public abstract bool SliderMotorEnable(BulletConstraint constrain, int linAng, float numericTrueFalse);
471
472public const int SLIDER_MOTOR_VELOCITY = 10;
473public const int SLIDER_MAX_MOTOR_FORCE = 11;
474public abstract bool SliderMotor(BulletConstraint constrain, int forceVel, int linAng, float val);
475
452public abstract bool CalculateTransforms(BulletConstraint constrain); 476public abstract bool CalculateTransforms(BulletConstraint constrain);
453 477
454public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); 478public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);