#define FG_LOCAL_Y 3 /* should be odd */
#define FG_LOCAL_X_Y 9 /* At least FG_LOCAL_X times FG_LOCAL_Y */
-#define FG_TILE_CACHE_SIZE 100 /* Must be > FG_LOCAL_X_Y */
-
/* closest (potentially viewable) tiles, centered on current tile.
* This is an array of pointers to cache indexes. */
int tiles[FG_LOCAL_X_Y];
-/* tile cache */
-struct fgTILE tile_cache[FG_TILE_CACHE_SIZE];
-
/* Initialize the Tile Manager subsystem */
void fgTileMgrInit( void ) {
fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
-
- fgTileCacheInit();
}
fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating for bucket %d %d %d %d\n",
p->lon, p->lat, p->x, p->y);
- *index = fgTileCacheNextAvail();
+ /* if not in cache, load tile into the next available slot */
+ if ( (*index = fgTileCacheExists(p)) < 0 ) {
+ *index = fgTileCacheNextAvail();
+ fgTileCacheEntryFillIn(*index, p);
+ }
+
fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index);
-
- fgTileCacheEntryFillIn(*index, p);
}
/* given the current lon/lat, fill in the array of local chunks. If
* the chunk isn't already in the cache, then read it from disk. */
void fgTileMgrUpdate( void ) {
- struct fgFLIGHT *f;
+ fgFLIGHT *f;
struct fgBUCKET p1, p2;
static struct fgBUCKET p_last = {-1000, 0, 0, 0};
int i, j, dw, dh;
- f = ¤t_aircraft.flight;
+ f = current_aircraft.flight;
fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p1);
dw = FG_LOCAL_X / 2;
/* fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index); */
fgTileCacheEntryInfo(index, &display_list, &local_ref );
- xglPushMatrix();
- xglTranslatef(local_ref.x - scenery.center.x,
- local_ref.y - scenery.center.y,
- local_ref.z - scenery.center.z);
- xglCallList(display_list);
- xglPopMatrix();
+ if ( display_list >= 0 ) {
+ xglPushMatrix();
+ xglTranslatef(local_ref.x - scenery.center.x,
+ local_ref.y - scenery.center.y,
+ local_ref.z - scenery.center.z);
+ xglCallList(display_list);
+ xglPopMatrix();
+ }
}
}
/* $Log$
-/* Revision 1.9 1998/01/27 03:26:44 curt
-/* Playing with new fgPrintf command.
+/* Revision 1.13 1998/02/07 15:29:46 curt
+/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.12 1998/02/01 03:39:55 curt
+ * Minor tweaks.
+ *
+ * Revision 1.11 1998/01/31 00:43:27 curt
+ * Added MetroWorks patches from Carmen Volpe.
+ *
+ * Revision 1.10 1998/01/29 00:51:40 curt
+ * First pass at tile cache, dynamic tile loading and tile unloading now works.
+ *
+ * Revision 1.9 1998/01/27 03:26:44 curt
+ * Playing with new fgPrintf command.
+ *
* Revision 1.8 1998/01/27 00:48:04 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.