Use some C++ FOOmagic to get the lat and lon updated in the property tree properly
This commit is contained in:
parent
9bc2517417
commit
c1eb54ae0a
2 changed files with 46 additions and 16 deletions
src/AIModel
|
@ -42,7 +42,14 @@
|
||||||
|
|
||||||
#include "AIBase.hxx"
|
#include "AIBase.hxx"
|
||||||
|
|
||||||
|
FGAIBase *FGAIBase::_self = NULL;
|
||||||
|
|
||||||
|
FGAIBase::FGAIBase() {
|
||||||
|
_self = this;
|
||||||
|
}
|
||||||
|
|
||||||
FGAIBase::~FGAIBase() {
|
FGAIBase::~FGAIBase() {
|
||||||
|
_self = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIBase::update(double dt) {
|
void FGAIBase::update(double dt) {
|
||||||
|
@ -81,8 +88,12 @@ void FGAIBase::bind() {
|
||||||
props->tie("velocities/vertical-speed-fps", SGRawValuePointer<double>(&vs));
|
props->tie("velocities/vertical-speed-fps", SGRawValuePointer<double>(&vs));
|
||||||
|
|
||||||
props->tie("position/altitude-ft", SGRawValuePointer<double>(&altitude));
|
props->tie("position/altitude-ft", SGRawValuePointer<double>(&altitude));
|
||||||
props->tie("position/latitude-deg", SGRawValuePointer<double>(&lat));
|
props->tie("position/latitude-deg",
|
||||||
props->tie("position/longitude-deg", SGRawValuePointer<double>(&lon));
|
SGRawValueFunctions<double>(FGAIBase::_getLatitude,
|
||||||
|
FGAIBase::_setLatitude));
|
||||||
|
props->tie("position/longitude-deg",
|
||||||
|
SGRawValueFunctions<double>(FGAIBase::_getLongitude,
|
||||||
|
FGAIBase::_setLongitude));
|
||||||
|
|
||||||
props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
|
props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
|
||||||
props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
|
props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
|
||||||
|
@ -101,3 +112,16 @@ void FGAIBase::unbind() {
|
||||||
props->untie("orientation/roll-deg");
|
props->untie("orientation/roll-deg");
|
||||||
props->untie("orientation/heading-deg");
|
props->untie("orientation/heading-deg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FGAIBase::_setLongitude( double longitude ) {
|
||||||
|
_self->pos.setlon(longitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FGAIBase::_setLatitude ( double latitude ) {
|
||||||
|
_self->pos.setlat(latitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
double FGAIBase::_getLongitude() { return _self->pos.lon(); }
|
||||||
|
|
||||||
|
double FGAIBase::_getLatitude () { return _self->pos.lat(); }
|
||||||
|
|
|
@ -29,8 +29,13 @@ SG_USING_STD(string);
|
||||||
|
|
||||||
class FGAIBase {
|
class FGAIBase {
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static FGAIBase *_self;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
FGAIBase();
|
||||||
virtual ~FGAIBase();
|
virtual ~FGAIBase();
|
||||||
virtual void update(double dt);
|
virtual void update(double dt);
|
||||||
inline Point3D GetPos() { return(pos); }
|
inline Point3D GetPos() { return(pos); }
|
||||||
|
@ -42,9 +47,9 @@ public:
|
||||||
void setPath( const char* model );
|
void setPath( const char* model );
|
||||||
void setSpeed( double speed_KTAS );
|
void setSpeed( double speed_KTAS );
|
||||||
void setAltitude( double altitude_ft );
|
void setAltitude( double altitude_ft );
|
||||||
void setLongitude( double longitude );
|
|
||||||
void setLatitude( double latitude );
|
|
||||||
void setHeading( double heading );
|
void setHeading( double heading );
|
||||||
|
void setLatitude( double latitude );
|
||||||
|
void setLongitude( double longitude );
|
||||||
|
|
||||||
void setDie( bool die );
|
void setDie( bool die );
|
||||||
bool getDie();
|
bool getDie();
|
||||||
|
@ -54,7 +59,6 @@ protected:
|
||||||
SGPropertyNode *props;
|
SGPropertyNode *props;
|
||||||
|
|
||||||
Point3D pos; // WGS84 lat & lon in degrees, elev above sea-level in meters
|
Point3D pos; // WGS84 lat & lon in degrees, elev above sea-level in meters
|
||||||
double lat, lon; // As above, this is needed for the property bindings
|
|
||||||
double hdg; // True heading in degrees
|
double hdg; // True heading in degrees
|
||||||
double roll; // degrees, left is negative
|
double roll; // degrees, left is negative
|
||||||
double pitch; // degrees, nose-down is negative
|
double pitch; // degrees, nose-down is negative
|
||||||
|
@ -77,6 +81,11 @@ protected:
|
||||||
|
|
||||||
void Transform();
|
void Transform();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void _setLongitude( double longitude );
|
||||||
|
static void _setLatitude ( double latitude );
|
||||||
|
static double _getLongitude();
|
||||||
|
static double _getLatitude ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,21 +102,18 @@ inline void FGAIBase::setAltitude( double altitude_ft ) {
|
||||||
pos.setelev(altitude * SG_FEET_TO_METER);
|
pos.setelev(altitude * SG_FEET_TO_METER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void FGAIBase::setLongitude( double longitude ) {
|
|
||||||
lon = longitude;
|
|
||||||
pos.setlon(longitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void FGAIBase::setLatitude( double latitude ) {
|
|
||||||
lat = latitude;
|
|
||||||
pos.setlat(latitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void FGAIBase::setHeading( double heading ) {
|
inline void FGAIBase::setHeading( double heading ) {
|
||||||
hdg = tgt_heading = heading;
|
hdg = tgt_heading = heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void FGAIBase::setLongitude( double longitude ) {
|
||||||
|
pos.setlon( longitude );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FGAIBase::setLatitude ( double latitude ) {
|
||||||
|
pos.setlat( latitude );
|
||||||
|
}
|
||||||
|
|
||||||
inline void FGAIBase::setDie( bool die ) { delete_me = die; }
|
inline void FGAIBase::setDie( bool die ) { delete_me = die; }
|
||||||
inline bool FGAIBase::getDie() { return delete_me; }
|
inline bool FGAIBase::getDie() { return delete_me; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue