From: James Turner Date: Thu, 23 Jan 2014 15:02:33 +0000 (+0000) Subject: Search all resources when adding models at runtime. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2a1e33863a27e8fff2f684afc1aca5e44e4948fe;p=flightgear.git Search all resources when adding models at runtime. geo.put-model / add-model mechanism now supports resolving paths using all the defined locations, including aircraft dirs and additional data dirs, --- diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 4af505c38..46ed240f4 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -69,13 +69,14 @@ FGModelMgr::add_model (SGPropertyNode * node) SG_LOG(SG_AIRCRAFT, SG_INFO, "Adding model " << node->getStringValue("name", "[unnamed]")); - const char *path = node->getStringValue("path", "Models/Geometry/glider.ac"); + const char *model_path = node->getStringValue("path", "Models/Geometry/glider.ac"); osg::Node *object; try { - object = SGModelLib::loadDeferredModel(path, globals->get_props()); + std::string fullPath = simgear::SGModelLib::findDataFile(model_path); + object = SGModelLib::loadDeferredModel(fullPath, globals->get_props()); } catch (const sg_throwable& t) { - SG_LOG(SG_AIRCRAFT, SG_ALERT, "Error loading " << path << ":\n " + SG_LOG(SG_AIRCRAFT, SG_ALERT, "Error loading " << model_path << ":\n " << t.getFormattedMessage() << t.getOrigin()); return; }