Fixes for win_ratio/aspect_ratio confusion. It was due to confusion in the
meaning of "win_ratio". I've removed win_ratio and added fov_ratio and aspect_ratio, as it seems both are needed. n.b. The multi-line changes in fgReshape comprise: extracting common code, removing an apparently arbitrary "+1" on the view height, changing "set_win_ratio" to "set_aspect_ratio".
This commit is contained in:
parent
fe8c751f1b
commit
b6a259dc90
7 changed files with 39 additions and 33 deletions
|
@ -1033,8 +1033,8 @@ static void set_hud_color(float r, float g, float b) {
|
|||
void fgUpdateHUD( void ) {
|
||||
|
||||
static const float normal_aspect = float(640) / float(480);
|
||||
// note: win_ratio is Y/X
|
||||
float current_aspect = 1.0f/globals->get_current_view()->get_win_ratio();
|
||||
// note: aspect_ratio is Y/X
|
||||
float current_aspect = 1.0f/globals->get_current_view()->get_aspect_ratio();
|
||||
if( current_aspect > normal_aspect ) {
|
||||
float aspect_adjust = current_aspect / normal_aspect;
|
||||
float adjust = 320.0f*aspect_adjust - 320.0f;
|
||||
|
|
|
@ -251,12 +251,12 @@ void HudLadder :: draw( void )
|
|||
}
|
||||
|
||||
xvvr = (((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi)*
|
||||
(factor/globals->get_current_view()->get_win_ratio()));
|
||||
(factor/globals->get_current_view()->get_aspect_ratio()));
|
||||
drift = ((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi);
|
||||
yvvr = ((actslope - pitch_value)*factor);
|
||||
vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
|
||||
vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*
|
||||
(factor/globals->get_current_view()->get_win_ratio());
|
||||
(factor/globals->get_current_view()->get_aspect_ratio());
|
||||
// printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
|
||||
//****************************************************************
|
||||
// OBJECT MOVING RETICLE
|
||||
|
|
|
@ -520,7 +520,7 @@ void fgHiResDump()
|
|||
glLoadIdentity();
|
||||
ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
|
||||
float fov = globals->get_current_view()->get_fov();
|
||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
|
||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
||||
// ssgSetNearFar( 10.0f, 120000.0f );
|
||||
ssgSetNearFar( 0.5f, 1200000.0f );
|
||||
|
||||
|
|
|
@ -587,12 +587,14 @@ bool fgInitSubsystems( void ) {
|
|||
// Initialize the view manager subsystem.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0 /* As this wrongly does an integer division and gets x and y the wrong way around, I guess it's not needed. JAF */
|
||||
// Initialize win_ratio parameters
|
||||
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
|
||||
globals->get_viewmgr()->get_view(i)->
|
||||
set_win_ratio( fgGetInt("/sim/startup/xsize") /
|
||||
fgGetInt("/sim/startup/ysize") );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Initialize pilot view
|
||||
FGViewerRPH *pilot_view =
|
||||
|
|
|
@ -952,7 +952,9 @@ getFOV ()
|
|||
static void
|
||||
setFOV (double fov)
|
||||
{
|
||||
globals->get_current_view()->set_fov( fov );
|
||||
if ( fov < 180 ) {
|
||||
globals->get_current_view()->set_fov( fov );
|
||||
}
|
||||
}
|
||||
|
||||
static long
|
||||
|
|
|
@ -684,7 +684,7 @@ void fgRenderFrame( void ) {
|
|||
// glMatrixMode( GL_PROJECTION );
|
||||
// glLoadIdentity();
|
||||
float fov = globals->get_current_view()->get_fov();
|
||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
|
||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
||||
|
||||
double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
|
||||
- scenery.cur_elev;
|
||||
|
@ -1391,36 +1391,28 @@ static void fgIdleFunction ( void ) {
|
|||
// options.cxx needs to see this for toggle_panel()
|
||||
// Handle new window size or exposure
|
||||
void fgReshape( int width, int height ) {
|
||||
// for all views
|
||||
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
|
||||
if ( ! fgPanelVisible() || idle_state != 1000 ) {
|
||||
globals->get_viewmgr()->get_view(i)->
|
||||
set_win_ratio( (float)height / (float)width );
|
||||
} else {
|
||||
int view_h =
|
||||
int((current_panel->getViewHeight() -
|
||||
current_panel->getYOffset())
|
||||
* (height / 768.0)) + 1;
|
||||
globals->get_viewmgr()->get_view(i)->
|
||||
set_win_ratio( (float)view_h / (float)width );
|
||||
}
|
||||
int view_h;
|
||||
|
||||
if ( fgPanelVisible() && idle_state == 1000 ) {
|
||||
view_h = (int)(height * (current_panel->getViewHeight() -
|
||||
current_panel->getYOffset()) / 768.0);
|
||||
} else {
|
||||
view_h = height;
|
||||
}
|
||||
|
||||
if ( ! fgPanelVisible() || idle_state != 1000 ) {
|
||||
glViewport(0, 0 , (GLint)(width), (GLint)(height) );
|
||||
} else {
|
||||
int view_h =
|
||||
int((current_panel->getViewHeight() - current_panel->getYOffset())
|
||||
* (height / 768.0)) + 1;
|
||||
glViewport(0, (GLint)(height - view_h),
|
||||
(GLint)(width), (GLint)(view_h) );
|
||||
// for all views
|
||||
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
|
||||
globals->get_viewmgr()->get_view(i)->
|
||||
set_aspect_ratio((float)view_h / (float)width);
|
||||
}
|
||||
|
||||
glViewport( 0, (GLint)(height - view_h), (GLint)(width), (GLint)(view_h) );
|
||||
|
||||
fgSetInt("/sim/startup/xsize", width);
|
||||
fgSetInt("/sim/startup/ysize", height);
|
||||
|
||||
float fov = globals->get_current_view()->get_fov();
|
||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
|
||||
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
|
||||
|
||||
fgHUDReshape();
|
||||
}
|
||||
|
|
|
@ -62,8 +62,11 @@ protected:
|
|||
// the field of view in the x (width) direction
|
||||
double fov;
|
||||
|
||||
// ratio of x and y fov's; fov(y) = fov(x) * win_ratio
|
||||
double win_ratio;
|
||||
// ratio of x and y fov's; fov(y) = fov(x) * fov_ratio
|
||||
double fov_ratio;
|
||||
|
||||
// ratio of window width and height; height = width * aspect_ratio
|
||||
double aspect_ratio;
|
||||
|
||||
// the current view offset angle from forward (rotated about the
|
||||
// view_up vector)
|
||||
|
@ -130,7 +133,13 @@ public:
|
|||
// setter functions
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
inline void set_fov( double amount ) { fov = amount; }
|
||||
inline void set_win_ratio( double r ) { win_ratio = r; }
|
||||
// Don't provide set_fov_ratio explicitely. Use set_aspect_ratio
|
||||
// instead.
|
||||
inline void set_aspect_ratio( double r ) {
|
||||
aspect_ratio = r;
|
||||
fov_ratio = atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) * aspect_ratio) *
|
||||
SG_RADIANS_TO_DEGREES / (fov/2);
|
||||
}
|
||||
inline void set_view_offset( double a ) {
|
||||
set_dirty();
|
||||
view_offset = a;
|
||||
|
@ -176,7 +185,8 @@ public:
|
|||
inline int is_a( int t ) const { return get_type() == t ; }
|
||||
inline bool is_dirty() const { return dirty; }
|
||||
inline double get_fov() const { return fov; }
|
||||
inline double get_win_ratio() const { return win_ratio; }
|
||||
inline double get_aspect_ratio() const { return aspect_ratio; }
|
||||
inline double get_fov_ratio() const { return fov_ratio; }
|
||||
inline double get_view_offset() const { return view_offset; }
|
||||
inline bool get_reverse_view_offset() const { return reverse_view_offset; }
|
||||
inline double get_goal_view_offset() const { return goal_view_offset; }
|
||||
|
|
Loading…
Reference in a new issue