]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIWingman.cxx
NavDisplay: fix update lag when switching range or centre.
[flightgear.git] / src / AIModel / AIWingman.cxx
index 59617b097460dd66a81afc7308eeca1f93004cf3..9ba01042a413a8ed6ca7615ef32587b3598399a0 100644 (file)
@@ -29,9 +29,9 @@
 
 FGAIWingman::FGAIWingman() : FGAIBallistic(otWingman),
 _formate_to_ac(true),
-_break_angle(-90),
 _break(false),
 _join(false),
+_break_angle(-90),
 _coeff_hdg(5.0),
 _coeff_pch(5.0),
 _coeff_bnk(5.0),
@@ -203,7 +203,11 @@ void FGAIWingman::unbind() {
 bool FGAIWingman::init(bool search_in_AI_path) {
     if (!FGAIBallistic::init(search_in_AI_path))
         return false;
+    reinit();
+    return true;
+}
 
+void FGAIWingman::reinit() {
     invisible = false;
 
     _tgt_x_offset = _x_offset;
@@ -223,7 +227,8 @@ bool FGAIWingman::init(bool search_in_AI_path) {
 
     props->setStringValue("submodels/path", _path.c_str());
     user_WoW_node      = fgGetNode("gear/gear[1]/wow", true);
-    return true;
+
+    FGAIBallistic::reinit();
 }
 
 void FGAIWingman::update(double dt) {
@@ -375,7 +380,7 @@ void FGAIWingman::Break(double dt) {
 void FGAIWingman::Join(double dt) {
 
     double range, bearing, az2;
-    double parent_hdg, parent_spd, parent_ht= 0;
+    double parent_hdg, parent_spd = 0;
     double p_hdg, p_pch, p_rll = 0;
 
     setTgtOffsets(dt, 25);
@@ -414,7 +419,7 @@ void FGAIWingman::Join(double dt) {
             _formate_to_ac = true;
             _join = false;
 
-            SG_LOG(SG_GENERAL, SG_ALERT, _name << " joined " << " RANGE " << distance
+            SG_LOG(SG_AI, SG_ALERT, _name << " joined " << " RANGE " << distance
             << " SPEED " << speed );
 
             return;
@@ -425,10 +430,10 @@ void FGAIWingman::Join(double dt) {
     double rel_brg   = calcRelBearingDeg(bearing, hdg);
     double recip_brg = calcRecipBearingDeg(bearing);
     double angle = calcAngle(distance,_offsetpos, pos);
-    double approx_angle = atan2(daltM, range);
+    //double approx_angle = atan2(daltM, range);
     double frm_spd = 50; // formation speed
     double join_rnge = 1000.0;
-    double recip_parent_hdg = calcRecipBearingDeg(parent_hdg);
+//    double recip_parent_hdg = calcRecipBearingDeg(parent_hdg);
     int turn = SGMiscd::sign(rel_brg);// turn direction: 1 = right, -1 = left
 
     if (range <= join_rnge && (hdg >= hdg_l_lim || hdg <= hdg_r_lim)){