From 88a8cada51957a7757876867e00be01c726439bd Mon Sep 17 00:00:00 2001 From: Nathaniel Warner Date: Mon, 23 Nov 2020 10:36:15 -0800 Subject: [PATCH] Rebase photoscenery patch on next --- src/GUI/AddOnsController.cxx | 4 ++-- src/Scenery/tileentry.cxx | 22 ++++++++++++++++++++++ src/Scenery/tileentry.hxx | 9 +++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/GUI/AddOnsController.cxx b/src/GUI/AddOnsController.cxx index 128166e96..aeae92a75 100644 --- a/src/GUI/AddOnsController.cxx +++ b/src/GUI/AddOnsController.cxx @@ -219,7 +219,7 @@ QString AddOnsController::addSceneryPath() const SGPath p(path.toStdString()); bool isValid = false; - for (const auto& dir: {"Objects", "Terrain", "Buildings", "Roads", "Pylons", "NavData", "Airports"}) { + for (const auto& dir: {"Objects", "Terrain", "Buildings", "Roads", "Pylons", "NavData", "Airports", "Orthophotos"}) { if ((p / dir).exists()) { isValid = true; break; @@ -232,7 +232,7 @@ QString AddOnsController::addSceneryPath() const mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); mb.setDefaultButton(QMessageBox::No); mb.setInformativeText(tr("Added scenery should contain at least one of the following " - "folders: Objects, Terrain, Buildings, Roads, Pylons, NavData, Airports.")); + "folders: Objects, Terrain, Buildings, Roads, Pylons, NavData, Airports, Orthophotos.")); mb.exec(); if (mb.result() == QMessageBox::No) { diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index 31d14c713..7ca48c555 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -46,6 +46,8 @@ TileEntry::TileEntry ( const SGBucket& b ) _current_view(false), _time_expired(-1.0) { + _create_orthophoto(); + tileFileName += ".stg"; _node->setName(tileFileName); // Give a default LOD range so that traversals that traverse @@ -62,6 +64,8 @@ TileEntry::TileEntry( const TileEntry& t ) _current_view(t._current_view), _time_expired(t._time_expired) { + _create_orthophoto(); + _node->setName(tileFileName); // Give a default LOD range so that traversals that traverse // active children (like the groundcache lookup) will work before @@ -69,6 +73,22 @@ TileEntry::TileEntry( const TileEntry& t ) _node->setRange(0, 0.0, 10000.0); } +void TileEntry::_create_orthophoto() { + bool use_photoscenery = fgGetBool("/sim/rendering/photoscenery/enabled"); + if (use_photoscenery) { + _orthophoto = simgear::Orthophoto::fromBucket(tile_bucket, globals->get_fg_scenery()); + if (_orthophoto) { + simgear::OrthophotoManager::instance()->registerOrthophoto(tile_bucket.gen_index(), _orthophoto); + } + } +} + +void TileEntry::_free_orthophoto() { + if (_orthophoto) { + simgear::OrthophotoManager::instance()->unregisterOrthophoto(tile_bucket.gen_index()); + } +} + // Destructor TileEntry::~TileEntry () { @@ -115,5 +135,7 @@ TileEntry::removeFromSceneGraph() parent->removeChild( _node.get() ); } } + + _free_orthophoto(); } diff --git a/src/Scenery/tileentry.hxx b/src/Scenery/tileentry.hxx index 56f2550cd..3eee3daa4 100644 --- a/src/Scenery/tileentry.hxx +++ b/src/Scenery/tileentry.hxx @@ -29,6 +29,9 @@ # error This library requires C++ #endif +#include
+#include
+ #include #include @@ -36,6 +39,7 @@ #include #include +#include #include #include @@ -59,6 +63,8 @@ private: // Reference to DatabaseRequest object set and used by the // osgDB::DatabasePager. osg::ref_ptr _databaseRequest; + // Overlay image/orthophoto for this tile + simgear::OrthophotoRef _orthophoto; /** * This value is used by the tile scheduler/loader to load tiles @@ -72,6 +78,9 @@ private: /** Time when tile expires. */ double _time_expired; + void _create_orthophoto(); + void _free_orthophoto(); + public: // Constructor