From 54088933cef250dd2eff24364ab7f656fc030a0a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Nov 2025 10:08:20 +0100 Subject: [PATCH] move R_QuickCamDist to r_main also mark it with PUREFUNC and R_QuickDist with FUNCMATH, so compiler may optimze it more agressively --- src/r_main.h | 20 ++++++++++++++++++++ src/r_things.h | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/r_main.h b/src/r_main.h index 04c996365..36c8756f8 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -150,6 +150,26 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) #define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2)) +FUNCMATH FUNCINLINE static ATTRINLINE fixed_t R_QuickDist(fixed_t x1, fixed_t y1, fixed_t x, fixed_t y) +{ + const fixed_t absx = abs(x - x1); + const fixed_t absy = abs(y - y1); +#ifdef __cplusplus + return std::max(absx, absy); +#else + return max(absx, absy); +#endif +} + +// Takes 2 fixed-point coordinates, returns "distance" between them and camera, +// as an fixed-point integer. +// It is very rough, tho it is used only for optimizing out unnecessary +// interpolation, so it is kinda ok on big distances. +FUNCINLINE static ATTRINLINE PUREFUNC fixed_t R_QuickCamDist(fixed_t x, fixed_t y) +{ + return R_QuickDist(viewx, viewy, x, y); +} + line_t *R_GetFFloorLine(const line_t *line, const ffloor_t *pfloor, const sector_t *sector); side_t *R_GetFFloorSide(const line_t *line, const ffloor_t *pfloor, const sector_t *sector); diff --git a/src/r_things.h b/src/r_things.h index b9c012b79..c8195891a 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -35,26 +35,6 @@ extern "C" { #define FEETADJUST (4<(absx, absy); -#else - return max(absx, absy); -#endif -} - -// Takes 2 fixed-point coordinates, returns "distance" between them and camera, -// as an fixed-point integer. -// It is very rough, tho it is used only for optimizing out unnecessary -// interpolation, so it is kinda ok on big distances. -FUNCINLINE static ATTRINLINE fixed_t R_QuickCamDist(fixed_t x, fixed_t y) -{ - return R_QuickDist(viewx, viewy, x, y); -} - // Constant arrays used for psprite clipping // and initializing clipping. extern INT16 *negonearray;