1
0
Fork 0

Rebase photoscenery patch on next

This commit is contained in:
Nathaniel Warner 2020-11-23 10:36:15 -08:00 committed by Scott Giese
parent b73413d52e
commit 88a8cada51
3 changed files with 33 additions and 2 deletions

View file

@ -219,7 +219,7 @@ QString AddOnsController::addSceneryPath() const
SGPath p(path.toStdString()); SGPath p(path.toStdString());
bool isValid = false; 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()) { if ((p / dir).exists()) {
isValid = true; isValid = true;
break; break;
@ -232,7 +232,7 @@ QString AddOnsController::addSceneryPath() const
mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
mb.setDefaultButton(QMessageBox::No); mb.setDefaultButton(QMessageBox::No);
mb.setInformativeText(tr("Added scenery should contain at least one of the following " 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(); mb.exec();
if (mb.result() == QMessageBox::No) { if (mb.result() == QMessageBox::No) {

View file

@ -46,6 +46,8 @@ TileEntry::TileEntry ( const SGBucket& b )
_current_view(false), _current_view(false),
_time_expired(-1.0) _time_expired(-1.0)
{ {
_create_orthophoto();
tileFileName += ".stg"; tileFileName += ".stg";
_node->setName(tileFileName); _node->setName(tileFileName);
// Give a default LOD range so that traversals that traverse // Give a default LOD range so that traversals that traverse
@ -62,6 +64,8 @@ TileEntry::TileEntry( const TileEntry& t )
_current_view(t._current_view), _current_view(t._current_view),
_time_expired(t._time_expired) _time_expired(t._time_expired)
{ {
_create_orthophoto();
_node->setName(tileFileName); _node->setName(tileFileName);
// Give a default LOD range so that traversals that traverse // Give a default LOD range so that traversals that traverse
// active children (like the groundcache lookup) will work before // 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); _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 // Destructor
TileEntry::~TileEntry () TileEntry::~TileEntry ()
{ {
@ -115,5 +135,7 @@ TileEntry::removeFromSceneGraph()
parent->removeChild( _node.get() ); parent->removeChild( _node.get() );
} }
} }
_free_orthophoto();
} }

View file

@ -29,6 +29,9 @@
# error This library requires C++ # error This library requires C++
#endif #endif
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <vector> #include <vector>
@ -36,6 +39,7 @@
#include <simgear/bucket/newbucket.hxx> #include <simgear/bucket/newbucket.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/scene/util/OrthophotoManager.hxx>
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osgDB/ReaderWriter> #include <osgDB/ReaderWriter>
@ -59,6 +63,8 @@ private:
// Reference to DatabaseRequest object set and used by the // Reference to DatabaseRequest object set and used by the
// osgDB::DatabasePager. // osgDB::DatabasePager.
osg::ref_ptr<osg::Referenced> _databaseRequest; osg::ref_ptr<osg::Referenced> _databaseRequest;
// Overlay image/orthophoto for this tile
simgear::OrthophotoRef _orthophoto;
/** /**
* This value is used by the tile scheduler/loader to load tiles * This value is used by the tile scheduler/loader to load tiles
@ -72,6 +78,9 @@ private:
/** Time when tile expires. */ /** Time when tile expires. */
double _time_expired; double _time_expired;
void _create_orthophoto();
void _free_orthophoto();
public: public:
// Constructor // Constructor