mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:23:06 +02:00
activate sprung objects when action strong enough
This commit is contained in:
parent
2288d96868
commit
6a5a74700f
1 changed files with 7 additions and 6 deletions
|
@ -62,9 +62,10 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) {
|
||||||
float offsetLength = offset.length();
|
float offsetLength = offset.length();
|
||||||
btVector3 targetVelocity(0.0f, 0.0f, 0.0f);
|
btVector3 targetVelocity(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
if (offsetLength > 0) {
|
float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f;
|
||||||
float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f;
|
if (speed > rigidBody->getLinearSleepingThreshold()) {
|
||||||
targetVelocity = (-speed / offsetLength) * offset;
|
targetVelocity = (-speed / offsetLength) * offset;
|
||||||
|
rigidBody->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this action is aggresively critically damped and defeats the current velocity
|
// this action is aggresively critically damped and defeats the current velocity
|
||||||
|
@ -90,10 +91,10 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) {
|
||||||
//
|
//
|
||||||
// dQ = Q1 * Q0^
|
// dQ = Q1 * Q0^
|
||||||
btQuaternion deltaQ = target * bodyRotation.inverse();
|
btQuaternion deltaQ = target * bodyRotation.inverse();
|
||||||
float angle = deltaQ.getAngle();
|
float speed = deltaQ.getAngle() / _angularTimeScale;
|
||||||
const float MIN_ANGLE = 1.0e-4f;
|
if (speed > rigidBody->getAngularSleepingThreshold()) {
|
||||||
if (angle > MIN_ANGLE) {
|
targetVelocity = speed * deltaQ.getAxis();
|
||||||
targetVelocity = (angle / _angularTimeScale) * deltaQ.getAxis();
|
rigidBody->activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// this action is aggresively critically damped and defeats the current velocity
|
// this action is aggresively critically damped and defeats the current velocity
|
||||||
|
|
Loading…
Reference in a new issue