keep small masses from introducing NaN into bullet's calculations

This commit is contained in:
Seth Alves 2018-06-08 16:07:01 -07:00
parent 0cadb95d62
commit a2399ea1f6

View file

@ -105,6 +105,10 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) {
}
case MOTION_TYPE_DYNAMIC: {
mass = motionState->getMass();
if (mass != mass || mass < 1.0f) {
qCDebug(physics) << "mass is too low, setting to 1.0 Kg --" << mass;
mass = 1.0f;
}
btCollisionShape* shape = const_cast<btCollisionShape*>(motionState->getShape());
assert(shape);
shape->calculateLocalInertia(mass, inertia);