X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Ftgdb%2Fpt_lights.cxx;h=7e123a475da55583f31b65ba2dd59e28ae846fa8;hb=e4dacaf0d270fb70beb2821888945b5e837afb50;hp=e4ec0d5995ae7de00936ffd9a3f603e121666ca2;hpb=ece38a6dbf4c4d7d4ab042f9096b2d69b02412d1;p=simgear.git diff --git a/simgear/scene/tgdb/pt_lights.cxx b/simgear/scene/tgdb/pt_lights.cxx index e4ec0d59..7e123a47 100644 --- a/simgear/scene/tgdb/pt_lights.cxx +++ b/simgear/scene/tgdb/pt_lights.cxx @@ -174,9 +174,12 @@ Effect* getLightEffect(float size, const Vec3& attenuation, PointParams pointParams(size, attenuation, minSize, maxSize, directional); ScopedLock lock(lightMutex); EffectMap::iterator eitr = effectMap.find(pointParams); - if ((eitr != effectMap.end())&& - eitr->second.valid()) - return eitr->second.get(); + if (eitr != effectMap.end()) + { + ref_ptr effect; + if (eitr->second.lock(effect)) + return effect.release(); + } // Basic stuff; no sprite or attenuation support Pass *basicPass = new Pass; basicPass->setRenderBinDetails(POINT_LIGHTS_BIN, "DepthSortedBin"); @@ -537,3 +540,35 @@ SGLightFactory::getOdal(const SGLightBin& lights) return sequence; } + +// Blinking hold short line lights +osg::Node* +SGLightFactory::getHoldShort(const SGDirectionalLightBin& lights) +{ + if (lights.getNumLights() < 2) + return 0; + + sg_srandom(unsigned(lights.getLight(0).position[0])); + float flashTime = 2 + 0.1 * sg_random(); + osg::Sequence* sequence = new osg::Sequence; + + // start with lights off + sequence->addChild(new osg::Group, flashTime); + // ...and increase the lights in steps + for (int i = 2; i < 7; i+=2) { + Effect* effect = getLightEffect(i, osg::Vec3(1, 0.001, 0.000002), + 0, i, true); + EffectGeode* egeode = new EffectGeode; + for (unsigned int j = 0; j < lights.getNumLights(); ++j) { + egeode->addDrawable(getLightDrawable(lights.getLight(j))); + egeode->setEffect(effect); + } + sequence->addChild(egeode, (i==6) ? flashTime : 0.1); + } + + sequence->setInterval(osg::Sequence::SWING, 0, -1); + sequence->setDuration(1.0f, -1); + sequence->setMode(osg::Sequence::START); + + return sequence; +}