From ae186d46c68ea442d84f97937857caa60f193f3d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 23 Apr 2018 14:46:23 -0700 Subject: [PATCH] don't try to build convex hulls with nan data --- libraries/physics/src/ShapeFactory.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/ShapeFactory.cpp b/libraries/physics/src/ShapeFactory.cpp index f484f32fdf..5abeb022aa 100644 --- a/libraries/physics/src/ShapeFactory.cpp +++ b/libraries/physics/src/ShapeFactory.cpp @@ -114,6 +114,11 @@ btConvexHullShape* createConvexHull(const ShapeInfo::PointList& points) { minCorner = glm::min(minCorner, points[i]); } center /= (float)(points.size()); + if (glm::any(glm::isnan(center))) { + // don't feed garbage to Bullet + assert(false); // crash here in DEBUG so we can investigate source of bad input + return nullptr; + } float margin = hull->getMargin(); @@ -265,7 +270,7 @@ btTriangleIndexVertexArray* createStaticMeshArray(const ShapeInfo& info) { } const btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info) { - btCollisionShape* shape = NULL; + btCollisionShape* shape = nullptr; int type = info.getType(); switch(type) { case SHAPE_TYPE_BOX: {