From 980fbd9b1030e2e2f143ad3a2fd9685f95a7bbdd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Apr 2025 08:39:43 +0200 Subject: [PATCH] use optimized P_DivlineSide instead of R_PointOnSideFast --- src/p_sight.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 84b96da16..31c82823a 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -39,10 +39,19 @@ static INT32 sightcounts[2]; // Returns side 0 (front), 1 (back), or 2 (on). // // killough 4/19/98: made static, cleaned up -static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) +static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node, boolean fast) { fixed_t left, right; + if (fast) + { + INT64 v = ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy; + + if (v == 0) + return 2; + return v > 0; + } + return( !node->dx ? x == node->x ? 2 : x <= node->x ? node->dy > 0 : node->dy < 0 : !node->dy ? y == node->y ? 2 : y <= node->y ? node->dx < 0 : node->dx > 0 : @@ -53,7 +62,7 @@ static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) static inline INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) { - return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node)); + return (P_DivlineSide(x1, y1, node, false) == P_DivlineSide(x2, y2, node, false)); } static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) @@ -296,8 +305,8 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { register node_t *bsp = nodes + bspnum; - INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x, los->strace.y, (divline_t *)bsp) & 1)); - INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); + INT32 side = P_DivlineSide(los->strace.x, los->strace.y, (divline_t *)bsp, fast) & 1; + INT32 side2 = P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp, fast); if (side == side2) {