1
0
Fork 0

Converted to use new bucket routines.

This commit is contained in:
curt 1999-03-25 19:03:24 +00:00
parent 3ef9585ac0
commit b722f8bb63
6 changed files with 76 additions and 52 deletions

View file

@ -29,7 +29,7 @@
#include <Debug/logstream.hxx> #include <Debug/logstream.hxx>
#include <Scenery/tile.hxx> #include <Scenery/tile.hxx>
#include "Bucket/bucketutils.hxx" #include "Bucket/newbucket.hxx"
#include "tile.hxx" #include "tile.hxx"
@ -67,6 +67,9 @@ fgTILE::release_fragments()
// $Log$ // $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 // Revision 1.15 1999/03/02 01:03:29 curt
// Tweaks for building with native SGI compilers. // Tweaks for building with native SGI compilers.
// //

View file

@ -46,18 +46,19 @@
#include <vector> #include <vector>
#include STL_STRING #include STL_STRING
#include <Bucket/bucketutils.h> #include <Bucket/newbucket.hxx>
#include <Math/mat3.h> #include <Math/mat3.h>
#include <Math/point3d.hxx> #include <Math/point3d.hxx>
#include <Objects/fragment.hxx> #include <Objects/fragment.hxx>
FG_USING_STD(string);
FG_USING_STD(vector);
#ifdef FG_HAVE_NATIVE_SGI_COMPILERS #ifdef FG_HAVE_NATIVE_SGI_COMPILERS
#include <strings.h> #include <strings.h>
#endif #endif
FG_USING_STD(string);
FG_USING_STD(vector);
// Scenery tile class // Scenery tile class
class fgTILE { class fgTILE {
@ -79,7 +80,7 @@ public:
GLdouble model_view[16]; GLdouble model_view[16];
// this tile's official location in the world // 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 // the tile cache will mark here if the tile is being used
bool used; bool used;
@ -161,6 +162,9 @@ private:
// $Log$ // $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 // Revision 1.25 1999/03/02 01:03:30 curt
// Tweaks for building with native SGI compilers. // Tweaks for building with native SGI compilers.
// //

View file

@ -35,7 +35,7 @@
#include <Debug/logstream.hxx> #include <Debug/logstream.hxx>
#include <Airports/genapt.hxx> #include <Airports/genapt.hxx>
#include <Bucket/bucketutils.hxx> // #include <Bucket/bucketutils.hxx>
#include <Main/options.hxx> #include <Main/options.hxx>
#include <Main/views.hxx> #include <Main/views.hxx>
#include <Objects/obj.hxx> #include <Objects/obj.hxx>
@ -69,7 +69,7 @@ fgTILECACHE::init( void )
// Search for the specified "bucket" in the cache // Search for the specified "bucket" in the cache
int int
fgTILECACHE::exists( const fgBUCKET& p ) fgTILECACHE::exists( const FGBucket& p )
{ {
int i; int i;
@ -87,11 +87,11 @@ fgTILECACHE::exists( const fgBUCKET& p )
// Fill in a tile cache entry with real data for the specified bucket // Fill in a tile cache entry with real data for the specified bucket
void 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 // Load the appropriate data file and build tile fragment list
string tile_path = current_options.get_fg_root() + 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].used = true;
tile_cache[index].tile_bucket = p; tile_cache[index].tile_bucket = p;
@ -181,6 +181,9 @@ fgTILECACHE::~fgTILECACHE( void ) {
// $Log$ // $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 // Revision 1.22 1999/02/26 22:10:04 curt
// Added initial support for native SGI compilers. // Added initial support for native SGI compilers.
// //

View file

@ -42,7 +42,7 @@
#include <GL/glut.h> #include <GL/glut.h>
#include <XGL/xgl.h> #include <XGL/xgl.h>
#include <Bucket/bucketutils.h> #include <Bucket/newbucket.hxx>
#include <Math/point3d.hxx> #include <Math/point3d.hxx>
#include "tile.hxx" #include "tile.hxx"
@ -75,7 +75,7 @@ public:
void init( void ); void init( void );
// Search for the specified "bucket" in the cache // 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 // Return index of next available slot in tile cache
int next_avail( void ); int next_avail( void );
@ -84,7 +84,7 @@ public:
void entry_free( int index ); void entry_free( int index );
// Fill in a tile cache entry with real data for the specified bucket // 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 // Return a pointer to the specified tile cache entry
fgTILE *get_tile( int index ) { fgTILE *get_tile( int index ) {
@ -104,6 +104,9 @@ extern fgTILECACHE global_tile_cache;
// $Log$ // $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 // Revision 1.13 1998/11/09 23:40:51 curt
// Bernie Bright <bbright@c031.aone.net.au> writes: // Bernie Bright <bbright@c031.aone.net.au> writes:
// I've made some changes to the Scenery handling. Basically just tidy ups. // I've made some changes to the Scenery handling. Basically just tidy ups.

View file

@ -36,7 +36,7 @@
#include <Aircraft/aircraft.hxx> #include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx> #include <Debug/logstream.hxx>
#include <Bucket/bucketutils.hxx> // #include <Bucket/bucketutils.hxx>
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
#include <Main/options.hxx> #include <Main/options.hxx>
#include <Main/views.hxx> #include <Main/views.hxx>
@ -89,7 +89,7 @@ int fgTileMgrInit( void ) {
// load a tile // load a tile
void fgTileMgrLoadTile( const fgBUCKET& p, int *index) { void fgTileMgrLoadTile( const FGBucket& p, int *index) {
fgTILECACHE *c; fgTILECACHE *c;
c = &global_tile_cache; 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(); p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z();
p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z(); p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z();
dist = fgPointLineSquared(p, p0, d); return fgPointLineSquared(p, p0, d);
// cout << "dist = " << dist << endl;
return(dist);
} }
@ -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. // explicitely. lat & lon are in radians. abs_view_pos in meters.
// Returns result in meters. // Returns result in meters.
double double
fgTileMgrCurElevNEW( const fgBUCKET& p ) { fgTileMgrCurElevNEW( const FGBucket& p ) {
fgTILE *t; fgTILE *t;
fgFRAGMENT *frag_ptr; fgFRAGMENT *frag_ptr;
Point3D abs_view_pos = current_view.get_abs_view_pos(); Point3D abs_view_pos = current_view.get_abs_view_pos();
@ -157,7 +153,7 @@ fgTileMgrCurElevNEW( const fgBUCKET& p ) {
scenery.next_center = t->center; scenery.next_center = t->center;
FG_LOG( FG_TERRAIN, FG_DEBUG, 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, FG_LOG( FG_TERRAIN, FG_DEBUG,
"abs_view_pos = " << abs_view_pos ); "abs_view_pos = " << abs_view_pos );
@ -231,18 +227,14 @@ double
fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) { fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) {
fgTILECACHE *c; fgTILECACHE *c;
fgTILE *t; fgTILE *t;
// fgVIEW *v;
fgFRAGMENT *frag_ptr; fgFRAGMENT *frag_ptr;
fgBUCKET p;
Point3D earth_center(0.0); Point3D earth_center(0.0);
Point3D result; Point3D result;
MAT3vec local_up; MAT3vec local_up;
double dist, lat_geod, alt, sea_level_r; double dist, lat_geod, alt, sea_level_r;
// double x, y, z;
int index; int index;
c = &global_tile_cache; c = &global_tile_cache;
// v = &current_view;
local_up[0] = abs_view_pos.x(); local_up[0] = abs_view_pos.x();
local_up[1] = abs_view_pos.y(); 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 ); FG_LOG( FG_TERRAIN, FG_DEBUG, "Absolute view pos = " << abs_view_pos );
// Find current translation offset // 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); index = c->exists(p);
if ( index < 0 ) { if ( index < 0 ) {
FG_LOG( FG_TERRAIN, FG_WARN, "Tile not found" ); 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, FG_LOG( FG_TERRAIN, FG_DEBUG,
"Pos = (" << lon * RAD_TO_DEG << ", " << lat * RAD_TO_DEG "Pos = (" << lon * RAD_TO_DEG << ", " << lat * RAD_TO_DEG
<< ") Current bucket = " << p << ") 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 // calculate tile offset
// x = (t->offset.x = t->center.x - scenery.center.x); // 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); */ v->local_up), t->bounding_radius); */
dist = point_line_dist_squared( t->center, abs_view_pos, local_up ); 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) ) { if ( dist < FG_SQUARE(t->bounding_radius) ) {
// traverse fragment list for tile // traverse fragment list for tile
@ -334,8 +331,10 @@ fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) {
int fgTileMgrUpdate( void ) { int fgTileMgrUpdate( void ) {
fgTILECACHE *c; fgTILECACHE *c;
FGInterface *f; FGInterface *f;
fgBUCKET p1, p2; FGBucket p2;
static fgBUCKET p_last = {-1000, 0, 0, 0}; 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 tile_diameter;
int i, j, dw, dh; int i, j, dw, dh;
@ -344,15 +343,15 @@ int fgTileMgrUpdate( void ) {
tile_diameter = current_options.get_tile_diameter(); tile_diameter = current_options.get_tile_diameter();
fgBucketFind( f->get_Longitude() * RAD_TO_DEG, FGBucket p1( f->get_Longitude() * RAD_TO_DEG,
f->get_Latitude() * RAD_TO_DEG, &p1); f->get_Latitude() * RAD_TO_DEG );
dw = tile_diameter / 2; dw = tile_diameter / 2;
dh = tile_diameter / 2; dh = tile_diameter / 2;
if ( p1 == p_last ) { if ( p1 == p_last ) {
// same bucket as last time // same bucket as last time
FG_LOG( FG_TERRAIN, FG_DEBUG, "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 // First time through, initialize the system and load all
// relavant tiles // relavant tiles
@ -368,7 +367,10 @@ int fgTileMgrUpdate( void ) {
// build the local area list and update cache // build the local area list and update cache
for ( j = 0; j < tile_diameter; j++ ) { for ( j = 0; j < tile_diameter; j++ ) {
for ( i = 0; i < tile_diameter; i++ ) { 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]); 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 ); FG_LOG( FG_TERRAIN, FG_INFO, "Updating Tile list for " << p1 );
if ( (p1.lon > p_last.lon) || if ( (p1.get_lon() > p_last.get_lon()) ||
( (p1.lon == p_last.lon) && (p1.x > p_last.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,
" Loading " << tile_diameter << "tiles" ); " Loading " << tile_diameter << "tiles" );
for ( j = 0; j < tile_diameter; j++ ) { for ( j = 0; j < tile_diameter; j++ ) {
@ -393,12 +395,13 @@ int fgTileMgrUpdate( void ) {
tiles[(j*tile_diameter) + i + 1]; tiles[(j*tile_diameter) + i + 1];
} }
// load in new column // 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) + fgTileMgrLoadTile( p2, &tiles[(j*tile_diameter) +
tile_diameter - 1]); tile_diameter - 1]);
} }
} else if ( (p1.lon < p_last.lon) || } else if ( (p1.get_lon() < p_last.get_lon()) ||
( (p1.lon == p_last.lon) && (p1.x < p_last.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,
" Loading " << tile_diameter << "tiles" ); " Loading " << tile_diameter << "tiles" );
for ( j = 0; j < tile_diameter; j++ ) { for ( j = 0; j < tile_diameter; j++ ) {
@ -408,13 +411,14 @@ int fgTileMgrUpdate( void ) {
tiles[(j*tile_diameter) + i - 1]; tiles[(j*tile_diameter) + i - 1];
} }
// load in new column // 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]); fgTileMgrLoadTile( p2, &tiles[(j*tile_diameter) + 0]);
} }
} }
if ( (p1.lat > p_last.lat) || if ( (p1.get_lat() > p_last.get_lat()) ||
( (p1.lat == p_last.lat) && (p1.y > p_last.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,
" Loading " << tile_diameter << "tiles" ); " Loading " << tile_diameter << "tiles" );
for ( i = 0; i < tile_diameter; i++ ) { for ( i = 0; i < tile_diameter; i++ ) {
@ -424,12 +428,13 @@ int fgTileMgrUpdate( void ) {
tiles[((j+1) * tile_diameter) + i]; tiles[((j+1) * tile_diameter) + i];
} }
// load in new column // 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) * fgTileMgrLoadTile( p2, &tiles[((tile_diameter-1) *
tile_diameter) + i]); tile_diameter) + i]);
} }
} else if ( (p1.lat < p_last.lat) || } else if ( (p1.get_lat() < p_last.get_lat()) ||
( (p1.lat == p_last.lat) && (p1.y < p_last.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,
" Loading " << tile_diameter << "tiles" ); " Loading " << tile_diameter << "tiles" );
for ( i = 0; i < tile_diameter; i++ ) { for ( i = 0; i < tile_diameter; i++ ) {
@ -439,7 +444,8 @@ int fgTileMgrUpdate( void ) {
tiles[((j-1) * tile_diameter) + i]; tiles[((j-1) * tile_diameter) + i];
} }
// load in new column // 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]); fgTileMgrLoadTile( p2, &tiles[0 + i]);
} }
} }
@ -453,10 +459,9 @@ int fgTileMgrUpdate( void ) {
fgTileMgrCurElev( f->get_Longitude(), f->get_Latitude(), fgTileMgrCurElev( f->get_Longitude(), f->get_Latitude(),
tmp_abs_view_pos ); tmp_abs_view_pos );
p_last.lon = p1.lon; p_last = p1;
p_last.lat = p1.lat; last_lon = f->get_Longitude() * RAD_TO_DEG;
p_last.x = p1.x; last_lat = f->get_Latitude() * RAD_TO_DEG;
p_last.y = p1.y;
return 1; return 1;
} }
@ -758,6 +763,9 @@ void fgTileMgrRender( void ) {
// $Log$ // $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 // Revision 1.54 1999/02/26 22:10:05 curt
// Added initial support for native SGI compilers. // Added initial support for native SGI compilers.
// //

View file

@ -31,7 +31,7 @@
#endif #endif
#include <Bucket/bucketutils.hxx> #include <Bucket/newbucket.hxx>
// Initialize the Tile Manager subsystem // 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 // 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. // explicitely. lat & lon are in radians. abs_view_pos in meters.
// Returns result 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 ); double fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos );
@ -59,6 +59,9 @@ void fgTileMgrRender( void );
// $Log$ // $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 // Revision 1.7 1999/01/27 04:49:49 curt
// Fixes so that the sim can start out at an airport below sea level. // Fixes so that the sim can start out at an airport below sea level.
// //