From f30a568858fef20578094902d8e7b0917468f835 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Mar 2021 19:10:46 +0100 Subject: [PATCH] - moved wallfront function into polymost.cpp. This was one of the few functions left in engine.cpp that accesses the global scene state. --- source/build/include/compat.h | 11 ----------- source/build/src/engine.cpp | 34 --------------------------------- source/build/src/engine_priv.h | 1 - source/build/src/polymost.cpp | 35 ++++++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 46 deletions(-) diff --git a/source/build/include/compat.h b/source/build/include/compat.h index f1ce512f0..85e7eb29e 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -12,17 +12,6 @@ #include "intvec.h" #include "m_swap.h" -////////// Compiler detection ////////// - -#ifdef __GNUC__ -# define EDUKE32_GCC_PREREQ(major, minor) (major < __GNUC__ || (major == __GNUC__ && minor <= __GNUC_MINOR__)) -#else -# define EDUKE32_GCC_PREREQ(major, minor) 0 -#endif - - -////////// Language detection ////////// - ////////// Language and compiler feature polyfills ////////// # define EXTERNC diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index ac425c089..1d9275964 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -198,40 +198,6 @@ int32_t renderAddTsprite(int16_t z, int16_t sectnum) } -// -// wallfront (internal) -// -int32_t wallfront(int32_t l1, int32_t l2) -{ - vec2_t const l1vect = wall[thewall[l1]].pos; - vec2_t const l1p2vect = wall[wall[thewall[l1]].point2].pos; - vec2_t const l2vect = wall[thewall[l2]].pos; - vec2_t const l2p2vect = wall[wall[thewall[l2]].point2].pos; - vec2_t d = { l1p2vect.x - l1vect.x, l1p2vect.y - l1vect.y }; - int32_t t1 = DMulScale(l2vect.x-l1vect.x, d.y, -d.x, l2vect.y-l1vect.y, 2); //p1(l2) vs. l1 - int32_t t2 = DMulScale(l2p2vect.x-l1vect.x, d.y, -d.x, l2p2vect.y-l1vect.y, 2); //p2(l2) vs. l1 - - if (t1 == 0) { if (t2 == 0) return -1; t1 = t2; } - if (t2 == 0) t2 = t1; - - if ((t1^t2) >= 0) //pos vs. l1 - return (DMulScale(globalposx-l1vect.x, d.y, -d.x, globalposy-l1vect.y, 2) ^ t1) >= 0; - - d.x = l2p2vect.x-l2vect.x; - d.y = l2p2vect.y-l2vect.y; - - t1 = DMulScale(l1vect.x-l2vect.x, d.y, -d.x, l1vect.y-l2vect.y, 2); //p1(l1) vs. l2 - t2 = DMulScale(l1p2vect.x-l2vect.x, d.y, -d.x, l1p2vect.y-l2vect.y, 2); //p2(l1) vs. l2 - - if (t1 == 0) { if (t2 == 0) return -1; t1 = t2; } - if (t2 == 0) t2 = t1; - - if ((t1^t2) >= 0) //pos vs. l2 - return (DMulScale(globalposx-l2vect.x,d.y,-d.x,globalposy-l2vect.y, 2) ^ t1) < 0; - - return -2; -} - // // animateoffs (internal) // diff --git a/source/build/src/engine_priv.h b/source/build/src/engine_priv.h index 3210d04d5..533c120ba 100644 --- a/source/build/src/engine_priv.h +++ b/source/build/src/engine_priv.h @@ -41,7 +41,6 @@ extern int16_t numscans, numbunches; // int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat); -int32_t wallfront(int32_t l1, int32_t l2); void set_globalang(fixed_t const ang); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 8ca354f79..9c1ee60cf 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -1776,6 +1776,41 @@ static void polymost_drawalls(int32_t const bunch) } } +// +// wallfront (internal) +// +int32_t wallfront(int32_t l1, int32_t l2) +{ + vec2_t const l1vect = wall[thewall[l1]].pos; + vec2_t const l1p2vect = wall[wall[thewall[l1]].point2].pos; + vec2_t const l2vect = wall[thewall[l2]].pos; + vec2_t const l2p2vect = wall[wall[thewall[l2]].point2].pos; + vec2_t d = { l1p2vect.x - l1vect.x, l1p2vect.y - l1vect.y }; + int32_t t1 = DMulScale(l2vect.x - l1vect.x, d.y, -d.x, l2vect.y - l1vect.y, 2); //p1(l2) vs. l1 + int32_t t2 = DMulScale(l2p2vect.x - l1vect.x, d.y, -d.x, l2p2vect.y - l1vect.y, 2); //p2(l2) vs. l1 + + if (t1 == 0) { if (t2 == 0) return -1; t1 = t2; } + if (t2 == 0) t2 = t1; + + if ((t1 ^ t2) >= 0) //pos vs. l1 + return (DMulScale(globalposx - l1vect.x, d.y, -d.x, globalposy - l1vect.y, 2) ^ t1) >= 0; + + d.x = l2p2vect.x - l2vect.x; + d.y = l2p2vect.y - l2vect.y; + + t1 = DMulScale(l1vect.x - l2vect.x, d.y, -d.x, l1vect.y - l2vect.y, 2); //p1(l1) vs. l2 + t2 = DMulScale(l1p2vect.x - l2vect.x, d.y, -d.x, l1p2vect.y - l2vect.y, 2); //p2(l1) vs. l2 + + if (t1 == 0) { if (t2 == 0) return -1; t1 = t2; } + if (t2 == 0) t2 = t1; + + if ((t1 ^ t2) >= 0) //pos vs. l2 + return (DMulScale(globalposx - l2vect.x, d.y, -d.x, globalposy - l2vect.y, 2) ^ t1) < 0; + + return -2; +} + + static int32_t polymost_bunchfront(const int32_t b1, const int32_t b2) { int b1f = bunchfirst[b1];