Changed the Optimizer::StateVisitor so that it can individually decide whether
to optimize away duplicate state with dynamic, static and unspecified DataVarience. By default the code now optimizes away duplicate state with either static and unspecied state, previously it was just handling static state.
This commit is contained in:
@@ -188,7 +188,11 @@ void Optimizer::optimize(osg::Node* node, unsigned int options)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"Optimizer::optimize() doing SHARE_DUPLICATE_STATE"<<std::endl;
|
||||
|
||||
StateVisitor osv(this);
|
||||
bool combineDynamicState = false;
|
||||
bool combineStaticState = true;
|
||||
bool combineUnspecifiedState = true;
|
||||
|
||||
StateVisitor osv(combineDynamicState, combineStaticState, combineUnspecifiedState, this);
|
||||
node->accept(osv);
|
||||
osv.optimize();
|
||||
}
|
||||
@@ -203,7 +207,11 @@ void Optimizer::optimize(osg::Node* node, unsigned int options)
|
||||
tav.optimize();
|
||||
|
||||
// now merge duplicate state, that may have been introduced by merge textures into texture atlas'
|
||||
StateVisitor osv(this);
|
||||
bool combineDynamicState = false;
|
||||
bool combineStaticState = true;
|
||||
bool combineUnspecifiedState = true;
|
||||
|
||||
StateVisitor osv(combineDynamicState, combineStaticState, combineUnspecifiedState, this);
|
||||
node->accept(osv);
|
||||
osv.optimize();
|
||||
}
|
||||
@@ -464,7 +472,7 @@ void Optimizer::StateVisitor::optimize()
|
||||
aitr!=attributes.end();
|
||||
++aitr)
|
||||
{
|
||||
if (aitr->second.first->getDataVariance()==osg::Object::STATIC)
|
||||
if (optimize(aitr->second.first->getDataVariance()))
|
||||
{
|
||||
attributeToStateSetMap[aitr->second.first.get()].insert(StateSetUnitPair(sitr->first,NON_TEXTURE_ATTRIBUTE));
|
||||
}
|
||||
@@ -479,7 +487,7 @@ void Optimizer::StateVisitor::optimize()
|
||||
aitr!=attributes.end();
|
||||
++aitr)
|
||||
{
|
||||
if (aitr->second.first->getDataVariance()==osg::Object::STATIC)
|
||||
if (optimize(aitr->second.first->getDataVariance()))
|
||||
{
|
||||
attributeToStateSetMap[aitr->second.first.get()].insert(StateSetUnitPair(sitr->first,unit));
|
||||
}
|
||||
@@ -492,7 +500,7 @@ void Optimizer::StateVisitor::optimize()
|
||||
uitr!=uniforms.end();
|
||||
++uitr)
|
||||
{
|
||||
if (uitr->second.first->getDataVariance()==osg::Object::STATIC)
|
||||
if (optimize(uitr->second.first->getDataVariance()))
|
||||
{
|
||||
uniformToStateSetMap[uitr->second.first.get()].insert(sitr->first);
|
||||
}
|
||||
|
||||
@@ -646,9 +646,8 @@ END_REFLECTOR
|
||||
BEGIN_OBJECT_REFLECTOR(osgUtil::Optimizer::StateVisitor)
|
||||
I_DeclaringFile("osgUtil/Optimizer");
|
||||
I_BaseType(osgUtil::BaseOptimizerVisitor);
|
||||
I_ConstructorWithDefaults1(IN, osgUtil::Optimizer *, optimizer, 0,
|
||||
Properties::NON_EXPLICIT,
|
||||
____StateVisitor__Optimizer_P1,
|
||||
I_ConstructorWithDefaults4(IN, bool, combineDynamicState, , IN, bool, combineStaticState, , IN, bool, combineUnspecifiedState, , IN, osgUtil::Optimizer *, optimizer, 0,
|
||||
____StateVisitor__bool__bool__bool__Optimizer_P1,
|
||||
"default to traversing all children. ",
|
||||
"");
|
||||
I_Method0(void, reset,
|
||||
@@ -677,6 +676,12 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::Optimizer::StateVisitor)
|
||||
__void__addStateSet__osg_StateSet_P1__osg_Object_P1,
|
||||
"",
|
||||
"");
|
||||
I_ProtectedMethod1(bool, optimize, IN, osg::Object::DataVariance, variance,
|
||||
Properties::NON_VIRTUAL,
|
||||
Properties::NON_CONST,
|
||||
__bool__optimize__osg_Object_DataVariance,
|
||||
"",
|
||||
"");
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgUtil::Optimizer::StaticObjectDetectionVisitor)
|
||||
|
||||
Reference in New Issue
Block a user