double throttle[MAX_ENGINES];
double brake[MAX_WHEELS];
+ inline void CLAMP(double *x, double min, double max ) {
+ if ( *x < min ) { *x = min; }
+ if ( *x > max ) { *x = max; }
+ }
+
public:
FGControls();
// Update functions
inline void set_aileron( double pos ) {
aileron = pos;
- if ( aileron < -1.0 ) aileron = -1.0;
- if ( aileron > 1.0 ) aileron = 1.0;
-
+ CLAMP( &aileron, -1.0, 1.0 );
+
// check for autocoordination
if ( current_options.get_auto_coordination() ==
fgOPTIONS::FG_AUTO_COORD_ENABLED )
}
inline void move_aileron( double amt ) {
aileron += amt;
- if ( aileron < -1.0 ) aileron = -1.0;
- if ( aileron > 1.0 ) aileron = 1.0;
-
+ CLAMP( &aileron, -1.0, 1.0 );
+
// check for autocoordination
if ( current_options.get_auto_coordination() ==
fgOPTIONS::FG_AUTO_COORD_ENABLED )
}
inline void set_elevator( double pos ) {
elevator = pos;
- if ( elevator < -1.0 ) elevator = -1.0;
- if ( elevator > 1.0 ) elevator = 1.0;
+ CLAMP( &elevator, -1.0, 1.0 );
}
inline void move_elevator( double amt ) {
elevator += amt;
- if ( elevator < -1.0 ) elevator = -1.0;
- if ( elevator > 1.0 ) elevator = 1.0;
+ CLAMP( &elevator, -1.0, 1.0 );
}
inline void set_elevator_trim( double pos ) {
elevator_trim = pos;
- if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
- if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
+ CLAMP( &elevator_trim, -1.0, 1.0 );
}
inline void move_elevator_trim( double amt ) {
elevator_trim += amt;
- if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
- if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
+ CLAMP( &elevator_trim, -1.0, 1.0 );
}
inline void set_rudder( double pos ) {
rudder = pos;
- if ( rudder < -1.0 ) rudder = -1.0;
- if ( rudder > 1.0 ) rudder = 1.0;
+ CLAMP( &rudder, -1.0, 1.0 );
}
inline void move_rudder( double amt ) {
rudder += amt;
- if ( rudder < -1.0 ) rudder = -1.0;
- if ( rudder > 1.0 ) rudder = 1.0;
+ CLAMP( &rudder, -1.0, 1.0 );
}
inline void set_throttle( int engine, double pos ) {
if ( engine == ALL_ENGINES ) {
for ( int i = 0; i < MAX_ENGINES; i++ ) {
throttle[i] = pos;
- if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
- if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
+ CLAMP( &throttle[i], 0.0, 1.0 );
}
} else {
if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
throttle[engine] = pos;
- if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
- if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
+ CLAMP( &throttle[engine], 0.0, 1.0 );
}
}
}
if ( engine == ALL_ENGINES ) {
for ( int i = 0; i < MAX_ENGINES; i++ ) {
throttle[i] += amt;
- if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
- if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
+ CLAMP( &throttle[i], 0.0, 1.0 );
}
} else {
if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
throttle[engine] += amt;
- if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
- if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
+ CLAMP( &throttle[engine], 0.0, 1.0 );
}
}
}
if ( wheel == ALL_WHEELS ) {
for ( int i = 0; i < MAX_WHEELS; i++ ) {
brake[i] = pos;
- if ( brake[i] < 0.0 ) brake[i] = 0.0;
- if ( brake[i] > 1.0 ) brake[i] = 1.0;
+ CLAMP( &brake[i], 0.0, 1.0 );
}
} else {
if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
brake[wheel] = pos;
- if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
- if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
+ CLAMP( &brake[wheel], 0.0, 1.0 );
}
}
}
if ( wheel == ALL_WHEELS ) {
for ( int i = 0; i < MAX_WHEELS; i++ ) {
brake[i] += amt;
- if ( brake[i] < 0.0 ) brake[i] = 0.0;
- if ( brake[i] > 1.0 ) brake[i] = 1.0;
+ CLAMP( &brake[i], 0.0, 1.0 );
}
} else {
if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
brake[wheel] += amt;
- if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
- if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
+ CLAMP( &brake[wheel], 0.0, 1.0 );
}
}
}
// inline void set_Sin_beta( double sb ) { sin_beta = sb; }
double cos_phi, sin_phi, cos_theta, sin_theta, cos_psi, sin_psi;
- // inline double get_Cos_phi() const { return cos_phi; }
- // inline void set_Cos_phi( double cp ) { cos_phi = cp; }
+ inline double get_Cos_phi() const { return cos_phi; }
+ inline void set_Cos_phi( double cp ) { cos_phi = cp; }
// inline double get_Sin_phi() const { return sin_phi; }
// inline void set_Sin_phi( double sp ) { sin_phi = sp; }
- // inline double get_Cos_theta() const { return cos_theta; }
- // inline void set_Cos_theta( double ct ) { cos_theta = ct; }
+ inline double get_Cos_theta() const { return cos_theta; }
+ inline void set_Cos_theta( double ct ) { cos_theta = ct; }
// inline double get_Sin_theta() const { return sin_theta; }
// inline void set_Sin_theta( double st ) { sin_theta = st; }
// inline double get_Cos_psi() const { return cos_psi; }
#include <Cockpit/hud.hxx>
#include <GUI/gui.h>
#include <Include/fg_constants.h>
+#include <Misc/fgpath.hxx>
#include <Scenery/tilemgr.hxx>
#include <Objects/materialmgr.hxx>
#include <Time/fg_time.hxx>
return;
case 112: // p key
t->togglePauseMode();
- // printf position and attitude information
- FG_LOG( FG_INPUT, FG_INFO,
- "Lon = " << f->get_Longitude() * RAD_TO_DEG
- << " Lat = " << f->get_Latitude() * RAD_TO_DEG
- << " Altitude = " << f->get_Altitude() * FEET_TO_METER );
- FG_LOG( FG_INPUT, FG_INFO,
- "Heading = " << f->get_Psi() * RAD_TO_DEG
- << " Roll = " << f->get_Phi() * RAD_TO_DEG
- << " Pitch = " << f->get_Theta() * RAD_TO_DEG );
+
+ {
+ FGBucket p( f->get_Longitude() * RAD_TO_DEG,
+ f->get_Latitude() * RAD_TO_DEG );
+ FGPath tile_path( current_options.get_fg_root() );
+ tile_path.append( "Scenery" );
+ tile_path.append( p.gen_base_path() );
+ tile_path.append( p.gen_index_str() );
+
+ // printf position and attitude information
+ FG_LOG( FG_INPUT, FG_INFO,
+ "Lon = " << f->get_Longitude() * RAD_TO_DEG
+ << " Lat = " << f->get_Latitude() * RAD_TO_DEG
+ << " Altitude = " << f->get_Altitude() * FEET_TO_METER
+ );
+ FG_LOG( FG_INPUT, FG_INFO,
+ "Heading = " << f->get_Psi() * RAD_TO_DEG
+ << " Roll = " << f->get_Phi() * RAD_TO_DEG
+ << " Pitch = " << f->get_Theta() * RAD_TO_DEG );
+ FG_LOG( FG_INPUT, FG_INFO, tile_path.c_str());
+ }
return;
case 116: // t key
t->adjust_warp_delta (+30);