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("velocities/true-airspeed-kt", SGRawValuePointer<double>(&speed));
|
||||
props->tie("velocities/vertical-speed-fps",
|
||||
SGRawValueFunctions<double>(FGAIBase::_getVS_fps,
|
||||
FGAIBase::_setVS_fps, this));
|
||||
SGRawValueMethods<FGAIBase,double>(*this,
|
||||
FGAIBase::_getVS_fps,
|
||||
FGAIBase::_setVS_fps));
|
||||
|
||||
props->tie("position/altitude-ft",
|
||||
SGRawValueFunctions<double>(FGAIBase::_getAltitude,
|
||||
FGAIBase::_setAltitude, this));
|
||||
SGRawValueMethods<FGAIBase,double>(*this,
|
||||
FGAIBase::_getAltitude,
|
||||
FGAIBase::_setAltitude));
|
||||
props->tie("position/latitude-deg",
|
||||
SGRawValueFunctions<double>(FGAIBase::_getLatitude,
|
||||
FGAIBase::_setLatitude, this));
|
||||
SGRawValueMethods<FGAIBase,double>(*this,
|
||||
FGAIBase::_getLatitude,
|
||||
FGAIBase::_setLatitude));
|
||||
props->tie("position/longitude-deg",
|
||||
SGRawValueFunctions<double>(FGAIBase::_getLongitude,
|
||||
FGAIBase::_setLongitude, this));
|
||||
SGRawValueMethods<FGAIBase,double>(*this,
|
||||
FGAIBase::_getLongitude,
|
||||
FGAIBase::_setLongitude));
|
||||
|
||||
props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
|
||||
props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
|
||||
|
@ -144,7 +148,7 @@ void FGAIBase::bind() {
|
|||
props->tie("radar/rotation", SGRawValuePointer<double>(&rotation));
|
||||
|
||||
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/strobe", true);
|
||||
}
|
||||
|
@ -178,46 +182,37 @@ void FGAIBase::unbind() {
|
|||
/*
|
||||
* getters and Setters
|
||||
*/
|
||||
void FGAIBase::_setLongitude( double longitude, void *p ) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
self->pos.setlon(longitude);
|
||||
void FGAIBase::_setLongitude( double longitude ) {
|
||||
pos.setlon(longitude);
|
||||
}
|
||||
void FGAIBase::_setLatitude ( double latitude, void *p ) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
self->pos.setlat(latitude);
|
||||
void FGAIBase::_setLatitude ( double latitude ) {
|
||||
pos.setlat(latitude);
|
||||
}
|
||||
|
||||
double FGAIBase::_getLongitude(void *p) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
return self->pos.lon();
|
||||
double FGAIBase::_getLongitude() const {
|
||||
return pos.lon();
|
||||
}
|
||||
double FGAIBase::_getLatitude (void *p) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
return self->pos.lat();
|
||||
double FGAIBase::_getLatitude () const {
|
||||
return pos.lat();
|
||||
}
|
||||
double FGAIBase::_getRdot(void *p) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
return self->rdot;
|
||||
double FGAIBase::_getRdot() const {
|
||||
return rdot;
|
||||
}
|
||||
double FGAIBase::_getVS_fps(void *p) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
return self->vs*60.0;
|
||||
double FGAIBase::_getVS_fps() const {
|
||||
return vs*60.0;
|
||||
}
|
||||
void FGAIBase::_setVS_fps( double _vs, void *p ) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
self->vs = _vs/60.0;
|
||||
void FGAIBase::_setVS_fps( double _vs ) {
|
||||
vs = _vs/60.0;
|
||||
}
|
||||
|
||||
double FGAIBase::_getAltitude(void *p) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
return self->altitude;
|
||||
double FGAIBase::_getAltitude() const {
|
||||
return altitude;
|
||||
}
|
||||
void FGAIBase::_setAltitude( double _alt, void *p ) {
|
||||
FGAIBase *self = (FGAIBase *)p;
|
||||
self->setAltitude( _alt );
|
||||
void FGAIBase::_setAltitude( double _alt ) {
|
||||
setAltitude( _alt );
|
||||
}
|
||||
|
||||
bool FGAIBase::_isNight() {
|
||||
bool FGAIBase::_isNight() const {
|
||||
return (fgGetFloat("/sim/time/sun-angle-rad") > 1.57);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,32 +115,30 @@ public:
|
|||
object_type getType();
|
||||
bool isa( object_type otype );
|
||||
|
||||
static double _getVS_fps(void *p);
|
||||
static void _setVS_fps( double _vs, void *p );
|
||||
double _getVS_fps() const;
|
||||
void _setVS_fps( double _vs );
|
||||
|
||||
static double _getAltitude(void *p);
|
||||
static void _setAltitude( double _alt, void *p );
|
||||
double _getAltitude() const;
|
||||
void _setAltitude( double _alt );
|
||||
|
||||
static void _setLongitude( double longitude, void *p );
|
||||
static void _setLatitude ( double latitude, void *p );
|
||||
void _setLongitude( double longitude );
|
||||
void _setLatitude ( double latitude );
|
||||
|
||||
static double _getLongitude(void *p);
|
||||
static double _getLatitude (void *p);
|
||||
double _getLongitude() const;
|
||||
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; };
|
||||
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();
|
||||
|
||||
private:
|
||||
FGAIBase *self;
|
||||
bool _isNight() const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -217,7 +217,6 @@ int FGAIManager::createAircraft( string model_class, string path,
|
|||
double heading, double speed, double pitch, double roll ) {
|
||||
|
||||
FGAIAircraft* ai_plane = new FGAIAircraft(this);
|
||||
cout << "ai_plane: " << ai_plane << endl;
|
||||
ai_list.push_back(ai_plane);
|
||||
ai_plane->setID( assignID() );
|
||||
++numObjects;
|
||||
|
@ -249,7 +248,6 @@ int FGAIManager::createAircraft( string model_class, string path,
|
|||
FGAIFlightPlan* flightplan ) {
|
||||
|
||||
FGAIAircraft* ai_plane = new FGAIAircraft(this);
|
||||
cout << "ai_plane1: " << ai_plane << endl;
|
||||
ai_list.push_back(ai_plane);
|
||||
ai_plane->setID( assignID() );
|
||||
++numObjects;
|
||||
|
|
Loading…
Reference in a new issue