#include <GUI/dialog.hxx>
#include <Aircraft/replay.hxx>
#include <Scenery/scenery.hxx>
+#include <Scenery/tilemgr.hxx>
#include <Scripting/NasalSys.hxx>
#include <Sound/sample_queue.hxx>
#include <Airports/xmlloader.hxx>
/**
* 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(),
+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 ) {
+
+ if ( ! loaded ) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Error loading materials file " << mpath.str() );
return false;
- }
-
- globals->set_matlib(new_matlib);
- return true;
- }
+ }
+
+ globals->set_matlib(new_matlib);
+ FGTileMgr* tileManager = static_cast<FGTileMgr*>(globals->get_subsystem("tile-manager"));
+ tileManager->materialLibChanged();
+
+ return true;
+}
#if 0
fg_home( "" ),
time_params( NULL ),
ephem( NULL ),
- matlib( NULL ),
route_mgr( NULL ),
ATIS_mgr( NULL ),
controls( NULL ),
void FGGlobals::set_matlib( SGMaterialLib *m )
{
- if (matlib)
- delete matlib;
matlib = m;
}
SGEphemeris *ephem;
// Material properties library
- SGMaterialLib *matlib;
+ SGSharedPtr<SGMaterialLib> matlib;
// Global autopilot "route"
FGRouteMgr *route_mgr;
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
_options = new simgear::SGReaderWriterOptions;
- _options->setMaterialLib(globals->get_matlib());
+
+ materialLibChanged();
_options->setPropertyNode(globals->get_props());
osgDB::FilePathList &fp = _options->getDatabasePathList();
fgSetBool("/sim/sceneryloaded",false);
fgSetDouble("/sim/startup/splash-alpha", 1.0);
- // Reload the materials definitions
- _options->setMaterialLib(globals->get_matlib());
+ materialLibChanged();
// remove all old scenery nodes from scenegraph and clear cache
osg::Group* group = globals->get_scenery()->get_terrain_branch();
update(0.0);
}
+void FGTileMgr::materialLibChanged()
+{
+ _options->setMaterialLib(globals->get_matlib());
+ _options->getMaterialLib()->refreshActiveMaterials();
+}
+
/* schedule a tile for loading, keep request for given amount of time.
* Returns true if tile is already loaded. */
bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_view, double duration)
// Returns true if tiles around current view position have been loaded
bool isSceneryLoaded();
+
+ // notify the tile manahger the material library was reloaded,
+ // so it can pass this through to its options object
+ void materialLibChanged();
};
simgear::ModelRegistry::instance();
sgUserDataInit(props.get());
- SGMaterialLib* ml = new SGMaterialLib;
+ SGMaterialLibPtr ml = new SGMaterialLib;
SGPath mpath(fg_root);
mpath.append("Materials/default/materials.xml");
try {
// FIXME Ok, replace this by querying the root of the property tree
sgUserDataInit(props.get());
SGSceneFeatures::instance()->setTextureCompression(SGSceneFeatures::DoNotUseCompression);
- SGMaterialLib* ml = new SGMaterialLib;
+ SGMaterialLibPtr ml = new SGMaterialLib;
SGPath mpath(fg_root);
mpath.append("Materials/default/materials.xml");
try {