X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2FAIGroundVehicle.cxx;h=b813b3c8211f3e3b2cf1d3f0f72366db4a70ec90;hb=afcdbd3158503773644aa07dd86cd92d67946bd4;hp=84e7bd1c909b38f710e4424222c557d3a429d885;hpb=f84d9d475752879b113e373d640f18ee6267c276;p=flightgear.git diff --git a/src/AIModel/AIGroundVehicle.cxx b/src/AIModel/AIGroundVehicle.cxx index 84e7bd1c9..b813b3c82 100644 --- a/src/AIModel/AIGroundVehicle.cxx +++ b/src/AIModel/AIGroundVehicle.cxx @@ -24,7 +24,7 @@ #include -#include
+#include #include #include @@ -84,65 +84,48 @@ void FGAIGroundVehicle::readFromScenario(SGPropertyNode* scFileNode) { void FGAIGroundVehicle::bind() { FGAIShip::bind(); - props->tie("controls/constants/elevation-coeff", + tie("controls/constants/elevation-coeff", SGRawValuePointer(&_elevation_coeff)); - props->tie("controls/constants/pitch-coeff", + tie("controls/constants/pitch-coeff", SGRawValuePointer(&_pitch_coeff)); - props->tie("position/ht-AGL-ft", + tie("position/ht-AGL-ft", SGRawValuePointer(&_ht_agl_ft)); - props->tie("hitch/rel-bearing-deg", + tie("hitch/rel-bearing-deg", SGRawValuePointer(&_relbrg)); - props->tie("hitch/tow-angle-deg", + tie("hitch/tow-angle-deg", SGRawValuePointer(&_tow_angle)); - props->tie("hitch/range-ft", + tie("hitch/range-ft", SGRawValuePointer(&_range_ft)); - props->tie("hitch/x-offset-ft", + tie("hitch/x-offset-ft", SGRawValuePointer(&_x_offset)); - props->tie("hitch/y-offset-ft", + tie("hitch/y-offset-ft", SGRawValuePointer(&_y_offset)); - props->tie("hitch/z-offset-ft", + tie("hitch/z-offset-ft", SGRawValuePointer(&_z_offset)); - props->tie("hitch/parent-x-offset-ft", + tie("hitch/parent-x-offset-ft", SGRawValuePointer(&_parent_x_offset)); - props->tie("hitch/parent-y-offset-ft", + tie("hitch/parent-y-offset-ft", SGRawValuePointer(&_parent_y_offset)); - props->tie("hitch/parent-z-offset-ft", + tie("hitch/parent-z-offset-ft", SGRawValuePointer(&_parent_z_offset)); - props->tie("controls/constants/tow-angle/gain", + tie("controls/constants/tow-angle/gain", SGRawValuePointer(&_tow_angle_gain)); - props->tie("controls/constants/tow-angle/limit-deg", + tie("controls/constants/tow-angle/limit-deg", SGRawValuePointer(&_tow_angle_limit)); - props->tie("controls/contact-x1-offset-ft", + tie("controls/contact-x1-offset-ft", SGRawValuePointer(&_contact_x1_offset)); - props->tie("controls/contact-x2-offset-ft", + tie("controls/contact-x2-offset-ft", SGRawValuePointer(&_contact_x2_offset)); } -void FGAIGroundVehicle::unbind() { - FGAIShip::unbind(); - - props->untie("controls/constants/elevation-coeff"); - props->untie("controls/constants/pitch-coeff"); - props->untie("position/ht-AGL-ft"); - props->untie("hitch/rel-bearing-deg"); - props->untie("hitch/tow-angle-deg"); - props->untie("hitch/range-ft"); - props->untie("hitch/x-offset-ft"); - props->untie("hitch/y-offset-ft"); - props->untie("hitch/z-offset-ft"); - props->untie("hitch/parent-x-offset-ft"); - props->untie("hitch/parent-y-offset-ft"); - props->untie("hitch/parent-y-offset-ft"); - props->untie("controls/constants/tow-angle/gain"); - props->untie("controls/constants/tow-angle/limit-deg"); - props->untie("controls/contact-x1-offset-ft"); - props->untie("controls/contact-x2-offset-ft"); -} - bool FGAIGroundVehicle::init(bool search_in_AI_path) { if (!FGAIShip::init(search_in_AI_path)) return false; + reinit(); + return true; +} +void FGAIGroundVehicle::reinit() { invisible = false; _limit = 200; no_roll = true; @@ -162,11 +145,11 @@ bool FGAIGroundVehicle::init(bool search_in_AI_path) { setParent(); } - return true; + FGAIShip::reinit(); } void FGAIGroundVehicle::update(double dt) { - // SG_LOG(SG_GENERAL, SG_ALERT, "updating GroundVehicle: " << _name ); + // SG_LOG(SG_AI, SG_ALERT, "updating GroundVehicle: " << _name ); FGAIShip::update(dt); RunGroundVehicle(dt); @@ -254,13 +237,13 @@ bool FGAIGroundVehicle::getPitch() { //double max_alt = 10000; if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodFront, 3000), - elev_front, &_material, 0)){ + elev_front, NULL, 0)){ front_elev_m = elev_front + _z_offset_m; } else return false; if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodRear, 3000), - elev_rear, &_material, 0)){ + elev_rear, NULL, 0)){ rear_elev_m = elev_rear; } else return false; @@ -386,11 +369,11 @@ void FGAIGroundVehicle::AdvanceFP(){ string parent_next_name =_selected_ac->getStringValue("waypoint/name-next"); while(fp->getNextWaypoint() != 0 && fp->getNextWaypoint()->getName() != "END" && count < 5){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name <<" advancing waypoint to: " << parent_next_name); if (fp->getNextWaypoint()->getName() == parent_next_name){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " not setting waypoint already at: " << fp->getNextWaypoint()->getName()); return; } @@ -401,7 +384,7 @@ void FGAIGroundVehicle::AdvanceFP(){ next = fp->getNextWaypoint(); if (fp->getNextWaypoint()->getName() == parent_next_name){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " waypoint set to: " << fp->getNextWaypoint()->getName()); return; } @@ -412,12 +395,12 @@ void FGAIGroundVehicle::AdvanceFP(){ while(fp->getPreviousWaypoint() != 0 && fp->getPreviousWaypoint()->getName() != "END" && count > -10){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " retreating waypoint to: " << parent_next_name << " at: " << fp->getNextWaypoint()->getName()); if (fp->getNextWaypoint()->getName() == parent_next_name){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " not setting waypoint already at:" << fp->getNextWaypoint()->getName() ); return; } @@ -428,7 +411,7 @@ void FGAIGroundVehicle::AdvanceFP(){ next = fp->getNextWaypoint(); if (fp->getNextWaypoint()->getName() == parent_next_name){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " waypoint set to: " << fp->getNextWaypoint()->getName()); return; } @@ -500,7 +483,7 @@ void FGAIGroundVehicle::RunGroundVehicle(double dt){ //bool parent_restart = _selected_ac->getBoolValue("controls/restart"); if (parent_next_name == "END" && fp->getNextWaypoint()->getName() != "END" ){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " setting END: getting new waypoints "); AdvanceFP(); setWPNames(); @@ -508,13 +491,13 @@ void FGAIGroundVehicle::RunGroundVehicle(double dt){ if(_restart) _missed_count = 200; /*} else if (parent_next_name == "WAIT" && fp->getNextWaypoint()->name != "WAIT" ){*/ } else if (parent_waiting && !_waiting){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " setting WAIT/WAITUNTIL: getting new waypoints "); AdvanceFP(); setWPNames(); _waiting = true; } else if (parent_next_name != "WAIT" && fp->getNextWaypoint()->getName() == "WAIT"){ - SG_LOG(SG_GENERAL, SG_DEBUG, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_DEBUG, "AIGroundVeh1cle: " << _name << " wait done: getting new waypoints "); _waiting = false; _wait_count = 0; @@ -533,7 +516,7 @@ void FGAIGroundVehicle::RunGroundVehicle(double dt){ setWPNames(); } else if (_range_ft > (_x_offset +_parent_x_offset)* 4 ){ - SG_LOG(SG_GENERAL, SG_ALERT, "AIGroundVeh1cle: " << _name + SG_LOG(SG_AI, SG_ALERT, "AIGroundVeh1cle: " << _name << " rescue: reforming train " << _range_ft );