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.
parent
2e32b2aacb
commit
7a9eb26b00
|
@ -399,13 +399,15 @@ public class ExtendedPhysics : INonSharedRegionModule
|
||||||
[ScriptConstant]
|
[ScriptConstant]
|
||||||
public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415;
|
public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415;
|
||||||
[ScriptConstant]
|
[ScriptConstant]
|
||||||
public const int PHYS_PARAM_SPRING_DAMPING = 14416;
|
public const int PHYS_PARAM_SPRING_AXIS_ENABLE = 14416;
|
||||||
[ScriptConstant]
|
[ScriptConstant]
|
||||||
public const int PHYS_PARAM_SPRING_STIFFNESS = 14417;
|
public const int PHYS_PARAM_SPRING_DAMPING = 14417;
|
||||||
[ScriptConstant]
|
[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, ...])
|
// physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...])
|
||||||
[ScriptInvocation]
|
[ScriptInvocation]
|
||||||
|
|
|
@ -292,7 +292,7 @@ public enum ConstraintParamAxis : int
|
||||||
AXIS_ANGULAR_X,
|
AXIS_ANGULAR_X,
|
||||||
AXIS_ANGULAR_Y,
|
AXIS_ANGULAR_Y,
|
||||||
AXIS_ANGULAR_Z,
|
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_ANGULAR_ALL,
|
||||||
AXIS_ALL
|
AXIS_ALL
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,7 +53,7 @@ public sealed class BSConstraintSpring : BSConstraint6Dof
|
||||||
m_body1.ID, frame1Loc, frame1Rot, frame2Loc, frame2Rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
|
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}",
|
PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEnable,obj1ID={1},obj2ID={2},indx={3},enable={4}",
|
||||||
m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pAxisEnable);
|
m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pAxisEnable);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* 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.Vector3 frameInBloc;
|
||||||
public OMV.Quaternion frameInBrot;
|
public OMV.Quaternion frameInBrot;
|
||||||
// Spring
|
// Spring
|
||||||
public float springDamping;
|
public bool[] springAxisEnable;
|
||||||
public float springStiffness;
|
public float[] springDamping;
|
||||||
|
public float[] springStiffness;
|
||||||
|
|
||||||
public BSLinkInfoConstraint(BSPrimLinkable pMember)
|
public BSLinkInfoConstraint(BSPrimLinkable pMember)
|
||||||
: base(pMember)
|
: base(pMember)
|
||||||
|
@ -90,8 +91,15 @@ public sealed class BSLinksetConstraints : BSLinkset
|
||||||
frameInArot = OMV.Quaternion.Identity;
|
frameInArot = OMV.Quaternion.Identity;
|
||||||
frameInBloc = OMV.Vector3.Zero;
|
frameInBloc = OMV.Vector3.Zero;
|
||||||
frameInBrot = OMV.Quaternion.Identity;
|
frameInBrot = OMV.Quaternion.Identity;
|
||||||
springDamping = -1f;
|
springAxisEnable = new bool[6];
|
||||||
springStiffness = -1f;
|
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);
|
member.PhysScene.DetailLog("{0},BSLinkInfoConstraint.ResetLink", member.LocalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,11 +147,13 @@ public sealed class BSLinksetConstraints : BSLinkset
|
||||||
}
|
}
|
||||||
for (int ii = 0; ii < 6; ii++)
|
for (int ii = 0; ii < 6; ii++)
|
||||||
{
|
{
|
||||||
if (springDamping != -1)
|
constrainSpring.SetAxisEnable(ii, springAxisEnable[ii]);
|
||||||
constrainSpring.SetDamping(ii, springDamping);
|
if (springDamping[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED)
|
||||||
if (springStiffness != -1)
|
constrainSpring.SetDamping(ii, springDamping[ii]);
|
||||||
constrainSpring.SetStiffness(ii, springStiffness);
|
if (springStiffness[ii] != BSAPITemplate.SPRING_NOT_SPECIFIED)
|
||||||
|
constrainSpring.SetStiffness(ii, springStiffness[ii]);
|
||||||
}
|
}
|
||||||
|
constrainSpring.SetEquilibriumPoint(BSAPITemplate.SPRING_NOT_SPECIFIED, BSAPITemplate.SPRING_NOT_SPECIFIED);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -707,15 +717,26 @@ public sealed class BSLinksetConstraints : BSLinkset
|
||||||
linkInfo.solverIterations = valueFloat;
|
linkInfo.solverIterations = valueFloat;
|
||||||
opIndex += 2;
|
opIndex += 2;
|
||||||
break;
|
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:
|
case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING:
|
||||||
valueFloat = (float)pParams[opIndex + 1];
|
valueInt = (int)pParams[opIndex + 1];
|
||||||
linkInfo.springDamping = valueFloat;
|
valueFloat = (float)pParams[opIndex + 2];
|
||||||
opIndex += 2;
|
if (valueInt >=0 && valueInt < linkInfo.springDamping.Length)
|
||||||
|
linkInfo.springDamping[valueInt] = valueFloat;
|
||||||
|
opIndex += 3;
|
||||||
break;
|
break;
|
||||||
case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS:
|
case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS:
|
||||||
valueFloat = (float)pParams[opIndex + 1];
|
valueInt = (int)pParams[opIndex + 1];
|
||||||
linkInfo.springStiffness = valueFloat;
|
valueFloat = (float)pParams[opIndex + 2];
|
||||||
opIndex += 2;
|
if (valueInt >=0 && valueInt < linkInfo.springStiffness.Length)
|
||||||
|
linkInfo.springStiffness[valueInt] = valueFloat;
|
||||||
|
opIndex += 3;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue