Merge pull request #6843 from AndrewMeadows/sadness

fix bug causing grab to disappear objects
This commit is contained in:
Seth Alves 2016-01-15 09:27:02 -08:00
commit fcd2284dc8
2 changed files with 7 additions and 8 deletions

View file

@ -241,7 +241,6 @@ void ObjectAction::activateBody(bool forceActivation) {
auto rigidBody = getRigidBody();
if (rigidBody) {
rigidBody->activate(forceActivation);
assert(rigidBody->isActive());
} else {
qDebug() << "ObjectAction::activateBody -- no rigid body" << (void*)rigidBody;
}

View file

@ -58,16 +58,16 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) {
const float MAX_TIMESCALE = 600.0f; // 10 min is a long time
if (_linearTimeScale < MAX_TIMESCALE) {
btVector3 targetVelocity(0.0f, 0.0f, 0.0f);
btVector3 offset = rigidBody->getCenterOfMassPosition() - glmToBullet(_positionalTarget);
float offsetLength = offset.length();
btVector3 targetVelocity(0.0f, 0.0f, 0.0f);
float speed = (offsetLength > FLT_EPSILON) ? glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED) : 0.0f;
targetVelocity = (-speed / offsetLength) * offset;
if (speed > rigidBody->getLinearSleepingThreshold()) {
rigidBody->activate();
if (offsetLength > FLT_EPSILON) {
float speed = glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED);
targetVelocity = (-speed / offsetLength) * offset;
if (speed > rigidBody->getLinearSleepingThreshold()) {
rigidBody->activate();
}
}
// this action is aggresively critically damped and defeats the current velocity
rigidBody->setLinearVelocity(targetVelocity);
}