History

activate sprung objects when action strong enough

Andrew Meadows committed 10 years ago

Commit 6a5a7471 parent 2288d961 file · +7 −6Browse files

Showing the changes to libraries/physics/src/ObjectActionSpring.cpp (1 of 1 file). Show all

Unified · Split

libraries/physics/src/ObjectActionSpring.cpp+7−6
@@ -62,9 +62,10 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { · 61 unmodified lines
6262 float offsetLength = offset.length();
6363 btVector3 targetVelocity(0.0f, 0.0f, 0.0f);
6464
65− if (offsetLength > 0) {
66− float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f;
65+ float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f;
66+ if (speed > rigidBody->getLinearSleepingThreshold()) {
6767 targetVelocity = (-speed / offsetLength) * offset;
68+ rigidBody->activate();
6869 }
6970
7071 // this action is aggresively critically damped and defeats the current velocity
@@ -90,10 +91,10 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { · 19 unmodified lines
9091 //
9192 // dQ = Q1 * Q0^
9293 btQuaternion deltaQ = target * bodyRotation.inverse();
93− float angle = deltaQ.getAngle();
94− const float MIN_ANGLE = 1.0e-4f;
95− if (angle > MIN_ANGLE) {
96− targetVelocity = (angle / _angularTimeScale) * deltaQ.getAxis();
94+ float speed = deltaQ.getAngle() / _angularTimeScale;
95+ if (speed > rigidBody->getAngularSleepingThreshold()) {
96+ targetVelocity = speed * deltaQ.getAxis();
97+ rigidBody->activate();
9798 }
9899 }
99100 // this action is aggresively critically damped and defeats the current velocity