Added osg::Node::getValidStateSet().

This commit is contained in:
Robert Osfield
2002-05-03 22:47:57 +00:00
parent 08a4fd5bfc
commit e296df4632
2 changed files with 14 additions and 2 deletions

View File

@@ -177,10 +177,15 @@ class SG_EXPORT Node : public Object
/** set the node's StateSet.*/
inline void setStateSet(osg::StateSet* dstate) { _dstate = dstate; }
/** return the node's StateSet.*/
/** return the node's StateSet, if one does not already exist create it
* set the node and return the newly created StateSet. This ensures
* that a valid StateSet is always returned and can be used directly.*/
osg::StateSet* getValidStateSet();
/** return the node's StateSet. returns NULL if a stateset is not attached.*/
inline osg::StateSet* getStateSet() { return _dstate.get(); }
/** return the node's const StateSet.*/
/** return the node's const StateSet. returns NULL if a stateset is not attached.*/
inline const osg::StateSet* getStateSet() const { return _dstate.get(); }
/** get the bounding sphere of node.

View File

@@ -68,6 +68,13 @@ void Node::ascend(NodeVisitor& nv)
std::for_each(_parents.begin(),_parents.end(),NodeAcceptOp(nv));
}
osg::StateSet* Node::getValidStateSet()
{
if (!_dstate) _dstate = osgNew StateSet;
return _dstate.get();
}
void Node::setAppCallback(NodeCallback* nc)
{
// if no changes just return.