From 2af409f54dbed4513cf9ab3bbd4c542daea7dc9d Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Sun, 5 Feb 2012 23:35:39 +0100 Subject: [PATCH] Save work on shadows --- simgear/scene/material/EffectCullVisitor.cxx | 15 ++++++++++++++- simgear/scene/material/EffectCullVisitor.hxx | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/simgear/scene/material/EffectCullVisitor.cxx b/simgear/scene/material/EffectCullVisitor.cxx index 36f85eb4..9960a4d4 100644 --- a/simgear/scene/material/EffectCullVisitor.cxx +++ b/simgear/scene/material/EffectCullVisitor.cxx @@ -27,12 +27,15 @@ #include "Effect.hxx" #include "Technique.hxx" +#include + namespace simgear { using osgUtil::CullVisitor; -EffectCullVisitor::EffectCullVisitor() +EffectCullVisitor::EffectCullVisitor(bool collectLights) : + _collectLights(collectLights) { } @@ -56,6 +59,9 @@ void EffectCullVisitor::apply(osg::Geode& node) CullVisitor::apply(node); return; } + if (_collectLights && ( eg->getNodeMask() & MODELLIGHT_BIT ) ) { + _lightList.push_back( eg ); + } Effect* effect = eg->getEffect(); Technique* technique = 0; if (!effect) { @@ -80,6 +86,13 @@ void EffectCullVisitor::apply(osg::Geode& node) } +void EffectCullVisitor::reset() +{ + _lightList.clear(); + + osgUtil::CullVisitor::reset(); +} + void EffectCullVisitor::clearBufferList() { _bufferList.clear(); diff --git a/simgear/scene/material/EffectCullVisitor.hxx b/simgear/scene/material/EffectCullVisitor.hxx index 4f0054dd..c4d3c630 100644 --- a/simgear/scene/material/EffectCullVisitor.hxx +++ b/simgear/scene/material/EffectCullVisitor.hxx @@ -29,14 +29,16 @@ class Texture2D; namespace simgear { +class EffectGeode; class EffectCullVisitor : public osgUtil::CullVisitor { public: - EffectCullVisitor(); + EffectCullVisitor(bool collectLights = false); EffectCullVisitor(const EffectCullVisitor&); virtual osgUtil::CullVisitor* clone() const; using osgUtil::CullVisitor::apply; virtual void apply(osg::Geode& node); + virtual void reset(); void clearBufferList(); void addBuffer(int i, osg::Texture2D* tex); @@ -44,6 +46,8 @@ public: private: std::map > _bufferList; + std::vector > _lightList; + bool _collectLights; }; } #endif -- 2.39.5