FlightGear next
tilemgr.hxx
Go to the documentation of this file.
1// tilemgr.hxx -- routines to handle dynamic management of scenery tiles
2//
3// Written by Curtis Olson, started January 1998.
4//
5// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License as
9// published by the Free Software Foundation; either version 2 of the
10// License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15// General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20//
21// $Id$
22
23
24#ifndef _TILEMGR_HXX
25#define _TILEMGR_HXX
26
27#include <simgear/compiler.h>
28
29#include <simgear/bucket/newbucket.hxx>
30#include "SceneryPager.hxx"
31#include "tilecache.hxx"
32
33namespace osg
34{
35class Node;
36}
37
38namespace simgear
39{
40class SGReaderWriterOptions;
41}
42
43class FGTileMgr {
44
45private:
46
47 // Tile loading state
48 enum load_state {
49 Start = 0,
50 Inited = 1,
51 Running = 2
52 };
53
54 load_state state, last_state;
55
56 // schedule a tile for loading, returns true when tile is already loaded
57 bool sched_tile( const SGBucket& b, double priority,bool current_view, double request_time);
58
59 // schedule a needed buckets for loading
60 void schedule_needed(const SGBucket& curr_bucket, double rangeM);
61
62 bool isTileDirSyncing(const std::string& tileFileName) const;
63
64 SGBucket previous_bucket;
65 SGBucket current_bucket;
66 SGBucket pending;
67 osg::ref_ptr<simgear::SGReaderWriterOptions> _options;
68
69 double scheduled_visibility;
70
74 TileCache tile_cache;
75
77 friend class TileManagerListener;
78 std::unique_ptr<TileManagerListener> _listener;
79
80 // update various queues internal queues
81 void update_queues(bool& isDownloadingScenery);
82
83 // schedule tiles for the viewer bucket
84 void schedule_tiles_at(const SGGeod& location, double rangeM);
85
86 SGPropertyNode_ptr _visibilityMeters;
87 SGPropertyNode_ptr _lodDetailed, _lodRoughDelta, _lodBareDelta, _disableNasalHooks;
88 SGPropertyNode_ptr _scenery_loaded, _scenery_override;
89
90 // Statistics from the database pager.
91 SGPropertyNode_ptr _pager_file_queue_size, _pager_compile_queue_size, _pager_merge_queue_size;
92 SGPropertyNode_ptr _pager_min_merge_time, _pager_mean_merge_time, _pager_max_merge_time;
93 SGPropertyNode_ptr _pager_active_lod_count;
94
95 osg::ref_ptr<flightgear::SceneryPager> _pager;
96
98 bool _enableCache;
99 bool _use_vpb;
100public:
101 FGTileMgr();
102 ~FGTileMgr();
103
104 // Initialize the Tile Manager
105 void init();
106 void reinit();
107 void shutdown();
108 void update(double dt);
109
110 const SGBucket& get_current_bucket () const { return current_bucket; }
111
112 // Returns true if scenery is available for the given lat, lon position
113 // within a range of range_m.
114 // lat and lon are expected to be in degrees.
115 bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
116
117 // Returns true if tiles around current view position have been loaded
118 bool isSceneryLoaded();
119
120 // notify the tile manahger the material library was reloaded,
121 // so it can pass this through to its options object
122 void materialLibChanged();
123};
124
125#endif // _TILEMGR_HXX
bool isSceneryLoaded()
Definition tilemgr.cxx:852
void reinit()
Definition tilemgr.cxx:353
bool schedule_scenery(const SGGeod &position, double range_m, double duration=0.0)
Schedules scenery for given position.
Definition tilemgr.cxx:795
void shutdown()
Definition tilemgr.cxx:339
void init()
Definition tilemgr.cxx:334
const SGBucket & get_current_bucket() const
Definition tilemgr.hxx:110
void materialLibChanged()
Definition tilemgr.cxx:449
void update(double dt)
Definition tilemgr.cxx:695
Definition AIBase.hxx:25