Skip to content

Commit

Permalink
#5949: Update the renderables whenever the contained model applies th…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
codereader committed Apr 29, 2022
1 parent 54cd1b6 commit 8c4caad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions radiantcore/model/StaticModel.cpp
Expand Up @@ -184,6 +184,11 @@ sigc::signal<void>& StaticModel::signal_ShadersChanged()
return _sigShadersChanged;
}

sigc::signal<void>& StaticModel::signal_SurfaceScaleApplied()
{
return _sigSurfaceScaleApplied;
}

// Update the list of active materials
void StaticModel::updateMaterialList() const
{
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions radiantcore/model/StaticModel.h
Expand Up @@ -90,6 +90,7 @@ class StaticModel :
IUndoStateSaver* _undoStateSaver;

sigc::signal<void> _sigShadersChanged;
sigc::signal<void> _sigSurfaceScaleApplied;

private:

Expand Down Expand Up @@ -127,6 +128,9 @@ class StaticModel :
// A signal that is emitted after the captured shaders have been changed (or cleared)
sigc::signal<void>& signal_ShadersChanged();

// Signal emitted when any surface scale has been changed
sigc::signal<void>& signal_SurfaceScaleApplied();

/**
* Return the number of surfaces in this model.
*/
Expand Down
8 changes: 6 additions & 2 deletions radiantcore/model/StaticModelNode.cpp
Expand Up @@ -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("");
Expand Down Expand Up @@ -228,7 +229,6 @@ void StaticModelNode::_onTransformationChanged()
{
_model->revertScale();
_model->evaluateScale(getScale());
queueRenderableUpdate();
}
else if (getTransformationType() == TransformationType::NoTransform)
{
Expand All @@ -238,7 +238,6 @@ void StaticModelNode::_onTransformationChanged()
{
// revertScale returned true, the scale has actually been modified
_model->evaluateScale(Vector3(1,1,1));
queueRenderableUpdate();
}
}
}
Expand All @@ -265,4 +264,9 @@ void StaticModelNode::onVisibilityChanged(bool isVisibleNow)
}
}

void StaticModelNode::onModelScaleApplied()
{
queueRenderableUpdate();
}

} // namespace model
4 changes: 4 additions & 0 deletions radiantcore/model/StaticModelNode.h
Expand Up @@ -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;
Expand Down

0 comments on commit 8c4caad

Please sign in to comment.