#include <math.h>
#include <algorithm>
+#include <OpenThreads/Mutex>
+#include <OpenThreads/ScopedLock>
+
#include <osg/AlphaFunc>
#include <osg/Drawable>
#include <osg/Geode>
}
\f
+// Don't create a new state state everytime we need GL_NORMALIZE!
+
+namespace
+{
+OpenThreads::Mutex normalizeMutex;
+
+osg::StateSet* getNormalizeStateSet()
+{
+ static osg::ref_ptr<osg::StateSet> normalizeStateSet;
+ OpenThreads::ScopedLock<OpenThreads::Mutex> lock(normalizeMutex);
+ if (!normalizeStateSet.valid()) {
+ normalizeStateSet = new osg::StateSet;
+ normalizeStateSet->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
+ normalizeStateSet->setDataVariance(osg::Object::STATIC);
+ }
+ return normalizeStateSet.get();
+}
+}
+
////////////////////////////////////////////////////////////////////////
// Implementation of dist scale animation
////////////////////////////////////////////////////////////////////////
{
setName(configNode->getStringValue("name", "dist scale animation"));
setReferenceFrame(RELATIVE_RF);
- getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
+ setStateSet(getNormalizeStateSet());
_factor = configNode->getFloatValue("factor", 1);
_offset = configNode->getFloatValue("offset", 0);
_min_v = configNode->getFloatValue("min", SGLimitsf::epsilon());
{
setReferenceFrame(RELATIVE_RF);
setName(configNode->getStringValue("name", "flash animation"));
- getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
+ setStateSet(getNormalizeStateSet());
_axis[0] = configNode->getFloatValue("axis/x", 0);
_axis[1] = configNode->getFloatValue("axis/y", 0);
osg::Geode* geode = new osg::Geode;
groundLights0->addChild(geode);
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.tileLights));
-
- groundLights0->addChild(geode);
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 4, -0.3f));
geode = new osg::Geode;