X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FScenery%2Ftilemgr.hxx;h=39b8103c521b350df3078f355e13dde67ea9039b;hb=470ee55fb7b3a913a14cb4e23ae526e624091822;hp=8fadc3b5c1d4e0ffd649deccb5ff78d4400e87b6;hpb=846ac621a2573b7d62243bcaa7edf49941f8a81e;p=flightgear.git diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index 8fadc3b5c..39b8103c5 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -29,12 +29,15 @@ # error This library requires C++ #endif -#include +#include #include -#include +#include +#include + +#include "hitlist.hxx" FG_USING_STD(list); @@ -50,6 +53,10 @@ FG_USING_STD(list); #endif +// forward declaration +class FGTileEntry; + + class FGLoadRec { public: @@ -59,9 +66,6 @@ public: }; -#define MAX_HITS 100 - - class FGTileMgr { private: @@ -75,17 +79,63 @@ private: load_state state; + enum SCROLL_DIRECTION { + SCROLL_INIT = -1, + SCROLL_NONE = 0, + SCROLL_NORTH, + SCROLL_EAST, + SCROLL_SOUTH, + SCROLL_WEST, + }; + + SCROLL_DIRECTION scroll_direction; + // pending tile load queue list < FGLoadRec > load_queue; + // initialize the cache + void initialize_queue(); + + // forced emptying of the queue. This is necessay to keep + // bookeeping straight for the tile_cache -- which actually + // handles all the (de)allocations + void destroy_queue(); + + FGBucket BucketOffset( int dx, int dy ); + // schedule a tile for loading int sched_tile( const FGBucket& b ); // load a tile void load_tile( const FGBucket& b, int cache_index ); - int hitcount; - sgVec3 hit_pts [ MAX_HITS ] ; + // schedule a tile row(column) for loading + void scroll( void ); + + // see comment at prep_ssg_nodes() + void prep_ssg_node( int idx ); + + // int hitcount; + // sgdVec3 hit_pts [ MAX_HITS ] ; + + // ssgEntity *last_hit; + FGHitList hit_list; + + FGBucket previous_bucket; + FGBucket current_bucket; + FGBucket pending; + + FGTileEntry *current_tile; + + // index of current tile in tile cache; + long int tile_index; + int tile_diameter; + + // current longitude latitude + double longitude; + double latitude; + double last_longitude; + double last_latitude; public: @@ -98,26 +148,31 @@ public: // Initialize the Tile Manager subsystem int init( void ); - // given the current lon/lat, fill in the array of local chunks. - // If the chunk isn't already in the cache, then read it from - // disk. - int update( void ); + // 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 lon, double lat ); // Determine scenery altitude. Normally this just happens when we // render the scene, but we'd also like to be able to do this // explicitely. lat & lon are in radians. abs_view_pos in // meters. Returns result in meters. - double current_elev( double lon, double lat, const Point3D& abs_view_pos ); - void my_ssg_los( string s, ssgBranch *branch, sgMat4 m, - const sgVec3 p, const sgVec3 dir ); - double current_elev_ssg( const Point3D& abs_view_pos, - const Point3D& view_pos ); - double current_elev_new( const FGBucket& p ); - + void my_ssg_los( string s, ssgBranch *branch, sgdMat4 m, + const sgdVec3 p, const sgdVec3 dir, sgdVec3 normal ); + + void my_ssg_los( ssgBranch *branch, sgdMat4 m, + const sgdVec3 p, const sgdVec3 dir, + FGHitList *list ); + + bool current_elev_ssg( sgdVec3 abs_view_pos, + sgVec3 view_pos ); + // Prepare the ssg nodes ... for each tile, set it's proper // transform and update it's range selector based on current // visibilty void prep_ssg_nodes( void ); + + inline int queue_size() const { return load_queue.size(); } }; @@ -126,5 +181,3 @@ extern FGTileMgr global_tile_mgr; #endif // _TILEMGR_HXX - -