root/OpenSceneGraph/trunk/src/osgUtil/StateGraph.cpp @ 13041

Revision 13041, 1.8 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13#include <osgUtil/StateGraph>
14
15#include <osg/Notify>
16
17using namespace osg;
18using namespace osgUtil;
19
20void StateGraph::reset()
21{
22    _parent = NULL;
23    _stateset = NULL;
24
25    _depth = 0;
26
27    _children.clear();
28    _leaves.clear();
29}
30
31/** recursively clean the StateGraph of all its drawables, lights and depths.
32  * Leaves children intact, and ready to be populated again.*/
33void StateGraph::clean()
34{
35
36    // clean local drawables etc.
37    _leaves.clear();
38
39    // call clean on all children.
40    for(ChildList::iterator itr=_children.begin();
41        itr!=_children.end();
42        ++itr)
43    {
44        itr->second->clean();
45    }
46
47}
48
49/** recursively prune the StateGraph of empty children.*/
50void StateGraph::prune()
51{
52    std::vector<const osg::StateSet*> toEraseList;
53
54    // call prune on all children.
55    for(ChildList::iterator citr=_children.begin();
56        citr!=_children.end();
57        ++citr)
58    {
59        citr->second->prune();
60
61        if (citr->second->empty())
62        {
63            toEraseList.push_back(citr->first);
64        }
65    }
66
67    for(std::vector<const osg::StateSet*>::iterator eitr=toEraseList.begin();
68        eitr!=toEraseList.end();
69        ++eitr)
70    {
71        _children.erase(*eitr);
72    }
73
74}
Note: See TracBrowser for help on using the browser.