From 1a0ee0f4c3763c9195322584b245858673aeb7b8 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 19 Mar 2019 17:08:35 +0000 Subject: [PATCH] Polymost relative texture alignment patch from Nuke This "fixes" relative texture alignment for floors and ceilings in Polymost to match classic mode. "Fix" is in quotes because this actually means the alignment is less correct in terms of proper scaling than before, but more correct in terms of accuracy to classic mode. git-svn-id: https://svn.eduke32.com/eduke32@7411 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/polymost.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 6f43adfb0..34a637dc9 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -4514,13 +4514,21 @@ static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0, if (globalorientation & 64) { //relative alignment - vec2f_t fxy = { (float)(wall[wall[sec->wallptr].point2].x - wall[sec->wallptr].x), - (float)(wall[wall[sec->wallptr].point2].y - wall[sec->wallptr].y) }; + vec2_t const xy = { wall[wall[sec->wallptr].point2].x - wall[sec->wallptr].x, + wall[wall[sec->wallptr].point2].y - wall[sec->wallptr].y }; + float r; + if (globalorientation & 2) + { + int i = krecipasm(nsqrtasm(uhypsq(xy.x,xy.y))); + r = i * (1.f/1073741824.f); + } + else + { + int i = nsqrtasm(uhypsq(xy.x,xy.y)); if (i == 0) i = 1024; else i = tabledivide32(1048576, i); + r = i * (1.f/1048576.f); + } - float r = polymost_invsqrt_approximation(fxy.x * fxy.x + fxy.y * fxy.y); - - fxy.x *= r; - fxy.y *= r; + vec2f_t const fxy = { xy.x*r, xy.y*r }; ft[0] = ((float)(globalposx - wall[sec->wallptr].x)) * fxy.x + ((float)(globalposy - wall[sec->wallptr].y)) * fxy.y; ft[1] = ((float)(globalposy - wall[sec->wallptr].y)) * fxy.x - ((float)(globalposx - wall[sec->wallptr].x)) * fxy.y;