mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-01 22:21:05 +00:00
Use angle instead of range when checking identical points
This commit is contained in:
parent
cf7c6585eb
commit
4cdd638a07
1 changed files with 17 additions and 7 deletions
24
src/r_main.c
24
src/r_main.c
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue