X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FUFO.hxx;h=d22832f70d56f25f12eb88ad692566b58eb8ab02;hb=312447c565ec410f52353ba22d305cf470e9ba33;hp=aed107e752a786e2ede2b03bdc7c1dc0cda0217b;hpb=18e36a3302c1f0d4dc17387e981659e691ed9710;p=flightgear.git diff --git a/src/FDM/UFO.hxx b/src/FDM/UFO.hxx index aed107e75..d22832f70 100644 --- a/src/FDM/UFO.hxx +++ b/src/FDM/UFO.hxx @@ -3,7 +3,7 @@ // Written by Curtis Olson, started October 1999. // Slightly modified from MagicCarpet.hxx by Jonathan Polley, April 2002 // -// Copyright (C) 1999-2002 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 1999-2002 Curtis L. Olson - http://www.flightgear.org/~curt // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -17,28 +17,56 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // #ifndef _UFO_HXX #define _UFO_HXX - #include "flight.hxx" class FGUFO: public FGInterface { +private: + + class lowpass { + private: + static double _dt; + double _coeff; + double _last; + bool _initialized; + public: + lowpass(double coeff) : _coeff(coeff), _initialized(false) {} + static inline void set_delta(double dt) { _dt = dt; } + double filter(double value) { + if (!_initialized) { + _initialized = true; + return _last = value; + } + double c = _dt / (_coeff + _dt); + return _last = value * c + _last * (1.0 - c); + } + }; + + lowpass *Throttle; + lowpass *Aileron; + lowpass *Elevator; + lowpass *Rudder; + lowpass *Aileron_Trim; + lowpass *Elevator_Trim; + lowpass *Rudder_Trim; + SGPropertyNode_ptr Speed_Max; public: FGUFO( double dt ); ~FGUFO(); - // reset flight params to a specific position + // reset flight params to a specific position void init(); // update position based on inputs, positions, velocities, etc. - void update( int multiloop ); + void update( double dt ); };