Mathias Frhlihlich:
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
This commit is contained in:
parent
7473730b85
commit
fad67bda10
15 changed files with 33 additions and 95 deletions
|
@ -99,7 +99,7 @@ void FGAIBase::Transform() {
|
|||
} else {
|
||||
aip.setOrientation(roll, pitch, hdg);
|
||||
}
|
||||
aip.update( globals->get_scenery()->get_center() );
|
||||
aip.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,15 +35,10 @@
|
|||
*
|
||||
******************************************************************/
|
||||
|
||||
#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>
|
||||
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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
|
||||
|
@ -21,13 +22,6 @@
|
|||
|
||||
#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;
|
||||
|
|
|
@ -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
|
||||
|
@ -23,13 +24,6 @@
|
|||
|
||||
#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;
|
||||
|
|
|
@ -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
|
||||
|
@ -26,17 +27,6 @@
|
|||
|
||||
#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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -20,13 +21,6 @@
|
|||
|
||||
#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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue