- moved wallfront function into polymost.cpp.

This was one of the few functions left in engine.cpp that accesses the global scene state.
This commit is contained in:
Christoph Oelckers 2021-03-20 19:10:46 +01:00
parent 91957e40f1
commit f30a568858
4 changed files with 35 additions and 46 deletions

View File

@ -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

View File

@ -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)
//

View File

@ -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);

View File

@ -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];