From a5d12fc97d13daeba9326af0d5c5cd223936f34e Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 10 Dec 2022 14:33:34 +0100 Subject: [PATCH] Made ExtractionMode::SphereCollapse fail more gracefully in case of incorrect data --- libraries/physics/src/MultiSphereShape.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/physics/src/MultiSphereShape.cpp b/libraries/physics/src/MultiSphereShape.cpp index 71702ac62b..372c2e8ec8 100644 --- a/libraries/physics/src/MultiSphereShape.cpp +++ b/libraries/physics/src/MultiSphereShape.cpp @@ -243,8 +243,12 @@ MultiSphereShape::CollapsingMode MultiSphereShape::computeSpheres(ExtractionMode break; case ExtractionMode::SphereCollapse: sphere._radius = 0.5f * glm::min(glm::min(dimensions.x, dimensions.y), dimensions.z); - sphere._position = glm::vec3(0.0f); - _spheres.push_back(sphere); + if (sphere._radius > 0.0f) { + sphere._position = glm::vec3(0.0f); + _spheres.push_back(sphere); + } else { + qDebug() << "MultiSphereShape::computeSpheres in mode ExtractionMode::SphereCollapse generated sphere with zero radius"; + } break; case ExtractionMode::SpheresX: axis = 0.5f* dimensions.x * Vectors::UNIT_NEG_X;