From 2a1e33863a27e8fff2f684afc1aca5e44e4948fe Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Thu, 23 Jan 2014 15:02:33 +0000
Subject: [PATCH] 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,
---
 src/Model/modelmgr.cxx | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

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;
   }