use optimized P_DivlineSide instead of R_PointOnSideFast

This commit is contained in:
Alug committed 2025-04-07 08:39:43 +02:00
1 parent 9902cac3ee
commit 980fbd9b10
1 file changed
+13 -4
+13 -4
View File
@@ -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)
{