try another way of fixing held object snagging at slow velocity

This commit is contained in:
Seth Alves 2015-10-19 10:10:43 -07:00
parent fbe3cb9511
commit 26dcaeb056
2 changed files with 7 additions and 4 deletions

View file

@ -194,7 +194,12 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
_entity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset()); _entity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset());
_entity->setRotation(bulletToGLM(worldTrans.getRotation())); _entity->setRotation(bulletToGLM(worldTrans.getRotation()));
_entity->setVelocity(getBodyLinearVelocity()); glm::vec3 velocity = getBodyLinearVelocity();
if (glm::length2(velocity) < MIN_LINEAR_SPEED_SQUARED) {
velocity *= 0.0f;
}
_entity->setVelocity(velocity);
_entity->setAngularVelocity(getBodyAngularVelocity()); _entity->setAngularVelocity(getBodyAngularVelocity());
_entity->setLastSimulated(usecTimestampNow()); _entity->setLastSimulated(usecTimestampNow());

View file

@ -80,9 +80,7 @@ void ObjectMotionState::setBodyGravity(const glm::vec3& gravity) const {
} }
glm::vec3 ObjectMotionState::getBodyLinearVelocity() const { glm::vec3 ObjectMotionState::getBodyLinearVelocity() const {
// returns the body's velocity return bulletToGLM(_body->getLinearVelocity());
btVector3 velocity = _body->getLinearVelocity();
return bulletToGLM(velocity);
} }
glm::vec3 ObjectMotionState::getObjectLinearVelocityChange() const { glm::vec3 ObjectMotionState::getObjectLinearVelocityChange() const {