1998-05-20 20:53:53 +00:00
|
|
|
// tilemgr.hxx -- routines to handle dynamic management of scenery tiles
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started January 1998.
|
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
|
1998-05-20 20:53:53 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1998-05-20 20:53:53 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
1998-01-07 23:50:01 +00:00
|
|
|
|
|
|
|
|
1998-04-22 13:21:26 +00:00
|
|
|
#ifndef _TILEMGR_HXX
|
|
|
|
#define _TILEMGR_HXX
|
1998-01-22 02:59:23 +00:00
|
|
|
|
2000-02-15 03:30:01 +00:00
|
|
|
#include <simgear/compiler.h>
|
1999-06-13 05:58:02 +00:00
|
|
|
|
2000-02-16 23:01:03 +00:00
|
|
|
#include <simgear/bucket/newbucket.hxx>
|
2012-04-15 13:30:44 +00:00
|
|
|
#include "SceneryPager.hxx"
|
2012-03-15 19:56:37 +00:00
|
|
|
#include "tilecache.hxx"
|
2000-06-15 22:32:26 +00:00
|
|
|
|
2008-08-01 15:57:29 +00:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Node;
|
|
|
|
}
|
2000-06-15 22:32:26 +00:00
|
|
|
|
2011-06-11 22:44:07 +00:00
|
|
|
namespace simgear
|
|
|
|
{
|
2011-11-12 18:45:20 +00:00
|
|
|
class SGReaderWriterOptions;
|
2011-06-11 22:44:07 +00:00
|
|
|
}
|
|
|
|
|
2016-07-30 12:26:45 +00:00
|
|
|
class FGTileMgr {
|
1999-06-13 05:58:02 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// Tile loading state
|
|
|
|
enum load_state {
|
2012-03-25 11:43:28 +00:00
|
|
|
Start = 0,
|
|
|
|
Inited = 1,
|
|
|
|
Running = 2
|
1999-06-13 05:58:02 +00:00
|
|
|
};
|
|
|
|
|
2011-12-17 14:22:50 +00:00
|
|
|
load_state state, last_state;
|
|
|
|
|
2010-11-19 12:59:43 +00:00
|
|
|
// 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);
|
1999-06-13 05:58:02 +00:00
|
|
|
|
2000-12-03 20:15:46 +00:00
|
|
|
// schedule a needed buckets for loading
|
2010-10-01 18:09:19 +00:00
|
|
|
void schedule_needed(const SGBucket& curr_bucket, double rangeM);
|
2000-06-15 22:32:26 +00:00
|
|
|
|
2013-09-30 11:03:47 +00:00
|
|
|
bool isTileDirSyncing(const std::string& tileFileName) const;
|
|
|
|
|
2000-12-13 20:36:04 +00:00
|
|
|
SGBucket previous_bucket;
|
|
|
|
SGBucket current_bucket;
|
|
|
|
SGBucket pending;
|
2011-11-12 18:45:20 +00:00
|
|
|
osg::ref_ptr<simgear::SGReaderWriterOptions> _options;
|
2008-05-14 22:10:07 +00:00
|
|
|
|
2010-11-19 12:59:43 +00:00
|
|
|
double scheduled_visibility;
|
1999-11-03 21:01:59 +00:00
|
|
|
|
2001-04-11 02:47:15 +00:00
|
|
|
/**
|
2001-04-14 03:11:39 +00:00
|
|
|
* tile cache
|
2001-04-11 02:47:15 +00:00
|
|
|
*/
|
2012-03-15 19:56:37 +00:00
|
|
|
TileCache tile_cache;
|
2014-02-21 16:52:07 +00:00
|
|
|
|
|
|
|
class TileManagerListener;
|
|
|
|
friend class TileManagerListener;
|
2020-08-11 10:44:29 +00:00
|
|
|
std::unique_ptr<TileManagerListener> _listener;
|
|
|
|
|
2012-09-24 21:42:25 +00:00
|
|
|
// update various queues internal queues
|
2013-09-30 15:13:04 +00:00
|
|
|
void update_queues(bool& isDownloadingScenery);
|
2011-11-13 14:47:52 +00:00
|
|
|
|
2012-09-24 21:42:25 +00:00
|
|
|
// schedule tiles for the viewer bucket
|
|
|
|
void schedule_tiles_at(const SGGeod& location, double rangeM);
|
|
|
|
|
2012-01-29 09:34:11 +00:00
|
|
|
SGPropertyNode_ptr _visibilityMeters;
|
2018-10-30 19:10:30 +00:00
|
|
|
SGPropertyNode_ptr _lodDetailed, _lodRoughDelta, _lodBareDelta, _disableNasalHooks;
|
2012-09-24 21:42:25 +00:00
|
|
|
SGPropertyNode_ptr _scenery_loaded, _scenery_override;
|
2012-04-15 13:30:44 +00:00
|
|
|
|
|
|
|
osg::ref_ptr<flightgear::SceneryPager> _pager;
|
|
|
|
|
2014-05-16 13:52:24 +00:00
|
|
|
/// is caching of expired tiles enabled or not?
|
2016-07-30 12:26:45 +00:00
|
|
|
bool _enableCache;
|
2021-10-20 22:39:59 +00:00
|
|
|
bool _use_vpb;
|
1999-06-13 05:58:02 +00:00
|
|
|
public:
|
2000-12-03 20:15:46 +00:00
|
|
|
FGTileMgr();
|
|
|
|
~FGTileMgr();
|
1998-01-07 23:50:01 +00:00
|
|
|
|
2008-05-14 22:10:07 +00:00
|
|
|
// Initialize the Tile Manager
|
2016-07-30 12:26:45 +00:00
|
|
|
void init();
|
|
|
|
void reinit();
|
|
|
|
void shutdown();
|
|
|
|
void update(double dt);
|
2002-11-30 02:21:04 +00:00
|
|
|
|
2007-05-08 06:12:26 +00:00
|
|
|
const SGBucket& get_current_bucket () const { return current_bucket; }
|
2004-04-02 14:42:42 +00:00
|
|
|
|
2012-09-24 21:42:25 +00:00
|
|
|
// 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.
|
2010-11-19 12:59:43 +00:00
|
|
|
bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
|
2007-11-29 23:59:14 +00:00
|
|
|
|
2010-11-19 12:59:43 +00:00
|
|
|
// Returns true if tiles around current view position have been loaded
|
2007-12-14 22:51:56 +00:00
|
|
|
bool isSceneryLoaded();
|
2014-01-19 16:49:32 +00:00
|
|
|
|
|
|
|
// notify the tile manahger the material library was reloaded,
|
|
|
|
// so it can pass this through to its options object
|
|
|
|
void materialLibChanged();
|
1999-06-13 05:58:02 +00:00
|
|
|
};
|
1998-08-22 14:49:55 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
#endif // _TILEMGR_HXX
|