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);
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);
//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);
return(1);
}
+
+
+void fgReInitSubsystems( void )
+{
+ FGInterface *f = current_aircraft.fdm_state;
+// fgLIGHT *l = &cur_light_params;
+// fgTIME *t = &cur_time_params;
+ FGView *v = ¤t_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();
+}
int fgInitSubsystems( void );
+// Reset
+void fgReInitSubsystems( void );
+
+
#endif // _FG_INIT_H
}
// 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; }
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;
m[15] = 1.0 /* m[3] * -eyex + m[7] * -eyey + m[11] * -eyez + m[15] */;
// xglMultMatrixd( m );
- xglLoadMatrixd( m );
+ xglLoadMatrixf( m );
}
// 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;
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
MAT3mat WORLD_TO_EYE;
// Current model view matrix;
- GLdouble MODEL_VIEW[16];
+ GLfloat MODEL_VIEW[16];
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; }
};
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;
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);
#endif // _TILE_HXX
-
-
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;
}
}
// 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
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;
}
// 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++ ) {
int viewable = 1; // start by assuming it's viewable
double x1, y1;
-/********************************/
+ /********************************/
#if defined( USE_FAST_FOV_CLIP ) // views.hxx
-/********************************/
+ /********************************/
MAT3vec eye;
double *mat;
// 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();
// 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();
// 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;
static void
update_tile_geometry( fgTILE *t, GLdouble *MODEL_VIEW)
{
- GLdouble *m;
+ GLfloat *m;
double x, y, z;
// calculate tile offset
material_mgr.render_fragments();
xglPopMatrix();
}
-
-