1
0
Fork 0

Patch from Melchior Franz:

Due to jumpy joystick read-outs the UFO jitters a lot in turns.
This patch implements simple damping for aileron/elevator/throttle.
Furthermore it lets the UFO fly backwards if brake[0] is active
(by default associated with the joystick's fire button). After all,
everyone knows that UFO's can fly backwards!
This commit is contained in:
david 2002-05-09 21:56:31 +00:00
parent 5c799d1ba2
commit 907e2942bb
2 changed files with 21 additions and 6 deletions

View file

@ -31,8 +31,15 @@
#include "UFO.hxx" #include "UFO.hxx"
const double throttle_damp = 0.05;
const double aileron_damp = 0.01;
const double elevator_damp = 0.01;
FGUFO::FGUFO( double dt ) { FGUFO::FGUFO( double dt )
: Throttle(0.0),
Aileron(0.0),
Elevator(0.0)
{
set_delta_t( dt ); set_delta_t( dt );
} }
@ -55,11 +62,17 @@ void FGUFO::update( int multiloop ) {
double time_step = get_delta_t() * multiloop; double time_step = get_delta_t() * multiloop;
// read the throttle // read the throttle
double Throttle = globals->get_controls()->get_throttle( 0 ); double th = globals->get_controls()->get_throttle( 0 );
if (globals->get_controls()->get_brake(0)) {
th = -th;
}
Throttle = th * throttle_damp + Throttle * (1 - throttle_damp);
// read the state of the control surfaces // read the state of the control surfaces
double Aileron = globals->get_controls()->get_aileron(); Aileron = globals->get_controls()->get_aileron() * aileron_damp
double Elevator = globals->get_controls()->get_elevator(); + Aileron * (1 - aileron_damp);
Elevator = globals->get_controls()->get_elevator() * elevator_damp
+ Elevator * (1 - elevator_damp);
// the velocity of the aircraft // the velocity of the aircraft
double velocity = Throttle * 2000; // meters/sec double velocity = Throttle * 2000; // meters/sec
@ -141,7 +154,7 @@ void FGUFO::update( int multiloop ) {
// update (lon/lat) position // update (lon/lat) position
double lat2, lon2, az2; double lat2, lon2, az2;
if ( speed > SG_EPSILON ) { if ( fabs(speed) > SG_EPSILON ) {
geo_direct_wgs_84 ( get_Altitude(), geo_direct_wgs_84 ( get_Altitude(),
get_Latitude() * SGD_RADIANS_TO_DEGREES, get_Latitude() * SGD_RADIANS_TO_DEGREES,
get_Longitude() * SGD_RADIANS_TO_DEGREES, get_Longitude() * SGD_RADIANS_TO_DEGREES,

View file

@ -29,7 +29,9 @@
class FGUFO: public FGInterface { class FGUFO: public FGInterface {
double Throttle;
double Aileron;
double Elevator;
public: public:
FGUFO( double dt ); FGUFO( double dt );
~FGUFO(); ~FGUFO();