avoid nan in Model::_scale

This commit is contained in:
Andrew Meadows 2019-04-04 08:28:03 -07:00
parent 0d8169bd35
commit 72ac35c6f7
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;