From 9d0e76b2e35376acec08cccb79f0564c6b759431 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 6 Nov 2017 05:56:48 +0000 Subject: [PATCH] Fox's projection patch 2.0 git-svn-id: https://svn.eduke32.com/eduke32@6496 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/polymost.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index acb923647..9ee14c2f8 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -522,10 +522,10 @@ static float get_projhack_ratio(void) { if (glprojectionhacks) { - static constexpr float const projhack_zoom = 1.3f; - static constexpr float const maxcoshoriz = 0.540971179375801f; // 128/sqrt(128^2+199^2) = cos of an horiz diff of 199 - static constexpr float const factor = (projhack_zoom - 1.f) * (1.f / maxcoshoriz); - return 1.f + (factor * (1.f - Bfabsf(gchang))); + // tangent of ((angle of 4 by 3) + (angle of 128 by 199)) / tangent of 90 + static constexpr float const projhack_constant = 1.166015625f; + float const projhack = 65536.f / fviewingrange; + return projhack_constant > projhack ? projhack_constant : projhack; } // No projection hacks (legacy or new-aspect) @@ -565,8 +565,10 @@ static void resizeglcheck(void) const int32_t ourxdimen = (windowxy2.x-windowxy1.x+1); float ratio = get_projhack_ratio(); const int32_t fovcorrect = (int32_t)(ourxdimen*ratio - ourxdimen); - + viewingrange = Blrintf(fviewingrange *= ratio); + float const halfydimen = fydimen * 0.5f; ratio = 1.f/ratio; + globalhoriz = ((globalhoriz - halfydimen) * ratio) + halfydimen; glox1 = (float)windowxy1.x; gloy1 = (float)windowxy1.y; glox2 = (float)windowxy2.x; gloy2 = (float)windowxy2.y;