From 186fa924cf4fb575785ba8a5db8630b0f9103fd2 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 5 Oct 2025 13:37:57 -0400 Subject: [PATCH] Revert "Optimize line checks on line interception" This reverts commit bd9924b794ed5e7b89f04278d295c937a31b8afb. --- src/p_maputl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index e2d08a930..0c03f61f1 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -107,11 +107,15 @@ void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *Line, vector3_t // P_PointOnLineSide // Returns 0 or 1 // +// killough 5/3/98: reformatted, cleaned up +// ioanch 20151228: made line const +// INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line) { - // use cross product to determine side quickly - INT64 v = ((INT64)y - line->v1->y) * line->dx - ((INT64)x - line->v1->x) * line->dy; - return v > 0; + 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 : + ((INT64)y - line->v1->y) * line->dx >= line->dy * ((INT64)x - line->v1->x); } // @@ -151,11 +155,15 @@ INT32 P_BoxOnLineSide(const fixed_t *tmbox, const line_t *ld) // P_PointOnDivlineSide // Returns 0 or 1. // +// killough 5/3/98: reformatted, cleaned up +// static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, const divline_t *line) { - // use cross product to determine side quickly - INT64 v = ((INT64)y - line->y) * line->dx - ((INT64)x - line->x) * line->dy; - return v > 0; + return + line->dx == 0 ? x <= line->x ? line->dy > 0 : line->dy < 0 : + line->dy == 0 ? y <= line->y ? line->dx < 0 : line->dx > 0 : + (line->dy ^ line->dx ^ (x -= line->x) ^ (y -= line->y)) < 0 ? (line->dy ^ x) < 0 : + (INT64)(y) * line->dx >= (INT64)(line->dy) * x; } //