From: ehofman Date: Mon, 5 Sep 2005 13:25:09 +0000 (+0000) Subject: Mathias Fröhölöiööhlich: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fad67bda100f7fb85e7641ded00450e1592769da;p=flightgear.git Mathias Fröhölöiööhlich: 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 --- diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 3675bf695..bb66a9b97 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -99,7 +99,7 @@ void FGAIBase::Transform() { } else { aip.setOrientation(roll, pitch, hdg); } - aip.update( globals->get_scenery()->get_center() ); + aip.update(); } } diff --git a/src/ATC/AIEntity.cxx b/src/ATC/AIEntity.cxx index 79d10a6a2..5736f2cbd 100644 --- a/src/ATC/AIEntity.cxx +++ b/src/ATC/AIEntity.cxx @@ -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(); } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index e3b2f22f9..257aa3c2b 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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 diff --git a/src/Main/renderer.cxx b/src/Main/renderer.cxx index cfa716fb4..b2146f5e4 100644 --- a/src/Main/renderer.cxx +++ b/src/Main/renderer.cxx @@ -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 diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx index 4affbfe40..5c62846c4 100644 --- a/src/Main/viewer.cxx +++ b/src/Main/viewer.cxx @@ -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); } diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx index 4a319edc3..5039e9a5c 100644 --- a/src/Main/viewer.hxx +++ b/src/Main/viewer.hxx @@ -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; diff --git a/src/Model/acmodel.cxx b/src/Model/acmodel.cxx index e28e10045..1edb6911d 100644 --- a/src/Model/acmodel.cxx +++ b/src/Model/acmodel.cxx @@ -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 diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 01743325f..50f5e60cc 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -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(); } } diff --git a/src/MultiPlayer/mpmessages.hxx b/src/MultiPlayer/mpmessages.hxx index 4a105aade..8340897ae 100644 --- a/src/MultiPlayer/mpmessages.hxx +++ b/src/MultiPlayer/mpmessages.hxx @@ -35,15 +35,10 @@ * ******************************************************************/ +#include + #ifdef HAVE_STDINT_H # include -#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 need to define int8_t, et. al." #endif #include diff --git a/src/Network/multiplay.cxx b/src/Network/multiplay.cxx index 54bd41da0..6772f07c1 100644 --- a/src/Network/multiplay.cxx +++ b/src/Network/multiplay.cxx @@ -29,6 +29,7 @@ #include #include +#include #include @@ -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], diff --git a/src/Network/net_ctrls.hxx b/src/Network/net_ctrls.hxx index 05b59367e..ba304379f 100644 --- a/src/Network/net_ctrls.hxx +++ b/src/Network/net_ctrls.hxx @@ -12,6 +12,7 @@ #ifndef _NET_CTRLS_HXX #define _NET_CTRLS_HXX +#include // NOTE: this file defines an external interface structure. Due to // variability between platforms and architectures, we only used fixed @@ -21,13 +22,6 @@ #ifdef HAVE_STDINT_H # include -#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 need to define int8_t, et. al." #endif const uint32_t FG_NET_CTRLS_VERSION = 26; diff --git a/src/Network/net_fdm.hxx b/src/Network/net_fdm.hxx index 2164cc8d8..3392cf01a 100644 --- a/src/Network/net_fdm.hxx +++ b/src/Network/net_fdm.hxx @@ -14,6 +14,7 @@ #include // time_t +#include // NOTE: this file defines an external interface structure. Due to // variability between platforms and architectures, we only used fixed @@ -23,13 +24,6 @@ #ifdef HAVE_STDINT_H # include -#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 need to define int8_t, et. al." #endif const uint32_t FG_NET_FDM_VERSION = 22; diff --git a/src/Network/net_fdm_mini.hxx b/src/Network/net_fdm_mini.hxx index c3c0b70bd..cf91b0c1b 100644 --- a/src/Network/net_fdm_mini.hxx +++ b/src/Network/net_fdm_mini.hxx @@ -17,6 +17,7 @@ # error This library requires C++ #endif +#include // NOTE: this file defines an external interface structure. Due to // variability between platforms and architectures, we only used fixed @@ -26,17 +27,6 @@ #ifdef HAVE_STDINT_H # include -#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 need to define int8_t, et. al." #endif diff --git a/src/Network/net_gui.hxx b/src/Network/net_gui.hxx index c69a1d291..0c94d6ffc 100644 --- a/src/Network/net_gui.hxx +++ b/src/Network/net_gui.hxx @@ -11,6 +11,7 @@ #ifndef _NET_GUI_HXX #define _NET_GUI_HXX +#include // NOTE: this file defines an external interface structure. Due to // variability between platforms and architectures, we only used fixed @@ -20,13 +21,6 @@ #ifdef HAVE_STDINT_H # include -#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 need to define int8_t, et. al." #endif const uint32_t FG_NET_GUI_VERSION = 7; diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 9b28c8894..fd986a0ec 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -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"); }