From 93ac70ead43f057f7e8b5429d305e9feb803f8c5 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 15 Jun 2018 10:28:12 -0700 Subject: [PATCH] avoid crash in inertia calculation of btBvhTriangleMeshShape --- libraries/physics/src/ObjectMotionState.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 64d2368207..161d6bd636 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -92,7 +92,7 @@ void ObjectMotionState::setMass(float mass) { } float ObjectMotionState::getMass() const { - if (_shape) { + if (_shape && _shape->getShapeType() != TRIANGLE_MESH_SHAPE_PROXYTYPE) { // scale the density by the current Aabb volume to get mass btTransform transform; transform.setIdentity(); @@ -348,8 +348,10 @@ void ObjectMotionState::updateLastKinematicStep() { void ObjectMotionState::updateBodyMassProperties() { float mass = getMass(); - btVector3 inertia(0.0f, 0.0f, 0.0f); - _body->getCollisionShape()->calculateLocalInertia(mass, inertia); + btVector3 inertia(1.0f, 1.0f, 1.0f); + if (mass > 0.0f) { + _body->getCollisionShape()->calculateLocalInertia(mass, inertia); + } _body->setMassProps(mass, inertia); _body->updateInertiaTensor(); }