Moved _stateset = new StateSet instances to setStateSet(new StateSet) to make

sure the wiring up of the StateSet parents is done consistently
This commit is contained in:
Robert Osfield
2008-08-25 10:20:20 +00:00
parent 8d8852bc23
commit ff35465a33
4 changed files with 16 additions and 6 deletions

View File

@@ -19,13 +19,14 @@ using namespace osg;
ClipNode::ClipNode():
_value(StateAttribute::ON)
{
_stateset = new StateSet;
setStateSet(new StateSet);
}
ClipNode::ClipNode(const ClipNode& cn, const CopyOp& copyop):
Group(cn,copyop),
_value(cn._value)
{
setStateSet(new StateSet);
for(ClipPlaneList::const_iterator itr=cn._planes.begin();
itr!=cn._planes.end();
++itr)
@@ -136,7 +137,8 @@ void ClipNode::setStateSetModes(StateSet& stateset,StateAttribute::GLModeValue v
void ClipNode::setLocalStateSetModes(StateAttribute::GLModeValue value)
{
_value = value;
if (!_stateset) _stateset = new StateSet;
if (!_stateset) setStateSet(new StateSet);
setStateSetModes(*_stateset,value);
}

View File

@@ -20,7 +20,7 @@ LightSource::LightSource():
{
// switch off culling of light source nodes by default.
setCullingActive(false);
_stateset = new StateSet;
setStateSet(new StateSet);
_light = new Light;
}
@@ -52,7 +52,8 @@ void LightSource::setStateSetModes(StateSet& stateset,StateAttribute::GLModeValu
void LightSource::setLocalStateSetModes(StateAttribute::GLModeValue value)
{
if (!_stateset) _stateset = new StateSet;
if (!_stateset) setStateSet(new StateSet);
_stateset->clear();
setStateSetModes(*_stateset,value);
}

View File

@@ -1714,15 +1714,20 @@ void StateSet::setEventCallback(Callback* ac)
_eventCallback = ac;
osg::notify(osg::NOTICE)<<"StateSet::setEventCallback("<<ac<<")"<<std::endl;
if (delta!=0 && _numChildrenRequiringEventTraversal==0)
{
for(ParentList::iterator itr=_parents.begin();
itr!=_parents.end();
++itr)
{
osg::notify(osg::NOTICE)<<" updating parent("<<*itr<<")"<<std::endl;
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(*itr);
if (drawable)
{
osg::notify(osg::NOTICE)<<" parent is a drawable("<<*itr<<")"<<std::endl;
//drawable->setNumChildrenRequiringUpdateTraversal(drawable->getNumChildrenRequiringUpdateTraversal()+delta);
}
else
@@ -1730,6 +1735,7 @@ void StateSet::setEventCallback(Callback* ac)
osg::Node* node = dynamic_cast<osg::Node*>(*itr);
if (node)
{
osg::notify(osg::NOTICE)<<" parent is a node("<<*itr<<")"<<std::endl;
node->setNumChildrenRequiringEventTraversal(node->getNumChildrenRequiringEventTraversal()+delta);
}
}

View File

@@ -22,7 +22,7 @@ TexGenNode::TexGenNode():
_textureUnit = 0;
_value = StateAttribute::ON;
_stateset = new StateSet;
setStateSet(new StateSet);
_texgen = new TexGen;
}
@@ -33,6 +33,7 @@ TexGenNode::TexGenNode(const TexGenNode& cn, const CopyOp& copyop):
_texgen(static_cast<TexGen*>(copyop(cn._texgen.get()))),
_referenceFrame(cn._referenceFrame)
{
setStateSet(new StateSet);
}
TexGenNode::TexGenNode(TexGen *texgen):
@@ -43,7 +44,7 @@ TexGenNode::TexGenNode(TexGen *texgen):
_textureUnit = 0;
_value = StateAttribute::ON;
_stateset = new StateSet;
setStateSet(new StateSet);
_texgen = texgen;
}