aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2013-09-09 14:53:16 -0700
committerRobert Adams2013-09-11 09:12:19 -0700
commitc5eabb28b4c933cfacefa85381e290372fbc094e (patch)
treec79acadaa6de935d18865a1bc0d5c9162e23747a /OpenSim/Region
parentBulletSim: add extended physics LSL constants for axis specification. (diff)
downloadopensim-SC-c5eabb28b4c933cfacefa85381e290372fbc094e.zip
opensim-SC-c5eabb28b4c933cfacefa85381e290372fbc094e.tar.gz
opensim-SC-c5eabb28b4c933cfacefa85381e290372fbc094e.tar.bz2
opensim-SC-c5eabb28b4c933cfacefa85381e290372fbc094e.tar.xz
BulletSim: add LSL function and plumbing for setting a spring
equilibrium point in the physics engine constraint.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs6
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs13
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs20
4 files changed, 40 insertions, 3 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
index b0b0bc6..9daf9d7 100755
--- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
@@ -408,8 +408,10 @@ public class ExtendedPhysics : INonSharedRegionModule
408 public const int PHYS_PARAM_LINK_TYPE = 14419; 408 public const int PHYS_PARAM_LINK_TYPE = 14419;
409 [ScriptConstant] 409 [ScriptConstant]
410 public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420; 410 public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420;
411 [ScriptConstant]
412 public const int PHYS_PARAM_SPRING_EQUILIBRIUM_POINT = 14421;
411 413
412 public const int PHYS_PARAM_MAX = 14420; 414 public const int PHYS_PARAM_MAX = 14421;
413 415
414 // Used when specifying a parameter that has settings for the three linear and three angular axis 416 // Used when specifying a parameter that has settings for the three linear and three angular axis
415 [ScriptConstant] 417 [ScriptConstant]
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
index 42b5c49..b47e9a8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
@@ -64,7 +64,7 @@ public abstract class BSConstraint : IDisposable
64 { 64 {
65 bool success = PhysicsScene.PE.DestroyConstraint(m_world, m_constraint); 65 bool success = PhysicsScene.PE.DestroyConstraint(m_world, m_constraint);
66 m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", 66 m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}",
67 BSScene.DetailLogZero, 67 m_body1.ID,
68 m_body1.ID, m_body1.AddrString, 68 m_body1.ID, m_body1.AddrString,
69 m_body2.ID, m_body2.AddrString, 69 m_body2.ID, m_body2.AddrString,
70 success); 70 success);
@@ -77,7 +77,10 @@ public abstract class BSConstraint : IDisposable
77 { 77 {
78 bool ret = false; 78 bool ret = false;
79 if (m_enabled) 79 if (m_enabled)
80 {
81 m_world.physicsScene.DetailLog("{0},BSConstraint.SetLinearLimits,taint,low={1},high={2}", m_body1.ID, low, high);
80 ret = PhysicsScene.PE.SetLinearLimits(m_constraint, low, high); 82 ret = PhysicsScene.PE.SetLinearLimits(m_constraint, low, high);
83 }
81 return ret; 84 return ret;
82 } 85 }
83 86
@@ -86,6 +89,7 @@ public abstract class BSConstraint : IDisposable
86 bool ret = false; 89 bool ret = false;
87 if (m_enabled) 90 if (m_enabled)
88 { 91 {
92 m_world.physicsScene.DetailLog("{0},BSConstraint.SetAngularLimits,taint,low={1},high={2}", m_body1.ID, low, high);
89 ret = PhysicsScene.PE.SetAngularLimits(m_constraint, low, high); 93 ret = PhysicsScene.PE.SetAngularLimits(m_constraint, low, high);
90 } 94 }
91 return ret; 95 return ret;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs
index 652c94a..8e7ddff 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs
@@ -85,6 +85,19 @@ public sealed class BSConstraintSpring : BSConstraint6Dof
85 return true; 85 return true;
86 } 86 }
87 87
88 public bool SetEquilibriumPoint(Vector3 linearEq, Vector3 angularEq)
89 {
90 PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEquilibriumPoint,obj1ID={1},obj2ID={2},linearEq={3},angularEq={4}",
91 m_body1.ID, m_body1.ID, m_body2.ID, linearEq, angularEq);
92 PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 0, linearEq.X);
93 PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 1, linearEq.Y);
94 PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 2, linearEq.Z);
95 PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 3, angularEq.X);
96 PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 4, angularEq.Y);
97 PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 5, angularEq.Z);
98 return true;
99 }
100
88} 101}
89 102
90} \ No newline at end of file 103} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index b3347bf..aaf92c8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -63,6 +63,8 @@ public sealed class BSLinksetConstraints : BSLinkset
63 public bool[] springAxisEnable; 63 public bool[] springAxisEnable;
64 public float[] springDamping; 64 public float[] springDamping;
65 public float[] springStiffness; 65 public float[] springStiffness;
66 public OMV.Vector3 springLinearEquilibriumPoint;
67 public OMV.Vector3 springAngularEquilibriumPoint;
66 68
67 public BSLinkInfoConstraint(BSPrimLinkable pMember) 69 public BSLinkInfoConstraint(BSPrimLinkable pMember)
68 : base(pMember) 70 : base(pMember)
@@ -102,6 +104,8 @@ public sealed class BSLinksetConstraints : BSLinkset
102 springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; 104 springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED;
103 springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; 105 springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED;
104 } 106 }
107 springLinearEquilibriumPoint = OMV.Vector3.Zero;
108 springAngularEquilibriumPoint = OMV.Vector3.Zero;
105 member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); 109 member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID);
106 } 110 }
107 111
@@ -155,7 +159,12 @@ public sealed class BSLinksetConstraints : BSLinkset
155 if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) 159 if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED)
156 constrainSpring.SetStiffness(ii, springStiffness[ii]); 160 constrainSpring.SetStiffness(ii, springStiffness[ii]);
157 } 161 }
158 constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); 162 constrainSpring.CalculateTransforms();
163
164 if (springLinearEquilibriumPoint != OMV.Vector3.Zero)
165 constrainSpring.SetEquilibriumPoint(springLinearEquilibriumPoint, springAngularEquilibriumPoint);
166 else
167 constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED);
159 } 168 }
160 break; 169 break;
161 default: 170 default:
@@ -618,6 +627,7 @@ public sealed class BSLinksetConstraints : BSLinkset
618 float valueFloat; 627 float valueFloat;
619 bool valueBool; 628 bool valueBool;
620 OMV.Vector3 valueVector; 629 OMV.Vector3 valueVector;
630 OMV.Vector3 valueVector2;
621 OMV.Quaternion valueQuaternion; 631 OMV.Quaternion valueQuaternion;
622 int axisLow, axisHigh; 632 int axisLow, axisHigh;
623 633
@@ -764,6 +774,14 @@ public sealed class BSLinksetConstraints : BSLinkset
764 linkInfo.springStiffness[ii] = valueFloat; 774 linkInfo.springStiffness[ii] = valueFloat;
765 opIndex += 3; 775 opIndex += 3;
766 break; 776 break;
777 case ExtendedPhysics.PHYS_PARAM_SPRING_EQUILIBRIUM_POINT:
778 errMsg = "PHYS_PARAM_SPRING_EQUILIBRIUM_POINT takes two parameters of type vector";
779 valueVector = (OMV.Vector3)pParams[opIndex + 1];
780 valueVector2 = (OMV.Vector3)pParams[opIndex + 2];
781 linkInfo.springLinearEquilibriumPoint = valueVector;
782 linkInfo.springAngularEquilibriumPoint = valueVector2;
783 opIndex += 3;
784 break;
767 case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA: 785 case ExtendedPhysics.PHYS_PARAM_USE_LINEAR_FRAMEA:
768 errMsg = "PHYS_PARAM_USE_LINEAR_FRAMEA takes one parameter of type integer (bool)"; 786 errMsg = "PHYS_PARAM_USE_LINEAR_FRAMEA takes one parameter of type integer (bool)";
769 valueBool = ((int)pParams[opIndex + 1]) != 0; 787 valueBool = ((int)pParams[opIndex + 1]) != 0;