]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/EffectCullVisitor.cxx
8d86d8e0ea6972b6c3716cbca6e1f81ea49578a8
[simgear.git] / simgear / scene / material / EffectCullVisitor.cxx
1 // Copyright (C) 2008  Timothy Moore timoore@redhat.com
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17 #include "EffectCullVisitor.hxx"
18
19 #include "EffectGeode.hxx"
20 #include "Effect.hxx"
21 #include "Technique.hxx"
22
23 namespace simgear
24 {
25
26 using osgUtil::CullVisitor;
27
28 EffectCullVisitor::EffectCullVisitor()
29 {
30 }
31
32 EffectCullVisitor::EffectCullVisitor(const EffectCullVisitor& rhs) :
33     CullVisitor(rhs)
34 {
35 }
36
37 CullVisitor* EffectCullVisitor::clone() const
38 {
39     return new EffectCullVisitor(*this);
40 }
41
42 void EffectCullVisitor::apply(osg::Geode& node)
43 {
44     if (isCulled(node))
45         return;
46     EffectGeode *eg = dynamic_cast<EffectGeode*>(&node);
47     if (!eg) {
48         CullVisitor::apply(node);
49         return;
50     }
51     Technique* technique = eg->getEffect()->chooseTechnique(&getRenderInfo());
52     if (!technique) {
53         CullVisitor::apply(node);
54         return;
55     }
56     for (EffectGeode::DrawablesIterator beginItr = eg->drawablesBegin(),
57              e = eg->drawablesEnd();
58          beginItr != e;
59          beginItr = technique->processDrawables(beginItr, e, this,
60                                                 eg->isCullingActive()))
61         ;
62 }
63 }