#include <GL/glut.h>
#include <XGL/xgl.h>
+#include <Airports/genapt.hxx>
#include <Bucket/bucketutils.h>
#include <Debug/fg_debug.h>
#include <Main/options.hxx>
// Initialize the tile cache subsystem
-void fgTILECACHE::Init( void ) {
+void
+fgTILECACHE::init( void )
+{
int i;
fgPrintf(FG_TERRAIN, FG_INFO, "Initializing the tile cache.\n");
// Search for the specified "bucket" in the cache
-int fgTILECACHE::Exists( fgBUCKET *p ) {
+int
+fgTILECACHE::exists( fgBUCKET *p )
+{
int i;
for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
// Fill in a tile cache entry with real data for the specified bucket
-void fgTILECACHE::EntryFillIn( int index, fgBUCKET *p ) {
- string root;
+void
+fgTILECACHE::fill_in( int index, fgBUCKET *p )
+{
+ string root, tile_path, apt_path;
+ char index_str[256];
char base_path[256];
- char file_name[256];
// Mark this cache entry as used
tile_cache[index].used = 1;
// Load the appropriate data file and built tile fragment list
fgBucketGenBasePath(p, base_path);
root = current_options.get_fg_root();
- sprintf(file_name, "%s/Scenery/%s/%ld", root.c_str(),
- base_path, fgBucketGenIndex(p));
- fgObjLoad(file_name, &tile_cache[index]);
- /*
- tile_cache[index].display_list =
- fgObjLoad(file_name, &tile_cache[index].local_ref,
- &tile_cache[index].bounding_radius);
- */
+ sprintf( index_str, "%ld", fgBucketGenIndex(p) );
+
+ tile_path = root + "/Scenery/" + base_path + "/" + index_str;
+ fgObjLoad( tile_path.c_str(), &tile_cache[index] );
+
+ // cout << " ncount before = " << tile_cache[index].ncount << "\n";
+ // cout << " fragments before = " << tile_cache[index].fragment_list.size()
+ // << "\n";
+
+ apt_path = tile_path + ".apt";
+ fgAptGenerate( apt_path, &tile_cache[index] );
+
+ // cout << " ncount after = " << tile_cache[index].ncount << "\n";
+ // cout << " fragments after = " << tile_cache[index].fragment_list.size()
+ // << "\n";
}
// Free a tile cache entry
-void fgTILECACHE::EntryFree( int index ) {
+void
+fgTILECACHE::entry_free( int index )
+{
fgFRAGMENT *fragment;
// Mark this cache entry as un-used
// Return the specified tile cache entry
-fgTILE *fgTILECACHE::GetTile( int index ) {
+fgTILE *
+fgTILECACHE::get_tile( int index )
+{
return ( &tile_cache[index] );
}
// Return index of next available slot in tile cache
-int fgTILECACHE::NextAvail( void ) {
+int
+fgTILECACHE::next_avail( void )
+{
fgVIEW *v;
int i;
float dx, dy, dz, max, med, min, tmp;
// We will instead free the furthest cache entry and return it's
// index.
- EntryFree( max_index );
+ entry_free( max_index );
return( max_index );
}
// $Log$
+// Revision 1.16 1998/09/14 12:45:23 curt
+// minor tweaks.
+//
// Revision 1.15 1998/08/27 17:02:10 curt
// Contributions from Bernie Bright <bbright@c031.aone.net.au>
// - use strings for fg_root and airport_id and added methods to return
fgTILECACHE( void );
// Initialize the tile cache subsystem
- void Init( void );
+ void init( void );
// Search for the specified "bucket" in the cache
- int Exists( fgBUCKET *p );
+ int exists( fgBUCKET *p );
// Return index of next available slot in tile cache
- int NextAvail( void );
+ int next_avail( void );
// Free a tile cache entry
- void EntryFree( int index );
+ void entry_free( int index );
// Fill in a tile cache entry with real data for the specified bucket
- void EntryFillIn( int index, fgBUCKET *p );
+ void fill_in( int index, fgBUCKET *p );
// Return a pointer to the specified tile cache entry
- fgTILE *GetTile( int index );
+ fgTILE *get_tile( int index );
// Destructor
~fgTILECACHE( void );
// $Log$
+// Revision 1.11 1998/09/14 12:45:25 curt
+// minor tweaks.
+//
// Revision 1.10 1998/07/04 00:54:31 curt
// Added automatic mipmap generation.
//
p->lon, p->lat, p->x, p->y);
// if not in cache, load tile into the next available slot
- if ( (*index = c->Exists(p)) < 0 ) {
- *index = c->NextAvail();
- c->EntryFillIn(*index, p);
+ if ( (*index = c->exists(p)) < 0 ) {
+ *index = c->next_avail();
+ c->fill_in(*index, p);
}
fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index);
tile_diameter * tile_diameter);
// wipe/initialize tile cache
- c->Init();
+ c->init();
// build the local area list and update cache
for ( j = 0; j < tile_diameter; j++ ) {
// Find current translation offset
fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
- index = c->Exists(&p);
- t = c->GetTile(index);
+ index = c->exists(&p);
+ t = c->get_tile(index);
scenery.next_center.x = t->center.x;
scenery.next_center.y = t->center.y;
// Find current translation offset
fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p);
- index = c->Exists(&p);
- t = c->GetTile(index);
+ index = c->exists(&p);
+ t = c->get_tile(index);
scenery.next_center.x = t->center.x;
scenery.next_center.y = t->center.y;
for ( i = 0; i < (tile_diameter * tile_diameter); i++ ) {
index = tiles[i];
// fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index);
- t = c->GetTile(index);
+ t = c->get_tile(index);
// calculate tile offset
x = (t->offset.x = t->center.x - scenery.center.x);
// $Log$
+// Revision 1.36 1998/09/14 12:45:26 curt
+// minor tweaks.
+//
// Revision 1.35 1998/09/10 19:07:16 curt
// /Simulator/Objects/fragment.hxx
// Nested fgFACE inside fgFRAGMENT since its not used anywhere else.