// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#ifdef HAVE_CONFIG_H
+# include <simgear_config.h>
+#endif
+
+#include <osg/StateSet>
+#include <osg/Texture2D>
+
#include "EffectCullVisitor.hxx"
#include "EffectGeode.hxx"
#include "Effect.hxx"
#include "Technique.hxx"
+#include <simgear/scene/util/RenderConstants.hxx>
+
namespace simgear
{
using osgUtil::CullVisitor;
-EffectCullVisitor::EffectCullVisitor()
+EffectCullVisitor::EffectCullVisitor(bool collectLights) :
+ _collectLights(collectLights)
{
}
EffectCullVisitor::EffectCullVisitor(const EffectCullVisitor& rhs) :
+ osg::Referenced(rhs),
CullVisitor(rhs)
{
}
CullVisitor::apply(node);
return;
}
- Technique* technique = eg->getEffect()->chooseTechnique(&getRenderInfo());
- if (!technique) {
+ if (_collectLights && ( eg->getNodeMask() & MODELLIGHT_BIT ) ) {
+ _lightList.push_back( eg );
+ }
+ Effect* effect = eg->getEffect();
+ Technique* technique = 0;
+ if (!effect) {
CullVisitor::apply(node);
return;
+ } else if (!(technique = effect->chooseTechnique(&getRenderInfo()))) {
+ return;
}
+ // push the node's state.
+ osg::StateSet* node_state = node.getStateSet();
+ if (node_state)
+ pushStateSet(node_state);
for (EffectGeode::DrawablesIterator beginItr = eg->drawablesBegin(),
e = eg->drawablesEnd();
beginItr != e;
beginItr = technique->processDrawables(beginItr, e, this,
eg->isCullingActive()))
;
+ // pop the node's state off the geostate stack.
+ if (node_state)
+ popStateSet();
+
+}
+
+void EffectCullVisitor::reset()
+{
+ _lightList.clear();
+
+ osgUtil::CullVisitor::reset();
}
+
+void EffectCullVisitor::clearBufferList()
+{
+ _bufferList.clear();
+}
+
+void EffectCullVisitor::addBuffer(int i, osg::Texture2D* tex)
+{
+ _bufferList.insert(std::make_pair(i,tex));
+}
+
+osg::Texture2D* EffectCullVisitor::getBuffer(int i)
+{
+ return _bufferList[i];
+}
+
}