Avoid direct use of FGViewer in various places, by providing property-based accessors to the current view position.
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
-#include <Viewer/viewer.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <Airports/dynamics.hxx>
void FGAIAircraft::checkVisibility()
{
double visibility_meters = fgGetDouble("/environment/visibility-m");
- FGViewer* vw = globals->get_current_view();
- invisible = (SGGeodesy::distanceM(vw->getPosition(), pos) > visibility_meters);
+ invisible = (SGGeodesy::distanceM(globals->get_view_position(), pos) > visibility_meters);
}
// Only do the proper hitlist stuff if we are within visible range of the viewer.
if (!invisible) {
- double visibility_meters = fgGetDouble("/environment/visibility-m");
- FGViewer* vw = globals->get_current_view();
-
- if (SGGeodesy::distanceM(vw->getPosition(), pos) > visibility_meters) {
+ double visibility_meters = fgGetDouble("/environment/visibility-m");
+ if (SGGeodesy::distanceM(globals->get_view_position(), pos) > visibility_meters) {
return;
}
SGVec3d cartPos = SGVec3d::fromGeod(pos);
const double d2 = (TRAFFICTOAIDISTTODIE * SG_NM_TO_METER) *
(TRAFFICTOAIDISTTODIE * SG_NM_TO_METER);
- return (distSqr(cartPos, globals->get_aircraft_positon_cart()) < d2);
+ return (distSqr(cartPos, globals->get_aircraft_position_cart()) < d2);
}
#include <math.h>
#include <Main/util.hxx>
-#include <Viewer/viewer.hxx>
#include "AICarrier.hxx"
SGVec3d cartPos = SGVec3d::fromGeod(pos);
// The position of the eyepoint - at least near that ...
- SGVec3d eyePos(globals->get_current_view()->get_view_pos());
+ SGVec3d eyePos(globals->get_view_position_cart());
// Add the position offset of the AIModel to gain the earth
// centered position
SGVec3d eyeWrtCarrier = eyePos - cartPos;
}
// Calculate the bearing to the transmitter
- SGVec3d location = globals->get_aircraft_positon_cart();
+ SGVec3d location = globals->get_aircraft_position_cart();
double distance_nm = dist(_transmitter_cart, location) * SG_METER_TO_NM;
double range_nm = adjust_range(_transmitter_pos.getElevationFt(),
positionLat = props->getNode("position/latitude-deg", true);
positionAlt = props->getNode("position/altitude-ft", true);
+ viewLon = props->getNode("sim/current-view/viewer-lon-deg", true);
+ viewLat = props->getNode("sim/current-view/viewer-lat-deg", true);
+ viewAlt = props->getNode("sim/current-view/viewer-elev-ft", true);
+
orientPitch = props->getNode("orientation/pitch-deg", true);
orientHeading = props->getNode("orientation/heading-deg", true);
orientRoll = props->getNode("orientation/roll-deg", true);
}
SGVec3d
-FGGlobals::get_aircraft_positon_cart() const
+FGGlobals::get_aircraft_position_cart() const
{
return SGVec3d::fromGeod(get_aircraft_position());
}
roll = orientRoll->getDoubleValue();
}
+SGGeod
+FGGlobals::get_view_position() const
+{
+ return SGGeod::fromDegFt(viewLon->getDoubleValue(),
+ viewLat->getDoubleValue(),
+ viewAlt->getDoubleValue());
+}
+
+SGVec3d
+FGGlobals::get_view_position_cart() const
+{
+ return SGVec3d::fromGeod(get_view_position());
+}
// Save the current state as the initial state.
void
bool haveUserSettings;
SGPropertyNode_ptr positionLon, positionLat, positionAlt;
+ SGPropertyNode_ptr viewLon, viewLat, viewAlt;
SGPropertyNode_ptr orientHeading, orientPitch, orientRoll;
public:
SGGeod get_aircraft_position() const;
- SGVec3d get_aircraft_positon_cart() const;
+ SGVec3d get_aircraft_position_cart() const;
void get_aircraft_orientation(double& heading, double& pitch, double& roll);
+ SGGeod get_view_position() const;
+
+ SGVec3d get_view_position_cart() const;
+
inline string_list *get_channel_options_list () {
return channel_options_list;
}
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Viewer/renderer.hxx>
-#include <Viewer/viewer.hxx>
#include <Viewer/splash.hxx>
#include <Scripting/NasalSys.hxx>
// disk.
void FGTileMgr::update(double)
{
- SGVec3d viewPos = globals->get_current_view()->get_view_pos();
double vis = _visibilityMeters->getDoubleValue();
- schedule_tiles_at(SGGeod::fromCart(viewPos), vis);
+ schedule_tiles_at(globals->get_view_position(), vis);
update_queues();
_sun_vec_inv = - _sun_vec;
// calculate the sun's relative angle to local up
- FGViewer *v = globals->get_current_view();
- SGQuatd hlOr = SGQuatd::fromLonLat( v->getPosition() );
+ SGQuatd hlOr = SGQuatd::fromLonLat( globals->get_view_position() );
SGVec3d world_up = hlOr.backTransform( -SGVec3d::e3() );
// cout << "nup = " << nup[0] << "," << nup[1] << ","
// << nup[2] << endl;
return;
}
- SGVec3d userCart = globals->get_aircraft_positon_cart();
+ SGVec3d userCart = globals->get_aircraft_position_cart();
if (currAircraft == scheduledAircraft.end()) {
currAircraft = scheduledAircraft.begin();