mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 18:34:48 +02:00
Merge pull request #278 from overte-org/fix/SphereCollapse
Made ExtractionMode::SphereCollapse fail more gracefully in case of incorrect data
This commit is contained in:
commit
c7a8f01234
2 changed files with 9 additions and 3 deletions
libraries
|
@ -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];
|
||||
|
|
|
@ -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,8 +244,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 > DIMENSIONS_EPSILON) {
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue