Skip to content

Commit

Permalink
#5893: Remove LightSources interface
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Feb 13, 2022
1 parent 4548390 commit 612eda2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 78 deletions.
50 changes: 0 additions & 50 deletions include/irender.h
Expand Up @@ -286,51 +286,6 @@ typedef std::function<void(Renderable&)> RenderableCallback;

typedef std::function<void(const RendererLight&)> RendererLightCallback;

/**
* \brief
* Simple container of light sources
*
* This is a storage class used to represent all light sources which fall upon
* a particular object. It is passed to the RenderSystem at render time to
* provide the list of lights which intersect the Renderable being submitted.
*/
class LightSources
{
public:

/// Invoke a callback on all contained lights.
virtual void forEachLight(const RendererLightCallback& callback) const = 0;
};

/// Debug stream insertion for LightSources
inline std::ostream& operator<< (std::ostream& s, const LightSources& ls)
{
s << "LightSources(";

// Insert comma-separated list of RendererLights
bool addComma = false;
ls.forEachLight(
[&](const RendererLight& l)
{
if (addComma)
s << ", ";
s << l;
addComma = true;
}
);

return s << ")";
}

/// Debug stream insertion for possibly null LightSources pointer
inline std::ostream& operator<< (std::ostream& s, const LightSources* ls)
{
if (ls)
return s << *ls;
else
return s << "[no lightsources]";
}

const int c_attr_TexCoord0 = 1;
const int c_attr_Tangent = 3;
const int c_attr_Binormal = 4;
Expand Down Expand Up @@ -460,16 +415,11 @@ class Shader :
* \param modelview
* The modelview transform for this object.
*
* \param lights
* Optional LightSources containing all of the lights which illuminate this
* object.
*
* \param entity
* Optional IRenderEntity exposing entity-related render parameters.
*/
virtual void addRenderable(const OpenGLRenderable& renderable,
const Matrix4& modelview,
const LightSources* lights = nullptr,
const IRenderEntity* entity = nullptr) = 0;

/**
Expand Down
1 change: 0 additions & 1 deletion include/irenderable.h
Expand Up @@ -11,7 +11,6 @@ class RenderSystem;
typedef std::shared_ptr<RenderSystem> RenderSystemPtr;

class OpenGLRenderable;
class LightSources;
class Matrix4;
class IRenderEntity;
class RendererLight;
Expand Down
6 changes: 3 additions & 3 deletions libs/render/CamRenderer.h
Expand Up @@ -71,18 +71,18 @@ class CamRenderer :

if (mergeShader)
{
mergeShader->addRenderable(renderable, localToWorld, nullptr, nullptr);
mergeShader->addRenderable(renderable, localToWorld, nullptr);
}
}

if ((_flags & Highlight::Flags::Primitives) != 0 && _shaders.primitiveHighlightShader)
{
_shaders.primitiveHighlightShader->addRenderable(renderable, localToWorld, nullptr, nullptr);
_shaders.primitiveHighlightShader->addRenderable(renderable, localToWorld, nullptr);
}

if ((_flags & Highlight::Flags::Faces) != 0 && _shaders.faceHighlightShader)
{
_shaders.faceHighlightShader->addRenderable(renderable, localToWorld, nullptr, nullptr);
_shaders.faceHighlightShader->addRenderable(renderable, localToWorld, nullptr);
}
}
};
Expand Down
10 changes: 5 additions & 5 deletions radiant/xyview/XYRenderer.h
Expand Up @@ -46,7 +46,7 @@ class XYRenderer :
{
addHighlightRenderable(renderable, localToWorld);

shader.addRenderable(renderable, localToWorld, nullptr, entity);
shader.addRenderable(renderable, localToWorld, entity);
}

void addHighlightRenderable(const OpenGLRenderable& renderable, const Matrix4& localToWorld) override
Expand All @@ -62,14 +62,14 @@ class XYRenderer :

if (mergeShader)
{
mergeShader->addRenderable(renderable, localToWorld, nullptr, nullptr);
mergeShader->addRenderable(renderable, localToWorld, nullptr);
}
}

// Elements can still be selected in merge mode
if ((_flags & Highlight::Flags::Primitives) != 0)
{
_shaders.selectedShader->addRenderable(renderable, localToWorld, nullptr, nullptr);
_shaders.selectedShader->addRenderable(renderable, localToWorld, nullptr);
}

return;
Expand All @@ -80,11 +80,11 @@ class XYRenderer :
{
if ((_flags & Highlight::Flags::GroupMember) != 0)
{
_shaders.selectedShaderGroup->addRenderable(renderable, localToWorld, nullptr, nullptr);
_shaders.selectedShaderGroup->addRenderable(renderable, localToWorld, nullptr);
}
else
{
_shaders.selectedShader->addRenderable(renderable, localToWorld, nullptr, nullptr);
_shaders.selectedShader->addRenderable(renderable, localToWorld, nullptr);
}
}
}
Expand Down
20 changes: 2 additions & 18 deletions radiantcore/rendersystem/backend/OpenGLShader.cpp
Expand Up @@ -89,31 +89,15 @@ void OpenGLShader::destroy()

void OpenGLShader::addRenderable(const OpenGLRenderable& renderable,
const Matrix4& modelview,
const LightSources* lights,
const IRenderEntity* entity)
{
if (!_isVisible) return;

// Add the renderable to all of our shader passes
for (const OpenGLShaderPassPtr& pass : _shaderPasses)
{
// If the shader pass cares about lighting, submit the renderable once
// for each incident light
if (pass->state().testRenderFlag(RENDER_BUMP))
{
if (lights)
{
lights->forEachLight([&](const RendererLight& light)
{
pass->addRenderable(renderable, modelview, &light, entity);
});
}
}
else
{
// No lighting, submit the renderable once
pass->addRenderable(renderable, modelview, nullptr, entity);
}
// Submit the renderable to each pass
pass->addRenderable(renderable, modelview, nullptr, entity);
}
}

Expand Down
1 change: 0 additions & 1 deletion radiantcore/rendersystem/backend/OpenGLShader.h
Expand Up @@ -98,7 +98,6 @@ class OpenGLShader :
std::string getName() const override { return _name; }
void addRenderable(const OpenGLRenderable& renderable,
const Matrix4& modelview,
const LightSources* lights,
const IRenderEntity* entity) override;

bool hasSurfaces() const;
Expand Down

0 comments on commit 612eda2

Please sign in to comment.