1
0
Fork 0

WS30 - Autogenerate 70% of earth surface

Generate Ocean tiles where no scenery is available.

As a side-effect, this also fixes bug which caused
sim to hang if unable to find WS3.0 scenery at
starting location.
This commit is contained in:
Stuart Buchanan 2023-01-29 21:50:04 +00:00
parent aae2d5d095
commit af8f71db40
3 changed files with 37 additions and 28 deletions

View file

@ -32,6 +32,7 @@
#include <simgear/bucket/newbucket.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/tgdb/SGOceanTile.hxx>
#include "tileentry.hxx"
@ -140,15 +141,41 @@ STGTileEntry::~STGTileEntry ()
{
}
// Constructur - VPB version
VPBTileEntry::VPBTileEntry ( const SGBucket& b ) : TileEntry(b)
// Constructor - VPB version
VPBTileEntry::VPBTileEntry ( const SGBucket& b, osg::ref_ptr<simgear::SGReaderWriterOptions> options ) : TileEntry(b)
{
tileFileName = "vpb/" + b.gen_vpb_base() + ".osgb";
_node->setName(tileFileName);
// Give a default LOD range so that traversals that traverse
// active children (like the groundcache lookup) will work before
// tile manager has had a chance to update this node.
_node->setRange(0, 0.0, 160000.0);
bool found = false;
auto filePathList = options->getDatabasePathList();
for (auto path : filePathList) {
SGPath p(path, tileFileName);
if (p.exists()) {
found = true;
break;
}
}
if (found) {
// File exists - set it up for loading later
_node->setName(tileFileName);
// Give a default LOD range so that traversals that traverse
// active children (like the groundcache lookup) will work before
// tile manager has had a chance to update this node.
_node->setRange(0, 0.0, 160000.0);
} else {
// File doesn't exist, so add a 1x1 degree Ocean tile.
double lat = floor(b.get_center_lat()) + 0.5;
double lon = floor(b.get_center_lon()) + 0.5;
SG_LOG( SG_TERRAIN, SG_DEBUG, "Generating Ocean Tile for " << lat << ", " << lon);
// Standard for WS2.0 is 5 points per bucket (~30km), or 8km spacing.
// 1 degree latitude and 1 degree of longitude at the equator is 111km, 15 points
// are equivalent resolution.
osg::Node* oceanTile = SGOceanTile(lat, lon, 1.0, 1.0, options->getMaterialLib(), 15, 15);
_node->addChild(oceanTile, 0, 250000.0);
}
}
// Destructor - VPB Variant

View file

@ -40,6 +40,7 @@
#include <simgear/bucket/newbucket.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/util/OrthophotoManager.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <osg/ref_ptr>
#include <osgDB/ReaderWriter>
@ -161,7 +162,7 @@ class STGTileEntry : public TileEntry {
class VPBTileEntry : public TileEntry {
public:
VPBTileEntry ( const SGBucket& b );
VPBTileEntry ( const SGBucket& b, osg::ref_ptr<simgear::SGReaderWriterOptions> options );
~VPBTileEntry();
inline TileEntry::Extension getExtension() { return TileEntry::Extension::VPB; };
};

View file

@ -318,26 +318,7 @@ bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_vie
if (!v)
{
// create a new entry
v = new VPBTileEntry( b );
// If we put the tile on the queue blindly and it doesn't exist,
// OSG created huge amounts of log spam and WARN level. So
// do a quick check here and drop out if the file doesn't exist.
bool found = false;
auto filePathList = _options->getDatabasePathList();
for (auto path : filePathList) {
SGPath p(path, v->tileFileName);
if (p.exists()) {
found = true;
break;
}
}
if (! found) {
delete v;
return false;
}
v = new VPBTileEntry( b, _options );
SG_LOG( SG_TERRAIN, SG_INFO, "sched_tile: new VPB tile entry for:" << b );
// insert the tile into the cache, update will generate load request