]> git.mxchange.org Git - flightgear.git/commitdiff
Various floating point / initial value bug fixes from Christian Mayer.
authorcurt <curt>
Thu, 11 Oct 2001 22:07:45 +0000 (22:07 +0000)
committercurt <curt>
Thu, 11 Oct 2001 22:07:45 +0000 (22:07 +0000)
src/Cockpit/radiostack.cxx
src/Main/main.cxx
src/Main/viewer.cxx
src/Navaids/ils.hxx
src/Navaids/nav.hxx
src/Scenery/hitlist.cxx

index 81f4e372504b7ad748ec4df553ac741078610f9f..cf6d798af181f9d65f6bacd625bab2ef943cc529 100644 (file)
@@ -83,13 +83,19 @@ FGRadioStack::FGRadioStack() :
     lat_node(fgGetNode("/position/latitude-deg", true)),
     alt_node(fgGetNode("/position/altitude-ft", true)),
     need_update(true),
+    nav1_freq(0.0),
+    nav1_alt_freq(0.0),
     nav1_radial(0.0),
+    nav2_freq(0.0),
+    nav2_alt_freq(0.0),
     nav2_radial(0.0),
     dme_freq(0.0),
     dme_dist(0.0),
     dme_prev_dist(0.0),
     dme_spd(0.0),
-    dme_ete(0.0)
+    dme_ete(0.0),
+    adf_freq(0.0),
+    adf_alt_freq(0.0)
 {
     SGPath path( globals->get_fg_root() );
     SGPath term = path;
index e1c20d71625bcf986848582a589aa2c9d7a38685..892aeb4d03f9ba2158c26332ca0e8efcbbc357f4 100644 (file)
 // Should already be inlcluded by gl.h if needed by your platform so
 // we shouldn't include this here.
 // #include <GL/glext.h>
-PFNGLPOINTPARAMETERFEXTPROC glPointParameterfEXT = 0;
-PFNGLPOINTPARAMETERFVEXTPROC glPointParameterfvEXT = 0;
+// PFNGLPOINTPARAMETERFEXTPROC glPointParameterfEXT = 0;
+// PFNGLPOINTPARAMETERFVEXTPROC glPointParameterfvEXT = 0;
 float default_attenuation[3] = {1.0, 0.0, 0.0};
 //Required for using GL_extensions
 void fgLoadDCS (void);
@@ -1866,16 +1866,24 @@ int mainLoop( int argc, char **argv ) {
 
 // Main entry point; catch any exceptions that have made it this far.
 int main ( int argc, char **argv ) {
-                               // FIXME: add other, more specific
-                               // exceptions.
-  try {
-    mainLoop(argc, argv);
-  } catch (sg_throwable &t) {
-    SG_LOG(SG_GENERAL, SG_ALERT,
-          "Fatal error: " << t.getFormattedMessage()
-          << "\n (received from " << t.getOrigin() << ')');
-    exit(1);
-  }
+
+#ifdef _MSC_VER
+    // Christian, we should document what this does
+    _control87( _EM_INEXACT, _MCW_EM );
+#endif
+
+    // FIXME: add other, more specific
+    // exceptions.
+    try {
+        mainLoop(argc, argv);
+    } catch (sg_throwable &t) {
+        SG_LOG(SG_GENERAL, SG_ALERT,
+               "Fatal error: " << t.getFormattedMessage()
+               << "\n (received from " << t.getOrigin() << ')');
+        exit(1);
+    }
+
+    return 0;
 }
 
 
@@ -1966,7 +1974,7 @@ void fgLoadDCS(void) {
                                                SG_LOG( SG_TERRAIN, SG_ALERT, "Cannot open file: " << modelpath.str() );
                                        } else {
                                                while ( ! in1.eof() ) {
-                                                       in1 >> skipws;
+                                                        in1 >> ::skipws;
                                                        if ( in1.get( c ) && c == '#' ) { 
                                                                in1 >> skipeol;
                                                        } else { 
index 8c75ed84851e445a50fc80d8c7067c5bf608566a..b723733ffd771c25d8ab8ae2b3c52a426a694cc3 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/constants.h>
 
 #include "viewer.hxx"
 
@@ -40,6 +41,10 @@ FGViewer::FGViewer( void ):
     goal_view_offset(0.0)
 {
     sgSetVec3( pilot_offset, 0.0, 0.0, 0.0 );
+    sgdZeroVec3(geod_view_pos);
+    sgdZeroVec3(abs_view_pos);
+    sea_level_radius = SG_EQUATORIAL_RADIUS_M; 
+    //a reasonable guess for init, so that the math doesn't blow up
 }
 
 
index d9d4c3ae1bdf7b6d516b0e22e05ff239ca14ca32..b97b2882e9a560199274c23b017b18909efc0d75 100644 (file)
@@ -128,7 +128,12 @@ inline istream&
 operator >> ( istream& in, FGILS& i )
 {
     double f;
-    in >> i.ilstype >> i.ilstypename >> i.aptcode >> i.rwyno 
+    in >> i.ilstype;
+    
+    if ( i.ilstype == '[' )
+          return in;
+
+    in >> i.ilstypename >> i.aptcode >> i.rwyno 
        >> f >> i.locident >> i.locheading >> i.loclat >> i.loclon
        >> i.gselev >> i.gsangle >> i.gslat >> i.gslon
        >> i.dmelat >> i.dmelon
index b5563ee4516a6c87ead269032d9ef6c800476180..5a521130472641e933b7536ee05bf0c051612625 100644 (file)
@@ -111,7 +111,12 @@ operator >> ( istream& in, FGNav& n )
        first_time = false;
     }
 
-    in >> n.type >> n.lat >> n.lon >> n.elev >> f >> n.range 
+    in >> n.type;
+    
+    if ( n.type == '[' )
+      return in >> skipeol;
+
+    in >> n.lat >> n.lon >> n.elev >> f >> n.range 
        >> c >> n.ident >> magvar_s;
 
     n.freq = (int)(f*100.0 + 0.5);
index e4a1e06f77b5569427c29d1d38b0609a0e307056..ca14e1965399d9e10678a651e952f71825d92f4f 100644 (file)
@@ -199,6 +199,13 @@ int FGHitList::IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
        sgdXformPnt3( tri[1], leaf->getVertex( i2 ), m );
        sgdXformPnt3( tri[2], leaf->getVertex( i3 ), m );
 
+        //avoid division by zero when two points are the same
+        if ( sgdEqualVec3(tri[0], tri[1]) ||
+             sgdEqualVec3(tri[1], tri[2]) ||
+             sgdEqualVec3(tri[2], tri[0]) ) {
+            continue;
+        }
+
        sgdVec4 plane;
        sgdMakePlane( plane, tri[0], tri[1], tri[2] );