Our cull visitor no longer collects light sources by default

This commit is contained in:
Fernando García Liñán 2021-01-01 10:34:01 +01:00
parent b62808bb4c
commit 5a2c348b12
4 changed files with 13 additions and 6 deletions

View File

@ -54,11 +54,14 @@ CullVisitor* EffectCullVisitor::clone() const
void EffectCullVisitor::apply(osg::Node &node)
{
// TODO: Properly cull lights outside the viewport (override computeBounds())
CullVisitor::apply(node);
if (_collectLights) {
// TODO: Properly cull lights outside the viewport
// (override computeBounds() in SGLight)
SGLight *light = dynamic_cast<SGLight *>(&node);
if (light)
_lightList.push_back(light);
}
}
void EffectCullVisitor::apply(osg::Geode& node)

View File

@ -284,7 +284,7 @@ Compositor::addPass(Pass *pass)
identifier = sceneView->getCullVisitor()->getIdentifier();
sceneView->setCullVisitor(
new EffectCullVisitor(false, pass->effect_scheme));
new EffectCullVisitor(pass->collect_lights, pass->effect_scheme));
sceneView->getCullVisitor()->setIdentifier(identifier.get());
identifier = sceneView->getCullVisitorLeft()->getIdentifier();

View File

@ -682,8 +682,10 @@ public:
const SGPropertyNode *p_clustered = root->getNode("clustered-shading");
ClusteredShading *clustered = nullptr;
if (p_clustered) {
if (checkConditional(p_clustered))
if (checkConditional(p_clustered)) {
clustered = new ClusteredShading(camera, p_clustered);
pass->collect_lights = true;
}
}
camera->setCullCallback(new SceneCullCallback(clustered));

View File

@ -48,6 +48,7 @@ class Compositor;
*/
struct Pass : public osg::Referenced {
Pass() :
collect_lights(false),
useMastersSceneData(true),
cull_mask(0xffffff),
inherit_cull_mask(false),
@ -57,6 +58,7 @@ struct Pass : public osg::Referenced {
int render_order;
std::string name;
std::string type;
bool collect_lights;
std::string effect_scheme;
osg::ref_ptr<osg::Camera> camera;
bool useMastersSceneData;