Skip to content

Commit

Permalink
Add new interface method RenderableCollector::addLight()
Browse files Browse the repository at this point in the history
This will be the entry point for light sources into the render front-end,
eventually replacing the "back channel" into the RenderSystem via
attachLight(). The new method is called from LightNode::renderSolid() but
currently has an empty implementation in each RenderableCollector.
  • Loading branch information
Matthew Mott committed Sep 2, 2020
1 parent 64547b9 commit a99eb27
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
37 changes: 23 additions & 14 deletions include/irenderable.h
Expand Up @@ -12,6 +12,7 @@ class OpenGLRenderable;
class LightSources;
class Matrix4;
class IRenderEntity;
class RendererLight;

/**
* \brief
Expand All @@ -25,7 +26,6 @@ class IRenderEntity;
* Renderable model class may submit each of its material surfaces separately
* with different shaders.
*/

class RenderableCollector
{
public:
Expand Down Expand Up @@ -57,6 +57,17 @@ class RenderableCollector
const LightSources* lights = nullptr,
const IRenderEntity* entity = nullptr) = 0;

/**
* \brief
* Submit a light source for the render operation.
*
* This is the entry point for lights into the render front-end. Each light
* in the scene graph must be submitted through this method in order to
* provide light for the final render. If the render is in wireframe mode,
* light sources can still be submitted but they will not have any effect.
*/
virtual void addLight(const RendererLight& light) = 0;

/**
* \brief
* Determine if this RenderableCollector can accept renderables for full
Expand Down Expand Up @@ -84,18 +95,19 @@ class RenderableCollector

class VolumeTest;

/** Interface class for Renderable objects. All objects which wish to be
* rendered need to implement this interface. During the scenegraph traversal
* for rendering, each Renderable object is passed a RenderableCollector object
* which it can use to submit its geometry and state parameters.
/**
* \brief
* Main interface for Renderable scene objects.
*
* All objects which wish to be rendered need to implement this interface.
* During the scenegraph traversal for rendering, each Renderable object is
* passed a RenderableCollector object which it can use to submit its geometry
* and state parameters.
*/

class Renderable
{
public:
/**
* Destructor
*/
/// Destroy the Renderable
virtual ~Renderable() {}

/**
Expand All @@ -104,14 +116,11 @@ class Renderable
*/
virtual void setRenderSystem(const RenderSystemPtr& renderSystem) = 0;

/** Submit renderable geometry when rendering takes place in Solid mode.
*/
/// Submit renderable geometry when rendering in Solid mode.
virtual void renderSolid(RenderableCollector& collector,
const VolumeTest& volume) const = 0;

/** Submit renderable geometry when rendering takes place in Wireframe
* mode.
*/
/// Submit renderable geometry when rendering in Wireframe mode.
virtual void renderWireframe(RenderableCollector& collector,
const VolumeTest& volume) const = 0;

Expand Down
2 changes: 2 additions & 0 deletions libs/render/SimpleFrontendRenderer.h
Expand Up @@ -26,6 +26,8 @@ class SimpleFrontendRenderer :
shader.addRenderable(renderable, world, lights, entity);
}

void addLight(const RendererLight&) override {}

bool supportsFullMaterials() const override
{
return true;
Expand Down
3 changes: 3 additions & 0 deletions radiant/camera/CamWnd.cpp
Expand Up @@ -630,6 +630,9 @@ class CamRenderer: public RenderableCollector
}
}

void addLight(const RendererLight& /* light */) override
{}

void addRenderable(Shader& shader, const OpenGLRenderable& renderable,
const Matrix4& world, const LightSources* lights,
const IRenderEntity* entity) override
Expand Down
18 changes: 11 additions & 7 deletions radiant/entity/light/LightNode.cpp
Expand Up @@ -267,15 +267,19 @@ void LightNode::selectedChangedComponent(const ISelectable& selectable) {
*/
void LightNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
{
EntityNode::renderSolid(collector, volume);
// Submit self to the renderer as an actual light source
collector.addLight(*this);

// Re-use the same method as in wireframe rendering for the moment
const bool lightIsSelected = isSelected();
_light.renderWireframe(
collector, volume, localToWorld(), lightIsSelected
);
// Render the visible representation of the light entity (origin, bounds etc)
EntityNode::renderSolid(collector, volume);

renderInactiveComponents(collector, volume, lightIsSelected);
// Re-use the same method as in wireframe rendering for the moment
const bool lightIsSelected = isSelected();
_light.renderWireframe(
collector, volume, localToWorld(), lightIsSelected
);

renderInactiveComponents(collector, volume, lightIsSelected);
}

void LightNode::renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const
Expand Down
7 changes: 5 additions & 2 deletions radiant/xyview/XYRenderer.h
Expand Up @@ -2,8 +2,8 @@

#include "irenderable.h"

class XYRenderer :
public RenderableCollector
/// RenderableCollector implementation for the ortho view
class XYRenderer: public RenderableCollector
{
// State type structure
struct State
Expand Down Expand Up @@ -50,6 +50,9 @@ class XYRenderer :
}
}

// Ortho view never processes lights
void addLight(const RendererLight&) override {}

void addRenderable(Shader& shader,
const OpenGLRenderable& renderable,
const Matrix4& world, const LightSources* lights,
Expand Down

0 comments on commit a99eb27

Please sign in to comment.