diff --git a/Scenery/tile.cxx b/Scenery/tile.cxx index 1443c6113..bd95eb6d5 100644 --- a/Scenery/tile.cxx +++ b/Scenery/tile.cxx @@ -29,7 +29,7 @@ #include #include -#include "Bucket/bucketutils.hxx" +#include "Bucket/newbucket.hxx" #include "tile.hxx" @@ -67,6 +67,9 @@ fgTILE::release_fragments() // $Log$ +// Revision 1.16 1999/03/25 19:03:24 curt +// Converted to use new bucket routines. +// // Revision 1.15 1999/03/02 01:03:29 curt // Tweaks for building with native SGI compilers. // diff --git a/Scenery/tile.hxx b/Scenery/tile.hxx index 46240a910..4fd636e17 100644 --- a/Scenery/tile.hxx +++ b/Scenery/tile.hxx @@ -46,18 +46,19 @@ #include #include STL_STRING -#include +#include #include #include #include -FG_USING_STD(string); -FG_USING_STD(vector); - #ifdef FG_HAVE_NATIVE_SGI_COMPILERS #include #endif +FG_USING_STD(string); +FG_USING_STD(vector); + + // Scenery tile class class fgTILE { @@ -79,7 +80,7 @@ public: GLdouble model_view[16]; // this tile's official location in the world - fgBUCKET tile_bucket; + FGBucket tile_bucket; // the tile cache will mark here if the tile is being used bool used; @@ -161,6 +162,9 @@ private: // $Log$ +// Revision 1.26 1999/03/25 19:03:25 curt +// Converted to use new bucket routines. +// // Revision 1.25 1999/03/02 01:03:30 curt // Tweaks for building with native SGI compilers. // diff --git a/Scenery/tilecache.cxx b/Scenery/tilecache.cxx index 21f93f7be..8b8c441d7 100644 --- a/Scenery/tilecache.cxx +++ b/Scenery/tilecache.cxx @@ -35,7 +35,7 @@ #include #include -#include +// #include #include
#include
#include @@ -69,7 +69,7 @@ fgTILECACHE::init( void ) // Search for the specified "bucket" in the cache int -fgTILECACHE::exists( const fgBUCKET& p ) +fgTILECACHE::exists( const FGBucket& p ) { int i; @@ -87,11 +87,11 @@ fgTILECACHE::exists( const fgBUCKET& p ) // Fill in a tile cache entry with real data for the specified bucket void -fgTILECACHE::fill_in( int index, const fgBUCKET& p ) +fgTILECACHE::fill_in( int index, FGBucket& p ) { // Load the appropriate data file and build tile fragment list string tile_path = current_options.get_fg_root() + - "/Scenery/" + fgBucketGenBasePath(p) + "/" + fgBucketGenIndex(p); + "/Scenery/" + p.gen_base_path() + "/" + p.gen_index_str(); tile_cache[index].used = true; tile_cache[index].tile_bucket = p; @@ -181,6 +181,9 @@ fgTILECACHE::~fgTILECACHE( void ) { // $Log$ +// Revision 1.23 1999/03/25 19:03:26 curt +// Converted to use new bucket routines. +// // Revision 1.22 1999/02/26 22:10:04 curt // Added initial support for native SGI compilers. // diff --git a/Scenery/tilecache.hxx b/Scenery/tilecache.hxx index 742921e3e..49e7c0c79 100644 --- a/Scenery/tilecache.hxx +++ b/Scenery/tilecache.hxx @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "tile.hxx" @@ -75,7 +75,7 @@ public: void init( void ); // Search for the specified "bucket" in the cache - int exists( const fgBUCKET& p ); + int exists( const FGBucket& p ); // Return index of next available slot in tile cache int next_avail( void ); @@ -84,7 +84,7 @@ public: void entry_free( int index ); // Fill in a tile cache entry with real data for the specified bucket - void fill_in( int index, const fgBUCKET& p ); + void fill_in( int index, FGBucket& p ); // Return a pointer to the specified tile cache entry fgTILE *get_tile( int index ) { @@ -104,6 +104,9 @@ extern fgTILECACHE global_tile_cache; // $Log$ +// Revision 1.14 1999/03/25 19:03:27 curt +// Converted to use new bucket routines. +// // Revision 1.13 1998/11/09 23:40:51 curt // Bernie Bright writes: // I've made some changes to the Scenery handling. Basically just tidy ups. diff --git a/Scenery/tilemgr.cxx b/Scenery/tilemgr.cxx index ba813f900..5c8e9b2c6 100644 --- a/Scenery/tilemgr.cxx +++ b/Scenery/tilemgr.cxx @@ -36,7 +36,7 @@ #include #include -#include +// #include #include #include
#include
@@ -89,7 +89,7 @@ int fgTileMgrInit( void ) { // load a tile -void fgTileMgrLoadTile( const fgBUCKET& p, int *index) { +void fgTileMgrLoadTile( const FGBucket& p, int *index) { fgTILECACHE *c; c = &global_tile_cache; @@ -117,11 +117,7 @@ static double point_line_dist_squared( const Point3D& tc, const Point3D& vp, p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z(); p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z(); - dist = fgPointLineSquared(p, p0, d); - - // cout << "dist = " << dist << endl; - - return(dist); + return fgPointLineSquared(p, p0, d); } @@ -130,7 +126,7 @@ static double point_line_dist_squared( const Point3D& tc, const Point3D& vp, // explicitely. lat & lon are in radians. abs_view_pos in meters. // Returns result in meters. double -fgTileMgrCurElevNEW( const fgBUCKET& p ) { +fgTileMgrCurElevNEW( const FGBucket& p ) { fgTILE *t; fgFRAGMENT *frag_ptr; Point3D abs_view_pos = current_view.get_abs_view_pos(); @@ -157,7 +153,7 @@ fgTileMgrCurElevNEW( const fgBUCKET& p ) { scenery.next_center = t->center; FG_LOG( FG_TERRAIN, FG_DEBUG, - "Current bucket = " << p << " Index = " << fgBucketGenIndex(&p) ); + "Current bucket = " << p << " Index = " << p.gen_index_str() ); FG_LOG( FG_TERRAIN, FG_DEBUG, "abs_view_pos = " << abs_view_pos ); @@ -231,18 +227,14 @@ double fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) { fgTILECACHE *c; fgTILE *t; - // fgVIEW *v; fgFRAGMENT *frag_ptr; - fgBUCKET p; Point3D earth_center(0.0); Point3D result; MAT3vec local_up; double dist, lat_geod, alt, sea_level_r; - // double x, y, z; int index; c = &global_tile_cache; - // v = ¤t_view; local_up[0] = abs_view_pos.x(); local_up[1] = abs_view_pos.y(); @@ -251,7 +243,7 @@ fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) { FG_LOG( FG_TERRAIN, FG_DEBUG, "Absolute view pos = " << abs_view_pos ); // Find current translation offset - fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p); + FGBucket p( lon * RAD_TO_DEG, lat * RAD_TO_DEG ); index = c->exists(p); if ( index < 0 ) { FG_LOG( FG_TERRAIN, FG_WARN, "Tile not found" ); @@ -265,7 +257,10 @@ fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) { FG_LOG( FG_TERRAIN, FG_DEBUG, "Pos = (" << lon * RAD_TO_DEG << ", " << lat * RAD_TO_DEG << ") Current bucket = " << p - << " Index = " << fgBucketGenIndex(&p) ); + << " Index = " << p.gen_index_str() ); + + FG_LOG( FG_TERRAIN, FG_DEBUG, "Tile center " << t->center + << " bounding radius = " << t->bounding_radius ); // calculate tile offset // x = (t->offset.x = t->center.x - scenery.center.x); @@ -281,6 +276,8 @@ fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) { v->local_up), t->bounding_radius); */ dist = point_line_dist_squared( t->center, abs_view_pos, local_up ); + FG_LOG( FG_TERRAIN, FG_DEBUG, "(gross check) dist squared = " << dist ); + if ( dist < FG_SQUARE(t->bounding_radius) ) { // traverse fragment list for tile @@ -334,8 +331,10 @@ fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) { int fgTileMgrUpdate( void ) { fgTILECACHE *c; FGInterface *f; - fgBUCKET p1, p2; - static fgBUCKET p_last = {-1000, 0, 0, 0}; + FGBucket p2; + static FGBucket p_last(false); + static double last_lon = -1000.0; // in degrees + static double last_lat = -1000.0; // in degrees int tile_diameter; int i, j, dw, dh; @@ -344,15 +343,15 @@ int fgTileMgrUpdate( void ) { tile_diameter = current_options.get_tile_diameter(); - fgBucketFind( f->get_Longitude() * RAD_TO_DEG, - f->get_Latitude() * RAD_TO_DEG, &p1); + FGBucket p1( f->get_Longitude() * RAD_TO_DEG, + f->get_Latitude() * RAD_TO_DEG ); dw = tile_diameter / 2; dh = tile_diameter / 2; if ( p1 == p_last ) { // same bucket as last time FG_LOG( FG_TERRAIN, FG_DEBUG, "Same bucket as last time" ); - } else if ( p_last.lon == -1000 ) { + } else if ( p_last.get_lon() == -1000 ) { // First time through, initialize the system and load all // relavant tiles @@ -368,7 +367,10 @@ int fgTileMgrUpdate( void ) { // build the local area list and update cache for ( j = 0; j < tile_diameter; j++ ) { for ( i = 0; i < tile_diameter; i++ ) { - fgBucketOffset(&p1, &p2, i - dw, j - dh); + // fgBucketOffset(&p1, &p2, i - dw, j - dh); + p2 = fgBucketOffset( f->get_Longitude() * RAD_TO_DEG, + f->get_Latitude() * RAD_TO_DEG, + i - dw, j -dh ); fgTileMgrLoadTile( p2, &tiles[(j*tile_diameter) + i]); } } @@ -382,8 +384,8 @@ int fgTileMgrUpdate( void ) { FG_LOG( FG_TERRAIN, FG_INFO, "Updating Tile list for " << p1 ); - if ( (p1.lon > p_last.lon) || - ( (p1.lon == p_last.lon) && (p1.x > p_last.x) ) ) { + if ( (p1.get_lon() > p_last.get_lon()) || + ( (p1.get_lon() == p_last.get_lon()) && (p1.get_x() > p_last.get_x()) ) ) { FG_LOG( FG_TERRAIN, FG_INFO, " Loading " << tile_diameter << "tiles" ); for ( j = 0; j < tile_diameter; j++ ) { @@ -393,12 +395,13 @@ int fgTileMgrUpdate( void ) { tiles[(j*tile_diameter) + i + 1]; } // load in new column - fgBucketOffset(&p_last, &p2, dw + 1, j - dh); + // fgBucketOffset(&p_last, &p2, dw + 1, j - dh); + p2 = fgBucketOffset( last_lon, last_lat, dw + 1, j - dh ); fgTileMgrLoadTile( p2, &tiles[(j*tile_diameter) + tile_diameter - 1]); } - } else if ( (p1.lon < p_last.lon) || - ( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) { + } else if ( (p1.get_lon() < p_last.get_lon()) || + ( (p1.get_lon() == p_last.get_lon()) && (p1.get_x() < p_last.get_x()) ) ) { FG_LOG( FG_TERRAIN, FG_INFO, " Loading " << tile_diameter << "tiles" ); for ( j = 0; j < tile_diameter; j++ ) { @@ -408,13 +411,14 @@ int fgTileMgrUpdate( void ) { tiles[(j*tile_diameter) + i - 1]; } // load in new column - fgBucketOffset(&p_last, &p2, -dw - 1, j - dh); + // fgBucketOffset(&p_last, &p2, -dw - 1, j - dh); + p2 = fgBucketOffset( last_lon, last_lat, -dw - 1, j - dh ); fgTileMgrLoadTile( p2, &tiles[(j*tile_diameter) + 0]); } } - if ( (p1.lat > p_last.lat) || - ( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) { + if ( (p1.get_lat() > p_last.get_lat()) || + ( (p1.get_lat() == p_last.get_lat()) && (p1.get_y() > p_last.get_y()) ) ) { FG_LOG( FG_TERRAIN, FG_INFO, " Loading " << tile_diameter << "tiles" ); for ( i = 0; i < tile_diameter; i++ ) { @@ -424,12 +428,13 @@ int fgTileMgrUpdate( void ) { tiles[((j+1) * tile_diameter) + i]; } // load in new column - fgBucketOffset(&p_last, &p2, i - dw, dh + 1); + // fgBucketOffset(&p_last, &p2, i - dw, dh + 1); + p2 = fgBucketOffset( last_lon, last_lat, i - dw, dh + 1); fgTileMgrLoadTile( p2, &tiles[((tile_diameter-1) * tile_diameter) + i]); } - } else if ( (p1.lat < p_last.lat) || - ( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) { + } else if ( (p1.get_lat() < p_last.get_lat()) || + ( (p1.get_lat() == p_last.get_lat()) && (p1.get_y() < p_last.get_y()) ) ) { FG_LOG( FG_TERRAIN, FG_INFO, " Loading " << tile_diameter << "tiles" ); for ( i = 0; i < tile_diameter; i++ ) { @@ -439,7 +444,8 @@ int fgTileMgrUpdate( void ) { tiles[((j-1) * tile_diameter) + i]; } // load in new column - fgBucketOffset(&p_last, &p2, i - dw, -dh - 1); + // fgBucketOffset(&p_last, &p2, i - dw, -dh - 1); + p2 = fgBucketOffset( last_lon, last_lat, i - dw, -dh - 1); fgTileMgrLoadTile( p2, &tiles[0 + i]); } } @@ -453,10 +459,9 @@ int fgTileMgrUpdate( void ) { fgTileMgrCurElev( f->get_Longitude(), f->get_Latitude(), tmp_abs_view_pos ); - p_last.lon = p1.lon; - p_last.lat = p1.lat; - p_last.x = p1.x; - p_last.y = p1.y; + p_last = p1; + last_lon = f->get_Longitude() * RAD_TO_DEG; + last_lat = f->get_Latitude() * RAD_TO_DEG; return 1; } @@ -758,6 +763,9 @@ void fgTileMgrRender( void ) { // $Log$ +// Revision 1.55 1999/03/25 19:03:28 curt +// Converted to use new bucket routines. +// // Revision 1.54 1999/02/26 22:10:05 curt // Added initial support for native SGI compilers. // diff --git a/Scenery/tilemgr.hxx b/Scenery/tilemgr.hxx index 51939495c..d35958c88 100644 --- a/Scenery/tilemgr.hxx +++ b/Scenery/tilemgr.hxx @@ -31,7 +31,7 @@ #endif -#include +#include // Initialize the Tile Manager subsystem @@ -47,7 +47,7 @@ int fgTileMgrUpdate( void ); // render the scene, but we'd also like to be able to do this // explicitely. lat & lon are in radians. abs_view_pos in meters. // Returns result in meters. -double fgTileMgrCurElevNEW( const fgBUCKET& p ); +double fgTileMgrCurElevNEW( const FGBucket& p ); double fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ); @@ -59,6 +59,9 @@ void fgTileMgrRender( void ); // $Log$ +// Revision 1.8 1999/03/25 19:03:29 curt +// Converted to use new bucket routines. +// // Revision 1.7 1999/01/27 04:49:49 curt // Fixes so that the sim can start out at an airport below sea level. //