Update FGViewer position clients to work with SGGeod directly
This commit is contained in:
parent
2fa160d41a
commit
e1583cb28c
5 changed files with 19 additions and 40 deletions
|
@ -167,19 +167,9 @@ void FGAIAircraft::setPerformance(const std::string& acclass) {
|
||||||
|
|
||||||
void FGAIAircraft::checkVisibility()
|
void FGAIAircraft::checkVisibility()
|
||||||
{
|
{
|
||||||
double visibility_meters = fgGetDouble("/environment/visibility-m");
|
double visibility_meters = fgGetDouble("/environment/visibility-m");
|
||||||
|
FGViewer* vw = globals->get_current_view();
|
||||||
FGViewer* vw = globals->get_current_view();
|
invisible = (SGGeodesy::distanceM(vw->getPosition(), pos) > visibility_meters);
|
||||||
double course, distance;
|
|
||||||
|
|
||||||
SGWayPoint current(pos.getLongitudeDeg(), pos.getLatitudeDeg(), 0);
|
|
||||||
SGWayPoint view (vw->getLongitude_deg(), vw->getLatitude_deg(), 0);
|
|
||||||
view.CourseAndDistance(current, &course, &distance);
|
|
||||||
if (distance > visibility_meters) {
|
|
||||||
invisible = true;
|
|
||||||
} else {
|
|
||||||
invisible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -409,14 +399,9 @@ void FGAIAircraft::getGroundElev(double dt) {
|
||||||
// Only do the proper hitlist stuff if we are within visible range of the viewer.
|
// Only do the proper hitlist stuff if we are within visible range of the viewer.
|
||||||
if (!invisible) {
|
if (!invisible) {
|
||||||
double visibility_meters = fgGetDouble("/environment/visibility-m");
|
double visibility_meters = fgGetDouble("/environment/visibility-m");
|
||||||
|
|
||||||
FGViewer* vw = globals->get_current_view();
|
FGViewer* vw = globals->get_current_view();
|
||||||
double course, distance;
|
|
||||||
|
if (SGGeodesy::distanceM(vw->getPosition(), pos) > visibility_meters) {
|
||||||
SGWayPoint current(pos.getLongitudeDeg(), pos.getLatitudeDeg(), 0);
|
|
||||||
SGWayPoint view (vw->getLongitude_deg(), vw->getLatitude_deg(), 0);
|
|
||||||
view.CourseAndDistance(current, &course, &distance);
|
|
||||||
if (distance > visibility_meters) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1539,21 +1539,21 @@ void FGAILocalTraffic::DoGroundElev() {
|
||||||
// Only do the proper hitlist stuff if we are within visible range of the viewer.
|
// Only do the proper hitlist stuff if we are within visible range of the viewer.
|
||||||
double visibility_meters = fgGetDouble("/environment/visibility-m");
|
double visibility_meters = fgGetDouble("/environment/visibility-m");
|
||||||
FGViewer* vw = globals->get_current_view();
|
FGViewer* vw = globals->get_current_view();
|
||||||
if(dclGetHorizontalSeparation(_pos, SGGeod::fromDegM(vw->getLongitude_deg(), vw->getLatitude_deg(), 0.0)) > visibility_meters) {
|
if(dclGetHorizontalSeparation(_pos, SGGeod::fromGeodM(vw->getPosition(), 0.0)) > visibility_meters) {
|
||||||
_ground_elevation_m = aptElev;
|
_ground_elevation_m = aptElev;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: make shure the pos.lat/pos.lon values are in degrees ...
|
// FIXME: make shure the pos.lat/pos.lon values are in degrees ...
|
||||||
double range = 500.0;
|
double range = 500.0;
|
||||||
if (!globals->get_tile_mgr()->scenery_available(_aip.getPosition(), range)) {
|
if (!globals->get_tile_mgr()->scenery_available(_aip.getPosition(), range)) {
|
||||||
// Try to shedule tiles for that position.
|
// Try to shedule tiles for that position.
|
||||||
globals->get_tile_mgr()->update( _aip.getPosition(), range );
|
globals->get_tile_mgr()->update( _aip.getPosition(), range );
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: make shure the pos.lat/pos.lon values are in degrees ...
|
// FIXME: make shure the pos.lat/pos.lon values are in degrees ...
|
||||||
double alt;
|
double alt;
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(_aip.getPosition(), 20000), alt, 0))
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(_aip.getPosition(), 20000), alt, 0))
|
||||||
_ground_elevation_m = alt;
|
_ground_elevation_m = alt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -496,8 +496,7 @@ static void fgMainLoop( void ) {
|
||||||
|
|
||||||
// get the orientation
|
// get the orientation
|
||||||
const SGQuatd view_or = current_view->getViewOrientation();
|
const SGQuatd view_or = current_view->getViewOrientation();
|
||||||
SGQuatd surf_or = SGQuatd::fromLonLatDeg(
|
SGQuatd surf_or = SGQuatd::fromLonLat(current_view->getPosition());
|
||||||
current_view->getLongitude_deg(), current_view->getLatitude_deg());
|
|
||||||
SGQuatd model_or = SGQuatd::fromYawPitchRollDeg(
|
SGQuatd model_or = SGQuatd::fromYawPitchRollDeg(
|
||||||
globals->get_aircraft_model()->get3DModel()->getHeadingDeg(),
|
globals->get_aircraft_model()->get3DModel()->getHeadingDeg(),
|
||||||
globals->get_aircraft_model()->get3DModel()->getPitchDeg(),
|
globals->get_aircraft_model()->get3DModel()->getPitchDeg(),
|
||||||
|
|
|
@ -103,13 +103,9 @@ public:
|
||||||
// pilot view, model in model view).
|
// pilot view, model in model view).
|
||||||
// FIXME: the model view position (ie target positions)
|
// FIXME: the model view position (ie target positions)
|
||||||
// should be in the model class.
|
// should be in the model class.
|
||||||
virtual double getLongitude_deg () const { return _position.getLongitudeDeg(); }
|
|
||||||
virtual double getLatitude_deg () const { return _position.getLatitudeDeg(); }
|
|
||||||
|
|
||||||
virtual void setPosition (double lon_deg, double lat_deg, double alt_ft);
|
virtual void setPosition (double lon_deg, double lat_deg, double alt_ft);
|
||||||
const SGGeod& getPosition() const { return _position; }
|
const SGGeod& getPosition() const { return _position; }
|
||||||
|
|
||||||
|
|
||||||
// Reference geodetic target position...
|
// Reference geodetic target position...
|
||||||
virtual void setTargetPosition (double lon_deg, double lat_deg, double alt_ft);
|
virtual void setTargetPosition (double lon_deg, double lat_deg, double alt_ft);
|
||||||
const SGGeod& getTargetPosition() const { return _target; }
|
const SGGeod& getTargetPosition() const { return _target; }
|
||||||
|
|
|
@ -226,9 +226,8 @@ FGFX::update_pos_and_orientation(SGSoundMgr *smgr, double dt)
|
||||||
|
|
||||||
// get the orientation
|
// get the orientation
|
||||||
const SGQuatd view_or = observer->getViewOrientation();
|
const SGQuatd view_or = observer->getViewOrientation();
|
||||||
SGQuatd surf_or = SGQuatd::fromLonLatDeg(
|
SGQuatd surf_or = SGQuatd::fromLonLat(observer->getPosition());
|
||||||
observer->getLongitude_deg(),
|
|
||||||
observer->getLatitude_deg());
|
|
||||||
SGQuatd model_or = SGQuatd::fromYawPitchRollDeg(
|
SGQuatd model_or = SGQuatd::fromYawPitchRollDeg(
|
||||||
model->getHeadingDeg(),
|
model->getHeadingDeg(),
|
||||||
model->getPitchDeg(),
|
model->getPitchDeg(),
|
||||||
|
|
Loading…
Reference in a new issue