mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #6843 from AndrewMeadows/sadness
fix bug causing grab to disappear objects
This commit is contained in:
commit
fcd2284dc8
2 changed files with 7 additions and 8 deletions
|
@ -241,7 +241,6 @@ void ObjectAction::activateBody(bool forceActivation) {
|
||||||
auto rigidBody = getRigidBody();
|
auto rigidBody = getRigidBody();
|
||||||
if (rigidBody) {
|
if (rigidBody) {
|
||||||
rigidBody->activate(forceActivation);
|
rigidBody->activate(forceActivation);
|
||||||
assert(rigidBody->isActive());
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "ObjectAction::activateBody -- no rigid body" << (void*)rigidBody;
|
qDebug() << "ObjectAction::activateBody -- no rigid body" << (void*)rigidBody;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,16 +58,16 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) {
|
||||||
|
|
||||||
const float MAX_TIMESCALE = 600.0f; // 10 min is a long time
|
const float MAX_TIMESCALE = 600.0f; // 10 min is a long time
|
||||||
if (_linearTimeScale < MAX_TIMESCALE) {
|
if (_linearTimeScale < MAX_TIMESCALE) {
|
||||||
|
btVector3 targetVelocity(0.0f, 0.0f, 0.0f);
|
||||||
btVector3 offset = rigidBody->getCenterOfMassPosition() - glmToBullet(_positionalTarget);
|
btVector3 offset = rigidBody->getCenterOfMassPosition() - glmToBullet(_positionalTarget);
|
||||||
float offsetLength = offset.length();
|
float offsetLength = offset.length();
|
||||||
btVector3 targetVelocity(0.0f, 0.0f, 0.0f);
|
if (offsetLength > FLT_EPSILON) {
|
||||||
|
float speed = glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED);
|
||||||
float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f;
|
targetVelocity = (-speed / offsetLength) * offset;
|
||||||
targetVelocity = (-speed / offsetLength) * offset;
|
if (speed > rigidBody->getLinearSleepingThreshold()) {
|
||||||
if (speed > rigidBody->getLinearSleepingThreshold()) {
|
rigidBody->activate();
|
||||||
rigidBody->activate();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this action is aggresively critically damped and defeats the current velocity
|
// this action is aggresively critically damped and defeats the current velocity
|
||||||
rigidBody->setLinearVelocity(targetVelocity);
|
rigidBody->setLinearVelocity(targetVelocity);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue