BulletSim: add API and calls for spring constraint parameters.

varregion
Robert Adams 2013-08-07 07:54:47 -07:00
parent 725751fd6c
commit 48ee73bfa7
3 changed files with 82 additions and 0 deletions

View File

@ -596,6 +596,30 @@ public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, flo
return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold);
}
public override bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse)
{
BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
return BSAPICPP.ConstraintSpringEnable2(constrainu.ptr, index, numericTrueFalse);
}
public override bool SpringSetEquilibriumPoint(BulletConstraint constrain, int index, float equilibriumPoint)
{
BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
return BSAPICPP.ConstraintSpringSetEquilibriumPoint2(constrainu.ptr, index, equilibriumPoint);
}
public override bool SpringSetStiffness(BulletConstraint constrain, int index, float stiffnesss)
{
BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
return BSAPICPP.ConstraintSpringSetStiffness2(constrainu.ptr, index, stiffnesss);
}
public override bool SpringSetDamping(BulletConstraint constrain, int index, float damping)
{
BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
return BSAPICPP.ConstraintSpringSetDamping2(constrainu.ptr, index, damping);
}
public override bool CalculateTransforms(BulletConstraint constrain)
{
BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
@ -1600,6 +1624,18 @@ public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enabl
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool ConstraintSpringEnable2(IntPtr constrain, int index, float numericTrueFalse);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool ConstraintSpringSetEquilibriumPoint2(IntPtr constrain, int index, float equilibriumPoint);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool ConstraintSpringSetStiffness2(IntPtr constrain, int index, float stiffness);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool ConstraintSpringSetDamping2(IntPtr constrain, int index, float damping);
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern bool CalculateTransforms2(IntPtr constrain);

View File

@ -752,6 +752,44 @@ private sealed class BulletConstraintXNA : BulletConstraint
constraint.SetBreakingImpulseThreshold(threshold);
return true;
}
public override bool SpringEnable(BulletConstraint pConstraint, int index, float numericTrueFalse)
{
Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
constraint.EnableSpring(index, (numericTrueFalse == 0f ? false : true));
return true;
}
public override bool SpringSetEquilibriumPoint(BulletConstraint pConstraint, int index, float equilibriumPoint)
{
Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
if (index == -1)
{
constraint.SetEquilibriumPoint();
}
else
{
if (equilibriumPoint == -1)
constraint.SetEquilibriumPoint(index);
else
constraint.SetEquilibriumPoint(index, equilibriumPoint);
}
return true;
}
public override bool SpringSetStiffness(BulletConstraint pConstraint, int index, float stiffness)
{
Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
constraint.SetStiffness(index, stiffness);
return true;
}
public override bool SpringSetDamping(BulletConstraint pConstraint, int index, float damping)
{
Generic6DofSpringConstraint constraint = (pConstraint as BulletConstraintXNA).constrain as Generic6DofSpringConstraint;
constraint.SetDamping(index, damping);
return true;
}
//BulletSimAPI.SetAngularDamping(Prim.PhysBody.ptr, angularDamping);
public override void SetAngularDamping(BulletBody pBody, float angularDamping)
{

View File

@ -441,6 +441,14 @@ public abstract bool TranslationalLimitMotor(BulletConstraint constrain, float e
public abstract bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold);
public abstract bool SpringEnable(BulletConstraint constrain, int index, float numericTrueFalse);
public abstract bool SpringSetEquilibriumPoint(BulletConstraint constrain, int index, float equilibriumPoint);
public abstract bool SpringSetStiffness(BulletConstraint constrain, int index, float stiffnesss);
public abstract bool SpringSetDamping(BulletConstraint constrain, int index, float damping);
public abstract bool CalculateTransforms(BulletConstraint constrain);
public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);