Skip to content

Commit

Permalink
#6009: Add notification method INode::onFiltersChanged which should b…
Browse files Browse the repository at this point in the history
…e invoked for every node in the tree when the filter system changed its state
  • Loading branch information
codereader committed Oct 29, 2022
1 parent 3eec85b commit f30361f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/inode.h
Expand Up @@ -259,6 +259,10 @@ class INode :

// Called during recursive transform changed, but only by INodes themselves
virtual void transformChangedLocal() = 0;

// Method invoked on every node whenever the filter system
// changes its state - nodes get a chance to react on that
virtual void onFiltersChanged() = 0;
};

/// Cast an INode to a particular interface
Expand Down
10 changes: 10 additions & 0 deletions libs/scene/BasicRootNode.h
Expand Up @@ -108,6 +108,16 @@ class BasicRootNode final :
{
return Node::getRenderSystem();
}

void onFiltersChanged() override
{
// Recursively notify the whole tree
foreachNode([](const INodePtr& node)
{
node->onFiltersChanged();
return true;
});
}
};

}
4 changes: 4 additions & 0 deletions libs/scene/Node.h
Expand Up @@ -194,6 +194,10 @@ class Node : public virtual INode, public std::enable_shared_from_this<Node>
virtual RenderSystemPtr getRenderSystem() const;
void setRenderSystem(const RenderSystemPtr& renderSystem) override;

// The default implementation doesn't react to this call
void onFiltersChanged() override
{}

protected:
// Set the "forced visible" flag, only to be used internally by subclasses
virtual void setForcedVisibility(bool forceVisible, bool includeChildren) override;
Expand Down
10 changes: 10 additions & 0 deletions radiantcore/map/RootNode.cpp
Expand Up @@ -109,4 +109,14 @@ void RootNode::onChildRemoved(const scene::INodePtr& child)
Node::onChildRemoved(child);
}

void RootNode::onFiltersChanged()
{
// Recursively notify the whole tree
foreachNode([](const scene::INodePtr& node)
{
node->onFiltersChanged();
return true;
});
}

} // namespace map
2 changes: 2 additions & 0 deletions radiantcore/map/RootNode.h
Expand Up @@ -97,6 +97,8 @@ class RootNode :
{
return Node::getRenderSystem();
}

void onFiltersChanged() override;
};
typedef std::shared_ptr<RootNode> RootNodePtr;

Expand Down

0 comments on commit f30361f

Please sign in to comment.