]> git.mxchange.org Git - flightgear.git/commitdiff
Continuing work on cleanups.
authorcurt <curt>
Wed, 25 Oct 2000 19:27:13 +0000 (19:27 +0000)
committercurt <curt>
Wed, 25 Oct 2000 19:27:13 +0000 (19:27 +0000)
Removed some commented out chunks of code that no longer make sense to keep
around.
Working on replacing instances of Point3D with sg{d,}Vec3.

src/GUI/gui.cxx
src/Main/fg_init.cxx
src/Main/keyboard.cxx
src/Main/main.cxx
src/Main/viewer.cxx
src/Main/viewer.hxx
src/Scenery/tilecache.cxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx
src/Time/moonpos.cxx
src/Time/sunpos.cxx

index d0380b096d12e87fbf5865c401d6623c374fd763..b9542d88778e7f01f631e9a779f1058ee1e05c87 100644 (file)
@@ -887,8 +887,8 @@ GLubyte *hiResScreenCapture( int multiplier )
     FGViewer *v = globals->get_current_view();
     globals->get_options()->set_fov(fov);
     fgInitVisuals();
-    int cur_width = globals->get_current_view()->get_winWidth( );
-    int cur_height = globals->get_current_view()->get_winHeight( );
+    int cur_width = globals->get_options()->get_xsize( );
+    int cur_height = globals->get_options()->get_ysize( );
     if (b1) delete( b1 );
     // New empty (mostly) bitmap
     b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
@@ -924,8 +924,8 @@ void printScreen ( puObject *obj ) {
     mainMenuBar->hide();
 
     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
-    int cur_width = globals->get_current_view()->get_winWidth( );
-    int cur_height = globals->get_current_view()->get_winHeight( );
+    int cur_width = globals->get_options()->get_xsize( );
+    int cur_height = globals->get_options()->get_ysize( );
     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
        p.End( hiResScreenCapture(3) );
 
index ace7460ece88cbc5e5b63c72185f55566ec36fc3..b6fa5ec5af0e6ac810682eccba63fd12dedeb1c1 100644 (file)
@@ -543,53 +543,27 @@ bool fgInitSubsystems( void ) {
            << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
            << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
 
-    // We need to calculate a few more values here that would normally
-    // be calculated by the FDM so that the current_view.UpdateViewMath()
-    // routine doesn't get hosed.
-
+    // We need to calculate a few sea_level_radius here so we can pass
+    // the correct value to the view class
     double sea_level_radius_meters;
     double lat_geoc;
-    // Set the FG variables first
-    sgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(),
+    sgGeodToGeoc( cur_fdm_state->get_Latitude(),
+                 cur_fdm_state->get_Altitude(),
                  &sea_level_radius_meters, &lat_geoc);
-    /* cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(),
-                               cur_fdm_state->get_Altitude() +
-                               (sea_level_radius_meters * METER_TO_FEET) );
-     */
-    cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
-
-    /* cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
-    cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
-       
-    cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
-    cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc)); */
-
+    cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters *
+                                        METER_TO_FEET );
 
     // The following section sets up the flight model EOM parameters
     // and should really be read in from one or more files.
 
     // Initial Velocity
-    //cur_fdm_state->set_Velocities_Local( globals->get_options()->get_uBody(),
-    //                         globals->get_options()->get_vBody(),
-    //                         globals->get_options()->get_wBody());
     fgVelocityInit();
 
     // Initial Orientation
-    cur_fdm_state->set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
-                        globals->get_options()->get_pitch() * DEG_TO_RAD,
-                        globals->get_options()->get_heading() * DEG_TO_RAD );
-
-    // Initial Angular Body rates
-    //cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
-
-    //cur_fdm_state->set_Earth_position_angle( 0.0 );
-
-    // Mass properties and geometry values
-    //cur_fdm_state->set_Inertias( 8.547270E+01,
-         //    1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
-
-    // CG position w.r.t. ref. point
-    //cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
+    cur_fdm_state->
+       set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
+                         globals->get_options()->get_pitch() * DEG_TO_RAD,
+                         globals->get_options()->get_heading() * DEG_TO_RAD );
 
     // Initialize the event manager
     global_events.Init();
@@ -615,27 +589,12 @@ bool fgInitSubsystems( void ) {
        set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
                              FEET_TO_METER ); 
     globals->get_current_view()->
-       set_hpr( cur_fdm_state->get_Psi(),
+       set_rph( cur_fdm_state->get_Phi(),
                 cur_fdm_state->get_Theta(),
-                cur_fdm_state->get_Phi() );
+                cur_fdm_state->get_Psi() );
 
-    // globals->get_current_view()->UpdateViewMath();
-    // globals->get_pilot_view()->UpdateViewMath();
     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = "
            << globals->get_current_view()->get_abs_view_pos());
-    // current_view.UpdateWorldToEye(f);
-
-    // Initialize the planetary subsystem
-    // global_events.Register( "fgPlanetsInit()", fgPlanetsInit,
-    //                     fgEVENT::FG_EVENT_READY, 600000);
-
-    // Initialize the sun's position
-    // global_events.Register( "fgSunInit()", fgSunInit,
-    //                     fgEVENT::FG_EVENT_READY, 30000 );
-
-    // Intialize the moon's position
-    // global_events.Register( "fgMoonInit()", fgMoonInit,
-    //                     fgEVENT::FG_EVENT_READY, 600000 );
 
     // fgUpdateSunPos() needs a few position and view parameters set
     // so it can calculate local relative sun angle and a few other
@@ -706,28 +665,6 @@ bool fgInitSubsystems( void ) {
     // Initialize the underlying radio stack model
     current_radiostack = new FGRadioStack;
 
-//     current_radiostack->set_nav1_freq( 117.30 );
-//     current_radiostack->set_nav1_alt_freq( 110.30 );
-//     current_radiostack->set_nav1_sel_radial( 119.0 );
-
-//     current_radiostack->set_nav2_freq( 111.80 );
-//     current_radiostack->set_nav2_alt_freq( 115.70 );
-//     current_radiostack->set_nav2_sel_radial( 029.0 );
-
-//     current_radiostack->set_adf_freq( 266.0 );
-
-#if 0
-    // This block of settings are Alex's defaults for San Diego
-    current_radiostack->set_nav1_freq( 111.70 );
-    current_radiostack->set_nav1_alt_freq( 115.30 );
-    current_radiostack->set_nav1_sel_radial( 280.0 );
-    current_radiostack->set_nav2_freq( 117.80 );
-    current_radiostack->set_nav2_alt_freq( 114.00 );
-    current_radiostack->set_nav2_sel_radial( 68.0 );
-    current_radiostack->set_adf_freq( 210.0 );
-    // End of Alex's custom settings
-#endif
-
     current_radiostack->search( cur_fdm_state->get_Longitude(),
                                cur_fdm_state->get_Latitude(),
                                cur_fdm_state->get_Altitude() * FEET_TO_METER );
@@ -752,8 +689,6 @@ bool fgInitSubsystems( void ) {
     // Initialize the flight model subsystem data structures base on
     // above values
 
-    // fgFDMInit( globals->get_options()->get_flight_model(), cur_fdm_state,
-    //            1.0 / globals->get_options()->get_model_hz() );
     if ( cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() ) ) {
        // fdm init successful
     } else {
@@ -761,12 +696,15 @@ bool fgInitSubsystems( void ) {
        exit(-1);
     }
 
-    // I'm just sticking this here for now, it should probably move
-    // eventually
+    // *ABCD* I'm just sticking this here for now, it should probably
+    // move eventually
     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
 
-    if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
-       cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
+    if ( cur_fdm_state->get_Altitude() <
+        cur_fdm_state->get_Runway_altitude() + 3.758099)
+    {
+       cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() +
+                                    3.758099 );
     }
 
     FG_LOG( FG_GENERAL, FG_INFO,
@@ -774,12 +712,11 @@ bool fgInitSubsystems( void ) {
            << (cur_fdm_state->get_Latitude() * RAD_TO_DEG) << ", "
            << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
            << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
-    // end of thing that I just stuck in that I should probably move
+    // *ABCD* end of thing that I just stuck in that I should probably
+    // move
 
     // Joystick support
-    if ( fgJoystickInit() ) {
-       // Joystick initialized ok.
-    } else {
+    if ( ! fgJoystickInit() ) {
        FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
     }
 
@@ -804,10 +741,11 @@ bool fgInitSubsystems( void ) {
                                          "Panels/Default/default.xml");
     current_panel = fgReadPanel(panel_path);
     if (current_panel == 0) {
-       FG_LOG(FG_INPUT, FG_ALERT,
-              "Error reading new panel from " << panel_path);
+       FG_LOG( FG_INPUT, FG_ALERT, 
+               "Error reading new panel from " << panel_path );
+    } else {
+       FG_LOG( FG_INPUT, FG_INFO, "Loaded new panel from " << panel_path );
     }
-    FG_LOG(FG_INPUT, FG_INFO, "Loaded new panel from " << panel_path);
 
     // Initialize the BFI
     FGBFI::init();
@@ -840,61 +778,39 @@ void fgReInitSubsystems( void )
                             scenery.cur_elev );
 
     // Reset our altitude if we are below ground
-    FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
-    FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " << 
-           cur_fdm_state->get_Runway_altitude() );
+    FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = "
+           << cur_fdm_state->get_Altitude() );
+    FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = "
+           << cur_fdm_state->get_Runway_altitude() );
 
-    if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
-       cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
+    if ( cur_fdm_state->get_Altitude() <
+        cur_fdm_state->get_Runway_altitude() + 3.758099)
+    {
+       cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() +
+                                    3.758099 );
     }
     double sea_level_radius_meters;
     double lat_geoc;
-    // Set the FG variables first
     sgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(), 
                  &sea_level_radius_meters, &lat_geoc);
-   /*  cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(), 
-                               cur_fdm_state->get_Altitude() + 
-                               (sea_level_radius_meters * METER_TO_FEET) );
-     */
-    cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
-       
-    //cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
-    //cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
+    cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters *
+                                        METER_TO_FEET );
        
-    //cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
-    //cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc));
-
     // The following section sets up the flight model EOM parameters
     // and should really be read in from one or more files.
 
     // Initial Velocity
-    //cur_fdm_state->set_Velocities_Local( globals->get_options()->get_uBody(),
-    //                         globals->get_options()->get_vBody(),
-    //                         globals->get_options()->get_wBody());
     fgVelocityInit();
 
     // Initial Orientation
-    cur_fdm_state->set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
-                        globals->get_options()->get_pitch() * DEG_TO_RAD,
-                        globals->get_options()->get_heading() * DEG_TO_RAD );
-
-    // Initial Angular Body rates
-    //cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
-
-    //cur_fdm_state->set_Earth_position_angle( 0.0 );
-
-    // Mass properties and geometry values
-    //cur_fdm_state->set_Inertias( 8.547270E+01, 
-               //    1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
-
-    // CG position w.r.t. ref. point
-    //cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
+    cur_fdm_state->
+       set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
+                         globals->get_options()->get_pitch() * DEG_TO_RAD,
+                         globals->get_options()->get_heading() * DEG_TO_RAD );
 
     // Initialize view parameters
     globals->get_current_view()->set_view_offset( 0.0 );
     globals->get_current_view()->set_goal_view_offset( 0.0 );
-    // globals->get_pilot_view()->set_view_offset( 0.0 );
-    // globals->get_pilot_view()->set_goal_view_offset( 0.0 );
 
     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
 
@@ -907,23 +823,22 @@ void fgReInitSubsystems( void )
        set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
                              FEET_TO_METER ); 
     globals->get_current_view()->
-       set_hpr( cur_fdm_state->get_Psi(),
+       set_rph( cur_fdm_state->get_Phi(),
                 cur_fdm_state->get_Theta(),
-                cur_fdm_state->get_Phi() );
+                cur_fdm_state->get_Psi() );
 
-    // globals->get_current_view()->UpdateViewMath();
-    // globals->get_pilot_view()->UpdateViewMath();
     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = "
            << globals->get_current_view()->get_abs_view_pos());
 
-    // fgFDMInit( globals->get_options()->get_flight_model(), cur_fdm_state, 
-    //            1.0 / globals->get_options()->get_model_hz() );
     cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() );
 
     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
 
-    if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
-       cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
+    if ( cur_fdm_state->get_Altitude() <
+        cur_fdm_state->get_Runway_altitude() + 3.758099)
+    {
+       cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() +
+                                    3.758099 );
     }
 
     controls.reset_all();
index 89073f386830a27e7431c8e4a1261405a9045b90..39219ea1cc51e29d1048fbbf048c724c5fee864c 100644 (file)
@@ -79,7 +79,6 @@ extern void fgReshape( int width, int height );
 // Handle keyboard events
 void GLUTkey(unsigned char k, int x, int y) {
     FGInterface *f;
-    SGTime *t;
     FGViewer *v;
     float fov, tmp;
     static bool winding_ccw = true;
index 24b36d4c0ef956f3c117b82baa92e0dadea9e114..7c7b798be2bb2d1b58fd9c595fd55c49e60fa857 100644 (file)
@@ -331,9 +331,9 @@ void fgRenderFrame( void ) {
            set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
                                  FEET_TO_METER ); 
        globals->get_current_view()->
-           set_hpr( cur_fdm_state->get_Psi(),
+           set_rph( cur_fdm_state->get_Phi(),
                     cur_fdm_state->get_Theta(),
-                    cur_fdm_state->get_Phi() );
+                    cur_fdm_state->get_Psi() );
 
        // update view volume parameters
        // cout << "before pilot_view update" << endl;
@@ -442,12 +442,6 @@ void fgRenderFrame( void ) {
  
        // update the sky dome
        if ( globals->get_options()->get_skyblend() ) {
-           sgVec3 view_pos;
-           sgSetVec3( view_pos,
-                      globals->get_current_view()->get_view_pos().x(),
-                      globals->get_current_view()->get_view_pos().y(),
-                      globals->get_current_view()->get_view_pos().z() );
-
            sgVec3 zero_elev;
            sgSetVec3( zero_elev,
                       globals->get_current_view()->get_cur_zero_elev().x(),
@@ -489,7 +483,8 @@ void fgRenderFrame( void ) {
                 << " moon ra = " << globals->get_ephem()->getMoonRightAscension()
                 << " moon dec = " << globals->get_ephem()->getMoonDeclination() << endl; */
 
-           thesky->reposition( view_pos, zero_elev,
+           thesky->reposition( globals->get_current_view()->get_view_pos(),
+                               zero_elev,
                                globals->get_current_view()->get_local_up(),
                                cur_fdm_state->get_Longitude(),
                                cur_fdm_state->get_Latitude(),
@@ -566,9 +561,7 @@ void fgRenderFrame( void ) {
 
            sgMat4 sgTRANS;
            sgMakeTransMat4( sgTRANS, 
-                            globals->get_current_view()->get_view_pos().x(),
-                            globals->get_current_view()->get_view_pos().y(),
-                            globals->get_current_view()->get_view_pos().z() );
+                            globals->get_current_view()->get_view_pos() );
 
            sgVec3 ownship_up;
            sgSetVec3( ownship_up, 0.0, 0.0, 1.0);
index 7e5c20ed466afd13ee1eaa2079cd366cbd9036c5..85401aa2985e4542d1e4b5a6116ef177866beaff 100644 (file)
@@ -171,12 +171,12 @@ static void print_sgMat4( sgMat4 &in) {
 // Update the view parameters
 void FGViewer::update() {
 
-    sgVec3 v0, minus_z, forward;
+    sgVec3 minus_z, forward;
     sgMat4 VIEWo;
 
     // calculate the cartesion coords of the current lat/lon/0 elev
-    Point3D p = Point3D( geod_view_pos.lon()
-                        geod_view_pos.lat()
+    Point3D p = Point3D( geod_view_pos[0]
+                        geod_view_pos[1]
                         sea_level_radius );
 
     cur_zero_elev = sgPolarToCart3d(p) - scenery.center;
@@ -184,20 +184,30 @@ void FGViewer::update() {
     // calculate view position in current FG view coordinate system
     // p.lon & p.lat are already defined earlier, p.radius was set to
     // the sea level radius, so now we add in our altitude.
-    if ( geod_view_pos.elev() > (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
-       p.setz( p.radius() + geod_view_pos.elev() );
+    if ( geod_view_pos[2] > (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
+       p.setz( p.radius() + geod_view_pos[2] );
     } else {
        p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
     }
 
-    abs_view_pos = sgPolarToCart3d(p);
-       
-    view_pos = abs_view_pos - scenery.center;
+    Point3D tmp = sgPolarToCart3d(p);
+    sgdSetVec3( abs_view_pos, tmp[0], tmp[1], tmp[2] );
+
+    sgdVec3 sc;
+    sgdSetVec3( sc, scenery.center.x(), scenery.center.y(), scenery.center.z());
+    sgdVec3 vp;
+    sgdSubVec3( vp, abs_view_pos, sc );
+    sgSetVec3( view_pos, vp );
+    // view_pos = abs_view_pos - scenery.center;
 
     FG_LOG( FG_VIEW, FG_DEBUG, "sea level radius = " << sea_level_radius );
     FG_LOG( FG_VIEW, FG_DEBUG, "Polar view pos = " << p );
-    FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = " << abs_view_pos );
-    FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = " << view_pos );
+    FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = "
+           << abs_view_pos[0] << ","
+           << abs_view_pos[1] << ","
+           << abs_view_pos[2] );
+    FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = "
+           << view_pos[0] << "," << view_pos[1] << "," << view_pos[2] );
 
     // code to calculate LOCAL matrix calculated from Phi, Theta, and
     // Psi (roll, pitch, yaw) in case we aren't running LaRCsim as our
@@ -205,19 +215,19 @@ void FGViewer::update() {
        
 #ifdef USE_FAST_LOCAL
        
-    fgMakeLOCAL( LOCAL, hpr[1], hpr[2], -hpr[0] );
+    fgMakeLOCAL( LOCAL, rph[1], rph[0], -rph[2] );
        
 #else // USE_TEXT_BOOK_METHOD
        
     sgVec3 rollvec;
     sgSetVec3( rollvec, 0.0, 0.0, 1.0 );
     sgMat4 PHI;                // roll
-    sgMakeRotMat4( PHI, hpr[2] * RAD_TO_DEG, rollvec );
+    sgMakeRotMat4( PHI, rph[0] * RAD_TO_DEG, rollvec );
 
     sgVec3 pitchvec;
     sgSetVec3( pitchvec, 0.0, 1.0, 0.0 );
     sgMat4 THETA;              // pitch
-    sgMakeRotMat4( THETA, hpr[1] * RAD_TO_DEG, pitchvec );
+    sgMakeRotMat4( THETA, rph[1] * RAD_TO_DEG, pitchvec );
 
     // ROT = PHI * THETA
     sgMat4 ROT;
@@ -228,7 +238,7 @@ void FGViewer::update() {
     sgVec3 yawvec;
     sgSetVec3( yawvec, 1.0, 0.0, 0.0 );
     sgMat4 PSI;                // heading
-    sgMakeRotMat4( PSI, -hpr[0] * RAD_TO_DEG, yawvec );
+    sgMakeRotMat4( PSI, -rph[2] * RAD_TO_DEG, yawvec );
 
     // LOCAL = ROT * PSI
     // sgMultMat4( LOCAL, ROT, PSI );
@@ -241,9 +251,9 @@ void FGViewer::update() {
     // print_sgMat4( LOCAL );
        
     sgMakeRotMat4( UP, 
-                  geod_view_pos.lon() * RAD_TO_DEG,
+                  geod_view_pos[0] * RAD_TO_DEG,
                   0.0,
-                  -geod_view_pos.lat() * RAD_TO_DEG );
+                  -geod_view_pos[1] * RAD_TO_DEG );
 
     sgSetVec3( local_up, UP[0][0], UP[0][1], UP[0][2] );
     // sgXformVec3( local_up, UP );
@@ -299,10 +309,7 @@ void FGViewer::update() {
     // print_sgMat4( VIEW_ROT );
 
     sgVec3 trans_vec;
-    sgSetVec3( trans_vec, 
-              view_pos.x() + pilot_offset_world[0],
-              view_pos.y() + pilot_offset_world[1],
-              view_pos.z() + pilot_offset_world[2] );
+    sgAddVec3( trans_vec, view_pos, pilot_offset_world );
 
     // VIEW = VIEW_ROT * TRANS
     sgCopyMat4( VIEW, VIEW_ROT );
@@ -316,15 +323,13 @@ void FGViewer::update() {
     sgPreMultMat4( VIEW, quat_mat);
     // !!!!!!!!!! testing      
 
-    // make a vector to the current view position
-    sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
-
     // Given a vector pointing straight down (-Z), map into onto the
     // local plane representing "horizontal".  This should give us the
     // local direction for moving "south".
     sgSetVec3( minus_z, 0.0, 0.0, -1.0 );
 
-    sgmap_vec_onto_cur_surface_plane(local_up, v0, minus_z, surface_south);
+    sgmap_vec_onto_cur_surface_plane(local_up, view_pos, minus_z,
+                                    surface_south);
     sgNormalizeVec3(surface_south);
     // cout << "Surface direction directly south " << surface_south[0] << ","
     //      << surface_south[1] << "," << surface_south[2] << endl;
index d0fc616cd0393b7bdbfb727d0e2709a539078967..7bfeb3b6b06b339e2a16dcc54db8ed88bb4c439f 100644 (file)
@@ -65,25 +65,25 @@ private:
     double goal_view_offset;
 
     // geodetic view position
-    Point3D geod_view_pos;
+    sgdVec3 geod_view_pos;
 
     // radius to sea level from center of the earth (m)
     double sea_level_radius;
 
     // absolute view position in earth coordinates
-    Point3D abs_view_pos;
+    sgdVec3 abs_view_pos;
 
     // view position in opengl world coordinates (this is the
     // abs_view_pos translated to scenery.center)
-    Point3D view_pos;
+    sgVec3 view_pos;
 
     // pilot offset from center of gravity.  The X axis is positive
     // out the tail, Y is out the right wing, and Z is positive up.
     // Distances in meters of course.
     sgVec3 pilot_offset;
 
-    // view orientation (heading, pitch, roll)
-    sgVec3 hpr;
+    // view orientation (roll, pitch, heading)
+    sgVec3 rph;
 
     // cartesion coordinates of current lon/lat if at sea level
     // translated to scenery.center
@@ -153,17 +153,17 @@ public:
        dirty = true;
        // cout << "set_geod_view_pos = " << lon << ", " << lat << ", " << alt
        //      << endl;
-       geod_view_pos = Point3D( lon, lat, alt );
+       sgdSetVec3( geod_view_pos, lon, lat, alt );
     }
     inline void set_sea_level_radius( double r ) {
        // data should be in meters from the center of the earth
        dirty = true;
        sea_level_radius = r;
     }
-    inline void set_hpr( double h, double p, double r ) {
+    inline void set_rph( double r, double p, double h ) {
        // data should be in radians
        dirty = true;
-       sgSetVec3( hpr, h, p, r );
+       sgSetVec3( rph, r, p, h );
     }
     inline void set_pilot_offset( float x, float y, float z ) {
        dirty = true;
@@ -189,16 +189,16 @@ public:
     inline double get_goal_view_offset() const { return goal_view_offset; }
     inline float *get_pilot_offset() { return pilot_offset; }
     inline double get_sea_level_radius() const { return sea_level_radius; }
-    inline float *get_hpr() { return hpr; }
+    inline float *get_rph() { return rph; }
 
     //////////////////////////////////////////////////////////////////////
     // derived values accessor functions
     //////////////////////////////////////////////////////////////////////
-    inline Point3D get_abs_view_pos() {
+    inline double *get_abs_view_pos() {
        if ( dirty ) { update(); }
        return abs_view_pos;
     }
-    inline Point3D get_view_pos() {
+    inline float *get_view_pos() {
        if ( dirty ) { update(); }
        return view_pos;
     }
index b801ec49af33b36681d904af03ef228e2ffecfa5..0d14651ba91540e225b53ba44b3eb3b8eadbf3ae 100644 (file)
@@ -263,7 +263,7 @@ int
 FGTileCache::next_avail( void )
 {
     // Point3D delta;
-    Point3D abs_view_pos;
+    sgdVec3 abs_view_pos;
     int i;
     // float max, med, min, tmp;
     float dist, max_dist;
@@ -282,10 +282,13 @@ FGTileCache::next_avail( void )
            return(i);
        } else if ( tile_cache[i].is_loaded() || tile_cache[i].is_cached() ) {
            // calculate approximate distance from view point
-           abs_view_pos = globals->get_current_view()->get_abs_view_pos();
+           sgdCopyVec3( abs_view_pos,
+                        globals->get_current_view()->get_abs_view_pos() );
 
-           FG_LOG( FG_TERRAIN, FG_DEBUG,
-                   "DIST Abs view pos = " << abs_view_pos );
+           FG_LOG( FG_TERRAIN, FG_DEBUG, "DIST Abs view pos = " 
+                   << abs_view_pos[0] << ","
+                   << abs_view_pos[1] << ","
+                   << abs_view_pos[2] );
            FG_LOG( FG_TERRAIN, FG_DEBUG,
                    "    ref point = " << tile_cache[i].center );
 
@@ -304,7 +307,12 @@ FGTileCache::next_avail( void )
            dist = max + (med + min) / 4;
            */
 
-           dist = tile_cache[i].center.distance3D( abs_view_pos );
+           sgdVec3 center;
+           sgdSetVec3( center,
+                       tile_cache[i].center[0],
+                       tile_cache[i].center[1],
+                       tile_cache[i].center[2] );
+           dist = sgdDistanceVec3( center, abs_view_pos );
 
            FG_LOG( FG_TERRAIN, FG_DEBUG, "    distance = " << dist );
 
index 6b148a629394b201cff5ead1e0af6851c8f10859..094d903d4596972998051ea6e20aa06e92cc0c0a 100644 (file)
@@ -160,13 +160,13 @@ void FGTileMgr::load_tile( const FGBucket& b, int cache_index) {
 // meters.
 
 bool
-FGTileMgr::current_elev_ssg( const Point3D& abs_view_pos, 
-                            const Point3D& view_pos )
+FGTileMgr::current_elev_ssg( sgdVec3 abs_view_pos, 
+                            sgVec3 view_pos )
 {
     sgdVec3 orig, dir;
 
-    sgdSetVec3(orig, view_pos.x(), view_pos.y(), view_pos.z() );
-    sgdSetVec3(dir, abs_view_pos.x(), abs_view_pos.y(), abs_view_pos.z() );
+    sgdSetVec3(orig, view_pos );
+    sgdCopyVec3(dir, abs_view_pos );
 
     hit_list.Intersect( terrain, orig, dir );
 
@@ -460,15 +460,20 @@ int FGTileMgr::update( double lon, double lat ) {
     if ( scenery.center == Point3D(0.0) ) {
        // initializing
        // cout << "initializing ... " << endl;
+       sgdVec3 tmp_abs_view_pos;
+       sgVec3 tmp_view_pos;
+
        Point3D geod_pos = Point3D( longitude * DEG_TO_RAD,
                                    latitude * DEG_TO_RAD,
                                    0.0);
-       Point3D tmp_abs_view_pos = sgGeodToCart( geod_pos );
-       scenery.center = tmp_abs_view_pos;
+       Point3D tmp = sgGeodToCart( geod_pos );
+       scenery.center = tmp;
+       sgdSetVec3( tmp_abs_view_pos, tmp.x(), tmp.y(), tmp.z() );
+
        // cout << "abs_view_pos = " << tmp_abs_view_pos << endl;
        prep_ssg_nodes();
-       current_elev_ssg( tmp_abs_view_pos,
-                         Point3D( 0.0 ) );
+       sgSetVec3( tmp_view_pos, 0.0, 0.0, 0.0 );
+       current_elev_ssg( tmp_abs_view_pos, tmp_view_pos );
     } else {
        // cout << "abs view pos = " << current_view.abs_view_pos
        //      << " view pos = " << current_view.view_pos << endl;
index 4cd675b7e40a846a81df54b132c20e7cdecaeff4..39b8103c521b350df3078f355e13dde67ea9039b 100644 (file)
@@ -164,8 +164,8 @@ public:
                     const sgdVec3 p, const sgdVec3 dir,
                     FGHitList *list );
 
-    bool current_elev_ssg( const Point3D& abs_view_pos, 
-                          const Point3D& view_pos );
+    bool current_elev_ssg( sgdVec3 abs_view_pos, 
+                          sgVec3 view_pos );
        
     // Prepare the ssg nodes ... for each tile, set it's proper
     // transform and update it's range selector based on current
index 23c6524c92ff3b3626f01e3cf5b53a16049e1432..6ee7d0137b45b603cfac6a68ed6b071957e1e21d 100644 (file)
@@ -1,5 +1,6 @@
-// moonpos.cxx (basically, this is a slightly modified version of the 'sunpos.cxx' file, adapted from XEarth)
-
+// moonpos.cxx (basically, this is a slightly modified version of the
+// 'sunpos.cxx' file, adapted from XEarth)
+//
 // kirk johnson
 // july 1993
 //
@@ -334,7 +335,7 @@ static void fgMoonPositionGST(double gst, double *lon, double *lat) {
 void fgUpdateMoonPos( void ) {
     fgLIGHT *l;
     FGViewer *v;
-    sgVec3 nup, nmoon, v0, surface_to_moon;
+    sgVec3 nup, nmoon, surface_to_moon;
     Point3D p, rel_moonpos;
     double dot, east_dot;
     double moon_gd_lat, sl_radius;
@@ -386,20 +387,19 @@ void fgUpdateMoonPos( void ) {
         << l->moon_angle << endl;
     
     // calculate vector to moon's position on the earth's surface
-    rel_moonpos = l->fg_moonpos - (v->get_view_pos() + scenery.center);
+    Point3D vp( v->get_view_pos()[0],
+               v->get_view_pos()[1],
+               v->get_view_pos()[1] );
+    rel_moonpos = l->fg_moonpos - ( vp + scenery.center );
     v->set_to_moon( rel_moonpos.x(), rel_moonpos.y(), rel_moonpos.z() );
     // printf( "Vector to moon = %.2f %.2f %.2f\n",
     //         v->to_moon[0], v->to_moon[1], v->to_moon[2]);
 
-    // make a vector to the current view position
-    Point3D view_pos = v->get_view_pos();
-    sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
-
     // Given a vector from the view position to the point on the
     // earth's surface the moon is directly over, map into onto the
     // local plane representing "horizontal".
 
-    sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v0
+    sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v->get_view_pos()
                                      v->get_to_moon(), surface_to_moon );
     sgNormalizeVec3(surface_to_moon);
     v->set_surface_to_moon( surface_to_moon[0], surface_to_moon[1], 
index 45cf9e3e175481a1b5474473ddc6208146f287b3..c0f67d3d28e4495b2856308e64c950b7ab9e2e75 100644 (file)
@@ -243,7 +243,7 @@ static void fgSunPositionGST(double gst, double *lon, double *lat) {
 void fgUpdateSunPos( void ) {
     fgLIGHT *l;
     FGViewer *v;
-    sgVec3 nup, nsun, v0, surface_to_sun;
+    sgVec3 nup, nsun, surface_to_sun;
     Point3D p, rel_sunpos;
     double dot, east_dot;
     double sun_gd_lat, sl_radius;
@@ -293,21 +293,20 @@ void fgUpdateSunPos( void ) {
     cout << "sun angle relative to current location = " << l->sun_angle << endl;
     
     // calculate vector to sun's position on the earth's surface
-    rel_sunpos = l->fg_sunpos - (v->get_view_pos() + scenery.center);
+    Point3D vp( v->get_view_pos()[0],
+               v->get_view_pos()[1],
+               v->get_view_pos()[1] );
+    rel_sunpos = l->fg_sunpos - ( vp + scenery.center );
     v->set_to_sun( rel_sunpos.x(), rel_sunpos.y(), rel_sunpos.z() );
     // printf( "Vector to sun = %.2f %.2f %.2f\n",
     //         v->to_sun[0], v->to_sun[1], v->to_sun[2]);
 
-    // make a vector to the current view position
-    Point3D view_pos = v->get_view_pos();
-    sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
-
     // Given a vector from the view position to the point on the
     // earth's surface the sun is directly over, map into onto the
     // local plane representing "horizontal".
 
-    sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v0, v->get_to_sun(), 
-                                     surface_to_sun );
+    sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v->get_view_pos(),
+                                     v->get_to_sun(), surface_to_sun );
     sgNormalizeVec3(surface_to_sun);
     v->set_surface_to_sun( surface_to_sun[0], surface_to_sun[1], 
                           surface_to_sun[2] );