diff options
Diffstat (limited to 'extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp')
-rw-r--r-- | extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp b/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp index 01c2dbf031d..be6793dc192 100644 --- a/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp +++ b/extern/bullet/BulletDynamics/ConstraintSolver/ContactConstraint.cpp @@ -139,28 +139,31 @@ SimdScalar rel_vel; */ rel_vel = normal.dot(vel); -// if (rel_vel< 0.f)//-SIMD_EPSILON) -// { float combinedRestitution = body1.getRestitution() * body2.getRestitution(); - SimdScalar rest = restitutionCurve(rel_vel, combinedRestitution); -// SimdScalar massTerm = 1.f / (body1.getInvMass() + body2.getInvMass()); + SimdScalar restitution = restitutionCurve(rel_vel, combinedRestitution); - SimdScalar timeCorrection = 0.5f / solverInfo.m_timeStep ; + SimdScalar Kfps = 1.f / solverInfo.m_timeStep ; float damping = solverInfo.m_damping ; - float tau = solverInfo.m_tau; - + float Kerp = solverInfo.m_tau; + if (useGlobalSettingContacts) { damping = contactDamping; - tau = contactTau; + Kerp = contactTau; } - SimdScalar penetrationImpulse = (-distance* tau *timeCorrection) * jacDiagABInv; - + float Kcor = Kerp *Kfps; + + + SimdScalar positionalError = Kcor *-distance; + //jacDiagABInv; + SimdScalar velocityError = -(1.0f + restitution) * damping * rel_vel; + + SimdScalar penetrationImpulse = positionalError * jacDiagABInv; - SimdScalar velocityImpulse = -(1.0f + rest) * damping * rel_vel * jacDiagABInv; + SimdScalar velocityImpulse = velocityError * jacDiagABInv; SimdScalar friction_impulse = 0.f; @@ -177,11 +180,11 @@ SimdScalar rel_vel; { - SimdVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); - SimdVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); - SimdVector3 vel = vel1 - vel2; - - rel_vel = normal.dot(vel); + SimdVector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1); + SimdVector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2); + SimdVector3 vel = vel1 - vel2; + + rel_vel = normal.dot(vel); #define PER_CONTACT_FRICTION #ifdef PER_CONTACT_FRICTION |