From 7c54630a2dde768e92b3034d76314cb1e061c348 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Aug 2013 16:31:17 -0700 Subject: BulletSim: add axis parameter for specifying enable, damping, and stiffness for spring constraints. Renumber parameter ops since I can as no one is using them yet. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 10 +++-- .../Region/Physics/BulletSPlugin/BSApiTemplate.cs | 2 +- .../Physics/BulletSPlugin/BSConstraintSpring.cs | 2 +- .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 51 +++++++++++++++------- 4 files changed, 44 insertions(+), 21 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index 2f88e2b..ef106bd 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -399,13 +399,15 @@ public class ExtendedPhysics : INonSharedRegionModule [ScriptConstant] public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415; [ScriptConstant] - public const int PHYS_PARAM_SPRING_DAMPING = 14416; + public const int PHYS_PARAM_SPRING_AXIS_ENABLE = 14416; [ScriptConstant] - public const int PHYS_PARAM_SPRING_STIFFNESS = 14417; + public const int PHYS_PARAM_SPRING_DAMPING = 14417; [ScriptConstant] - public const int PHYS_PARAM_LINK_TYPE = 14418; + public const int PHYS_PARAM_SPRING_STIFFNESS = 14418; + [ScriptConstant] + public const int PHYS_PARAM_LINK_TYPE = 14419; - public const int PHYS_PARAM_MAX = 14418; + public const int PHYS_PARAM_MAX = 14419; // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...]) [ScriptInvocation] diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index 9d8838b..0b3f467 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -292,7 +292,7 @@ public enum ConstraintParamAxis : int AXIS_ANGULAR_X, AXIS_ANGULAR_Y, AXIS_ANGULAR_Z, - AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls + AXIS_LINEAR_ALL = 20, // added by BulletSim so we don't have to do zillions of calls AXIS_ANGULAR_ALL, AXIS_ALL }; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs index 410584d..432e5b2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs @@ -53,7 +53,7 @@ public sealed class BSConstraintSpring : BSConstraint6Dof m_body1.ID, frame1Loc, frame1Rot, frame2Loc, frame2Rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); } - public bool SetEnable(int pIndex, bool pAxisEnable) + public bool SetAxisEnable(int pIndex, bool pAxisEnable) { PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEnable,obj1ID={1},obj2ID={2},indx={3},enable={4}", m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pAxisEnable); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index be97c29..f623231 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -59,8 +59,9 @@ public sealed class BSLinksetConstraints : BSLinkset public OMV.Vector3 frameInBloc; public OMV.Quaternion frameInBrot; // Spring - public float springDamping; - public float springStiffness; + public bool[] springAxisEnable; + public float[] springDamping; + public float[] springStiffness; public BSLinkInfoConstraint(BSPrimLinkable pMember) : base(pMember) @@ -90,8 +91,15 @@ public sealed class BSLinksetConstraints : BSLinkset frameInArot = OMV.Quaternion.Identity; frameInBloc = OMV.Vector3.Zero; frameInBrot = OMV.Quaternion.Identity; - springDamping = -1f; - springStiffness = -1f; + springAxisEnable = new bool[6]; + springDamping = new float[6]; + springStiffness = new float[6]; + for (int ii = 0; ii < springAxisEnable.Length; ii++) + { + springAxisEnable[ii] = false; + springDamping[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; + springStiffness[ii] = BSAPITemplate.SPRING_NOT_SPECIFIED; + } member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID); } @@ -139,11 +147,13 @@ public sealed class BSLinksetConstraints : BSLinkset } for (int ii = 0; ii < 6; ii++) { - if (springDamping != -1) - constrainSpring.SetDamping(ii, springDamping); - if (springStiffness != -1) - constrainSpring.SetStiffness(ii, springStiffness); + constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]); + if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) + constrainSpring.SetDamping(ii, springDamping[ii]); + if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED) + constrainSpring.SetStiffness(ii, springStiffness[ii]); } + constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED); } break; default: @@ -707,15 +717,26 @@ public sealed class BSLinksetConstraints : BSLinkset linkInfo.solverIterations = valueFloat; opIndex += 2; break; + case ExtendedPhysics.PHYS_PARAM_SPRING_AXIS_ENABLE: + valueInt = (int)pParams[opIndex + 1]; + valueBool = ((int)pParams[opIndex + 2] != 0); + if (valueInt >=0 && valueInt < linkInfo.springAxisEnable.Length) + linkInfo.springAxisEnable[valueInt] = valueBool; + opIndex += 3; + break; case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: - valueFloat = (float)pParams[opIndex + 1]; - linkInfo.springDamping = valueFloat; - opIndex += 2; + valueInt = (int)pParams[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 2]; + if (valueInt >=0 && valueInt < linkInfo.springDamping.Length) + linkInfo.springDamping[valueInt] = valueFloat; + opIndex += 3; break; case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: - valueFloat = (float)pParams[opIndex + 1]; - linkInfo.springStiffness = valueFloat; - opIndex += 2; + valueInt = (int)pParams[opIndex + 1]; + valueFloat = (float)pParams[opIndex + 2]; + if (valueInt >=0 && valueInt < linkInfo.springStiffness.Length) + linkInfo.springStiffness[valueInt] = valueFloat; + opIndex += 3; break; default: break; -- cgit v1.1