void PerspectiveImpl::ComputeDefaultAngle (float width) { float rview_fov = (float)GetDefaultFOV () * 0.5f; float disp_width = (float)width * 0.5f; float inv_disp_radius = csQisqrt ( rview_fov * rview_fov + disp_width * disp_width); default_fov_angle = 2.0f * (float)acos (disp_width * inv_disp_radius) * (360.0f / TWO_PI); }
float Misc::CalcFOV(const size_t iResX, const size_t iResY) { constexpr float fDeg2Rad = static_cast<float>(M_PI) / 180.0f; constexpr float fDefaultAspect = 4.0f / 3.0f; const float fAspect = static_cast<float>(iResX) / iResY; const float fFov = atanf(tanf(0.5f*GetDefaultFOV()*fDeg2Rad)*(fAspect / fDefaultAspect)) / fDeg2Rad*2.0f; return fFov; }
float CBasePlayer::GetFOVDistanceAdjustFactor() { float defaultFOV = (float)GetDefaultFOV(); float localFOV = (float)GetFOV(); if ( localFOV == defaultFOV || defaultFOV < 0.001f ) { return 1.0f; } // If FOV is lower, then we're "zoomed" in and this will give a factor < 1 so apparent LOD distances can be // shorted accordingly return localFOV / defaultFOV; }