aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-08-24 08:33:28 -0700
committerRobert Adams2013-09-11 09:12:16 -0700
commitcf2cdc191d0a93860da1ff4c42d34138e8f369fb (patch)
tree7df673cb1393a19cd5188494980ed557fa838db7 /OpenSim
parentBulletSim: add axis parameter for specifying enable, damping, and stiffness f... (diff)
downloadopensim-SC_OLD-cf2cdc191d0a93860da1ff4c42d34138e8f369fb.zip
opensim-SC_OLD-cf2cdc191d0a93860da1ff4c42d34138e8f369fb.tar.gz
opensim-SC_OLD-cf2cdc191d0a93860da1ff4c42d34138e8f369fb.tar.bz2
opensim-SC_OLD-cf2cdc191d0a93860da1ff4c42d34138e8f369fb.tar.xz
BulletSim: ability to specify groups of axis to modify in constraint parameters that control multiple axis. Add useLinearReferenceFrameA constraint parameter.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs12
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs53
2 files changed, 56 insertions, 9 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
index ef106bd..94367f5 100755
--- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
@@ -406,8 +406,18 @@ public class ExtendedPhysics : INonSharedRegionModule
406 public const int PHYS_PARAM_SPRING_STIFFNESS = 14418; 406 public const int PHYS_PARAM_SPRING_STIFFNESS = 14418;
407 [ScriptConstant] 407 [ScriptConstant]
408 public const int PHYS_PARAM_LINK_TYPE = 14419; 408 public const int PHYS_PARAM_LINK_TYPE = 14419;
409 [ScriptConstant]
410 public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420;
411
412 public const int PHYS_PARAM_MAX = 14420;
409 413
410 public const int PHYS_PARAM_MAX = 14419; 414 // Used when specifying a parameter that has settings for the three linear and three angular axis
415 [ScriptConstant]
416 public const int PHYS_AXIS_ALL = -1;
417 [ScriptConstant]
418 public const int PHYS_AXIS_ALL_LINEAR = -2;
419 [ScriptConstant]
420 public const int PHYS_AXIS_ALL_ANGULAR = -3;
411 421
412 // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) 422 // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...])
413 [ScriptInvocation] 423 [ScriptInvocation]
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index f623231..ff5ac0e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -58,6 +58,7 @@ public sealed class BSLinksetConstraints : BSLinkset
58 public OMV.Quaternion frameInArot; 58 public OMV.Quaternion frameInArot;
59 public OMV.Vector3 frameInBloc; 59 public OMV.Vector3 frameInBloc;
60 public OMV.Quaternion frameInBrot; 60 public OMV.Quaternion frameInBrot;
61 public bool useLinearReferenceFrameA;
61 // Spring 62 // Spring
62 public bool[] springAxisEnable; 63 public bool[] springAxisEnable;
63 public float[] springDamping; 64 public float[] springDamping;
@@ -91,6 +92,7 @@ public sealed class BSLinksetConstraints : BSLinkset
91 frameInArot = OMV.Quaternion.Identity; 92 frameInArot = OMV.Quaternion.Identity;
92 frameInBloc = OMV.Vector3.Zero; 93 frameInBloc = OMV.Vector3.Zero;
93 frameInBrot = OMV.Quaternion.Identity; 94 frameInBrot = OMV.Quaternion.Identity;
95 useLinearReferenceFrameA = true;
94 springAxisEnable = new bool[6]; 96 springAxisEnable = new bool[6];
95 springDamping = new float[6]; 97 springDamping = new float[6];
96 springStiffness = new float[6]; 98 springStiffness = new float[6];
@@ -145,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset
145 { 147 {
146 constrainSpring.SetSolverIterations(solverIterations); 148 constrainSpring.SetSolverIterations(solverIterations);
147 } 149 }
148 for (int ii = 0; ii < 6; ii++) 150 for (int ii = 0; ii < springAxisEnable.Length; ii++)
149 { 151 {
150 constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]); 152 constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]);
151 if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) 153 if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED)
@@ -401,7 +403,7 @@ public sealed class BSLinksetConstraints : BSLinkset
401 case ConstraintType.D6_SPRING_CONSTRAINT_TYPE: 403 case ConstraintType.D6_SPRING_CONSTRAINT_TYPE:
402 constrain = new BSConstraintSpring(m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody, 404 constrain = new BSConstraintSpring(m_physicsScene.World, rootPrim.PhysBody, linkInfo.member.PhysBody,
403 linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, 405 linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot,
404 true /*useLinearReferenceFrameA*/, 406 linkInfo.useLinearReferenceFrameA,
405 true /*disableCollisionsBetweenLinkedBodies*/); 407 true /*disableCollisionsBetweenLinkedBodies*/);
406 DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6}", 408 DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6}",
407 rootPrim.LocalID, 409 rootPrim.LocalID,
@@ -619,6 +621,7 @@ public sealed class BSLinksetConstraints : BSLinkset
619 bool valueBool; 621 bool valueBool;
620 OMV.Vector3 valueVector; 622 OMV.Vector3 valueVector;
621 OMV.Quaternion valueQuaternion; 623 OMV.Quaternion valueQuaternion;
624 int axisLow, axisHigh;
622 625
623 int opIndex = 2; 626 int opIndex = 2;
624 while (opIndex < pParams.Length) 627 while (opIndex < pParams.Length)
@@ -720,24 +723,32 @@ public sealed class BSLinksetConstraints : BSLinkset
720 case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: 723 case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE:
721 valueInt = (int)pParams[opIndex + 1]; 724 valueInt = (int)pParams[opIndex + 1];
722 valueBool = ((int)pParams[opIndex + 2] != 0); 725 valueBool = ((int)pParams[opIndex + 2] != 0);
723 if (valueInt >=0 && valueInt < linkInfo.springAxisEnable.Length) 726 GetAxisRange(valueInt, out axisLow, out axisHigh);
724 linkInfo.springAxisEnable[valueInt] = valueBool; 727 for (int ii = axisLow; ii <= axisHigh; ii++)
728 linkInfo.springAxisEnable[ii] = valueBool;
725 opIndex += 3; 729 opIndex += 3;
726 break; 730 break;
727 case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: 731 case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING:
728 valueInt = (int)pParams[opIndex + 1]; 732 valueInt = (int)pParams[opIndex + 1];
729 valueFloat = (float)pParams[opIndex + 2]; 733 valueFloat = (float)pParams[opIndex + 2];
730 if (valueInt >=0 && valueInt < linkInfo.springDamping.Length) 734 GetAxisRange(valueInt, out axisLow, out axisHigh);
731 linkInfo.springDamping[valueInt] = valueFloat; 735 for (int ii = axisLow; ii <= axisHigh; ii++)
736 linkInfo.springDamping[ii] = valueFloat;
732 opIndex += 3; 737 opIndex += 3;
733 break; 738 break;
734 case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: 739 case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS:
735 valueInt = (int)pParams[opIndex + 1]; 740 valueInt = (int)pParams[opIndex + 1];
736 valueFloat = (float)pParams[opIndex + 2]; 741 valueFloat = (float)pParams[opIndex + 2];
737 if (valueInt >=0 && valueInt < linkInfo.springStiffness.Length) 742 GetAxisRange(valueInt, out axisLow, out axisHigh);
738 linkInfo.springStiffness[valueInt] = valueFloat; 743 for (int ii = axisLow; ii <= axisHigh; ii++)
744 linkInfo.springStiffness[ii] = valueFloat;
739 opIndex += 3; 745 opIndex += 3;
740 break; 746 break;
747 case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA:
748 valueBool = (bool)pParams[opIndex + 1];
749 linkInfo.useLinearReferenceFrameA = valueBool;
750 opIndex += 2;
751 break;
741 default: 752 default:
742 break; 753 break;
743 } 754 }
@@ -760,6 +771,32 @@ public sealed class BSLinksetConstraints : BSLinkset
760 } 771 }
761 return ret; 772 return ret;
762 } 773 }
774
775 // Bullet constraints keep some limit parameters for each linear and angular axis.
776 // Setting same is easier if there is an easy way to see all or types.
777 // This routine returns the array limits for the set of axis.
778 private void GetAxisRange(int rangeSpec, out int low, out int high)
779 {
780 switch (rangeSpec)
781 {
782 case ExtendedPhysics.PHYS_AXIS_ALL_LINEAR:
783 low = 0;
784 high = 2;
785 break;
786 case ExtendedPhysics.PHYS_AXIS_ALL_ANGULAR:
787 low = 3;
788 high = 5;
789 break;
790 case ExtendedPhysics.PHYS_AXIS_ALL:
791 low = 0;
792 high = 5;
793 break;
794 default:
795 low = high = rangeSpec;
796 break;
797 }
798 return;
799 }
763 #endregion // Extension 800 #endregion // Extension
764 801
765} 802}