#endif
#include <simgear/compiler.h>
+#include <cassert>
#include "fg_props.hxx"
#include <simgear/debug/logstream.hxx>
#include <simgear/constants.h>
#include <simgear/scene/model/placement.hxx>
-#include <simgear/math/vector.hxx>
#include <Main/globals.hxx>
#include <Scenery/scenery.hxx>
_pitch_deg(0),
_heading_deg(0),
_scaling_type(FG_SCALING_MAX),
- _aspect_ratio(0),
_cameraGroup(CameraGroup::getDefault())
{
_absolute_view_pos = SGVec3d(0, 0, 0);
} else {
_fov_deg = 55;
}
- _aspect_ratio = 1;
+
_aspect_ratio_multiplier = aspect_ratio_multiplier;
_target_offset_m.x() = target_x_offset_m;
_target_offset_m.y() = target_y_offset_m;
FGViewer::setHeadingOffset_deg (double heading_offset_deg)
{
_dirty = true;
- _heading_offset_deg = heading_offset_deg;
+ if (_at_model && (_offset_m.x() == 0.0)&&(_offset_m.z() == 0.0))
+ {
+ /* avoid optical effects (e.g. rotating sky) when "looking at" with
+ * heading offsets x==z==0 (view heading cannot change). */
+ _heading_offset_deg = 0.0;
+ }
+ else
+ _heading_offset_deg = heading_offset_deg;
}
void
FGViewer::setGoalHeadingOffset_deg (double goal_heading_offset_deg)
{
_dirty = true;
+ if (_at_model && (_offset_m.x() == 0.0)&&(_offset_m.z() == 0.0))
+ {
+ /* avoid optical effects (e.g. rotating sky) when "looking at" with
+ * heading offsets x==z==0 (view heading cannot change). */
+ _goal_heading_offset_deg = 0.0;
+ return;
+ }
+
_goal_heading_offset_deg = goal_heading_offset_deg;
while ( _goal_heading_offset_deg < 0.0 ) {
_goal_heading_offset_deg += 360;
double
FGViewer::get_h_fov()
{
+ double aspectRatio = _cameraGroup->getMasterAspectRatio();
switch (_scaling_type) {
case FG_SCALING_WIDTH: // h_fov == fov
return _fov_deg;
case FG_SCALING_MAX:
- if (_aspect_ratio < 1.0) {
+ if (aspectRatio < 1.0) {
// h_fov == fov
return _fov_deg;
} else {
// v_fov == fov
return
atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
- / (_aspect_ratio*_aspect_ratio_multiplier))
+ / (aspectRatio*_aspect_ratio_multiplier))
* SG_RADIANS_TO_DEGREES * 2;
}
default:
double
FGViewer::get_v_fov()
{
+ double aspectRatio = _cameraGroup->getMasterAspectRatio();
switch (_scaling_type) {
case FG_SCALING_WIDTH: // h_fov == fov
return
atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
- * (_aspect_ratio*_aspect_ratio_multiplier))
+ * (aspectRatio*_aspect_ratio_multiplier))
* SG_RADIANS_TO_DEGREES * 2;
case FG_SCALING_MAX:
- if (_aspect_ratio < 1.0) {
+ if (aspectRatio < 1.0) {
// h_fov == fov
return
atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
- * (_aspect_ratio*_aspect_ratio_multiplier))
+ * (aspectRatio*_aspect_ratio_multiplier))
* SG_RADIANS_TO_DEGREES * 2;
} else {
// v_fov == fov
}
}
recalc();
- _cameraGroup->update(toOsg(_absolute_view_pos), toOsg(mViewOrientation));
- _cameraGroup->setCameraParameters(get_v_fov(), get_aspect_ratio());
+ if( fgGetBool( "/sim/rendering/draw-otw", true ) ) {
+ _cameraGroup->update(toOsg(_absolute_view_pos), toOsg(mViewOrientation));
+ _cameraGroup->setCameraParameters(get_v_fov(), get_aspect_ratio());
+ }
+}
+
+double FGViewer::get_aspect_ratio() const
+{
+ return _cameraGroup->getMasterAspectRatio();
}