Showing the changes to libraries/physics/src/ObjectActionSpring.cpp (1 of 1 file). Show all
Unified · Split
| @@ -62,9 +62,10 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { · 61 unmodified lines | |||
| 62 | float offsetLength = offset.length(); | 62 | float offsetLength = offset.length(); |
| 63 | btVector3 targetVelocity(0.0f, 0.0f, 0.0f); | 63 | btVector3 targetVelocity(0.0f, 0.0f, 0.0f); |
| 64 | 64 | ||
| 65 | if (offsetLength > 0) { | 65 | float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f; |
| 66 | float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f; | 66 | if (speed > rigidBody->getLinearSleepingThreshold()) { |
| 67 | targetVelocity = (-speed / offsetLength) * offset; | 67 | targetVelocity = (-speed / offsetLength) * offset; |
| 68 | rigidBody->activate(); | ||
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | // this action is aggresively critically damped and defeats the current velocity | 71 | // this action is aggresively critically damped and defeats the current velocity |
| @@ -90,10 +91,10 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { · 19 unmodified lines | |||
| 90 | // | 91 | // |
| 91 | // dQ = Q1 * Q0^ | 92 | // dQ = Q1 * Q0^ |
| 92 | btQuaternion deltaQ = target * bodyRotation.inverse(); | 93 | btQuaternion deltaQ = target * bodyRotation.inverse(); |
| 93 | float angle = deltaQ.getAngle(); | 94 | float speed = deltaQ.getAngle() / _angularTimeScale; |
| 94 | const float MIN_ANGLE = 1.0e-4f; | 95 | if (speed > rigidBody->getAngularSleepingThreshold()) { |
| 95 | if (angle > MIN_ANGLE) { | 96 | targetVelocity = speed * deltaQ.getAxis(); |
| 96 | targetVelocity = (angle / _angularTimeScale) * deltaQ.getAxis(); | 97 | rigidBody->activate(); |
| 97 | } | 98 | } |
| 98 | } | 99 | } |
| 99 | // this action is aggresively critically damped and defeats the current velocity | 100 | // this action is aggresively critically damped and defeats the current velocity |