]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/tgdb/TileEntry.hxx
simgear/scene/sky/sky.cxx: Include sg_inlines.h with simgear/ prefix as all other...
[simgear.git] / simgear / scene / tgdb / TileEntry.hxx
index eee74541292c39c831a823202a4a70025a29d3a5..ffe789478f79514726fe971000c608b2303d3edc 100644 (file)
@@ -35,9 +35,7 @@
 #include <string>
 
 #include <simgear/bucket/newbucket.hxx>
-#include <simgear/math/point3d.hxx>
 #include <simgear/misc/sg_path.hxx>
-#include <simgear/scene/model/placementtrans.hxx>
 
 #include <osg/ref_ptr>
 #include <osgDB/ReaderWriter>
@@ -48,9 +46,6 @@
 #include <strings.h>
 #endif
 
-using std::string;
-using std::vector;
-
 namespace simgear {
 
 class ModelLoadHelper;
@@ -65,10 +60,6 @@ public:
     SGBucket tile_bucket;
     std::string tileFileName;
 
-    typedef vector < Point3D > point_list;
-    typedef point_list::iterator point_list_iterator;
-    typedef point_list::const_iterator const_point_list_iterator;
-
 private:
 
     // pointer to ssg range selector for this tile
@@ -83,29 +74,16 @@ private:
                           const osgDB::ReaderWriter::Options* options);
 
     /**
-     * this value is used by the tile scheduler/loader to mark which
-     * tiles are in the primary ring (i.e. the current tile or the
-     * surrounding eight.)  Other routines then can use this as an
-     * optimization and not do some operation to tiles outside of this
-     * inner ring.  (For instance vasi color updating)
-     */
-    bool is_inner_ring;
-
-    /**
-     * this variable tracks the status of the incremental memory
-     * freeing.
+     * This value is used by the tile scheduler/loader to load tiles
+     * in a useful sequence. The priority is set to reflect the tiles
+     * distance from the center, so all tiles are loaded in an innermost
+     * to outermost sequence.
      */
-    enum {
-        NODES = 0x01,
-        VEC_PTRS = 0x02,
-        TERRA_NODE = 0x04,
-        GROUND_LIGHTS = 0x08,
-        VASI_LIGHTS = 0x10,
-        RWY_LIGHTS = 0x20,
-        TAXI_LIGHTS = 0x40,
-        LIGHTMAPS = 0x80
-    };
-    int free_tracker;
+    float _priority;
+    /** Flag indicating if tile belongs to current view. */ 
+    bool _current_view;
+    /** Time when tile expires. */ 
+    double _time_expired;
 
     static ModelLoadHelper *_modelLoader;
 
@@ -119,14 +97,6 @@ public:
 
     static void setModelLoadHelper(ModelLoadHelper *m) { _modelLoader=m; }
 
-    // Clean up the memory used by this tile and delete the arrays
-    // used by ssg as well as the whole ssg branch.  This does a
-    // partial clean up and exits so we can spread the load across
-    // multiple frames.  Returns false if work remaining to be done,
-    // true if dynamically allocated memory used by this tile is
-    // completely freed.
-    bool free_tile();
-
     // Update the ssg transform node for this tile so it can be
     // properly drawn relative to our (0,0,0) point
     void prep_ssg_node(float vis);
@@ -134,8 +104,8 @@ public:
     /**
      * Transition to OSG database pager
      */
-    static osg::Node* loadTileByName(const std::string& index_str,
-                                     const osgDB::ReaderWriter::Options*);
+    static osg::Node* loadTileByFileName(const std::string& index_str,
+                                         const osgDB::ReaderWriter::Options*);
     /**
      * Return true if the tile entry is loaded, otherwise return false
      * indicating that the loading thread is still working on this.
@@ -167,11 +137,19 @@ public:
      */
     osg::LOD *getNode() const { return _node.get(); }
 
-    double get_timestamp() const;
-    void set_timestamp( double time_ms );
+    inline double get_time_expired() const { return _time_expired; }
+    inline void update_time_expired( double time_expired ) { if (_time_expired<time_expired) _time_expired = time_expired; }
+
+    inline void set_priority(float priority) { _priority=priority; }
+    inline float get_priority() const { return _priority; }
+    inline void set_current_view(bool current_view) { _current_view = current_view; }
+    inline bool is_current_view() const { return _current_view; }
 
-    inline bool get_inner_ring() const { return is_inner_ring; }
-    inline void set_inner_ring( bool val ) { is_inner_ring = val; }
+    /**
+     * Return true if the tile entry is still needed, otherwise return false
+     * indicating that the tile is no longer in active use.
+     */
+    inline bool is_expired(double current_time) const { return (_current_view) ? false : (current_time > _time_expired); }
 
     // Get the ref_ptr to the DatabaseRequest object, in order to pass
     // this to the pager.
@@ -183,7 +161,7 @@ public:
 
 class ModelLoadHelper {
 public:
-    virtual osg::Node *loadTileModel(const string& modelPath, bool cacheModel)=0;
+    virtual osg::Node *loadTileModel(const std::string& modelPath, bool cacheModel)=0;
 
 };