@ -212,15 +212,17 @@ namespace Shader
void ShaderVisitor : : apply ( osg : : Node & node )
{
if ( node . getStateSet ( ) )
bool needPop = false ;
if ( node . getStateSet ( ) | | mRequirements . empty ( ) )
{
needPop = true ;
pushRequirements ( node ) ;
if ( node . getStateSet ( ) )
applyStateSet ( node . getStateSet ( ) , node ) ;
traverse ( node ) ;
popRequirements ( ) ;
}
else
traverse ( node ) ;
if ( needPop )
popRequirements ( ) ;
}
osg : : StateSet * getWritableStateSet ( osg : : Node & node )
@ -865,12 +867,12 @@ namespace Shader
void ShaderVisitor : : apply ( osg : : Geometry & geometry )
{
bool needPop = ( geometry . getStateSet ( ) ! = nullptr ) ;
if ( geometry . getStateSet ( ) ) // TODO: check if stateset affects shader permutation before pushing it
{
bool needPop = geometry . getStateSet ( ) | | mRequirements . empty ( ) ;
if ( needPop )
pushRequirements ( geometry ) ;
if ( geometry . getStateSet ( ) ) // TODO: check if stateset affects shader permutation before pushing it
applyStateSet ( geometry . getStateSet ( ) , geometry ) ;
}
if ( ! mRequirements . empty ( ) )
{
@ -889,7 +891,7 @@ namespace Shader
void ShaderVisitor : : apply ( osg : : Drawable & drawable )
{
bool needPop = drawable . getStateSet ( ) ;
bool needPop = drawable . getStateSet ( ) | | mRequirements . empty ( ) ;
if ( needPop )
{
@ -899,8 +901,6 @@ namespace Shader
applyStateSet ( drawable . getStateSet ( ) , drawable ) ;
}
if ( ! mRequirements . empty ( ) )
{
const ShaderRequirements & reqs = mRequirements . back ( ) ;
createProgram ( reqs ) ;
@ -926,9 +926,6 @@ namespace Shader
osgaRig - > setSourceRigGeometry ( sourceOsgaRigGeometry ) ;
}
}
}
else
ensureFFP ( drawable ) ;
if ( needPop )
popRequirements ( ) ;