Use angle instead of range when checking identical points

This commit is contained in:
Gustaf Alhäll 2024-01-03 20:49:17 +01:00
parent cf7c6585eb
commit 4cdd638a07
No known key found for this signature in database
GPG key ID: 6C1F67D690CDEDFD

View file

@ -1058,19 +1058,29 @@ boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y)
}
else if (dist == closestdist)
{
// we're most likely matching against a corner here, so check which point is closest on the opposite side.
vertex_t *diff;
// coordinates are the same; we're most likely matching against a corner here.
// check closest angle instead.
vertex_t *cv, *dv;
angle_t angle = R_PointToAngle2(v.x, v.y, x, y);
angle_t ca, da;
if (closest->v1->x == v.x && closest->v1->y == v.y)
diff = closest->v2;
cv = closest->v2;
else
diff = closest->v1;
cv = closest->v1;
if (v1->x == v.x && v1->y == v.y)
v = *v2;
dv = v2;
else
v = *v1;
dv = v1;
if (R_PointToDist2(v.x, v.y, x, y) < R_PointToDist2(diff->x, diff->y, x, y))
ca = R_PointToAngle2(v.x, v.y, cv->x, cv->y) - angle;
da = R_PointToAngle2(v.x, v.y, dv->x, dv->y) - angle;
if (ca > ANGLE_180)
ca = ANGLE_180 - (ca - ANGLE_180);
if (da > ANGLE_180)
da = ANGLE_180 - (da - ANGLE_180);
if (ca > da)
{
closest = sector->lines[i];
closestdist = dist;