X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2FAIBallistic.cxx;h=f7a2fc7d6c954404334871d3856bd17c2071a790;hb=588eba658a6f348e517a23d22ffa2d9b44f11cc7;hp=4336fa14c88b977af10994273cc973604b3a38ea;hpb=ce97a1e4c54bae27f9da19f41f366f161562a0d3;p=flightgear.git diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 4336fa14c..f7a2fc7d6 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -126,7 +126,11 @@ void FGAIBallistic::readFromScenario(SGPropertyNode* scFileNode) { bool FGAIBallistic::init(bool search_in_AI_path) { FGAIBase::init(search_in_AI_path); + reinit(); + return true; +} +void FGAIBallistic::reinit() { _impact_reported = false; _collision_reported = false; _expiry_reported = false; @@ -179,110 +183,78 @@ bool FGAIBallistic::init(bool search_in_AI_path) { setParentNodes(_selected_ac); - return true; + FGAIBase::reinit(); } void FGAIBallistic::bind() { // FGAIBase::bind(); - props->tie("sim/time/elapsed-sec", + _tiedProperties.setRoot(props); + tie("sim/time/elapsed-sec", SGRawValueMethods(*this, &FGAIBallistic::_getTime, &FGAIBallistic::setTime)); - //props->tie("mass-slug", + //tie("mass-slug", // SGRawValueMethods(*this, // &FGAIBallistic::getMass)); - props->tie("material/solid", + tie("material/solid", SGRawValuePointer(&_solid)); - props->tie("altitude-agl-ft", + tie("altitude-agl-ft", SGRawValuePointer(&_ht_agl_ft)); - props->tie("controls/slave-to-ac", + tie("controls/slave-to-ac", SGRawValueMethods (*this, &FGAIBallistic::getSlaved, &FGAIBallistic::setSlaved)); - props->tie("controls/invisible", + tie("controls/invisible", SGRawValuePointer(&invisible)); if(_external_force || _slave_to_ac){ - props->tie("controls/force_stabilized", + tie("controls/force_stabilized", SGRawValuePointer(&_force_stabilised)); - props->tie("position/global-x", + tie("position/global-x", SGRawValueMethods(*this, &FGAIBase::_getCartPosX, 0)); - props->tie("position/global-y", + tie("position/global-y", SGRawValueMethods(*this, &FGAIBase::_getCartPosY, 0)); - props->tie("position/global-z", + tie("position/global-z", SGRawValueMethods(*this, &FGAIBase::_getCartPosZ, 0)); - props->tie("velocities/vertical-speed-fps", + tie("velocities/vertical-speed-fps", SGRawValuePointer(&vs)); - props->tie("velocities/true-airspeed-kt", + tie("velocities/true-airspeed-kt", SGRawValuePointer(&speed)); - props->tie("velocities/horizontal-speed-fps", + tie("velocities/horizontal-speed-fps", SGRawValuePointer(&hs)); - props->tie("position/altitude-ft", + tie("position/altitude-ft", SGRawValueMethods(*this, &FGAIBase::_getElevationFt, &FGAIBase::_setAltitude)); - props->tie("position/latitude-deg", + tie("position/latitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLatitude, &FGAIBase::_setLatitude)); - props->tie("position/longitude-deg", + tie("position/longitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLongitude, &FGAIBase::_setLongitude)); - props->tie("orientation/hdg-deg", + tie("orientation/hdg-deg", SGRawValuePointer(&hdg)); - props->tie("orientation/pitch-deg", + tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); - props->tie("orientation/roll-deg", + tie("orientation/roll-deg", SGRawValuePointer(&roll)); - props->tie("controls/slave-load-to-ac", + tie("controls/slave-load-to-ac", SGRawValueMethods (*this, &FGAIBallistic::getSlavedLoad, &FGAIBallistic::setSlavedLoad)); - props->tie("position/load-offset", + tie("position/load-offset", SGRawValueMethods (*this, &FGAIBallistic::getLoadOffset, &FGAIBallistic::setLoadOffset)); - props->tie("load/distance-to-hitch-ft", + tie("load/distance-to-hitch-ft", SGRawValueMethods (*this, &FGAIBallistic::getDistanceToHitch)); - props->tie("load/elevation-to-hitch-deg", + tie("load/elevation-to-hitch-deg", SGRawValueMethods (*this, &FGAIBallistic::getElevToHitch)); - props->tie("load/bearing-to-hitch-deg", + tie("load/bearing-to-hitch-deg", SGRawValueMethods (*this, &FGAIBallistic::getBearingToHitch)); - props->tie("material/load-resistance", + tie("material/load-resistance", SGRawValuePointer(&_load_resistance)); } } -void FGAIBallistic::unbind() { -// FGAIBase::unbind(); - - props->untie("sim/time/elapsed-sec"); - props->untie("mass-slug"); - props->untie("material/solid"); - props->untie("altitude-agl-ft"); - props->untie("controls/slave-to-ac"); - props->untie("controls/invisible"); - - if(_external_force || _slave_to_ac){ - props->untie("position/global-y"); - props->untie("position/global-x"); - props->untie("position/global-z"); - props->untie("velocities/vertical-speed-fps"); - props->untie("velocities/true-airspeed-kt"); - props->untie("velocities/horizontal-speed-fps"); - props->untie("position/altitude-ft"); - props->untie("position/latitude-deg"); - props->untie("position/longitude-deg"); - props->untie("position/ht-agl-ft"); - props->untie("orientation/hdg-deg"); - props->untie("orientation/pitch-deg"); - props->untie("orientation/roll-deg"); - props->untie("controls/force_stabilized"); - props->untie("position/load-offset"); - props->untie("load/distance-to-hitch-ft"); - props->untie("load/elevation-to-hitch-deg"); - props->untie("load/bearing-to-hitch-deg"); - props->untie("material/load-resistance"); - } -} - void FGAIBallistic::update(double dt) { FGAIBase::update(dt); _setUserPos(); @@ -635,21 +607,21 @@ void FGAIBallistic::slaveToAC(double dt){ if (invisible) return; - double hdg, pch, rll, agl = 0; + double hdg, pch, rll;//, agl = 0; if (_pnode != 0) { setParentPos(); hdg = _p_hdg_node->getDoubleValue(); pch = _p_pch_node->getDoubleValue(); rll = _p_rll_node->getDoubleValue(); - agl = _p_agl_node->getDoubleValue(); +// agl = _p_agl_node->getDoubleValue(); setOffsetPos(_parentpos, hdg, pch, rll); setSpeed(_p_spd_node->getDoubleValue()); }else { hdg = manager->get_user_heading(); pch = manager->get_user_pitch(); rll = manager->get_user_roll(); - agl = manager->get_user_agl(); +// agl = manager->get_user_agl(); setOffsetPos(userpos, hdg, pch, rll); setSpeed(manager->get_user_speed()); } @@ -859,7 +831,7 @@ void FGAIBallistic::Run(double dt) { hs = 0; // adjust vertical speed for acceleration of gravity, buoyancy, and vertical force - double gravity = Environment::Gravity::instance()->getGravity(pos); + double gravity = SG_METER_TO_FEET * (Environment::Gravity::instance()->getGravity(pos)); vs -= (gravity - _buoyancy - v_force_acc_fpss - normal_force_fpss) * dt; if (vs <= 0.00001 && vs >= -0.00001) @@ -970,7 +942,7 @@ void FGAIBallistic::handle_impact() { return; if (_ht_agl_ft <= 0) { - SG_LOG(SG_GENERAL, SG_DEBUG, "AIBallistic: terrain impact material" << _mat_name); + SG_LOG(SG_AI, SG_DEBUG, "AIBallistic: terrain impact material" << _mat_name); report_impact(_elevation_m); _impact_reported = true; @@ -983,7 +955,7 @@ void FGAIBallistic::handle_impact() { void FGAIBallistic::handle_expiry() { - //SG_LOG(SG_GENERAL, SG_DEBUG, "AIBallistic: handle_expiry " << pos.getElevationM()); + //SG_LOG(SG_AI, SG_DEBUG, "AIBallistic: handle_expiry " << pos.getElevationM()); report_impact(pos.getElevationM()); _expiry_reported = true; @@ -1024,7 +996,7 @@ void FGAIBallistic::report_impact(double elevation, const FGAIBase *object) else n->setStringValue("type", "terrain"); - SG_LOG(SG_GENERAL, SG_DEBUG, "AIBallistic: object impact " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIBallistic: object impact " << _name << " lon " <<_impact_lon << " lat " <<_impact_lat << " sec " << _life_timer); n->setDoubleValue("longitude-deg", _impact_lon);