#ifndef _TILEMGR_HXX
#define _TILEMGR_HXX
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
#include <simgear/compiler.h>
-#include <simgear/math/point3d.hxx>
-#include <simgear/scene/model/location.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/bucket/newbucket.hxx>
-#include "newcache.hxx"
+#include <simgear/scene/tgdb/TileEntry.hxx>
+#include <simgear/scene/tgdb/TileCache.hxx>
-#if defined(USE_MEM) || defined(WIN32)
-# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
-#else
-# define FG_MEM_COPY(to,from,n) bcopy(from, to, n)
-#endif
+namespace osg
+{
+class Node;
+}
-// forward declaration
-class FGTileEntry;
+namespace simgear
+{
+class SGTerraSync;
+class SGReaderWriterOptions;
+}
-class osg::Node;
-
-class FGTileMgr {
+class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
private:
};
load_state state;
-
- // initialize the cache
- void initialize_queue();
-
- // schedule a tile for loading
- void sched_tile( const SGBucket& b, const bool is_inner_ring );
+
+ // schedule a tile for loading, returns true when tile is already loaded
+ bool sched_tile( const SGBucket& b, double priority,bool current_view, double request_time);
// schedule a needed buckets for loading
- void schedule_needed(double visibility_meters, const SGBucket& curr_bucket);
+ void schedule_needed(const SGBucket& curr_bucket, double rangeM);
SGBucket previous_bucket;
SGBucket current_bucket;
SGBucket pending;
-
- FGTileEntry *current_tile;
-
+ osg::ref_ptr<simgear::SGReaderWriterOptions> _options;
+
// x and y distance of tiles to load/draw
float vis;
int xrange, yrange;
-
+
// current longitude latitude
double longitude;
double latitude;
- double altitude_m;
+ double scheduled_visibility;
/**
* tile cache
*/
- FGNewCache tile_cache;
+ simgear::TileCache tile_cache;
+ simgear::SGTerraSync* _terra_sync;
-public:
+ // Update the various queues maintained by the tilemagr (private
+ // internal function, do not call directly.)
+ void update_queues();
+
+ static void refresh_tile(void* tileMgr, long tileIndex);
- // Constructor
+ SGPropertyNode* _visibilityMeters;
+ SGPropertyNode_ptr _maxTileRangeM;
+
+public:
FGTileMgr();
- // Destructor
~FGTileMgr();
- // Initialize the Tile Manager subsystem
- int init();
+ // Initialize the Tile Manager
+ virtual void init();
+ virtual void reinit();
- // Update the various queues maintained by the tilemagr (private
- // internal function, do not call directly.)
- void update_queues();
+ virtual void update(double dt);
- // given the current lon/lat (in degrees), fill in the array of
- // local chunks. If the chunk isn't already in the cache, then
- // read it from disk.
- int update( double visibility_meters );
- int update( SGLocation *location, double visibility_meters);
+ int schedule_tiles_at(const SGGeod& location, double rangeM);
- // Prepare the ssg nodes corresponding to each tile. For each
- // tile, set the ssg transform and update it's range selector
- // based on current visibilty void prep_ssg_nodes( float
- // visibility_meters );
- void prep_ssg_nodes(float visibility_meters );
const SGBucket& get_current_bucket () const { return current_bucket; }
- /// Returns true if scenery is avaliable for the given lat, lon position
+ /// Returns true if scenery is available for the given lat, lon position
/// within a range of range_m.
/// lat and lon are expected to be in degrees.
- bool scenery_available(double lat, double lon, double range_m);
+ bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
// Load a model for a tile
- static osg::Node* loadTileModel(const string& modelPath, bool cacheModel);
+ osg::Node* loadTileModel(const std::string& modelPath, bool cacheModel);
- // Returns true if all the tiles in the tile cache have been loaded
+ // Returns true if tiles around current view position have been loaded
bool isSceneryLoaded();
};