Changed the toggle of defines so that it works with assumed defaults now set up by the GeometryPool so that when toggling it doesn't have a delay in what the user would expect

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14708 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2015-02-20 15:12:57 +00:00
parent 72c4f3a8ba
commit 1320c923ca

View File

@@ -167,7 +167,7 @@ public:
}
else if (ea.getKey()=='d')
{
toggleDefine("COMPUTE_DIAGONALS");
toggleDefine("COMPUTE_DIAGONALS", osg::StateAttribute::OFF);
return true;
}
@@ -178,20 +178,21 @@ public:
}
}
void toggleDefine(const std::string& defineName)
void toggleDefine(const std::string& defineName, int expectedDefault=osg::StateAttribute::ON)
{
osg::StateSet::DefineList& defineList = _terrain->getOrCreateStateSet()->getDefineList();
osg::StateSet::DefineList::iterator itr = defineList.find(defineName);
if (itr==defineList.end())
{
defineList[defineName].second = (osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
else
{
osg::StateSet::DefinePair& dp = itr->second;
if ( (dp.second & osg::StateAttribute::ON)==0) dp.second = (osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
else dp.second = (osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
defineList[defineName].second = (expectedDefault | osg::StateAttribute::OVERRIDE); // assume the defines start off.
itr = defineList.find(defineName);
}
osg::StateSet::DefinePair& dp = itr->second;
if ( (dp.second & osg::StateAttribute::ON)==0) dp.second = (osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
else dp.second = (osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
}
protected: