Skip to content

Commit

Permalink
#5584: For oriented renderables that need to have the parent local2wo…
Browse files Browse the repository at this point in the history
…rld transform applied before rendering, there's not quick solution here.

Introduce Renderable::isOriented() which should return true to have the nodes rendered in the regular frontend pass.
Brushes and Patches return isOriented == false since their regular visual mesh is attached to the large vertex buffer in the material. They only get rendered if there's something to highlight like selections or merge visualisations.
  • Loading branch information
codereader committed Nov 13, 2021
1 parent cdafb3b commit e4bae9c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions include/irenderable.h
Expand Up @@ -172,6 +172,14 @@ class Renderable
virtual void onPreRender(const VolumeTest& volume)
{}

// Returns true if this renderable makes use of a non-identity model matrix,
// or submit their geometry in final world coordinates.
// Geometry of renderables returning true will not be streamlined into a larger buffer
virtual bool isOriented() const
{
return false; // by default, renderables render in world coordinates
}

/// Submit renderable geometry when rendering in Solid mode.
virtual void renderSolid(RenderableCollector& collector,
const VolumeTest& volume) const = 0;
Expand Down
4 changes: 2 additions & 2 deletions libs/render/RenderableCollectionWalker.h
Expand Up @@ -152,8 +152,8 @@ class RenderableCollectionWalker :
}

// If any of the above concludes that this node should be highlighted,
// ask it to submit its geometry.
if (_collector.hasHighlightFlags())
// ask it to submit its geometry. Oriented nodes are submitting every frame.
if (_collector.hasHighlightFlags() || node->isOriented())
{
dispatchRenderable(*node);
}
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/brush/BrushNode.h
Expand Up @@ -142,7 +142,7 @@ class BrushNode :
bool intersectsLight(const RendererLight& light) const override;

// Renderable implementation
virtual void onPreRender(const VolumeTest& volume) override;
void onPreRender(const VolumeTest& volume) override;
void renderComponents(RenderableCollector& collector, const VolumeTest& volume) const override;
void renderSolid(RenderableCollector& collector, const VolumeTest& volume) const override;
void renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const override;
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/entity/EntityNode.cpp
Expand Up @@ -352,6 +352,11 @@ scene::INode::Type EntityNode::getNodeType() const
return Type::Entity;
}

bool EntityNode::isOriented() const
{
return true;
}

void EntityNode::renderSolid(RenderableCollector& collector,
const VolumeTest& volume) const
{
Expand Down
1 change: 1 addition & 0 deletions radiantcore/entity/EntityNode.h
Expand Up @@ -144,6 +144,7 @@ class EntityNode :
Type getNodeType() const override;

// Renderable implementation, can be overridden by subclasses
virtual bool isOriented() const override;
virtual void renderSolid(RenderableCollector& collector, const VolumeTest& volume) const override;
virtual void renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const override;
virtual void setRenderSystem(const RenderSystemPtr& renderSystem) override;
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/model/StaticModelNode.cpp
Expand Up @@ -91,6 +91,11 @@ bool StaticModelNode::intersectsLight(const RendererLight& light) const
return light.lightAABB().intersects(worldAABB());
}

bool StaticModelNode::isOriented() const
{
return true;
}

void StaticModelNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
{
assert(_renderEntity);
Expand Down
1 change: 1 addition & 0 deletions radiantcore/model/StaticModelNode.h
Expand Up @@ -74,6 +74,7 @@ class StaticModelNode :
bool intersectsLight(const RendererLight& light) const override;

// Renderable implementation
bool isOriented() const override;
void renderSolid(RenderableCollector& collector, const VolumeTest& volume) const override;
void renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const override;
void setRenderSystem(const RenderSystemPtr& renderSystem) override;
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/particles/ParticleNode.cpp
Expand Up @@ -59,6 +59,11 @@ Matrix4 ParticleNode::localToParent() const
return _local2Parent;
}

bool ParticleNode::isOriented() const
{
return true;
}

void ParticleNode::renderSolid(RenderableCollector& collector,
const VolumeTest& volume) const
{
Expand Down
1 change: 1 addition & 0 deletions radiantcore/particles/ParticleNode.h
Expand Up @@ -35,6 +35,7 @@ class ParticleNode :
const AABB& localAABB() const override;
std::size_t getHighlightFlags() override;

bool isOriented() const override;
void renderSolid(RenderableCollector& collector, const VolumeTest& volume) const override;
void renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const override;

Expand Down

0 comments on commit e4bae9c

Please sign in to comment.