From 8c4caad6f222c2efff08c030142137605c03d816 Mon Sep 17 00:00:00 2001 From: codereader Date: Fri, 29 Apr 2022 19:36:23 +0200 Subject: [PATCH] #5949: Update the renderables whenever the contained model applies the scale to its surfaces. This fixes the model renderables not reacting to undo/redo calls that are directly issued to the StaticModel instance, not the owning node. --- radiantcore/model/StaticModel.cpp | 8 ++++++++ radiantcore/model/StaticModel.h | 4 ++++ radiantcore/model/StaticModelNode.cpp | 8 ++++++-- radiantcore/model/StaticModelNode.h | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/radiantcore/model/StaticModel.cpp b/radiantcore/model/StaticModel.cpp index 636b999738..51c88f1de8 100644 --- a/radiantcore/model/StaticModel.cpp +++ b/radiantcore/model/StaticModel.cpp @@ -184,6 +184,11 @@ sigc::signal& StaticModel::signal_ShadersChanged() return _sigShadersChanged; } +sigc::signal& StaticModel::signal_SurfaceScaleApplied() +{ + return _sigSurfaceScaleApplied; +} + // Update the list of active materials void StaticModel::updateMaterialList() const { @@ -311,6 +316,9 @@ void StaticModel::applyScaleToSurfaces() // Extend the model AABB to include the surface's AABB _localAABB.includeAABB(surf.surface->getAABB()); } + + // Notify the model node to queue a renderable update + _sigSurfaceScaleApplied.emit(); } // Freeze transform, move the applied scale to the original model diff --git a/radiantcore/model/StaticModel.h b/radiantcore/model/StaticModel.h index 4b3eda2311..514016ffd8 100644 --- a/radiantcore/model/StaticModel.h +++ b/radiantcore/model/StaticModel.h @@ -90,6 +90,7 @@ class StaticModel : IUndoStateSaver* _undoStateSaver; sigc::signal _sigShadersChanged; + sigc::signal _sigSurfaceScaleApplied; private: @@ -127,6 +128,9 @@ class StaticModel : // A signal that is emitted after the captured shaders have been changed (or cleared) sigc::signal& signal_ShadersChanged(); + // Signal emitted when any surface scale has been changed + sigc::signal& signal_SurfaceScaleApplied(); + /** * Return the number of surfaces in this model. */ diff --git a/radiantcore/model/StaticModelNode.cpp b/radiantcore/model/StaticModelNode.cpp index 816a6f5fd2..d5c7a7a824 100644 --- a/radiantcore/model/StaticModelNode.cpp +++ b/radiantcore/model/StaticModelNode.cpp @@ -20,6 +20,7 @@ StaticModelNode::StaticModelNode(const StaticModelPtr& picoModel) : _attachedToShaders(false) { _model->signal_ShadersChanged().connect(sigc::mem_fun(*this, &StaticModelNode::onModelShadersChanged)); + _model->signal_SurfaceScaleApplied().connect(sigc::mem_fun(*this, &StaticModelNode::onModelScaleApplied)); // Update the skin skinChanged(""); @@ -228,7 +229,6 @@ void StaticModelNode::_onTransformationChanged() { _model->revertScale(); _model->evaluateScale(getScale()); - queueRenderableUpdate(); } else if (getTransformationType() == TransformationType::NoTransform) { @@ -238,7 +238,6 @@ void StaticModelNode::_onTransformationChanged() { // revertScale returned true, the scale has actually been modified _model->evaluateScale(Vector3(1,1,1)); - queueRenderableUpdate(); } } } @@ -265,4 +264,9 @@ void StaticModelNode::onVisibilityChanged(bool isVisibleNow) } } +void StaticModelNode::onModelScaleApplied() +{ + queueRenderableUpdate(); +} + } // namespace model diff --git a/radiantcore/model/StaticModelNode.h b/radiantcore/model/StaticModelNode.h index 71d55eeae9..5106b0e36e 100644 --- a/radiantcore/model/StaticModelNode.h +++ b/radiantcore/model/StaticModelNode.h @@ -93,6 +93,10 @@ class StaticModelNode final : void transformChangedLocal() override; + // Called when the contained model has applied the scale to its surfaces + // The Node listens to this and queues a renderable update + void onModelScaleApplied(); + protected: void _onTransformationChanged() override; void _applyTransformation() override;