Skip to content

Commit

Permalink
#5949: Don't update the renderable geometry in StaticModelNode::_onTr…
Browse files Browse the repository at this point in the history
…ansformationChanged() if nothing has changed
  • Loading branch information
codereader committed Apr 29, 2022
1 parent 81bce09 commit 54cd1b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion radiantcore/model/StaticModel.cpp
Expand Up @@ -274,9 +274,12 @@ void StaticModel::setModelPath(const std::string& modelPath)
_modelPath = modelPath;
}

void StaticModel::revertScale()
bool StaticModel::revertScale()
{
if (_scaleTransformed == _scale) return false;

_scaleTransformed = _scale;
return true;
}

void StaticModel::evaluateScale(const Vector3& scale)
Expand Down
4 changes: 2 additions & 2 deletions radiantcore/model/StaticModel.h
Expand Up @@ -202,8 +202,8 @@ class StaticModel :
*/
const SurfaceList& getSurfaces() const;

// Revert to base scale
void revertScale();
// Revert to base scale (returns true if the scale was actually changed by this call)
bool revertScale();

// TransformationChanged, apply the given scale to the "working copy"
void evaluateScale(const Vector3& scale);
Expand Down
9 changes: 6 additions & 3 deletions radiantcore/model/StaticModelNode.cpp
Expand Up @@ -234,9 +234,12 @@ void StaticModelNode::_onTransformationChanged()
{
// Transformation has been changed but no transform mode is set,
// so the reason we got here is a cancelTransform() call, revert everything
_model->revertScale();
_model->evaluateScale(Vector3(1,1,1));
queueRenderableUpdate();
if (_model->revertScale())
{
// revertScale returned true, the scale has actually been modified
_model->evaluateScale(Vector3(1,1,1));
queueRenderableUpdate();
}
}
}

Expand Down

0 comments on commit 54cd1b6

Please sign in to comment.