diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-03-31 12:08:16 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-04-09 19:14:35 +0300 |
commit | 26a283deae7a3b78a197d4bcf4bfd288c598aedc (patch) | |
tree | e6c38423101f5c63b8476a96e26b3be391fedd58 /intern/rigidbody/rb_bullet_api.cpp | |
parent | 7e39d151d850590fbabc9870bc5134d9421c5c2c (diff) |
Use the newer version of the bullet 6dof spring constraint for rigidbody.
The new constraint is slower and not backward compatible, but should
be better, especially in the damping side. The new constraint also
has a different valid range of the damping coefficient, and a limit
implementation that bounces instead of making the object stationary.
Reviewers: sergof
Differential Revision: https://developer.blender.org/D3125
Diffstat (limited to 'intern/rigidbody/rb_bullet_api.cpp')
-rw-r--r-- | intern/rigidbody/rb_bullet_api.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp index 17bb3817908..a9fbcb28529 100644 --- a/intern/rigidbody/rb_bullet_api.cpp +++ b/intern/rigidbody/rb_bullet_api.cpp @@ -954,7 +954,7 @@ rbConstraint *RB_constraint_new_6dof_spring(float pivot[3], float orn[4], rbRigi make_constraint_transforms(transform1, transform2, body1, body2, pivot, orn); - btTypedConstraint *con = new btGeneric6DofSpringConstraint(*body1, *body2, transform1, transform2, true); + btTypedConstraint *con = new btGeneric6DofSpring2Constraint(*body1, *body2, transform1, transform2); return (rbConstraint *)con; } @@ -1034,32 +1034,38 @@ void RB_constraint_set_limits_6dof(rbConstraint *con, int axis, float lower, flo constraint->setLimit(axis, lower, upper); } +void RB_constraint_set_limits_6dof_spring(rbConstraint *con, int axis, float lower, float upper) +{ + btGeneric6DofSpring2Constraint *constraint = reinterpret_cast<btGeneric6DofSpring2Constraint*>(con); + + constraint->setLimit(axis, lower, upper); +} + void RB_constraint_set_stiffness_6dof_spring(rbConstraint *con, int axis, float stiffness) { - btGeneric6DofSpringConstraint *constraint = reinterpret_cast<btGeneric6DofSpringConstraint*>(con); - + btGeneric6DofSpring2Constraint *constraint = reinterpret_cast<btGeneric6DofSpring2Constraint*>(con); + constraint->setStiffness(axis, stiffness); } void RB_constraint_set_damping_6dof_spring(rbConstraint *con, int axis, float damping) { - btGeneric6DofSpringConstraint *constraint = reinterpret_cast<btGeneric6DofSpringConstraint*>(con); - - // invert damping range so that 0 = no damping - constraint->setDamping(axis, 1.0f - damping); + btGeneric6DofSpring2Constraint *constraint = reinterpret_cast<btGeneric6DofSpring2Constraint*>(con); + + constraint->setDamping(axis, damping); } void RB_constraint_set_spring_6dof_spring(rbConstraint *con, int axis, int enable) { - btGeneric6DofSpringConstraint *constraint = reinterpret_cast<btGeneric6DofSpringConstraint*>(con); - + btGeneric6DofSpring2Constraint *constraint = reinterpret_cast<btGeneric6DofSpring2Constraint*>(con); + constraint->enableSpring(axis, enable); } void RB_constraint_set_equilibrium_6dof_spring(rbConstraint *con) { - btGeneric6DofSpringConstraint *constraint = reinterpret_cast<btGeneric6DofSpringConstraint*>(con); - + btGeneric6DofSpring2Constraint *constraint = reinterpret_cast<btGeneric6DofSpring2Constraint*>(con); + constraint->setEquilibriumPoint(); } |