]> git.mxchange.org Git - flightgear.git/commitdiff
Changes by NHV to allow the sim to be reset.
authorcurt <curt>
Tue, 27 Apr 1999 15:52:32 +0000 (15:52 +0000)
committercurt <curt>
Tue, 27 Apr 1999 15:52:32 +0000 (15:52 +0000)
Simulator/Main/GLUTkey.cxx
Simulator/Main/fg_init.cxx
Simulator/Main/fg_init.hxx
Simulator/Main/options.hxx
Simulator/Main/views.cxx
Simulator/Main/views.hxx
Simulator/Scenery/tile.hxx
Simulator/Scenery/tilecache.cxx
Simulator/Scenery/tilemgr.cxx

index ef3ada9f49d1425c6f6b05a156fa4d703e1ca237..8d9ccced4a5eaf0353b5c3dde2a1707770d04128 100644 (file)
@@ -176,14 +176,14 @@ void GLUTkey(unsigned char k, int x, int y) {
        FG_LOG( FG_INPUT, FG_DEBUG, "" );
        switch (k) {
        case 50: // numeric keypad 2
-           if( fgAPAltitudeEnabled() ) {
+           if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
                fgAPAltitudeAdjust( 100 );
            } else {
                controls.move_elevator(-0.05);
            }
            return;
        case 56: // numeric keypad 8
-           if( fgAPAltitudeEnabled() ) {
+           if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
                fgAPAltitudeAdjust( -100 );
            } else {
                controls.move_elevator(0.05);
@@ -352,7 +352,7 @@ void GLUTspecialkey(int k, int x, int y) {
 
            return;
        case GLUT_KEY_F9: // F9 toggles textures on and off...
-           if ( material_mgr.get_textures_loaded() ) {
+           if ( material_mgr.loaded() ) {
                current_options.get_textures() ?
                    current_options.set_textures(false) :
                    current_options.set_textures(true);
@@ -370,14 +370,14 @@ void GLUTspecialkey(int k, int x, int y) {
            //exit(1);
            return;
        case GLUT_KEY_UP:
-           if( fgAPAltitudeEnabled() ) {
+           if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
                fgAPAltitudeAdjust( -100 );
            } else {
                controls.move_elevator(0.05);
            }
            return;
        case GLUT_KEY_DOWN:
-           if( fgAPAltitudeEnabled() ) {
+           if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
                fgAPAltitudeAdjust( 100 );
            } else {
                controls.move_elevator(-0.05);
index ef007b264d473e87f7a01d44d293c839d8be4c34..e192fbda7546ee9a9c2e6a4501babecca292ed80 100644 (file)
@@ -417,3 +417,90 @@ int fgInitSubsystems( void )
 
     return(1);
 }
+
+
+void fgReInitSubsystems( void )
+{
+    FGInterface *f = current_aircraft.fdm_state;
+//    fgLIGHT *l = &cur_light_params;
+//    fgTIME *t = &cur_time_params;
+    FGView *v = &current_view;
+
+       fgInitPosition();
+    if( fgTileMgrInit() ) {
+               // Load the local scenery data
+               fgTileMgrUpdate();
+    } else {
+       FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
+               exit(-1);
+    }
+    fgFDMSetGroundElevation( current_options.get_flight_model(), 
+                            scenery.cur_elev );
+
+    // Reset our altitude if we are below ground
+    FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << f->get_Altitude() );
+    FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " << 
+           f->get_Runway_altitude() );
+
+    if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
+       f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
+    }
+    double sea_level_radius_meters;
+    double lat_geoc;
+    // Set the FG variables first
+    fgGeodToGeoc( f->get_Latitude(), f->get_Altitude(), 
+                 &sea_level_radius_meters, &lat_geoc);
+    f->set_Geocentric_Position( lat_geoc, f->get_Longitude(), 
+                               f->get_Altitude() + 
+                               (sea_level_radius_meters * METER_TO_FEET) );
+    f->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
+       
+       f->set_sin_cos_longitude(f->get_Longitude());
+       f->set_sin_cos_latitude(f->get_Latitude());
+       
+       f->set_sin_lat_geocentric(sin(lat_geoc));
+       f->set_cos_lat_geocentric(cos(lat_geoc));
+
+    // The following section sets up the flight model EOM parameters
+    // and should really be read in from one or more files.
+
+    // Initial Velocity
+    f->set_Velocities_Local( 0.0, 0.0, 0.0 );
+
+    // Initial Orientation
+    f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
+                        current_options.get_pitch() * DEG_TO_RAD,
+                        current_options.get_heading() * DEG_TO_RAD );
+
+    // Initial Angular Body rates
+    f->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
+
+    f->set_Earth_position_angle( 0.0 );
+
+    // Mass properties and geometry values
+    f->set_Inertias( 8.547270E+01, 
+                    1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
+
+    // CG position w.r.t. ref. point
+    f->set_CG_Position( 0.0, 0.0, 0.0 );
+
+    // Initialize view parameters
+    FG_LOG( FG_GENERAL, FG_DEBUG, "Before v->init()");
+    v->Init();
+    FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()");
+    v->UpdateViewMath(f);
+    FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << v->get_abs_view_pos());
+    v->UpdateWorldToEye(f);
+
+    fgFDMInit( current_options.get_flight_model(), cur_fdm_state, 
+                      1.0 / DEFAULT_MODEL_HZ );
+
+    scenery.cur_elev = f->get_Runway_altitude() * FEET_TO_METER;
+
+    if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
+       f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
+    }
+
+       controls.reset_all();
+       fgAPReset();
+}
index 7f0e90f225513ca72f53785be513525b8abe1f78..cee62e05f31345cfb35ee038ce575e28400104be 100644 (file)
@@ -41,6 +41,10 @@ int fgInitGeneral ( void );
 int fgInitSubsystems( void );
 
 
+// Reset
+void fgReInitSubsystems( void );
+
+
 #endif // _FG_INIT_H
 
 
index f97c58fe5a2b2442b4de4f92c9d4e74babbb2085..90b4e69eabdabdaa1e7bbd1ab148c76d5d16c0d3 100644 (file)
@@ -212,6 +212,7 @@ public:
     }
 
     // Update functions
+    inline void set_airport_id( const string id ) { airport_id = id; }
     inline void set_hud_status( bool status ) { hud_status = status; }
     inline void set_fov( double amount ) { fov = amount; }
     inline void set_textures( bool status ) { textures = status; }
index 7b690a21f8bc3175b9f10a549ad61546340aa1ee..9639f9617ebabdad18793377252bd04fe9f123e5 100644 (file)
@@ -133,7 +133,7 @@ void FGView::UpdateFOV( const fgOPTIONS& o ) {
 void FGView::LookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
                     GLdouble centerx, GLdouble centery, GLdouble centerz,
                     GLdouble upx, GLdouble upy, GLdouble upz ) {
-    GLdouble *m;
+    GLfloat *m;
     GLdouble x[3], y[3], z[3];
     GLdouble mag;
 
@@ -208,7 +208,7 @@ void FGView::LookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
     m[15] = 1.0 /* m[3] * -eyex + m[7] * -eyey + m[11] * -eyez + m[15] */;
 
     // xglMultMatrixd( m );
-    xglLoadMatrixd( m );
+    xglLoadMatrixf( m );
 }
 
 
@@ -279,7 +279,7 @@ void FGView::UpdateViewParams( void ) {
     //              GLdouble centerx, GLdouble centery, GLdouble centerz,
     //              GLdouble upx, GLdouble upy, GLdouble upz )
     {
-       GLdouble *m;
+       GLfloat *m;
        GLdouble x[3], y[3], z[3];
        //    GLdouble mag;
 
@@ -369,7 +369,7 @@ void FGView::UpdateViewParams( void ) {
        m[15] = 1.0 /* m[3] * -view_pos.x() + m[7] * -view_pos.y() + m[11] * -view_pos.z() + m[15] */;
 
        // xglMultMatrixd( m );
-       xglLoadMatrixd( m );
+       xglLoadMatrixf( m );
     }
 #endif // FG_VIEW_INLINE_OPTIMIZATIONS
        
index 866b2ac06789299b9694a49f7815f08291aad596..22f84d063d34f281654f1413b75ec313bd3a0b0c 100644 (file)
@@ -150,7 +150,7 @@ public:
     MAT3mat WORLD_TO_EYE;
 
     // Current model view matrix;
-    GLdouble MODEL_VIEW[16];
+    GLfloat MODEL_VIEW[16];
 
 public:
 
@@ -242,7 +242,7 @@ public:
     inline double *get_surface_east() { return surface_east; }
     inline double *get_local_up() { return local_up; }
     inline const MAT3mat *get_WORLD_TO_EYE() const { return &WORLD_TO_EYE; }
-    inline GLdouble *get_MODEL_VIEW() { return MODEL_VIEW; }
+    inline GLfloat *get_MODEL_VIEW() { return MODEL_VIEW; }
 };
 
 
index 3f30b139005fc58065bc69c340c9cf839b82d078..a1b235c0f2409f1e42e19ea950b4df243d708d6e 100644 (file)
@@ -76,7 +76,7 @@ public:
     Point3D center;
     double bounding_radius;
     Point3D offset;
-    GLdouble model_view[16];
+    GLfloat model_view[16];
 
     // this tile's official location in the world
     FGBucket tile_bucket;
@@ -122,16 +122,18 @@ public:
        offset = center - off;
     }
 
+    // Return this tile's offset
+    inline Point3D GetOffset( void ) const { return offset; }
 
     // Calculate the model_view transformation matrix for this tile
     inline void
-    UpdateViewMatrix(GLdouble *MODEL_VIEW)
+    UpdateViewMatrix(GLfloat *MODEL_VIEW)
     {
 
 #if defined( USE_MEM ) || defined( WIN32 )
-       memcpy( model_view, MODEL_VIEW, 16*sizeof(GLdouble) );
+       memcpy( model_view, MODEL_VIEW, 16*sizeof(GLfloat) );
 #else 
-       bcopy( MODEL_VIEW, model_view, 16*sizeof(GLdouble) );
+       bcopy( MODEL_VIEW, model_view, 16*sizeof(GLfloat) );
 #endif
        
        // This is equivalent to doing a glTranslatef(x, y, z);
@@ -158,5 +160,3 @@ private:
 
 
 #endif // _TILE_HXX 
-
-
index 8924a869383c496942cb36d670e8a3df18e776a2..c0ac2969ca299c64c4b081c0441786671c8761e7 100644 (file)
@@ -61,6 +61,10 @@ fgTILECACHE::init( void )
     FG_LOG( FG_TERRAIN, FG_INFO, "Initializing the tile cache." );
 
     for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
+       if ( tile_cache[i].used ) {
+           entry_free(i);
+           tile_cache[i].tile_bucket.make_bad();
+       }
        tile_cache[i].used = 0;
     }
 }
index d62a320a0c53bb9e5b426b973325705c5d66ca23..8dd8d149ac8703f306ed7507001daeefc26dbf74 100644 (file)
@@ -56,8 +56,8 @@
 
 // to test clipping speedup in fgTileMgrRender()
 #if defined ( USE_FAST_FOV_CLIP )
-  // #define TEST_FOV_CLIP
-  // #define TEST_ELEV
+// #define TEST_FOV_CLIP
+// #define TEST_ELEV
 #endif
 
 
@@ -81,7 +81,9 @@ int fgTileMgrInit( void ) {
     FG_LOG( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem." );
 
     // load default material library
-    material_mgr.load_lib();
+    if ( ! material_mgr.loaded() ) {
+       material_mgr.load_lib();
+    }
 
     return 1;
 }
@@ -362,6 +364,7 @@ int fgTileMgrUpdate( void ) {
 
        // wipe/initialize tile cache
        c->init();
+       p_last.make_bad();
 
        // build the local area list and update cache
        for ( j = 0; j < tile_diameter; j++ ) {
@@ -471,9 +474,9 @@ static int viewable( const Point3D& cp, double radius ) {
     int viewable = 1; // start by assuming it's viewable
     double x1, y1;
 
-/********************************/
+    /********************************/
 #if defined( USE_FAST_FOV_CLIP ) // views.hxx
-/********************************/
+    /********************************/
        
     MAT3vec eye;       
     double *mat;
@@ -490,9 +493,9 @@ static int viewable( const Point3D& cp, double radius ) {
     // Check near and far clip plane
     if( ( eye[2] > radius ) ||
        ( eye[2] + radius + current_weather.get_visibility() < 0) )
-    {
-       return(0);
-    }
+       {
+           return(0);
+       }
        
     eye[0] = (x*mat[0] + y*mat[4] + z*mat[8] + mat[12])
        * current_view.get_slope_x();
@@ -500,9 +503,9 @@ static int viewable( const Point3D& cp, double radius ) {
     // check right and left clip plane (from eye perspective)
     x1 = radius * current_view.get_fov_x_clip();
     if( (eye[2] > -(eye[0]+x1)) || (eye[2] > (eye[0]-x1)) )
-    {
-       return(0);
-    }
+       {
+           return(0);
+       }
        
     eye[1] = (x*mat[1] + y*mat[5] + z*mat[9] + mat[13]) 
        * current_view.get_slope_y();
@@ -510,13 +513,13 @@ static int viewable( const Point3D& cp, double radius ) {
     // check bottom and top clip plane (from eye perspective)
     y1 = radius * current_view.get_fov_y_clip();
     if( (eye[2] > -(eye[1]+y1)) || (eye[2] > (eye[1]-y1)) )
-    {
-       return(0);
-    }
+       {
+           return(0);
+       }
 
-/********************************/     
+    /********************************/ 
 #else // DO NOT USE_FAST_FOV_CLIP
-/********************************/     
+    /********************************/ 
 
     fgVIEW *v;
     MAT3hvec world, eye;
@@ -628,7 +631,7 @@ inrange( const double radius, const Point3D& center, const Point3D& vp,
 static void
 update_tile_geometry( fgTILE *t, GLdouble *MODEL_VIEW)
 {
-    GLdouble *m;
+    GLfloat *m;
     double x, y, z;
        
     // calculate tile offset
@@ -759,5 +762,3 @@ void fgTileMgrRender( void ) {
     material_mgr.render_fragments();
     xglPopMatrix();
 }
-
-