1
0
Fork 0

Removed extra square array of indirection indices between what's visible

and where these things are in the cache.  We just let ssg sort out what needs
to be drawn based on visual range.
This commit is contained in:
curt 1999-08-08 15:23:39 +00:00
parent 1e8b5c8956
commit a5f19c7a7c
4 changed files with 27 additions and 49 deletions

View file

@ -2,7 +2,7 @@
// //
// Written by Curtis Olson, started January 1998. // Written by Curtis Olson, started January 1998.
// //
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com // Copyright (C) 1998, 1999 Curtis L. Olson - curt@flightgear.org
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as

View file

@ -2,7 +2,7 @@
// //
// Written by Curtis Olson, started January 1998. // Written by Curtis Olson, started January 1998.
// //
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com // Copyright (C) 1998, 1999 Curtis L. Olson - curt@flightgear.org
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
@ -82,6 +82,9 @@ public:
return &tile_cache[index]; return &tile_cache[index];
} }
// Return the cache size
inline size_t get_size() const { return tile_cache.size(); }
// Destructor // Destructor
~FGTileCache( void ); ~FGTileCache( void );
}; };

View file

@ -445,7 +445,7 @@ int FGTileMgr::update( void ) {
p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG, p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG, f->get_Latitude() * RAD_TO_DEG,
0, 0 ); 0, 0 );
tiles[(dh*tile_diameter) + dw] = sched_tile( p2 ); sched_tile( p2 );
for ( i = 3; i <= tile_diameter; i = i + 2 ) { for ( i = 3; i <= tile_diameter; i = i + 2 ) {
int span = i / 2; int span = i / 2;
@ -455,7 +455,7 @@ int FGTileMgr::update( void ) {
p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG, p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG, f->get_Latitude() * RAD_TO_DEG,
j, -span ); j, -span );
tiles[((dh-span)*tile_diameter) + dw+j] = sched_tile( p2 ); sched_tile( p2 );
} }
// top row // top row
@ -463,7 +463,7 @@ int FGTileMgr::update( void ) {
p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG, p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG, f->get_Latitude() * RAD_TO_DEG,
j, span ); j, span );
tiles[((dh+span)*tile_diameter) + dw+j] = sched_tile( p2 ); sched_tile( p2 );
} }
// middle rows // middle rows
@ -471,11 +471,11 @@ int FGTileMgr::update( void ) {
p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG, p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG, f->get_Latitude() * RAD_TO_DEG,
-span, j ); -span, j );
tiles[((dh+j)*tile_diameter) + dw-span] = sched_tile( p2 ); sched_tile( p2 );
p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG, p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG, f->get_Latitude() * RAD_TO_DEG,
span, j ); span, j );
tiles[((dh+j)*tile_diameter) + dw+span] = sched_tile( p2 ); sched_tile( p2 );
} }
} }
@ -486,7 +486,7 @@ int FGTileMgr::update( void ) {
p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG, p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG, f->get_Latitude() * RAD_TO_DEG,
i - dw, j -dh ); i - dw, j -dh );
tiles[(j*tile_diameter) + i] = sched_tile( p2 ); sched_tile( p2 );
} }
} */ } */
@ -526,19 +526,15 @@ int FGTileMgr::update( void ) {
FG_LOG( FG_TERRAIN, FG_INFO, "Updating Tile list for " << p1 ); FG_LOG( FG_TERRAIN, FG_INFO, "Updating Tile list for " << p1 );
if ( (p1.get_lon() > p_last.get_lon()) || if ( (p1.get_lon() > p_last.get_lon()) ||
( (p1.get_lon() == p_last.get_lon()) && (p1.get_x() > p_last.get_x()) ) ) { ( (p1.get_lon() == p_last.get_lon()) &&
(p1.get_x() > p_last.get_x()) ) ) {
FG_LOG( FG_TERRAIN, FG_INFO, FG_LOG( FG_TERRAIN, FG_INFO,
" (East) Loading " << tile_diameter << " tiles" ); " (East) Loading " << tile_diameter << " tiles" );
for ( j = 0; j < tile_diameter; j++ ) { for ( j = 0; j < tile_diameter; j++ ) {
// scrolling East // scrolling East
disable_tile( tiles[(j*tile_diameter) + 0] ); // schedule new column
for ( i = 0; i < tile_diameter - 1; i++ ) {
tiles[(j*tile_diameter) + i] =
tiles[(j*tile_diameter) + i + 1];
}
// load in new column
p2 = fgBucketOffset( last_lon, last_lat, dw + 1, j - dh ); p2 = fgBucketOffset( last_lon, last_lat, dw + 1, j - dh );
tiles[(j*tile_diameter) + tile_diameter - 1] = sched_tile( p2 ); sched_tile( p2 );
} }
} else if ( (p1.get_lon() < p_last.get_lon()) || } else if ( (p1.get_lon() < p_last.get_lon()) ||
( (p1.get_lon() == p_last.get_lon()) && ( (p1.get_lon() == p_last.get_lon()) &&
@ -547,47 +543,33 @@ int FGTileMgr::update( void ) {
" (West) Loading " << tile_diameter << " tiles" ); " (West) Loading " << tile_diameter << " tiles" );
for ( j = 0; j < tile_diameter; j++ ) { for ( j = 0; j < tile_diameter; j++ ) {
// scrolling West // scrolling West
disable_tile( tiles[(j*tile_diameter) + tile_diameter - 1] ); // schedule new column
for ( i = tile_diameter - 1; i > 0; i-- ) {
tiles[(j*tile_diameter) + i] =
tiles[(j*tile_diameter) + i - 1];
}
// load in new column
p2 = fgBucketOffset( last_lon, last_lat, -dw - 1, j - dh ); p2 = fgBucketOffset( last_lon, last_lat, -dw - 1, j - dh );
tiles[(j*tile_diameter) + 0] = sched_tile( p2 ); sched_tile( p2 );
} }
} }
if ( (p1.get_lat() > p_last.get_lat()) || if ( (p1.get_lat() > p_last.get_lat()) ||
( (p1.get_lat() == p_last.get_lat()) && (p1.get_y() > p_last.get_y()) ) ) { ( (p1.get_lat() == p_last.get_lat()) &&
(p1.get_y() > p_last.get_y()) ) ) {
FG_LOG( FG_TERRAIN, FG_INFO, FG_LOG( FG_TERRAIN, FG_INFO,
" (North) Loading " << tile_diameter << " tiles" ); " (North) Loading " << tile_diameter << " tiles" );
for ( i = 0; i < tile_diameter; i++ ) { for ( i = 0; i < tile_diameter; i++ ) {
// scrolling North // scrolling North
disable_tile( tiles[0 + i] ); // schedule new row
for ( j = 0; j < tile_diameter - 1; j++ ) {
tiles[(j * tile_diameter) + i] =
tiles[((j+1) * tile_diameter) + i];
}
// load in new column
p2 = fgBucketOffset( last_lon, last_lat, i - dw, dh + 1); p2 = fgBucketOffset( last_lon, last_lat, i - dw, dh + 1);
tiles[((tile_diameter-1) * tile_diameter) + i] = sched_tile( p2 );
sched_tile( p2 );
} }
} else if ( (p1.get_lat() < p_last.get_lat()) || } else if ( (p1.get_lat() < p_last.get_lat()) ||
( (p1.get_lat() == p_last.get_lat()) && (p1.get_y() < p_last.get_y()) ) ) { ( (p1.get_lat() == p_last.get_lat()) &&
(p1.get_y() < p_last.get_y()) ) ) {
FG_LOG( FG_TERRAIN, FG_INFO, FG_LOG( FG_TERRAIN, FG_INFO,
" (South) Loading " << tile_diameter << " tiles" ); " (South) Loading " << tile_diameter << " tiles" );
for ( i = 0; i < tile_diameter; i++ ) { for ( i = 0; i < tile_diameter; i++ ) {
// scrolling South // scrolling South
disable_tile( tiles[((tile_diameter-1) * tile_diameter) + i] ); // schedule new row
for ( j = tile_diameter - 1; j > 0; j-- ) {
tiles[(j * tile_diameter) + i] =
tiles[((j-1) * tile_diameter) + i];
}
// load in new column
p2 = fgBucketOffset( last_lon, last_lat, i - dw, -dh - 1); p2 = fgBucketOffset( last_lon, last_lat, i - dw, -dh - 1);
tiles[0 + i] = sched_tile( p2 ); sched_tile( p2 );
} }
} }
} }
@ -695,16 +677,13 @@ update_tile_geometry( FGTileEntry *t, GLdouble *MODEL_VIEW)
void FGTileMgr::prep_ssg_nodes( void ) { void FGTileMgr::prep_ssg_nodes( void ) {
FGTileEntry *t; FGTileEntry *t;
int tile_diameter = current_options.get_tile_diameter();
float ranges[2]; float ranges[2];
ranges[0] = 0.0f; ranges[0] = 0.0f;
// traverse the potentially viewable tile list and update range // traverse the potentially viewable tile list and update range
// selector and transform // selector and transform
for ( int i = 0; i < (tile_diameter * tile_diameter); i++ ) { for ( int i = 0; i < (int)global_tile_cache.get_size(); i++ ) {
int index = tiles[i]; t = global_tile_cache.get_tile( i );
t = global_tile_cache.get_tile(index);
if ( t->is_loaded() ) { if ( t->is_loaded() ) {
// set range selector (LOD trick) to be distance to center // set range selector (LOD trick) to be distance to center

View file

@ -63,10 +63,6 @@ class FGTileMgr {
private: private:
// closest (potentially viewable) tiles, centered on current tile.
// This is an array of pointers to cache indexes.
int tiles[FG_LOCAL_X_Y];
// Tile loading state // Tile loading state
enum load_state { enum load_state {
Start = 0, Start = 0,