-// load a tile
-void FGTileMgr::load_tile( const FGBucket& b, int cache_index) {
-
- FG_LOG( FG_TERRAIN, FG_DEBUG, "Loading tile " << b );
-
- global_tile_cache.fill_in(cache_index, b);
-
- FG_LOG( FG_TERRAIN, FG_DEBUG, "Loaded for cache index: " << cache_index );
-}
-
-
-// Determine scenery altitude via ssg. 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. view_pos in current world
-// coordinate translated near (0,0,0) (in meters.) Returns result in
-// meters.
-
-bool
-FGTileMgr::current_elev_ssg( const Point3D& abs_view_pos,
- const Point3D& view_pos )
-{
- sgdVec3 orig, dir;
-
- sgdSetVec3(orig, view_pos.x(), view_pos.y(), view_pos.z() );
- sgdSetVec3(dir, abs_view_pos.x(), abs_view_pos.y(), abs_view_pos.z() );
-
- hit_list.Intersect( terrain, orig, dir );
-
- int this_hit=0;
- Point3D geoc;
- double result = -9999;
-
- int hitcount = hit_list.num_hits();
- for ( int i = 0; i < hitcount; ++i ) {
- geoc = fgCartToPolar3d( scenery.center + hit_list.get_point(i) );
- double lat_geod, alt, sea_level_r;
- fgGeocToGeod(geoc.lat(), geoc.radius(), &lat_geod,
- &alt, &sea_level_r);
- if ( alt > result && alt < 10000 ) {
- result = alt;
- this_hit = i;
+ // insert the tile into the cache
+ if ( tile_cache.insert_tile( e ) ) {
+ // Schedule tile for loading
+ loader.add( e );
+ } else {
+ // insert failed (cache full with no available entries to
+ // delete.) Try again later
+ delete e;