]> git.mxchange.org Git - flightgear.git/blobdiff - Scenery/tilemgr.cxx
Renamed class fgFLIGHT to class FGState as per request by JSB.
[flightgear.git] / Scenery / tilemgr.cxx
index b9a9ee8099ce4aed5af0b896f89bae95234579b2..369f6bb54b35428051041a417cb8cd60c283cc7a 100644 (file)
 #include <GL/glut.h>
 #include <XGL/xgl.h>
 
-#include <Aircraft/aircraft.h>
+#include <Aircraft/aircraft.hxx>
 
-#include <Bucket/bucketutils.h>
-#include <Debug/fg_debug.h>
+#include <Bucket/bucketutils.hxx>
+#include <Debug/logstream.hxx>
 #include <Include/fg_constants.h>
-// #include <Include/fg_types.h>
 #include <Main/options.hxx>
 #include <Main/views.hxx>
-#include <Math/fg_geodesy.h>
+#include <Math/fg_geodesy.hxx>
 #include <Math/mat3.h>
 #include <Math/point3d.hxx>
 #include <Math/polar3d.hxx>
 #include <Math/vector.hxx>
 #include <Objects/material.hxx>
 #include <Objects/obj.hxx>
-#include <Weather/weather.h>
+#include <Weather/weather.hxx>
 
 #include "scenery.hxx"
 #include "tile.hxx"
 #include "tilecache.hxx"
+#include "tilemgr.hxx"
 
 
 // to test clipping speedup in fgTileMgrRender()
 
 #define FG_SQUARE( X ) ( (X) * (X) )
 
-#ifdef WIN32
-#  define FG_MEM_COPY(to,from,n)       memcpy(to, from, n)
+#if defined(USE_MEM) || defined(WIN32)
+#  define FG_MEM_COPY(to,from,n)        memcpy(to, from, n)
 #else
-#  define FG_MEM_COPY(to,from,n)       bcopy(from, to, n)
+#  define FG_MEM_COPY(to,from,n)        bcopy(from, to, n)
 #endif
 
 // closest (potentially viewable) tiles, centered on current tile.
@@ -79,7 +79,7 @@ int tiles[FG_LOCAL_X_Y];
 
 // Initialize the Tile Manager subsystem
 int fgTileMgrInit( void ) {
-    fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
+    FG_LOG( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem." );
 
     // load default material library
     material_mgr.load_lib();
@@ -89,21 +89,241 @@ int fgTileMgrInit( void ) {
 
 
 // load a tile
-void fgTileMgrLoadTile( fgBUCKET *p, int *index) {
+void fgTileMgrLoadTile( const fgBUCKET& p, int *index) {
     fgTILECACHE *c;
 
     c = &global_tile_cache;
 
-    fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating for bucket %d %d %d %d\n", 
-          p->lon, p->lat, p->x, p->y);
+    FG_LOG( FG_TERRAIN, FG_DEBUG, "Updating for bucket " << p );
     
     // if not in cache, load tile into the next available slot
-    if ( (*index = c->exists(p)) < 0 ) {
+    *index = c->exists(p);
+    if ( *index < 0 ) {
        *index = c->next_avail();
        c->fill_in(*index, p);
     }
 
-    fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index);
+    FG_LOG( FG_TERRAIN, FG_DEBUG, "Selected cache index: " << *index );
+}
+
+
+// Calculate shortest distance from point to line
+static double point_line_dist_squared( const Point3D& tc, const Point3D& vp, 
+                                      MAT3vec d )
+{
+    MAT3vec p, p0;
+    double dist;
+
+    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);
+}
+
+
+// Determine scenery altitude.  Normally this just happens when we
+// 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
+fgTileMgrCurElev( const fgBUCKET& p ) {
+    fgTILE *t;
+    fgFRAGMENT *frag_ptr;
+    Point3D abs_view_pos = current_view.abs_view_pos;
+    Point3D earth_center(0.0);
+    Point3D result;
+    MAT3vec local_up;
+    double dist, lat_geod, alt, sea_level_r;
+    int index;
+
+    local_up[0] = abs_view_pos.x();
+    local_up[1] = abs_view_pos.y();
+    local_up[2] = abs_view_pos.z();
+
+    // Find current translation offset
+    // fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
+    index = global_tile_cache.exists(p);
+    if ( index < 0 ) {
+       FG_LOG( FG_TERRAIN, FG_WARN, "Tile not found" );
+       return 0.0;
+    }
+
+    t = global_tile_cache.get_tile(index);
+
+    scenery.next_center = t->center;
+    
+    FG_LOG( FG_TERRAIN, FG_DEBUG, 
+           "Current bucket = " << p << "  Index = " << fgBucketGenIndex(&p) );
+    FG_LOG( FG_TERRAIN, FG_DEBUG,
+           "abs_view_pos = " << abs_view_pos );
+
+    // calculate tile offset
+    // x = (t->offset.x = t->center.x - scenery.center.x);
+    // y = (t->offset.y = t->center.y - scenery.center.y);
+    // z = (t->offset.z = t->center.z - scenery.center.z);
+    
+    // calc current terrain elevation calculate distance from
+    // vertical tangent line at current position to center of
+    // tile.
+       
+    /* printf("distance squared = %.2f, bounding radius = %.2f\n", 
+       point_line_dist_squared(&(t->offset), &(v->view_pos), 
+       v->local_up), t->bounding_radius); */
+
+    dist = point_line_dist_squared( t->center, abs_view_pos, local_up );
+    if ( dist < FG_SQUARE(t->bounding_radius) ) {
+
+       // traverse fragment list for tile
+        fgTILE::FragmentIterator current = t->begin();
+        fgTILE::FragmentIterator last = t->end();
+
+       for ( ; current != last; ++current ) {
+           frag_ptr = &(*current);
+           /* printf("distance squared = %.2f, bounding radius = %.2f\n", 
+              point_line_dist_squared( &(frag_ptr->center), 
+              &abs_view_pos), local_up),
+              frag_ptr->bounding_radius); */
+
+           dist = point_line_dist_squared( frag_ptr->center,
+                                           abs_view_pos,
+                                           local_up);
+           if ( dist <= FG_SQUARE(frag_ptr->bounding_radius) ) {
+               if ( frag_ptr->intersect( abs_view_pos, 
+                                         earth_center, 0, result ) ) {
+                   FG_LOG( FG_TERRAIN, FG_DEBUG, "intersection point " <<
+                           result );
+                   // compute geocentric coordinates of tile center
+                   Point3D pp = fgCartToPolar3d(result);
+                   FG_LOG( FG_TERRAIN, FG_DEBUG, "  polar form = " << pp );
+                   // convert to geodetic coordinates
+                   fgGeocToGeod(pp.lat(), pp.radius(), &lat_geod, 
+                                &alt, &sea_level_r);
+
+                   // printf("alt = %.2f\n", alt);
+                   // exit since we found an intersection
+                   if ( alt > -9999.0 ) {
+                       // printf("returning alt\n");
+                       return alt;
+                   } else {
+                       // printf("returning 0\n");
+                       return 0.0;
+                   }
+               }
+           }
+       }
+    }
+
+    cout << "(new) no terrain intersection found\n";
+    return 0.0;
+}
+
+
+// Determine scenery altitude.  Normally this just happens when we
+// 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
+fgTileMgrCurElevOLD( 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 = &current_view;
+
+    local_up[0] = abs_view_pos.x();
+    local_up[1] = abs_view_pos.y();
+    local_up[2] = abs_view_pos.z();
+
+    // Find current translation offset
+    fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
+    index = c->exists(p);
+    if ( index < 0 ) {
+       FG_LOG( FG_TERRAIN, FG_WARN, "Tile not found" );
+       return 0.0;
+    }
+
+    t = c->get_tile(index);
+
+    scenery.next_center = t->center;
+    
+    // earth_center = Point3D(0.0, 0.0, 0.0);
+
+    FG_LOG( FG_TERRAIN, FG_DEBUG, 
+           "Pos = (" << lon * RAD_TO_DEG << ", " << lat * RAD_TO_DEG
+           << ")  Current bucket = " << p 
+           << "  Index = " << fgBucketGenIndex(&p) );
+
+    // calculate tile offset
+    // x = (t->offset.x = t->center.x - scenery.center.x);
+    // y = (t->offset.y = t->center.y - scenery.center.y);
+    // z = (t->offset.z = t->center.z - scenery.center.z);
+    
+    // calc current terrain elevation calculate distance from
+    // vertical tangent line at current position to center of
+    // tile.
+       
+    /* printf("distance squared = %.2f, bounding radius = %.2f\n", 
+       point_line_dist_squared(&(t->offset), &(v->view_pos), 
+       v->local_up), t->bounding_radius); */
+
+    dist = point_line_dist_squared( t->center, abs_view_pos, local_up );
+    if ( dist < FG_SQUARE(t->bounding_radius) ) {
+
+       // traverse fragment list for tile
+        fgTILE::FragmentIterator current = t->begin();
+        fgTILE::FragmentIterator last = t->end();
+
+       for ( ; current != last; ++current ) {
+           frag_ptr = &(*current);
+           /* printf("distance squared = %.2f, bounding radius = %.2f\n", 
+              point_line_dist_squared( &(frag_ptr->center), 
+              &abs_view_pos), local_up),
+              frag_ptr->bounding_radius); */
+
+           dist = point_line_dist_squared( frag_ptr->center,
+                                           abs_view_pos,
+                                           local_up);
+           if ( dist <= FG_SQUARE(frag_ptr->bounding_radius) ) {
+               if ( frag_ptr->intersect( abs_view_pos, 
+                                         earth_center, 0, result ) ) {
+                   FG_LOG( FG_TERRAIN, FG_DEBUG, "intersection point " <<
+                           result );
+                   // compute geocentric coordinates of tile center
+                   Point3D pp = fgCartToPolar3d(result);
+                   FG_LOG( FG_TERRAIN, FG_DEBUG, "  polar form = " << pp );
+                   // convert to geodetic coordinates
+                   fgGeocToGeod(pp.lat(), pp.radius(), &lat_geod, 
+                                &alt, &sea_level_r);
+
+                   // printf("alt = %.2f\n", alt);
+                   // exit since we found an intersection
+                   if ( alt > -9999.0 ) {
+                       // printf("returning alt\n");
+                       return alt;
+                   } else {
+                       // printf("returning 0\n");
+                       return 0.0;
+                   }
+               }
+           }
+       }
+    }
+
+    cout << "(old) no terrain intersection found\n";
+    return 0.0;
 }
 
 
@@ -111,34 +331,33 @@ void fgTileMgrLoadTile( fgBUCKET *p, int *index) {
 // the chunk isn't already in the cache, then read it from disk.
 int fgTileMgrUpdate( void ) {
     fgTILECACHE *c;
-    fgFLIGHT *f;
+    FGState *f;
     fgBUCKET p1, p2;
     static fgBUCKET p_last = {-1000, 0, 0, 0};
     int tile_diameter;
     int i, j, dw, dh;
 
     c = &global_tile_cache;
-    f = current_aircraft.flight;
+    f = current_aircraft.fdm_state;
 
     tile_diameter = current_options.get_tile_diameter();
 
-    fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p1);
+    fgBucketFind( f->get_Longitude() * RAD_TO_DEG,
+                 f->get_Latitude() * RAD_TO_DEG, &p1);
     dw = tile_diameter / 2;
     dh = tile_diameter / 2;
 
-    if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
-        (p1.x == p_last.x) && (p1.y == p_last.y) ) {
+    if ( p1 == p_last ) {
        // same bucket as last time
-       fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n");
+       FG_LOG( FG_TERRAIN, FG_DEBUG, "Same bucket as last time" );
     } else if ( p_last.lon == -1000 ) {
        // First time through, initialize the system and load all
        // relavant tiles
 
-       fgPrintf( FG_TERRAIN, FG_INFO, "  First time through ... ");
-       fgPrintf( FG_TERRAIN, FG_INFO, "  Updating Tile list for %d,%d %d,%d\n",
-                 p1.lon, p1.lat, p1.x, p1.y);
-       fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n", 
-                 tile_diameter * tile_diameter);
+       FG_LOG( FG_TERRAIN, FG_INFO, "  First time through ... " );
+       FG_LOG( FG_TERRAIN, FG_INFO, "  Updating Tile list for " << p1 );
+       FG_LOG( FG_TERRAIN, FG_INFO, "  Loading " 
+               << tile_diameter * tile_diameter << " tiles" );
 
        // wipe/initialize tile cache
        c->init();
@@ -147,7 +366,7 @@ int fgTileMgrUpdate( void ) {
        for ( j = 0; j < tile_diameter; j++ ) {
            for ( i = 0; i < tile_diameter; i++ ) {
                fgBucketOffset(&p1, &p2, i - dw, j - dh);
-               fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + i]);
+               fgTileMgrLoadTile( p2, &tiles[(j*tile_diameter) + i]);
            }
        }
     } else {
@@ -158,13 +377,12 @@ int fgTileMgrUpdate( void ) {
        // AT ULTRA HIGH SPEEDS THIS ASSUMPTION MAY NOT BE VALID IF
        // THE AIRCRAFT CAN SKIP A TILE IN A SINGLE ITERATION.
 
-       fgPrintf( FG_TERRAIN, FG_INFO, "Updating Tile list for %d,%d %d,%d\n",
-                 p1.lon, p1.lat, p1.x, p1.y);
+       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) ) ) {
-           fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n"
-                     tile_diameter);
+           FG_LOG( FG_TERRAIN, FG_INFO
+                   "  Loading " << tile_diameter << "tiles" );
            for ( j = 0; j < tile_diameter; j++ ) {
                // scrolling East
                for ( i = 0; i < tile_diameter - 1; i++ ) {
@@ -173,13 +391,13 @@ int fgTileMgrUpdate( void ) {
                }
                // load in new column
                fgBucketOffset(&p_last, &p2, dw + 1, j - dh);
-               fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + 
+               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) ) ) {
-           fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n"
-                     tile_diameter);
+           FG_LOG( FG_TERRAIN, FG_INFO
+                   "  Loading " << tile_diameter << "tiles" );
            for ( j = 0; j < tile_diameter; j++ ) {
                // scrolling West
                for ( i = tile_diameter - 1; i > 0; i-- ) {
@@ -188,14 +406,14 @@ int fgTileMgrUpdate( void ) {
                }
                // load in new column
                fgBucketOffset(&p_last, &p2, -dw - 1, j - dh);
-               fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + 0]);
+               fgTileMgrLoadTile( p2, &tiles[(j*tile_diameter) + 0]);
            }
        }
 
        if ( (p1.lat > p_last.lat) ||
             ( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) {
-           fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n"
-                     tile_diameter);
+           FG_LOG( FG_TERRAIN, FG_INFO
+                   "  Loading " << tile_diameter << "tiles" );
            for ( i = 0; i < tile_diameter; i++ ) {
                // scrolling North
                for ( j = 0; j < tile_diameter - 1; j++ ) {
@@ -204,13 +422,13 @@ int fgTileMgrUpdate( void ) {
                }
                // load in new column
                fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
-               fgTileMgrLoadTile(&p2, &tiles[((tile_diameter-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) ) ) {
-           fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n"
-                     tile_diameter);
+           FG_LOG( FG_TERRAIN, FG_INFO
+                   "  Loading " << tile_diameter << "tiles" );
            for ( i = 0; i < tile_diameter; i++ ) {
                // scrolling South
                for ( j = tile_diameter - 1; j > 0; j-- ) {
@@ -219,33 +437,20 @@ int fgTileMgrUpdate( void ) {
                }
                // load in new column
                fgBucketOffset(&p_last, &p2, i - dw, -dh - 1);
-               fgTileMgrLoadTile(&p2, &tiles[0 + i]);
+               fgTileMgrLoadTile( p2, &tiles[0 + i]);
            }
        }
     }
+
+    // find our current elevation (feed in the current bucket to save work)
+    scenery.cur_elev = fgTileMgrCurElev( p1 );
+
     p_last.lon = p1.lon;
     p_last.lat = p1.lat;
     p_last.x = p1.x;
     p_last.y = p1.y;
-    return 1;
-}
-
 
-// Calculate shortest distance from point to line
-static double point_line_dist_squared( const Point3D& tc, const Point3D& vp, 
-                                      MAT3vec d )
-{
-    MAT3vec p, p0;
-    double dist;
-
-    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);
-
-    // printf("dist = %.2f\n", dist);
-
-    return(dist);
+    return 1;
 }
 
 
@@ -402,97 +607,6 @@ inrange( const double radius, const Point3D& center, const Point3D& vp,
 }
 
 
-// Determine scenery altitude.  Normally this just happens when we
-// 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 fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) {
-    fgTILECACHE *c;
-    fgTILE *t;
-    // fgVIEW *v;
-    fgFRAGMENT *frag_ptr;
-    fgBUCKET p;
-    Point3D earth_center, result;
-    Point3D pp;
-    MAT3vec local_up;
-    list < fgFRAGMENT > :: iterator current;
-    list < fgFRAGMENT > :: iterator last;
-    double dist, lat_geod, alt, sea_level_r;
-    // double x, y, z;
-    int index;
-
-    c = &global_tile_cache;
-    // v = &current_view;
-
-    local_up[0] = abs_view_pos.x();
-    local_up[1] = abs_view_pos.y();
-    local_up[2] = abs_view_pos.z();
-
-    // Find current translation offset
-    fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
-    index = c->exists(&p);
-    t = c->get_tile(index);
-
-    scenery.next_center = t->center;
-    
-    earth_center.setvals(0.0, 0.0, 0.0);
-
-    fgPrintf( FG_TERRAIN, FG_DEBUG, 
-             "Pos = (%.2f, %.2f) Current bucket = %d %d %d %d  Index = %ld\n", 
-             lon * RAD_TO_DEG, lat * RAD_TO_DEG,
-             p.lon, p.lat, p.x, p.y, fgBucketGenIndex(&p) );
-
-    // calculate tile offset
-    // x = (t->offset.x = t->center.x - scenery.center.x);
-    // y = (t->offset.y = t->center.y - scenery.center.y);
-    // z = (t->offset.z = t->center.z - scenery.center.z);
-    
-    // calc current terrain elevation calculate distance from
-    // vertical tangent line at current position to center of
-    // tile.
-       
-    /* printf("distance squared = %.2f, bounding radius = %.2f\n", 
-       point_line_dist_squared(&(t->offset), &(v->view_pos), 
-       v->local_up), t->bounding_radius); */
-
-    dist = point_line_dist_squared( t->center, abs_view_pos, local_up );
-    if ( dist < FG_SQUARE(t->bounding_radius) ) {
-
-       // traverse fragment list for tile
-       current = t->fragment_list.begin();
-       last = t->fragment_list.end();
-
-       for ( ; current != last; ++current ) {
-           frag_ptr = &(*current);
-           /* printf("distance squared = %.2f, bounding radius = %.2f\n", 
-              point_line_dist_squared( &(frag_ptr->center), 
-              &abs_view_pos), local_up),
-              frag_ptr->bounding_radius); */
-
-           dist = point_line_dist_squared( frag_ptr->center,
-                                           abs_view_pos,
-                                           local_up);
-           if ( dist <= FG_SQUARE(frag_ptr->bounding_radius) ) {
-               if ( frag_ptr->intersect( abs_view_pos, 
-                                         earth_center, 0, result ) ) {
-                   // compute geocentric coordinates of tile center
-                   pp = fgCartToPolar3d(result);
-                   // convert to geodetic coordinates
-                   fgGeocToGeod(pp.lat(), pp.radius(), &lat_geod, 
-                                &alt, &sea_level_r);
-                   // printf("alt = %.2f\n", alt);
-                   // exit since we found an intersection
-                   return(alt);
-               }
-           }
-       }
-    }
-
-    printf("no terrain intersection found\n");
-    return(0);
-}
-
-
 // NEW for legibility
 
 // update this tile's geometry for current view
@@ -527,15 +641,13 @@ update_tile_geometry( fgTILE *t, GLdouble *MODEL_VIEW)
 
 // Render the local tiles
 void fgTileMgrRender( void ) {
-    fgFLIGHT *f;
+    FGState *f;
     fgTILECACHE *c;
     fgTILE *t;
     fgVIEW *v;
     Point3D frag_offset;
     fgFRAGMENT *frag_ptr;
     fgMATERIAL *mtl_ptr;
-    list < fgFRAGMENT > :: iterator current;
-    list < fgFRAGMENT > :: iterator last;
     int i;
     int tile_diameter;
     int index;
@@ -543,13 +655,15 @@ void fgTileMgrRender( void ) {
     int drawn = 0;
 
     c = &global_tile_cache;
-    f = current_aircraft.flight;
+    f = current_aircraft.fdm_state;
     v = &current_view;
 
     tile_diameter = current_options.get_tile_diameter();
 
-    scenery.cur_elev = fgTileMgrCurElev( FG_Longitude, FG_Latitude, 
-                                        v->abs_view_pos );
+    // moved to fgTileMgrUpdate, right after we check if we need to
+    // load additional tiles:
+    // scenery.cur_elev = fgTileMgrCurElev( FG_Longitude, FG_Latitude, 
+    //                                      v->abs_view_pos );
  
     // initialize the transient per-material fragment lists
     material_mgr.init_transient_material_lists();
@@ -576,8 +690,8 @@ void fgTileMgrRender( void ) {
            // xglTranslatef(t->offset.x, t->offset.y, t->offset.z);
 
            // traverse fragment list for tile
-           current = t->fragment_list.begin();
-           last = t->fragment_list.end();
+            fgTILE::FragmentIterator current = t->begin();
+            fgTILE::FragmentIterator last = t->end();
 
            for ( ; current != last; ++current ) {
                frag_ptr = &(*current);
@@ -595,8 +709,8 @@ void fgTileMgrRender( void ) {
                        mtl_ptr = frag_ptr->material_ptr;
                        // printf(" lookup = %s\n", mtl_ptr->texture_name);
                        if ( ! mtl_ptr->append_sort_list( frag_ptr ) ) {
-                           fgPrintf( FG_TERRAIN, FG_ALERT,
-                                     "Overran material sorting array\n" );
+                           FG_LOG( FG_TERRAIN, FG_ALERT,
+                                   "Overran material sorting array" );
                        }
 
                        // xglCallList(frag_ptr->display_list);
@@ -634,6 +748,66 @@ void fgTileMgrRender( void ) {
 
 
 // $Log$
+// Revision 1.49  1998/12/05 15:54:26  curt
+// Renamed class fgFLIGHT to class FGState as per request by JSB.
+//
+// Revision 1.48  1998/12/05 14:20:21  curt
+// Looking into a terrain intersection problem.
+//
+// Revision 1.47  1998/12/05 14:11:19  curt
+// Sun portability tweak.
+//
+// Revision 1.46  1998/12/03 14:15:24  curt
+// Actually set the current scenery elevation based on scenery intersection point
+// rather than calculating the intesection point and throwing it away.
+//
+// Revision 1.45  1998/12/03 01:18:18  curt
+// Converted fgFLIGHT to a class.
+// Tweaks for Sun Portability.
+// Tweaked current terrain elevation code as per NHV.
+//
+// Revision 1.44  1998/11/23 21:49:48  curt
+// minor tweaks.
+//
+// Revision 1.43  1998/11/09 23:40:52  curt
+// Bernie Bright <bbright@c031.aone.net.au> writes:
+// I've made some changes to the Scenery handling.  Basically just tidy ups.
+// The main difference is in tile.[ch]xx where I've changed list<fgFRAGMENT> to
+// vector<fgFRAGMENT>.  Studying our usage patterns this seems reasonable.
+// Lists are good if you need to insert/delete elements randomly but we
+// don't do that.  All access seems to be sequential.  Two additional
+// benefits are smaller memory usage - each list element requires pointers
+// to the next and previous elements, and faster access - vector iterators
+// are smaller and faster than list iterators.  This should also help
+// Charlie Hotchkiss' problem when compiling with Borland and STLport.
+//
+// ./Lib/Bucket/bucketutils.hxx
+//   Convenience functions for fgBUCKET.
+//
+// ./Simulator/Scenery/tile.cxx
+// ./Simulator/Scenery/tile.hxx
+//   Changed fragment list to a vector.
+//   Added some convenience member functions.
+//
+// ./Simulator/Scenery/tilecache.cxx
+// ./Simulator/Scenery/tilecache.hxx
+//   use const fgBUCKET& instead of fgBUCKET* where appropriate.
+//
+// ./Simulator/Scenery/tilemgr.cxx
+// ./Simulator/Scenery/tilemgr.hxx
+//   uses all the new convenience functions.
+//
+// Revision 1.42  1998/11/06 21:18:23  curt
+// Converted to new logstream debugging facility.  This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
+// Revision 1.41  1998/10/18 01:17:23  curt
+// Point3D tweaks.
+//
+// Revision 1.40  1998/10/17 01:34:28  curt
+// C++ ifying ...
+//
 // Revision 1.39  1998/10/16 00:55:50  curt
 // Converted to Point3D class.
 //