Add command to reload materials definitions. Note that this explicitly
does not attempt to delete the old materials definitions, as they may be in use at the time.
This commit is contained in:
parent
a2bd520a3b
commit
5e3ec6209c
2 changed files with 28 additions and 0 deletions
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue