From 26dcaeb0562af7ce4c52c9abf7cd65a83f307b8c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 19 Oct 2015 10:10:43 -0700 Subject: [PATCH] try another way of fixing held object snagging at slow velocity --- libraries/physics/src/EntityMotionState.cpp | 7 ++++++- libraries/physics/src/ObjectMotionState.cpp | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 2290f5832e..a8194f76e3 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -194,7 +194,12 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) { _entity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset()); _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->setLastSimulated(usecTimestampNow()); diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 8bd6c3c983..7a384e32d1 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -80,9 +80,7 @@ void ObjectMotionState::setBodyGravity(const glm::vec3& gravity) const { } glm::vec3 ObjectMotionState::getBodyLinearVelocity() const { - // returns the body's velocity - btVector3 velocity = _body->getLinearVelocity(); - return bulletToGLM(velocity); + return bulletToGLM(_body->getLinearVelocity()); } glm::vec3 ObjectMotionState::getObjectLinearVelocityChange() const {