Skip to content

Commit

Permalink
#5893: Extend IRenderEntity interface to enumerate renderables withou…
Browse files Browse the repository at this point in the history
…t bounds check
  • Loading branch information
codereader committed Feb 19, 2022
1 parent 6a2149a commit fe94f37
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/irender.h
Expand Up @@ -185,6 +185,11 @@ class IRenderEntity

using ObjectVisitFunction = std::function<void(const render::IRenderableObject::Ptr&, Shader*)>;

/**
* Enumerate all entity object, unconditionally.
*/
virtual void foreachRenderable(const ObjectVisitFunction& functor) = 0;

/**
* Enumerate all entity object (partially) intersecting with the given bounds.
* The bounds are specified in world coordinates.
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/entity/EntityNode.cpp
Expand Up @@ -223,6 +223,11 @@ void EntityNode::removeRenderable(const render::IRenderableObject::Ptr& object)
_renderObjects.removeRenderable(object);
}

void EntityNode::foreachRenderable(const IRenderEntity::ObjectVisitFunction& functor)
{
_renderObjects.foreachRenderable(functor);
}

void EntityNode::foreachRenderableTouchingBounds(const AABB& bounds,
const IRenderEntity::ObjectVisitFunction& functor)
{
Expand Down
1 change: 1 addition & 0 deletions radiantcore/entity/EntityNode.h
Expand Up @@ -133,6 +133,7 @@ class EntityNode :

virtual void addRenderable(const render::IRenderableObject::Ptr& object, Shader* shader) override;
virtual void removeRenderable(const render::IRenderableObject::Ptr& object) override;
virtual void foreachRenderable(const ObjectVisitFunction& functor) override;
virtual void foreachRenderableTouchingBounds(const AABB& bounds,
const ObjectVisitFunction& functor) override;

Expand Down
10 changes: 10 additions & 0 deletions radiantcore/entity/RenderableObjectCollection.h
Expand Up @@ -64,6 +64,16 @@ class RenderableObjectCollection :
_collectionBoundsNeedUpdate = true;
}

void foreachRenderable(const IRenderEntity::ObjectVisitFunction& functor)
{
ensureBoundsUpToDate();

for (const auto& [object, objectData] : _objects)
{
functor(object, objectData.shader);
}
}

void foreachRenderableTouchingBounds(const AABB& bounds,
const IRenderEntity::ObjectVisitFunction& functor)
{
Expand Down

0 comments on commit fe94f37

Please sign in to comment.