move R_QuickCamDist to r_main

also mark it with PUREFUNC and R_QuickDist with FUNCMATH, so compiler may optimze it more agressively
This commit is contained in:
Alug committed 2025-11-26 10:08:20 +01:00
1 parent da57112086
commit 54088933ce
2 files changed
+20 -20

No files matched your search

+20
View File
@@ -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<fixed_t>(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);
-20
View File
@@ -35,26 +35,6 @@ extern "C" {
#define FEETADJUST (4<<FRACBITS) // R_AddSingleSpriteDef
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<fixed_t>(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;