From e336c9276dde27f5e3f6ca73f4e08d6f3c37c508 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 1 Aug 2018 17:39:57 -0700 Subject: [PATCH] first set shape THEN use it --- interface/src/avatar/AvatarMotionState.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/interface/src/avatar/AvatarMotionState.cpp b/interface/src/avatar/AvatarMotionState.cpp index bff5233f1d..07e6b3f6b0 100644 --- a/interface/src/avatar/AvatarMotionState.cpp +++ b/interface/src/avatar/AvatarMotionState.cpp @@ -181,15 +181,12 @@ float AvatarMotionState::getMass() const { void AvatarMotionState::cacheShapeDiameter() { if (_shape) { - // measure XZ diameter of capsule shape + // shape is capsuleY btVector3 aabbMin, aabbMax; btTransform transform; transform.setIdentity(); _shape->getAabb(transform, aabbMin, aabbMax); - aabbMax -= aabbMin; - aabbMax.setY(0.0f); - const float SQRT_TWO = 1.414213562f; - _diameter = SQRT_TWO * aabbMax.length(); + _diameter = (aabbMax - aabbMin).getX(); } else { _diameter = 0.0f; } @@ -204,6 +201,6 @@ void AvatarMotionState::setRigidBody(btRigidBody* body) { } void AvatarMotionState::setShape(const btCollisionShape* shape) { - cacheShapeDiameter(); ObjectMotionState::setShape(shape); + cacheShapeDiameter(); }