]> git.mxchange.org Git - flightgear.git/commitdiff
Mathias Fröhölöiööhlich:
authorehofman <ehofman>
Mon, 5 Sep 2005 13:25:09 +0000 (13:25 +0000)
committerehofman <ehofman>
Mon, 5 Sep 2005 13:25:09 +0000 (13:25 +0000)
There was a patch from Manuel Masing a few months ago which cleaned up
SGLocation's way depending on input values. That means that with that patch
SGLocation does no longer have calls with unneeded input arguments.
I took his patch and integrated that into flightgear and made maximum use of
that changes.

Erik Hofman:
Remove some duplicate code that was moved to simgear/compiler.h

15 files changed:
src/AIModel/AIBase.cxx
src/ATC/AIEntity.cxx
src/Main/main.cxx
src/Main/renderer.cxx
src/Main/viewer.cxx
src/Main/viewer.hxx
src/Model/acmodel.cxx
src/Model/modelmgr.cxx
src/MultiPlayer/mpmessages.hxx
src/Network/multiplay.cxx
src/Network/net_ctrls.hxx
src/Network/net_fdm.hxx
src/Network/net_fdm_mini.hxx
src/Network/net_gui.hxx
src/Scenery/tilemgr.cxx

index 3675bf6953fe33ca667e93e92e86e8d633dba549..bb66a9b9777d4b84a3542121c6dd61450dd1d1b6 100644 (file)
@@ -99,7 +99,7 @@ void FGAIBase::Transform() {
       } else {
          aip.setOrientation(roll, pitch, hdg);
       }
-      aip.update( globals->get_scenery()->get_center() );    
+      aip.update();    
     }
 }
 
index 79d10a6a2a823f0d6b5f4cfd9829a991bb690eac..5736f2cbd9e635ad820b6c01e2ea8554acb29350 100644 (file)
@@ -80,5 +80,5 @@ void FGAIEntity::RegisterTransmission(int code) {
 void FGAIEntity::Transform() {
     _aip.setPosition(_pos.lon(), _pos.lat(), _pos.elev() * SG_METER_TO_FEET);
     _aip.setOrientation(_roll, _pitch, _hdg);
-    _aip.update( globals->get_scenery()->get_center() );    
+    _aip.update();    
 }
index e3b2f22f98e40c55c4db7bdc4c258f431f92254b..257aa3c2bca7e7ea2ce286384c76348398a3a637 100644 (file)
@@ -558,8 +558,6 @@ static void fgMainLoop( void ) {
       }
     }
 
-    view_location->set_tile_center( globals->get_scenery()->get_next_center() );
-
 #ifdef ENABLE_AUDIO_SUPPORT
     // Right now we make a simplifying assumption that the primary
     // aircraft is the source of all sounds and that all sounds are
@@ -573,10 +571,13 @@ static void fgMainLoop( void ) {
         get_aircraft_model()->get3DModel()->getSGLocation();
 
     // set positional offset for sources
-    sgVec3 source_pos_offset;
-    sgSubVec3( source_pos_offset,
-               view_location->get_view_pos(), acmodel_loc->get_view_pos() );
+    sgdVec3 dsource_pos_offset;
+    sgdSubVec3( dsource_pos_offset,
+                view_location->get_absolute_view_pos(),
+                acmodel_loc->get_absolute_view_pos() );
     // cout << "pos all = " << source_pos_offset[0] << " " << source_pos_offset[1] << " " << source_pos_offset[2] << endl;
+    sgVec3 source_pos_offset;
+    sgSetVec3(source_pos_offset, dsource_pos_offset);
     globals->get_soundmgr()->set_source_pos_all( source_pos_offset );
 
     // set the velocity
index cfa716fb499daa9424109e78d875e5b0a20b91e5..b2146f5e475572d19db85c757590ff81339165be 100644 (file)
@@ -314,7 +314,8 @@ FGRenderer::update( bool refresh_camera_settings ) {
     // calculate our current position in cartesian space
     Point3D cntr = globals->get_scenery()->get_next_center();
     globals->get_scenery()->set_center(cntr);
-    current__view->set_scenery_center(cntr);
+    // Force update of center dependent values ...
+    current__view->set_dirty();
 
     if ( refresh_camera_settings ) {
         // update view port
index 4affbfe409ce189814b69425a7da88d91d93ae5d..5c62846c4c1e2b019d39944f8e44e60bc4518eaf 100644 (file)
@@ -531,26 +531,16 @@ FGViewer::getRelativeViewPos ()
   return _relative_view_pos;
 }
 
-float *
-FGViewer::getZeroElevViewPos () 
-{
-  if (_dirty)
-    recalc();
-  return _zero_elev_view_pos;
-}
-
 void
 FGViewer::updateFromModelLocation (SGLocation * location)
 {
-  Point3D center = globals->get_scenery()->get_next_center();
-  sgCopyMat4(LOCAL, location->getTransformMatrix(center));
+  sgCopyMat4(LOCAL, location->getTransformMatrix());
 }
 
 void
 FGViewer::updateAtModelLocation (SGLocation * location)
 {
-  Point3D center = globals->get_scenery()->get_next_center();
-  sgCopyMat4(ATLOCAL, location->getTransformMatrix(center));
+  sgCopyMat4(ATLOCAL, location->getTransformMatrix());
 }
 
 void
@@ -561,20 +551,7 @@ FGViewer::recalcOurOwnLocation (SGLocation * location, double lon_deg, double la
   dampEyeData(roll_deg, pitch_deg, heading_deg);
   location->setPosition( lon_deg, lat_deg, alt_ft );
   location->setOrientation( roll_deg, pitch_deg, heading_deg );
-  Point3D center = globals->get_scenery()->get_next_center();
-  sgCopyMat4(LOCAL, location->getTransformMatrix(center));
-}
-
-void
-FGViewer::set_scenery_center(const Point3D& center)
-{
-  _location->set_tile_center(center);
-  _location->getTransformMatrix(center);
-  if (_type == FG_LOOKAT) {
-    _target_location->set_tile_center(center);
-    _target_location->getTransformMatrix(center);
-  }
-  set_dirty();
+  sgCopyMat4(LOCAL, location->getTransformMatrix());
 }
 
 // recalc() is done every time one of the setters is called (making the 
@@ -686,9 +663,7 @@ FGViewer::recalcLookAt ()
   Point3D center = globals->get_scenery()->get_next_center();
   sgdVec3 dVec3;
   sgdSetVec3(dVec3, center[0], center[1], center[2]);
-  sgdSubVec3(dVec3,
-             _target_location->get_absolute_view_pos(center),
-             dVec3 );
+  sgdSubVec3(dVec3, _target_location->get_absolute_view_pos(), dVec3 );
   sgSetVec3(at_pos, dVec3[0], dVec3[1], dVec3[2]);
 
   // Update location data for eye...
@@ -701,7 +676,7 @@ FGViewer::recalcLookAt ()
           _roll_deg, _pitch_deg, _heading_deg );
   }
   // save the eye positon...
-  sgCopyVec3(eye_pos,  _location->get_view_pos());
+  sgCopyVec3(eye_pos,  _location->get_view_pos(center));
 
   // copy data from location class to local items...
   copyLocationData();
@@ -752,11 +727,10 @@ FGViewer::recalcLookAt ()
 void
 FGViewer::copyLocationData()
 {
+  Point3D center = globals->get_scenery()->get_center();
   // Get our friendly vectors from the eye location...
-  sgdCopyVec3(_absolute_view_pos,
-              _location->get_absolute_view_pos(globals->get_scenery()->get_next_center()));
-  sgCopyVec3(_zero_elev_view_pos,  _location->get_zero_elev());
-  sgCopyVec3(_relative_view_pos, _location->get_view_pos());
+  sgdCopyVec3(_absolute_view_pos, _location->get_absolute_view_pos());
+  sgCopyVec3(_relative_view_pos, _location->get_view_pos(center));
   sgCopyMat4(UP, _location->getCachedUpMatrix());
   sgCopyVec3(_world_up, _location->get_world_up());
   // these are the vectors that the sun and moon code like to get...
@@ -782,7 +756,8 @@ FGViewer::copyLocationData()
   }
 
   // copy coordinates to outputs for viewer...
-  sgCopyVec3(_zero_elev, _zero_elev_view_pos);
+  sgCopyVec3(_zero_elev, _relative_view_pos);
+  sgAddScaledVec3(_zero_elev, _world_up, -_alt_ft*SG_FEET_TO_METER);
   sgCopyVec3(_view_pos, _relative_view_pos);
 }
 
index 4a319edc361190b969791a909feef64fe2c9058f..5039e9a5c750a206c4353ff635ec547f52d6655a 100644 (file)
@@ -219,8 +219,6 @@ public:
     virtual float *get_world_up() {if ( _dirty ) { recalc(); } return _world_up; }
     // Get the relative (to scenery center) view position in fgfs coordinates.
     virtual float * getRelativeViewPos ();
-    // Get the absolute zero-elevation view position in fgfs coordinates.
-    virtual float * getZeroElevViewPos ();
     // Get surface east vector
     virtual float *get_surface_east() {        if ( _dirty ) { recalc(); } return _surface_east; }
     // Get surface south vector
@@ -258,8 +256,6 @@ public:
         _ground_level_nearplane_m = near_m;
     }
 
-    void set_scenery_center(const Point3D& center);
-
     //////////////////////////////////////////////////////////////////////
     // Part 5: misc setters and getters
     //////////////////////////////////////////////////////////////////////
@@ -282,7 +278,6 @@ private:
 
     mutable sgdVec3 _absolute_view_pos;
     mutable sgVec3 _relative_view_pos;
-    mutable sgVec3 _zero_elev_view_pos;
 
     double _lon_deg;
     double _lat_deg;
index e28e100459f94099c4100ddb283d8de593e49fd6..1edb6911d940d86d60decc2808a51e5c3e21bef9 100644 (file)
@@ -115,8 +115,7 @@ FGAircraftModel::update (double dt)
   _aircraft->setOrientation(fgGetDouble("/orientation/roll-deg"),
                            fgGetDouble("/orientation/pitch-deg"),
                            fgGetDouble("/orientation/heading-deg"));
-  _aircraft->update( globals->get_scenery()->get_center() );
-
+  _aircraft->update();
 }
 
 void
index 01743325fbb98f5939c18d25603d76aed5c6de3d..50f5e60cc64e48ffa41b39a118686555a3e21a84 100644 (file)
@@ -143,7 +143,7 @@ FGModelMgr::update (double dt)
     if (instance->heading_deg_node != 0)
       model->setHeadingDeg(instance->heading_deg_node->getDoubleValue());
 
-    instance->model->update( globals->get_scenery()->get_center() );
+    instance->model->update();
   }
 }
 
index 4a105aadec79e6b6e46c12db277674e79e625e00..8340897aef806f449b8049cc3040ebf94498af1b 100644 (file)
 *
 ******************************************************************/
 
+#include <simgear/compiler.h>
+
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
-#elif defined( _MSC_VER ) || defined(__MINGW32__) || defined(sun)
-typedef signed short     int16_t;
-typedef signed int       int32_t;
-typedef unsigned short   uint16_t;
-typedef unsigned int     uint32_t;
-#else
-# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
 #endif
 #include <plib/sg.h>
 
index 54bd41da000288fb902d2dbdab6fca0be7221d6a..6772f07c1beaae3453d88b80b3d5f90ccc63189c 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/scene/model/placement.hxx>
+#include <simgear/scene/model/placementtrans.hxx>
 
 #include <Scenery/scenery.hxx>
 
@@ -108,7 +109,7 @@ bool FGMultiplay::process() {
   } else if (get_direction() == SG_IO_OUT) {
 
     sgMat4 posTrans;
-    sgCopyMat4(posTrans, globals->get_aircraft_model()->get3DModel()->get_POS());
+    globals->get_aircraft_model()->get3DModel()->getTransform()->getTransform(posTrans);
     Point3D center = globals->get_scenery()->get_center();
     sgdVec3 PlayerPosition;
     sgdSetVec3(PlayerPosition, posTrans[3][0] + center[0],
index 05b59367eaad1155477abe73d624da29541a0e38..ba304379f810e33dc299c658d4d4aa08881d5da7 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef _NET_CTRLS_HXX
 #define _NET_CTRLS_HXX
 
+#include <simgear/compiler.h>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
 
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
-#elif defined( _MSC_VER ) || defined(__MINGW32__) || defined(sun)
-typedef signed short     int16_t;
-typedef signed int       int32_t;
-typedef unsigned short   uint16_t;
-typedef unsigned int     uint32_t;
-#else
-# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
 #endif
 
 const uint32_t FG_NET_CTRLS_VERSION = 26;
index 2164cc8d8c72223e98aeaaabe7bd5c7d19ec2c8d..3392cf01aadd441d349763fb9a21d9fb36bc7658 100644 (file)
@@ -14,6 +14,7 @@
 
 
 #include <time.h> // time_t
+#include <simgear/compiler.h>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
 
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
-#elif defined( _MSC_VER ) || defined(__MINGW32__) || defined(sun)
-typedef signed short     int16_t;
-typedef signed int       int32_t;
-typedef unsigned short   uint16_t;
-typedef unsigned int     uint32_t;
-#else
-# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
 #endif
 
 const uint32_t FG_NET_FDM_VERSION = 22;
index c3c0b70bd93d4b8f447fa589c3b16293b3ca56a0..cf91b0c1b356369ed4fad736dc550114e1022f6c 100644 (file)
@@ -17,6 +17,7 @@
 # error This library requires C++
 #endif                                   
 
+#include <simgear/compiler.h>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
 
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
-#elif defined( _MSC_VER ) || defined(__MINGW32__)
-typedef signed char      int8_t;
-typedef signed short     int16_t;
-typedef signed int       int32_t;
-typedef signed __int64   int64_t;
-typedef unsigned char    uint8_t;
-typedef unsigned short   uint16_t;
-typedef unsigned int     uint32_t;
-typedef unsigned __int64 uint64_t;
-#else
-# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
 #endif
 
 
index c69a1d291984977f4ea517edf0e3fb48aa074091..0c94d6ffc2c2feccc1c51180bf41b05c8cfb7791 100644 (file)
@@ -11,6 +11,7 @@
 #ifndef _NET_GUI_HXX
 #define _NET_GUI_HXX
 
+#include <simgear/compiler.h>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
 
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
-#elif defined( _MSC_VER ) || defined(__MINGW32__) || defined(sun)
-typedef signed short     int16_t;
-typedef signed int       int32_t;
-typedef unsigned short   uint16_t;
-typedef unsigned int     uint32_t;
-#else
-# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
 #endif
 
 const uint32_t FG_NET_GUI_VERSION = 7;
index 9b28c8894939dd70f10612af69d84c166746be02..fd986a0ec769edec7f2bd4d354f9ca5c85b67439 100644 (file)
@@ -457,18 +457,17 @@ void FGTileMgr::prep_ssg_nodes( SGLocation *location, float vis ) {
     // traverse the potentially viewable tile list and update range
     // selector and transform
 
-    Point3D center = location->get_tile_center();
-    if (center == Point3D(0.0))
-      return;
     float *up = location->get_world_up();
 
     FGTileEntry *e;
     tile_cache.reset_traversal();
 
+    const double *vp = location->get_absolute_view_pos();
+    Point3D viewpos(vp[0], vp[1], vp[2]);
     while ( ! tile_cache.at_end() ) {
         // cout << "processing a tile" << endl;
         if ( (e = tile_cache.get_current()) ) {
-            e->prep_ssg_node( center, up, vis);
+            e->prep_ssg_node( viewpos, up, vis);
         } else {
             SG_LOG(SG_INPUT, SG_ALERT, "warning ... empty tile in cache");
         }