14#ifndef OSGUTIL_STATEGRAPH
15#define OSGUTIL_STATEGRAPH 1
35 return (lhs->_depth < rhs->_depth);
46 typedef std::map< const osg::StateSet*, osg::ref_ptr<StateGraph> >
ChildList;
47 typedef std::vector< osg::ref_ptr<RenderLeaf> >
LeafList;
51#ifdef OSGUTIL_RENDERBACKEND_USE_REF_PTR
102 virtual const char*
className()
const {
return "StateGraph"; }
110#ifdef OSGUTIL_RENDERBACKEND_USE_REF_PTR
133 for(LeafList::const_iterator itr=
_leaves.begin();
149 LeafList::const_iterator itr=
_leaves.begin();
181 for(ChildList::iterator itr =
_children.begin();
188 for(LeafList::iterator itr =
_leaves.begin();
192 (*itr)->resizeGLObjectBuffers(maxSize);
200 for(ChildList::const_iterator itr =
_children.begin();
207 for(LeafList::const_iterator itr =
_leaves.begin();
211 (*itr)->releaseGLObjects(state);
218 ChildList::iterator itr =
_children.find(stateset);
219 if (itr!=
_children.end())
return itr->second.get();
243 if (sg_new==sg_curr || sg_new==
NULL)
return;
249 std::vector<StateGraph*> return_path;
250 return_path.reserve(sg_new->
_depth+1);
255 return_path.push_back(sg_new);
259 for(std::vector<StateGraph*>::reverse_iterator itr=return_path.rbegin();
260 itr!=return_path.rend();
291 std::vector<StateGraph*> return_path;
292 return_path.reserve(sg_new->
_depth+1);
297 return_path.push_back(sg_new);
306 while (sg_curr != sg_new)
311 return_path.push_back(sg_new);
315 for(std::vector<StateGraph*>::reverse_iterator itr=return_path.rbegin();
316 itr!=return_path.rend();
354 StateGraph& operator = (
const StateGraph&) {
return *
this; }
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
The osgUtil library provides general purpose utility classes such as update, cull and draw traverses,...
Definition NodeVisitor:25
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
@ DYNAMIC
Definition Object:218
DataVariance getDataVariance() const
Get the data variance of this object.
Definition Object:231
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Base class for providing reference counted objects.
Definition Referenced:44
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
void popStateSet()
Pop stateset off state stack.
void pushStateSet(const StateSet *dstate)
Push stateset onto state stack.
Stores a set of modes and attributes which represent a set of OpenGL state.
Definition StateSet:46
Container class for all data required for rendering of drawables.
Definition RenderLeaf:34
StateGraph * _parent
Definition RenderLeaf:92
bool _dynamic
Definition RenderLeaf:104
bool operator()(const osg::ref_ptr< RenderLeaf > &lhs, const osg::ref_ptr< RenderLeaf > &rhs)
Definition StateGraph:33
StateGraph - contained in a renderBin, defines the scene to be drawn.
Definition StateGraph:42
virtual const char * className() const
return the name of the object's class type.
Definition StateGraph:102
osg::ref_ptr< osg::Referenced > _userData
Definition StateGraph:64
float _minimumDistance
Definition StateGraph:62
bool _dynamic
Definition StateGraph:66
void clean()
Recursively clean the StateGraph of all its drawables, lights and depths.
StateGraph * find_or_insert(const osg::StateSet *stateset)
Definition StateGraph:215
ChildList _children
Definition StateGraph:58
virtual bool isSameKindAs(const osg::Object *obj) const
Definition StateGraph:100
StateGraph(StateGraph *parent, const osg::StateSet *stateset)
Definition StateGraph:79
osg::Referenced * getUserData()
Get user data.
Definition StateGraph:105
void releaseGLObjects(osg::State *state=0) const
If State is non-zero, this function releases any associated OpenGL objects for the specified graphics...
Definition StateGraph:196
LeafList _leaves
Definition StateGraph:59
float getAverageDistance() const
Definition StateGraph:128
void setStateSet(const osg::StateSet *stateset)
Definition StateGraph:108
bool leaves_empty() const
Definition StateGraph:122
virtual StateGraph * cloneStateGraph() const
Definition StateGraph:98
static int numToPop(StateGraph *sg_curr)
Definition StateGraph:336
virtual osg::Object * cloneType() const
Clone the type of an object, with Object* return type.
Definition StateGraph:97
StateGraph * _parent
Definition StateGraph:49
void reset()
Reset the internal contents of a StateGraph, including deleting all children.
static void moveToRootStateGraph(osg::State &state, StateGraph *sg_curr)
Definition StateGraph:325
StateGraph()
Definition StateGraph:68
void addLeaf(RenderLeaf *leaf)
add a render leaf.
Definition StateGraph:229
void prune()
Recursively prune the StateGraph of empty children.
void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
Definition StateGraph:179
void setUserData(osg::Referenced *obj)
Set user data, data must be subclassed from Referenced to allow automatic memory handling.
Definition StateGraph:104
std::map< const osg::StateSet *, osg::ref_ptr< StateGraph > > ChildList
Definition StateGraph:46
const osg::StateSet * getStateSet() const
Definition StateGraph:113
float getMinimumDistance() const
Definition StateGraph:145
virtual const char * libraryName() const
return the name of the object's library.
Definition StateGraph:101
float _averageDistance
Definition StateGraph:61
~StateGraph()
Definition StateGraph:94
static void moveStateGraph(osg::State &state, StateGraph *sg_curr, StateGraph *sg_new)
Definition StateGraph:241
bool empty() const
return true if all of drawables, lights and children are empty.
Definition StateGraph:117
int _depth
Definition StateGraph:57
void sortFrontToBack()
Definition StateGraph:163
const osg::StateSet * _stateset
Definition StateGraph:54
std::vector< osg::ref_ptr< RenderLeaf > > LeafList
Definition StateGraph:47
virtual osg::Object * clone(const osg::CopyOp &) const
Clone an object, with Object* return type.
Definition StateGraph:99
const osg::Referenced * getUserData() const
Get const user data.
Definition StateGraph:106
#define NULL
Definition Export:55
#define OSGUTIL_EXPORT
Definition Export:40