diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-11 16:14:54 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-11 16:14:54 +0100 |
| commit | 24af775b5041cbed67dfc84f3a0d67850a4b6a1b (patch) | |
| tree | 8858ba5158aa7a4b78e12ecbd17b509afda3f9d7 /math_helper.c | |
| parent | 4933a7c038087ae465e588fafb392a57d7f92b87 (diff) | |
pathfinding
Diffstat (limited to 'math_helper.c')
| -rw-r--r-- | math_helper.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/math_helper.c b/math_helper.c index 782599d..648fbd2 100644 --- a/math_helper.c +++ b/math_helper.c @@ -49,7 +49,8 @@ bool lines_intersect(vec2f p1, vec2f q1, vec2f p2, vec2f q2) if (o1 != o2 && o3 != o4) { vec2f bdir = get_dir_of_line(p1, q1); vec2f pdir = get_dir_of_line(p1, p2); - if ((neg2(bdir.x, pdir.x) || pos2(bdir.x, pdir.x)) && (neg2(bdir.y, pdir.y) || pos2(bdir.y, pdir.y))) return true; // going down + if (((p1.x <= p2.x && q1.x >= p2.x) || (p1.x >= p2.x && q1.x <= p2.x)) || ((p1.y <= p2.y && q1.y >= p2.y) || (p1.y >= p2.y && q1.y <= p2.y))) + if ((neg2(bdir.x, pdir.x) || pos2(bdir.x, pdir.x)) && (neg2(bdir.y, pdir.y) || pos2(bdir.y, pdir.y))) return true; } // Special Cases |
