From 9e13a4b6956bf0da9bef996e91cb3310d642da98 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 23:49:33 +0100 Subject: [PATCH] Revert "port R_PointToPseudoAngle && gld_clipper_AngleToPseudo from dsda-doom" This reverts commit 353589d13a57c93bc808bee96209895d4a11037f. --- src/hardware/hw_clip.c | 23 ----------------------- src/hardware/hw_clip.h | 1 - src/hardware/hw_main.cpp | 10 +++++----- src/m_fixed.h | 29 +++++++++++++++++++++++++++++ src/m_misc.h | 34 ---------------------------------- src/r_main.cpp | 39 --------------------------------------- src/r_main.h | 1 - 7 files changed, 34 insertions(+), 103 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 0a1e67a59..caa19f565 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -190,29 +190,6 @@ void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) } } -static angle_t gld_clipper_AngleToPseudo(angle_t ang) -{ - const double angradians = ang * (M_PI / (double)ANGLE_180); - double vecx = cos(angradians); - double vecy = sin(angradians); - - double result = vecy / (fabs(vecx) + fabs(vecy)); - - if (vecx < 0) - { - result = 2.0 - result; - } - - return (angle_t)xs_CRoundToUInt(result * (1<<30)); -} - -void gld_clipper_SafeAddClipRangeRealAngles(angle_t startangle, angle_t endangle) -{ - gld_clipper_SafeAddClipRange( - gld_clipper_AngleToPseudo(startangle), - gld_clipper_AngleToPseudo(endangle)); -} - static void gld_clipper_AddClipRange(angle_t start, angle_t end) { clipnode_t *node, *temp, *prevNode, *node2, *delnode; diff --git a/src/hardware/hw_clip.h b/src/hardware/hw_clip.h index d7de80333..232d09c06 100644 --- a/src/hardware/hw_clip.h +++ b/src/hardware/hw_clip.h @@ -20,7 +20,6 @@ extern "C" { boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle); void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); -void gld_clipper_SafeAddClipRangeRealAngles(angle_t startangle, angle_t endangle); void gld_clipper_Clear(void); angle_t gld_FrustumAngle(angle_t tiltangle); #ifdef HAVE_SPHEREFRUSTRUM diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8eee3f3d3..434ff5252 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2473,8 +2473,8 @@ static void HWR_AddLine(seg_t *line) v2y = gl_curline->v2->y; // OPTIMIZE: quickly reject orthogonal back sides. - angle1 = R_PointToPseudoAngle(v1x, v1y); - angle2 = R_PointToPseudoAngle(v2x, v2y); + angle1 = R_PointToAngle64(v1x, v1y); + angle2 = R_PointToAngle64(v2x, v2y); // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! if (angle2 - angle1 < ANGLE_180) @@ -2586,8 +2586,8 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) return false; } - angle1 = R_PointToPseudoAngle(px1, py1); - angle2 = R_PointToPseudoAngle(px2, py2); + angle1 = R_PointToAngle64(px1, py1); + angle2 = R_PointToAngle64(px2, py2); return gld_clipper_SafeCheckRange(angle2, angle1); } @@ -5511,7 +5511,7 @@ void HWR_ClearClipper(void) const angle_t a1 = gld_FrustumAngle(gl_aimingangle); gld_clipper_Clear(); - gld_clipper_SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); + gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); #ifdef HAVE_SPHEREFRUSTRUM gld_FrustumSetup(); #endif diff --git a/src/m_fixed.h b/src/m_fixed.h index 894e2b1cc..c0afae941 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -265,6 +265,35 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x) return INT32_MAX; } +/** \brief The xs_CRoundToInt function + + \param val double number + + \return Round toward nearest, but ties round toward even +*/ +#if defined(SRB2_BIG_ENDIAN) + #define _xs_iexp_ 0 + #define _xs_iman_ 1 +#else + #define _xs_iexp_ 1 //intel is little endian + #define _xs_iman_ 0 +#endif //BigEndian_ + +typedef double real64; + +typedef union _xs_doubleints +{ + real64 val; + unsigned ival[2]; +} _xs_doubleints; + +FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val) +{ + _xs_doubleints uval; + uval.val = val + 6755399441055744.0; + return uval.ival[_xs_iman_]; +} + typedef struct { fixed_t x; diff --git a/src/m_misc.h b/src/m_misc.h index 15f063f23..ab7c8986f 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -102,40 +102,6 @@ TMatrix *RotateYMatrix(angle_t rad); #endif TMatrix *RotateZMatrix(angle_t rad); -/** \brief The xs_CRoundToInt function - - \param val double number - - \return Round toward nearest, but ties round toward even -*/ -#if defined(SRB2_BIG_ENDIAN) - #define _xs_iexp_ 0 - #define _xs_iman_ 1 -#else - #define _xs_iexp_ 1 //intel is little endian - #define _xs_iman_ 0 -#endif //BigEndian_ - -typedef double real64; - -typedef union _xs_doubleints -{ - real64 val; - unsigned ival[2]; -} _xs_doubleints; - -FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val) -{ - _xs_doubleints uval; - uval.val = val + 6755399441055744.0; - return uval.ival[_xs_iman_]; -} - -FUNCMATH FUNCINLINE static ATTRINLINE unsigned xs_CRoundToUInt(real64 val) -{ - return (unsigned)xs_CRoundToInt(val); -} - // s1 = s2+s3+s1 (1024 lenghtmax) void strcatbf(char *s1, const char *s2, const char *s3); diff --git a/src/r_main.cpp b/src/r_main.cpp index b5ac83ab8..af5e821b2 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -366,45 +366,6 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) 0; } -//----------------------------------------------------------------------------- -// -// ! Returns the pseudoangle between the line p1 to (infinity, p1.y) and the -// line from p1 to p2. The pseudoangle has the property that the ordering of -// points by true angle anround p1 and ordering of points by pseudoangle are the -// same. -// -// For clipping exact angles are not needed. Only the ordering matters. -// This is about as fast as the fixed point R_PointToAngle2 but without -// the precision issues associated with that function. -// -//----------------------------------------------------------------------------- - -#define EPSILON 1e-2 - -angle_t R_PointToPseudoAngle(fixed_t x, fixed_t y) -{ - // Note: float won't work here as it's less precise than the BAM values being passed as parameters - double vecx = (double)x - (double)viewx; - double vecy = (double)y - (double)viewy; - - if (fabs(vecx) < EPSILON && fabs(vecy) < EPSILON) - { - return 0; - } - else - { - double result = vecy / (fabs(vecx) + fabs(vecy)); - - if (vecx < 0) - { - result = 2.0 - result; - } - - return (angle_t)xs_CRoundToInt(result * (1 << 30)); - } -} -#undef EPSILON - angle_t R_PlayerSliptideAngle(player_t *player) { mobj_t *mo; diff --git a/src/r_main.h b/src/r_main.h index 855be32a3..36c8756f8 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -125,7 +125,6 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); -angle_t R_PointToPseudoAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PlayerSliptideAngle(player_t *player);