]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/renderer.cxx
Update GroundLightManager
[flightgear.git] / src / Main / renderer.cxx
index bbb7557e2e99f352ed3ab0d138176d36133d5d77..e4f0d5230acf64265f421ff873440c364c89f0c4 100644 (file)
@@ -70,6 +70,8 @@
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/scene/model/placement.hxx>
 #include <simgear/scene/util/SGUpdateVisitor.hxx>
+#include <simgear/scene/util/RenderConstants.hxx>
+#include <simgear/scene/tgdb/GroundLightManager.hxx>
 #include <simgear/scene/tgdb/pt_lights.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/timing/sg_time.hxx>
 #include <Instrumentation/instrument_mgr.hxx>
 #include <Instrumentation/HUD/HUD.hxx>
 
+#include <Include/general.hxx>
 #include "splash.hxx"
 #include "renderer.hxx"
 #include "main.hxx"
 
 // XXX Make this go away when OSG 2.2 is released.
-#if ((2 <= OSG_VERSION_MAJOR) && (1 <= OSG_VERSION_MINOR) \
-     && (4 <= OSG_VERSION_PATCH))
+#if (FG_OSG_VERSION >= 21004)
 #define UPDATE_VISITOR_IN_VIEWER 1
 #endif
 
@@ -373,9 +375,7 @@ FGRenderer::FGRenderer()
 #ifdef FG_JPEG_SERVER
    jpgRenderFrame = FGRenderer::update;
 #endif
-#ifdef ENABLE_OSGVIEWER
    manipulator = new FGManipulator;
-#endif   
 }
 
 FGRenderer::~FGRenderer()
@@ -828,20 +828,19 @@ FGRenderer::update( bool refresh_camera_settings ) {
                              l->adj_fog_color(),
                              l->get_sun_angle()*SGD_RADIANS_TO_DEGREES);
     mUpdateVisitor->setVisibility(actual_visibility);
+    simgear::GroundLightManager::instance()->update(mUpdateVisitor.get());
     bool hotspots = fgGetBool("/sim/panel-hotspots");
+    osg::Node::NodeMask cullMask = ~simgear::LIGHTS_BITS & ~simgear::PICK_BIT;
+    cullMask |= simgear::GroundLightManager::instance()
+        ->getLightNodeMask(mUpdateVisitor.get());
+    if (hotspots)
+        cullMask |= simgear::PICK_BIT;
     if (viewer) {
-       if (hotspots)
-           camera->setCullMask(camera->getCullMask()|SG_NODEMASK_PICK_BIT);
-       else
-           camera->setCullMask(camera->getCullMask()
-                               & ~SG_NODEMASK_PICK_BIT);
+        camera->setCullMask(cullMask);
+        for (int i = 0; i < viewer->getNumSlaves(); ++i)
+            viewer->getSlave(i)._camera->setCullMask(cullMask);
     } else {
-       if (hotspots)
-           sceneView->setCullMask(sceneView->getCullMask()
-                                  |SG_NODEMASK_PICK_BIT);
-       else
-           sceneView->setCullMask(sceneView->getCullMask()
-                                  &(~SG_NODEMASK_PICK_BIT));
+        sceneView->setCullMask(cullMask);
        sceneView->update();
        sceneView->cull();
        sceneView->draw();
@@ -1071,5 +1070,12 @@ fgDumpSceneGraphToFile(const char* filename)
     return osgDB::writeNodeFile(*mRealRoot.get(), filename);
 }
 
+bool
+fgDumpTerrainBranchToFile(const char* filename)
+{
+    return osgDB::writeNodeFile( *globals->get_scenery()->get_terrain_branch(),
+                                 filename );
+}
+
 // end of renderer.cxx