Use SGRawValueMethods rather than SGRawValueFunctions because that allows one to pass the 'this' pointer. Remove some debug code.
This commit is contained in:
parent
1b5483bc63
commit
70a6f2c014
3 changed files with 50 additions and 59 deletions
|
@ -117,18 +117,22 @@ void FGAIBase::bind() {
|
||||||
props->tie("id", SGRawValuePointer<int>(&id));
|
props->tie("id", SGRawValuePointer<int>(&id));
|
||||||
props->tie("velocities/true-airspeed-kt", SGRawValuePointer<double>(&speed));
|
props->tie("velocities/true-airspeed-kt", SGRawValuePointer<double>(&speed));
|
||||||
props->tie("velocities/vertical-speed-fps",
|
props->tie("velocities/vertical-speed-fps",
|
||||||
SGRawValueFunctions<double>(FGAIBase::_getVS_fps,
|
SGRawValueMethods<FGAIBase,double>(*this,
|
||||||
FGAIBase::_setVS_fps, this));
|
FGAIBase::_getVS_fps,
|
||||||
|
FGAIBase::_setVS_fps));
|
||||||
|
|
||||||
props->tie("position/altitude-ft",
|
props->tie("position/altitude-ft",
|
||||||
SGRawValueFunctions<double>(FGAIBase::_getAltitude,
|
SGRawValueMethods<FGAIBase,double>(*this,
|
||||||
FGAIBase::_setAltitude, this));
|
FGAIBase::_getAltitude,
|
||||||
|
FGAIBase::_setAltitude));
|
||||||
props->tie("position/latitude-deg",
|
props->tie("position/latitude-deg",
|
||||||
SGRawValueFunctions<double>(FGAIBase::_getLatitude,
|
SGRawValueMethods<FGAIBase,double>(*this,
|
||||||
FGAIBase::_setLatitude, this));
|
FGAIBase::_getLatitude,
|
||||||
|
FGAIBase::_setLatitude));
|
||||||
props->tie("position/longitude-deg",
|
props->tie("position/longitude-deg",
|
||||||
SGRawValueFunctions<double>(FGAIBase::_getLongitude,
|
SGRawValueMethods<FGAIBase,double>(*this,
|
||||||
FGAIBase::_setLongitude, this));
|
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));
|
||||||
|
@ -144,7 +148,7 @@ void FGAIBase::bind() {
|
||||||
props->tie("radar/rotation", SGRawValuePointer<double>(&rotation));
|
props->tie("radar/rotation", SGRawValuePointer<double>(&rotation));
|
||||||
|
|
||||||
props->tie("controls/lighting/nav-lights",
|
props->tie("controls/lighting/nav-lights",
|
||||||
SGRawValueFunctions<bool>(FGAIBase::_isNight));
|
SGRawValueMethods<FGAIBase,bool>(*this, _isNight));
|
||||||
props->setBoolValue("controls/lighting/beacon", true);
|
props->setBoolValue("controls/lighting/beacon", true);
|
||||||
props->setBoolValue("controls/lighting/strobe", true);
|
props->setBoolValue("controls/lighting/strobe", true);
|
||||||
}
|
}
|
||||||
|
@ -178,46 +182,37 @@ void FGAIBase::unbind() {
|
||||||
/*
|
/*
|
||||||
* getters and Setters
|
* getters and Setters
|
||||||
*/
|
*/
|
||||||
void FGAIBase::_setLongitude( double longitude, void *p ) {
|
void FGAIBase::_setLongitude( double longitude ) {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
pos.setlon(longitude);
|
||||||
self->pos.setlon(longitude);
|
|
||||||
}
|
}
|
||||||
void FGAIBase::_setLatitude ( double latitude, void *p ) {
|
void FGAIBase::_setLatitude ( double latitude ) {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
pos.setlat(latitude);
|
||||||
self->pos.setlat(latitude);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double FGAIBase::_getLongitude(void *p) {
|
double FGAIBase::_getLongitude() const {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
return pos.lon();
|
||||||
return self->pos.lon();
|
|
||||||
}
|
}
|
||||||
double FGAIBase::_getLatitude (void *p) {
|
double FGAIBase::_getLatitude () const {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
return pos.lat();
|
||||||
return self->pos.lat();
|
|
||||||
}
|
}
|
||||||
double FGAIBase::_getRdot(void *p) {
|
double FGAIBase::_getRdot() const {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
return rdot;
|
||||||
return self->rdot;
|
|
||||||
}
|
}
|
||||||
double FGAIBase::_getVS_fps(void *p) {
|
double FGAIBase::_getVS_fps() const {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
return vs*60.0;
|
||||||
return self->vs*60.0;
|
|
||||||
}
|
}
|
||||||
void FGAIBase::_setVS_fps( double _vs, void *p ) {
|
void FGAIBase::_setVS_fps( double _vs ) {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
vs = _vs/60.0;
|
||||||
self->vs = _vs/60.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double FGAIBase::_getAltitude(void *p) {
|
double FGAIBase::_getAltitude() const {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
return altitude;
|
||||||
return self->altitude;
|
|
||||||
}
|
}
|
||||||
void FGAIBase::_setAltitude( double _alt, void *p ) {
|
void FGAIBase::_setAltitude( double _alt ) {
|
||||||
FGAIBase *self = (FGAIBase *)p;
|
setAltitude( _alt );
|
||||||
self->setAltitude( _alt );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FGAIBase::_isNight() {
|
bool FGAIBase::_isNight() const {
|
||||||
return (fgGetFloat("/sim/time/sun-angle-rad") > 1.57);
|
return (fgGetFloat("/sim/time/sun-angle-rad") > 1.57);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,32 +115,30 @@ public:
|
||||||
object_type getType();
|
object_type getType();
|
||||||
bool isa( object_type otype );
|
bool isa( object_type otype );
|
||||||
|
|
||||||
static double _getVS_fps(void *p);
|
double _getVS_fps() const;
|
||||||
static void _setVS_fps( double _vs, void *p );
|
void _setVS_fps( double _vs );
|
||||||
|
|
||||||
static double _getAltitude(void *p);
|
double _getAltitude() const;
|
||||||
static void _setAltitude( double _alt, void *p );
|
void _setAltitude( double _alt );
|
||||||
|
|
||||||
static void _setLongitude( double longitude, void *p );
|
void _setLongitude( double longitude );
|
||||||
static void _setLatitude ( double latitude, void *p );
|
void _setLatitude ( double latitude );
|
||||||
|
|
||||||
static double _getLongitude(void *p);
|
double _getLongitude() const;
|
||||||
static double _getLatitude (void *p);
|
double _getLatitude () const;
|
||||||
|
|
||||||
|
double _getBearing() const;
|
||||||
|
double _getElevation() const;
|
||||||
|
double _getRdot() const;
|
||||||
|
double _getH_offset() const;
|
||||||
|
double _getV_offset() const;
|
||||||
|
double _getX_shift() const;
|
||||||
|
double _getY_shift() const;
|
||||||
|
double _getRotation() const;
|
||||||
|
|
||||||
static double _getBearing(void *p);
|
|
||||||
static double _getElevation(void *p);
|
|
||||||
inline double _getRange() { return range; };
|
inline double _getRange() { return range; };
|
||||||
static double _getRdot(void *p);
|
|
||||||
static double _getH_offset(void *p);
|
|
||||||
static double _getV_offset(void *p);
|
|
||||||
static double _getX_shift(void *p);
|
|
||||||
static double _getY_shift(void *p);
|
|
||||||
static double _getRotation(void *p);
|
|
||||||
|
|
||||||
static bool _isNight();
|
bool _isNight() const;
|
||||||
|
|
||||||
private:
|
|
||||||
FGAIBase *self;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,6 @@ int FGAIManager::createAircraft( string model_class, string path,
|
||||||
double heading, double speed, double pitch, double roll ) {
|
double heading, double speed, double pitch, double roll ) {
|
||||||
|
|
||||||
FGAIAircraft* ai_plane = new FGAIAircraft(this);
|
FGAIAircraft* ai_plane = new FGAIAircraft(this);
|
||||||
cout << "ai_plane: " << ai_plane << endl;
|
|
||||||
ai_list.push_back(ai_plane);
|
ai_list.push_back(ai_plane);
|
||||||
ai_plane->setID( assignID() );
|
ai_plane->setID( assignID() );
|
||||||
++numObjects;
|
++numObjects;
|
||||||
|
@ -249,7 +248,6 @@ int FGAIManager::createAircraft( string model_class, string path,
|
||||||
FGAIFlightPlan* flightplan ) {
|
FGAIFlightPlan* flightplan ) {
|
||||||
|
|
||||||
FGAIAircraft* ai_plane = new FGAIAircraft(this);
|
FGAIAircraft* ai_plane = new FGAIAircraft(this);
|
||||||
cout << "ai_plane1: " << ai_plane << endl;
|
|
||||||
ai_list.push_back(ai_plane);
|
ai_list.push_back(ai_plane);
|
||||||
ai_plane->setID( assignID() );
|
ai_plane->setID( assignID() );
|
||||||
++numObjects;
|
++numObjects;
|
||||||
|
|
Loading…
Reference in a new issue