From 039daa0145c69e2eec480bb0ef3f488a77ebaf34 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Sep 2025 14:56:16 +0200 Subject: [PATCH] inline P_PointOn stuff + fix declarations --- src/m_fixed.c | 4 ++-- src/p_maputl.c | 20 +++----------------- src/p_maputl.h | 18 +++++++++++++++--- src/p_slopes.c | 2 +- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/m_fixed.c b/src/m_fixed.c index ddd1ce63a..0eeab810f 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -23,7 +23,7 @@ #include "m_fixed.h" #include "tables.h" // ANGLETOFINESHIFT -fixed_t FixedSqrt(fixed_t x) +FUNCMATH fixed_t FixedSqrt(fixed_t x) { #ifdef HAVE_SQRT const float fx = FIXED_TO_FLOAT(x); @@ -61,7 +61,7 @@ fixed_t FixedSqrt(fixed_t x) #endif } -fixed_t FixedHypot(fixed_t x, fixed_t y) +FUNCMATH fixed_t FixedHypot(fixed_t x, fixed_t y) { // Moved the code from R_PointToDist2 to here, // since R_PointToDist2 did the same thing, diff --git a/src/p_maputl.c b/src/p_maputl.c index 68de643e5..de88d4668 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -130,25 +130,12 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte return; } -// -// P_PointOnLineSide -// Returns 0 or 1 -// -INT32 PUREFUNC P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line) -{ - return - !line->dx ? x <= line->v1->x ? line->dy > 0 : line->dy < 0 : - !line->dy ? y <= line->v1->y ? line->dx < 0 : line->dx > 0 : - FixedMul(y-line->v1->y, line->dx>>FRACBITS) >= - FixedMul(line->dy>>FRACBITS, x-line->v1->x); -} - // // P_BoxOnLineSide // Considers the line to be infinite // Returns side 0 or 1, -1 if box crosses the line. // -INT32 PUREFUNC P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld) +PUREFUNC INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld) { INT32 p1, p2; @@ -198,7 +185,7 @@ INT32 PUREFUNC P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld) // P_PointOnDivlineSide // Returns 0 or 1. // -static INT32 PUREFUNC P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line) +FUNCINLINE static ATTRINLINE PUREFUNC INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line) { return !line->dx ? x <= line->x ? line->dy > 0 : line->dy < 0 : @@ -207,7 +194,6 @@ static INT32 PUREFUNC P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line FixedMul(y>>8, line->dx>>8) >= FixedMul(line->dy>>8, x>>8); } - // // P_MakeDivline // @@ -224,7 +210,7 @@ void P_MakeDivline(line_t *li, divline_t *dl) // Returns the fractional intercept point along the first divline. // This is only called by the addthings and addlines traversers. // -fixed_t PUREFUNC P_InterceptVector(divline_t *v2, divline_t *v1) +PUREFUNC fixed_t P_InterceptVector(divline_t *v2, divline_t *v1) { fixed_t frac, num, den; diff --git a/src/p_maputl.h b/src/p_maputl.h index c337c0f87..22d269924 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -41,14 +41,26 @@ typedef boolean (*traverser_t)(intercept_t *in); boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, INT32 pflags, traverser_t ptrav); +// +// P_PointOnLineSide +// Returns 0 or 1 +// +FUNCINLINE static ATTRINLINE PUREFUNC INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line) +{ + return + !line->dx ? x <= line->v1->x ? line->dy > 0 : line->dy < 0 : + !line->dy ? y <= line->v1->y ? line->dx < 0 : line->dx > 0 : + FixedMul(y-line->v1->y, line->dx>>FRACBITS) >= + FixedMul(line->dy>>FRACBITS, x-line->v1->x); +} + #define P_AproxDistance(dx, dy) FixedHypot(dx, dy) void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result); -INT32 PUREFUNC P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line); void P_MakeDivline(line_t *li, divline_t *dl); void P_CameraLineOpening(line_t *plinedef); -fixed_t PUREFUNC P_InterceptVector(divline_t *v2, divline_t *v1); -INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld); +PUREFUNC fixed_t P_InterceptVector(divline_t *v2, divline_t *v1); +PUREFUNC INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld); void P_UnsetPrecipThingPosition(precipmobj_t *thing); void P_SetPrecipitationThingPosition(precipmobj_t *thing); void P_CreatePrecipSecNodeList(precipmobj_t *thing, fixed_t x,fixed_t y); diff --git a/src/p_slopes.c b/src/p_slopes.c index e1bd15ef5..499e8dca3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -623,7 +623,7 @@ void P_SpawnSlope_Line(int linenum) } } - if(!line->tag) + if (!line->tag) return; }