if( dt == 0 && _drawable )
_drawable->getBound();
- if( _attributes_dirty & BLEND_FUNC )
+ if( (_attributes_dirty & BLEND_FUNC) && _transform.valid() )
{
parseBlendFunc(
_transform->getOrCreateStateSet(),
//----------------------------------------------------------------------------
void Element::setClip(const std::string& clip)
{
+ osg::StateSet* ss = getOrCreateStateSet();
+ if( !ss )
+ return;
+
if( clip.empty() || clip == "auto" )
{
- getOrCreateStateSet()->removeAttribute(osg::StateAttribute::SCISSOR);
+ ss->removeAttribute(osg::StateAttribute::SCISSOR);
_scissor = 0;
return;
}
else
_scissor->_coord_reference = GLOBAL;
- getOrCreateStateSet()->setAttributeAndModes(_scissor);
+ ss->setAttributeAndModes(_scissor);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
osg::StateSet* Element::getOrCreateStateSet()
{
- return _drawable ? _drawable->getOrCreateStateSet()
- : _transform->getOrCreateStateSet();
+ if( _drawable.valid() )
+ return _drawable->getOrCreateStateSet();
+ if( _transform.valid() )
+ return _transform->getOrCreateStateSet();
+
+ return 0;
}
//----------------------------------------------------------------------------