From ae7674181e8dfae5ec0e691e59fc0b5c1ab8ddd3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 5 Nov 2018 22:41:05 +0100 Subject: math/line: explicitly allow movement away from line segments --- src/math/line.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/math') diff --git a/src/math/line.ts b/src/math/line.ts index 28a636e..2e38f81 100644 --- a/src/math/line.ts +++ b/src/math/line.ts @@ -111,6 +111,9 @@ export class LineSegment extends Line implements Collidable { if (this.distancePoint(move.p1) < 0) return false; + if (crossz(move.v, this.v) < 0) + return false; + const t = this.getNormal(vec2.create()); vec2.scale(t, t, -r); -- cgit v1.2.3