]> git.mxchange.org Git - flightgear.git/commitdiff
Add command to reload materials definitions. Note that this explicitly
authorStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Thu, 19 Jul 2012 21:06:08 +0000 (22:06 +0100)
committerStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Thu, 19 Jul 2012 21:06:08 +0000 (22:06 +0100)
does not attempt to delete the old materials definitions, as they
may be in use at the time.

src/Main/fg_commands.cxx
src/Scenery/tilemgr.cxx

index 9c11836aebff2b2802505bf3983ac710fb2d77a6..21711098b75ddfc52503f90e9ba68af5ecf0ea63 100644 (file)
@@ -531,6 +531,30 @@ do_tile_cache_reload (const SGPropertyNode * arg)
     return true;
 }
 
+/**
+ * Reload the materials definition
+ */
+ static bool
+ do_materials_reload (const SGPropertyNode * arg)
+ {
+   SG_LOG(SG_INPUT, SG_INFO, "Reloading Materials");
+   SGMaterialLib* new_matlib =  new SGMaterialLib;
+   SGPath mpath( globals->get_fg_root() );
+   mpath.append( fgGetString("/sim/rendering/materials-file") );
+   bool loaded = new_matlib->load(globals->get_fg_root(), 
+                                  mpath.str(), 
+                                  globals->get_props());
+   
+   if ( ! loaded ) {
+       SG_LOG( SG_GENERAL, SG_ALERT,
+               "Error loading materials file " << mpath.str() );
+       return false;
+   }  
+   
+   globals->set_matlib(new_matlib);    
+   return true;   
+ }
+
 
 #if 0
 These do_set_(some-environment-parameters) are deprecated and no longer 
@@ -1531,6 +1555,7 @@ static struct {
     { "dump-terrainbranch", do_dump_terrain_branch },
     { "print-visible-scene", do_print_visible_scene_info },
     { "reload-shaders", do_reload_shaders },
+    { "reload-materials", do_materials_reload },
 
     { 0, 0 }                   // zero-terminated
 };
index 5a9679221073de0f22c186e25b43cbe03ffab776..e05133a3eb59b59678dc0f59825bb27c87164606 100644 (file)
@@ -108,6 +108,9 @@ void FGTileMgr::reinit()
         return;
     fgSetBool("/sim/sceneryloaded",false);
     fgSetDouble("/sim/startup/splash-alpha", 1.0);
+    
+    // Reload the materials definitions
+    _options->setMaterialLib(globals->get_matlib());
 
     // remove all old scenery nodes from scenegraph and clear cache
     osg::Group* group = globals->get_scenery()->get_terrain_branch();