From a5d12fc97d13daeba9326af0d5c5cd223936f34e Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 10 Dec 2022 14:33:34 +0100 Subject: [PATCH 1/3] 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; From 088da60116f678c84a9eff2b179af525e4c45394 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 10 Dec 2022 17:07:31 +0100 Subject: [PATCH 2/3] Added epsilon for dimensions of sphere in SphereCollapse --- libraries/physics/src/MultiSphereShape.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/MultiSphereShape.cpp b/libraries/physics/src/MultiSphereShape.cpp index 372c2e8ec8..42de501eef 100644 --- a/libraries/physics/src/MultiSphereShape.cpp +++ b/libraries/physics/src/MultiSphereShape.cpp @@ -210,6 +210,7 @@ MultiSphereShape::CollapsingMode MultiSphereShape::computeSpheres(ExtractionMode auto& diff = data._diff; auto& epsilon = data._epsilon; auto& dimensions = data._dimensions; + const float DIMENSIONS_EPSILON = 0.000001f; if (_mode == ExtractionMode::Automatic) { if (diff.xy < 0.5f * epsilon.xy && diff.xz < 0.5f * epsilon.xz && diff.yz < 0.5f * epsilon.yz) { @@ -243,7 +244,7 @@ MultiSphereShape::CollapsingMode MultiSphereShape::computeSpheres(ExtractionMode break; case ExtractionMode::SphereCollapse: sphere._radius = 0.5f * glm::min(glm::min(dimensions.x, dimensions.y), dimensions.z); - if (sphere._radius > 0.0f) { + if (sphere._radius > DIMENSIONS_EPSILON) { sphere._position = glm::vec3(0.0f); _spheres.push_back(sphere); } else { From 20e673e36431d824e6e49b1fac37a45ddba76a39 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 10 Dec 2022 19:51:11 +0100 Subject: [PATCH 3/3] Fixed weight comparison --- libraries/model-serializers/src/GLTFSerializer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/model-serializers/src/GLTFSerializer.cpp b/libraries/model-serializers/src/GLTFSerializer.cpp index c3bb3022b7..2304440a9f 100755 --- a/libraries/model-serializers/src/GLTFSerializer.cpp +++ b/libraries/model-serializers/src/GLTFSerializer.cpp @@ -1572,7 +1572,8 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash& glm::vec3 globalMeshScale = extractScale(globalTransforms[nodeIndex]); const glm::mat4 meshToJoint = glm::scale(glm::mat4(), globalMeshScale) * jointInverseBindTransforms[clusterIndex]; - const float EXPANSION_WEIGHT_THRESHOLD = 0.25f; + // TODO: The entire clustering is probably broken and detailed collision shapes fail to generate due to it. + const uint16_t EXPANSION_WEIGHT_THRESHOLD = UINT16_MAX/4; // Equivalent of 0.25f? if (mesh.clusterWeights[j] >= EXPANSION_WEIGHT_THRESHOLD) { // TODO: fix transformed vertices being pushed back auto& vertex = mesh.vertices[i];