From 80d77f64cf5cc5a2c1282fd21c46c6edd5fc15c9 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 18 Apr 2019 17:24:34 +0000 Subject: [PATCH] This version of equation() compiles into fewer instructions git-svn-id: https://svn.eduke32.com/eduke32@7592 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/engine.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 7d0237fa6..347c7cd1f 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -8289,24 +8289,16 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, // returns equation of a line given two points static inline _equation equation(float const x1, float const y1, float const x2, float const y2) { - _equation ret; const float f = x2-x1; // vertical if (f == 0.f) + return { 1, 0, -x1 }; + else { - ret.a = 1; - ret.b = 0; - ret.c = -x1; - - return ret; + float const ff = (y2 - y1) / f; + return { ff, -1, (y1 - (ff * x1)) }; } - - 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)