This version of equation() compiles into fewer instructions

git-svn-id: https://svn.eduke32.com/eduke32@7592 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-04-18 17:24:34 +00:00 committed by Christoph Oelckers
parent 413d68f1f8
commit 80d77f64cf

View file

@ -8289,24 +8289,16 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
// returns equation of a line given two points // returns equation of a line given two points
static inline _equation equation(float const x1, float const y1, float const x2, float const y2) static inline _equation equation(float const x1, float const y1, float const x2, float const y2)
{ {
_equation ret;
const float f = x2-x1; const float f = x2-x1;
// vertical // vertical
if (f == 0.f) if (f == 0.f)
return { 1, 0, -x1 };
else
{ {
ret.a = 1; float const ff = (y2 - y1) / f;
ret.b = 0; return { ff, -1, (y1 - (ff * x1)) };
ret.c = -x1;
return ret;
} }
ret.a = (float) (y2 - y1)/f;
ret.b = -1;
ret.c = (y1 - (ret.a * x1));
return ret;
} }
int32_t wallvisible(int32_t const x, int32_t const y, int16_t const wallnum) int32_t wallvisible(int32_t const x, int32_t const y, int16_t const wallnum)