-osg::Node*
-FGTileMgr::loadTileModel(const string& modelPath, bool cacheModel)
-{
- SGPath fullPath;
- if (fgGetBool("/sim/paths/use-custom-scenery-data") == true) {
- string_list sc = globals->get_fg_scenery();
-
- for (string_list_iterator it = sc.begin(); it != sc.end(); ++it) {
- SGPath tmpPath(*it);
- tmpPath.append(modelPath);
- if (tmpPath.exists()) {
- fullPath = tmpPath;
- break;
- }
- }
- } else {
- fullPath.append(modelPath);
- }
- osg::Node* result = 0;
- try {
- if(cacheModel)
- result =
- SGModelLib::loadModel(fullPath.str(), globals->get_props(),
- new FGNasalModelData);
- else
- result=
- SGModelLib::loadPagedModel(modelPath, globals->get_props(),
- new FGNasalModelData);
- } catch (const sg_io_exception& exc) {
- string m(exc.getMessage());
- m += " ";
- m += exc.getLocation().asString();
- SG_LOG( SG_ALL, SG_ALERT, m );
- } catch (const sg_exception& exc) { // XXX may be redundant
- SG_LOG( SG_ALL, SG_ALERT, exc.getMessage());
- }
- return result;
-}
-
-// Helper class for STL fun
-class TileLoad : public std::unary_function<TileCache::tile_map::value_type,
- void>
-{
-public:
- TileLoad(SceneryPager *pager, osg::FrameStamp* framestamp,
- osg::Group* terrainBranch, osgDB::ReaderWriter::Options* options) :
- _pager(pager), _framestamp(framestamp), _options(options) {}
-
- TileLoad(const TileLoad& rhs) :
- _pager(rhs._pager), _framestamp(rhs._framestamp),
- _options(rhs._options) {}
-
- void operator()(TileCache::tile_map::value_type& tilePair)
- {
- TileEntry* entry = tilePair.second;
- if (entry->getNode()->getNumChildren() == 0) {
- _pager->queueRequest(entry->tileFileName,
- entry->getNode(),
- entry->get_inner_ring() ? 10.0f : 1.0f,
- _framestamp,
- entry->getDatabaseRequest(),
- _options);
- }
- }
-private:
- SceneryPager* _pager;
- osg::FrameStamp* _framestamp;
- osgDB::ReaderWriter::Options* _options;
-};
-