]> git.mxchange.org Git - simgear.git/commitdiff
add global switch for particle systems
authormfranz <mfranz>
Fri, 17 Oct 2008 21:15:58 +0000 (21:15 +0000)
committermfranz <mfranz>
Fri, 17 Oct 2008 21:15:58 +0000 (21:15 +0000)
simgear/scene/model/particles.cxx
simgear/scene/model/particles.hxx

index 0194e960c4ff9a91a712e659efdf04f1758aa840..2dd2a0a46f5d8214b8259dc3b7890788db320dc1 100644 (file)
@@ -48,6 +48,9 @@ namespace simgear
 {
 void GlobalParticleCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
 {
+    enabled = !enabledNode || enabledNode->getBoolValue();
+    if (!enabled)
+        return;
     SGQuatd q
         = SGQuatd::fromLonLatDeg(modelRoot->getFloatValue("/position/longitude-deg",0),
                                  modelRoot->getFloatValue("/position/latitude-deg",0));
@@ -65,6 +68,8 @@ void GlobalParticleCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
 //static members
 osg::Vec3 GlobalParticleCallback::gravity;
 osg::Vec3 GlobalParticleCallback::wind;
+bool GlobalParticleCallback::enabled = true;
+SGConstPropertyNode_ptr GlobalParticleCallback::enabledNode = 0;
 
 osg::ref_ptr<osg::Group> Particles::commonRoot;
 osg::ref_ptr<osgParticle::ParticleSystemUpdater> Particles::psu = new osgParticle::ParticleSystemUpdater;
@@ -513,7 +518,7 @@ void Particles::operator()(osg::Node* node, osg::NodeVisitor* nv)
     else if (counterCond)
         counter->setRateRange(counterStaticValue,
                               counterStaticValue + counterStaticExtraRange);
-    if (counterCond && !counterCond->test())
+    if (!GlobalParticleCallback::getEnabled() || (counterCond && !counterCond->test()))
         counter->setRateRange(0, 0);
     bool colorchange=false;
     for (int i = 0; i < 8; ++i) {
index 4c9d5053f63bd55038ad14f57ffe0056612aea47..b01b190a4bc52cb9a51a46196b9aa8ec98b755c5 100644 (file)
@@ -86,10 +86,22 @@ public:
         return wind;
     }
 
+    static void setSwitch(const SGPropertyNode* n)
+    {
+        enabledNode = n;
+    }
+
+    static bool getEnabled()
+    {
+        return enabled;
+    }
+
 private:
     static osg::Vec3 gravity;
     static osg::Vec3 wind;
     const SGPropertyNode* modelRoot;
+    static SGConstPropertyNode_ptr enabledNode;
+    static bool enabled;
 };