]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/HUD/HUD_ladder.cxx
Merge branch 'next' of D:\Git_New\flightgear into next
[flightgear.git] / src / Instrumentation / HUD / HUD_ladder.cxx
index 4d0b6a3690b56971c6bec51ce073a5aa195e9c9b..478ffa1b1ae50c51ea3c042c5b6b7e56c5a50e2b 100644 (file)
 #endif
 
 #include <sstream>
-#include <simgear/math/vector.hxx>
+#include <simgear/math/SGGeometry.hxx>
 #include <Main/viewer.hxx>
 #include "HUD.hxx"
 
-
 // FIXME
-float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
-float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
-float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
-float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
-float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
-float get__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
-float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
-float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
-float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
-float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
+static float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
+static float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
+static float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
+static float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
+static float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
+static float get__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
+static float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
+static float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
+static float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
+static float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
 #undef ENABLE_SP_FDM
 
 
@@ -70,7 +69,7 @@ HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
     _zenith(n->getBoolValue("enable-zenith")),
     _nadir(n->getBoolValue("enable-nadir")),
     _hat(n->getBoolValue("enable-hat")),
-    _clip_box(new ClipBox(n->getNode("clip")))
+    _clip_box(new ClipBox(n->getNode("clipping")))
 {
     const char *t = n->getStringValue("type");
     _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
@@ -424,12 +423,11 @@ void HUD::Ladder::draw(void)
             // however the horizon line should always stay on the horizon.  We
             // project the alpha/beta offset onto the horizon line to get the
             // result we want.
-            sgdVec3 p1; // result
-            sgdVec3 p; sgdSetVec3(p, vel_x, vel_y, 0.0);
-            sgdVec3 p0; sgdSetVec3(p0, 0.0, 0.0, 0.0);
-            sgdVec3 d; sgdSetVec3(d, cos(roll_value), sin(roll_value), 0.0);
-            sgdClosestPointToLine(p1, p, p0, d);
-            glTranslatef(p1[0], p1[1], 0);
+            
+            SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
+            SGRayd r(SGVec3d::zeros(), d);
+            SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
+            glTranslatef(p[0], p[1], 0);
         }
     } else {
         // ladder position is fixed relative to the center of the screen.
@@ -478,9 +476,9 @@ void HUD::Ladder::draw(void)
             else if (i == -90 && _nadir)
                 draw_nadir(0.0, y);
 
-            if (_zenith && i > 85 || i > 90)
+            if ((_zenith && i > 85) || i > 90)
                 continue;
-            if (_nadir && i < -85 || i < -90)
+            if ((_nadir && i < -85) || i < -90)
                 continue;
 
             lo.x = -half_span;
@@ -540,7 +538,9 @@ void HUD::Ladder::draw(void)
             // draw numbers
             std::ostringstream str;
             str << i;
-            const char *num = str.str().c_str();
+            // must keep this string, otherwise it will free the c_str!
+            string num_str = str.str();
+            const char *num = num_str.c_str();
             int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER;
             draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num,
                     valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));
@@ -559,9 +559,7 @@ void HUD::Ladder::draw(void)
         _locStippleLineList.draw();
         glDisable(GL_LINE_STIPPLE);
     }
-    glDisable(GL_CLIP_PLANE0);
-    glDisable(GL_CLIP_PLANE1);
-    glDisable(GL_CLIP_PLANE2);
+    _clip_box->unset();
     glPopMatrix();
     //*************************************************************