mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 23:53:26 +02:00
fix bug with attachments being stretched
This commit is contained in:
parent
ec23a7a868
commit
c32d5db75c
1 changed files with 15 additions and 1 deletions
|
@ -894,7 +894,21 @@ void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions) {
|
|||
}
|
||||
|
||||
void Model::setScaleToFit(bool scaleToFit, float largestDimension) {
|
||||
setScaleToFit(scaleToFit, glm::vec3(largestDimension, largestDimension, largestDimension));
|
||||
if (_scaleToFit != scaleToFit || glm::length(_scaleToFitDimensions) != largestDimension) {
|
||||
_scaleToFit = scaleToFit;
|
||||
|
||||
// we only need to do this work if we're "turning on" scale to fit.
|
||||
if (scaleToFit) {
|
||||
Extents modelMeshExtents = getUnscaledMeshExtents();
|
||||
float maxDimension = glm::distance(modelMeshExtents.maximum, modelMeshExtents.minimum);
|
||||
float maxScale = largestDimension / maxDimension;
|
||||
glm::vec3 modelMeshDimensions = modelMeshExtents.maximum - modelMeshExtents.minimum;
|
||||
glm::vec3 dimensions = modelMeshDimensions * maxScale;
|
||||
|
||||
_scaleToFitDimensions = dimensions;
|
||||
_scaledToFit = false; // force rescaling
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Model::scaleToFit() {
|
||||
|
|
Loading…
Reference in a new issue