Change the tile light group node mask to traverse VASI lights too.
authortimoore <timoore>
Mon, 24 Mar 2008 21:41:30 +0000 (21:41 +0000)
committertimoore <timoore>
Mon, 24 Mar 2008 21:41:30 +0000 (21:41 +0000)
The change to set the light group node mask to LIGHTS_BITS caused
VASI/PAPI lights to not be displayed during the day. This patch fixes
that and optimizes VASI creation a bit.

simgear/scene/tgdb/obj.cxx

index 4f3a3be0603d213b5196dd2c21e7be0768584cb0..7576c0495feca9f79bd82b3db69fd386fdf0b5e4 100644 (file)
@@ -691,8 +691,9 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool
       lightGroup->addChild(groundLights2);
     }
   }
-    
+
   if (!tileGeometryBin.vasiLights.empty()) {
+    osg::Geode* vasiGeode = new osg::Geode;
     SGVec4f red(1, 0, 0, 1);
     SGMaterial* mat = matlib->find("RWY_RED_LIGHTS");
     if (mat)
@@ -702,17 +703,14 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool
     if (mat)
       white = mat->get_light_color();
 
-    osg::Geode* geode = new osg::Geode;
     SGDirectionalLightListBin::const_iterator i;
     for (i = tileGeometryBin.vasiLights.begin();
          i != tileGeometryBin.vasiLights.end(); ++i) {
-      geode->addDrawable(SGLightFactory::getVasi(up, *i, red, white));
+      vasiGeode->addDrawable(SGLightFactory::getVasi(up, *i, red, white));
     }
-    osg::Group* vasiLights = new osg::Group;
-    vasiLights->setCullCallback(new SGPointSpriteLightCullCallback(osg::Vec3(1, 0.0001, 0.000001), 6));
-    vasiLights->setStateSet(lightManager->getRunwayLightStateSet());
-    vasiLights->addChild(geode);
-    lightGroup->addChild(vasiLights);
+    vasiGeode->setCullCallback(new SGPointSpriteLightCullCallback(osg::Vec3(1, 0.0001, 0.000001), 6));
+    vasiGeode->setStateSet(lightManager->getRunwayLightStateSet());
+    lightGroup->addChild(vasiGeode);
   }
 
   if (tileGeometryBin.runwayLights.getNumLights() > 0
@@ -765,7 +763,8 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool
   if (lightGroup->getNumChildren() > 0) {
     osg::LOD* lightLOD = new osg::LOD;
     lightLOD->addChild(lightGroup.get(), 0, 30000);
-    lightLOD->setNodeMask(LIGHTS_BITS);
+    // VASI is always on, so doesn't use light bits.
+    lightLOD->setNodeMask(LIGHTS_BITS | MODEL_BIT); 
     transform->addChild(lightLOD);
   }