]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/tilemgr.hxx
Continuing work on cleanups.
[flightgear.git] / src / Scenery / tilemgr.hxx
index 8fadc3b5c1d4e0ffd649deccb5ff78d4400e87b6..39b8103c521b350df3078f355e13dde67ea9039b 100644 (file)
 # error This library requires C++
 #endif                                   
 
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
 
 #include <list>
 
-#include <Bucket/newbucket.hxx>
+#include <plib/ssg.h>
 
+#include <simgear/bucket/newbucket.hxx>
+
+#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
-
-