diff --git a/engine/client/cl_view.c b/engine/client/cl_view.c index c2ec4265..d4628f3e 100644 --- a/engine/client/cl_view.c +++ b/engine/client/cl_view.c @@ -360,6 +360,29 @@ qboolean V_PreRender( void ) //============================================================================ +/* +==================== +V_ApplyRefUnderwater + +apply underwater fov effect +==================== +*/ +static void V_ApplyRefUnderwater( ref_viewpass_t *rvp ) +{ + if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP|RF_DRAW_OVERVIEW )) + return; + + if( !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE )) + return; + + if( cl.local.waterlevel < 3 ) + return; + + rvp->fov_x = atan( tan( DEG2RAD( rvp->fov_x ) / 2 ) * ( 0.97f + sin( cl.time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f); + rvp->fov_y = atan( tan( DEG2RAD( rvp->fov_y ) / 2 ) * ( 1.03f - sin( cl.time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f); + +} + /* ================== V_RenderView @@ -389,6 +412,7 @@ void V_RenderView( void ) clgame.dllFuncs.pfnCalcRefdef( &rp ); V_GetRefParams( &rp, &rvp ); V_RefApplyOverview( &rvp ); + V_ApplyRefUnderwater( &rvp ); if( viewnum == 0 && FBitSet( rvp.flags, RF_ONLY_CLIENTDRAW )) { diff --git a/ref/gl/gl_rmain.c b/ref/gl/gl_rmain.c index b5eb6e99..c73ab9bc 100644 --- a/ref/gl/gl_rmain.c +++ b/ref/gl/gl_rmain.c @@ -352,14 +352,6 @@ R_SetupFrustum */ void R_SetupFrustum( void ) { - const ref_overview_t *ov = gEngfuncs.GetOverviewParms(); - - if( RP_NORMALPASS() && FBitSet( gp_host->features, ENGINE_QUAKE_COMPATIBLE ) && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 )) - { - RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97f + sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f); - RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03f - sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f); - } - // build the transformation matrix for the given view angles AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup ); @@ -372,8 +364,14 @@ void R_SetupFrustum( void ) } if( RI.drawOrtho ) + { + const ref_overview_t *ov = gEngfuncs.GetOverviewParms(); GL_FrustumInitOrtho( &RI.frustum, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar ); - else GL_FrustumInitProj( &RI.frustum, 0.0f, R_GetFarClip(), RI.fov_x, RI.fov_y ); // NOTE: we ignore nearplane here (mirrors only) + } + else + { + GL_FrustumInitProj( &RI.frustum, 0.0f, R_GetFarClip(), RI.fov_x, RI.fov_y ); // NOTE: we ignore nearplane here (mirrors only) + } } /*