Merge pull request #15324 from AndrewMeadows/avoid-nan-model-scale

Case 22054: flat models can introduce nan into geometry
This commit is contained in:
Sam Gateau 2019-04-04 14:51:19 -07:00 committed by GitHub
commit bda54c71ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -1289,6 +1289,8 @@ void Model::scaleToFit() {
// size is our "target size in world space"
// we need to set our model scale so that the extents of the mesh, fit in a box that size...
glm::vec3 meshDimensions = modelMeshExtents.maximum - modelMeshExtents.minimum;
const glm::vec3 MIN_MESH_DIMENSIONS { 1.0e-6f }; // one micrometer
meshDimensions = glm::max(meshDimensions, MIN_MESH_DIMENSIONS);
glm::vec3 rescaleDimensions = _scaleToFitDimensions / meshDimensions;
setScaleInternal(rescaleDimensions);
_scaledToFit = true;

View file

@ -397,7 +397,7 @@ protected:
glm::vec3 _translation; // this is the translation in world coordinates to the model's registration point
glm::quat _rotation;
glm::vec3 _scale;
glm::vec3 _scale { 1.0f };
glm::vec3 _overrideTranslation;
glm::quat _overrideRotation;