From 5a2c348b12f86d957411bd00308acafcb3441471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Li=C3=B1=C3=A1n?= Date: Fri, 1 Jan 2021 10:34:01 +0100 Subject: [PATCH] Our cull visitor no longer collects light sources by default --- simgear/scene/material/EffectCullVisitor.cxx | 11 +++++++---- simgear/scene/viewer/Compositor.cxx | 2 +- simgear/scene/viewer/CompositorPass.cxx | 4 +++- simgear/scene/viewer/CompositorPass.hxx | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/simgear/scene/material/EffectCullVisitor.cxx b/simgear/scene/material/EffectCullVisitor.cxx index e8750d86..c4fbfa07 100644 --- a/simgear/scene/material/EffectCullVisitor.cxx +++ b/simgear/scene/material/EffectCullVisitor.cxx @@ -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); - SGLight *light = dynamic_cast(&node); - if (light) - _lightList.push_back(light); + if (_collectLights) { + // TODO: Properly cull lights outside the viewport + // (override computeBounds() in SGLight) + SGLight *light = dynamic_cast(&node); + if (light) + _lightList.push_back(light); + } } void EffectCullVisitor::apply(osg::Geode& node) diff --git a/simgear/scene/viewer/Compositor.cxx b/simgear/scene/viewer/Compositor.cxx index 2d6d51af..2a93e980 100644 --- a/simgear/scene/viewer/Compositor.cxx +++ b/simgear/scene/viewer/Compositor.cxx @@ -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(); diff --git a/simgear/scene/viewer/CompositorPass.cxx b/simgear/scene/viewer/CompositorPass.cxx index b438b424..11068b4b 100644 --- a/simgear/scene/viewer/CompositorPass.cxx +++ b/simgear/scene/viewer/CompositorPass.cxx @@ -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)); diff --git a/simgear/scene/viewer/CompositorPass.hxx b/simgear/scene/viewer/CompositorPass.hxx index d8e26fa8..fc10be5f 100644 --- a/simgear/scene/viewer/CompositorPass.hxx +++ b/simgear/scene/viewer/CompositorPass.hxx @@ -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 camera; bool useMastersSceneData;