From 3469b37b1b748a9a7d907cd26ec13266eec380fa Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 5 Nov 2018 22:19:07 +0100 Subject: math/line: use center point for behind-wall check Fixes collision in case of rounding errors. --- src/math/line.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/math') diff --git a/src/math/line.ts b/src/math/line.ts index d29bc76..28a636e 100644 --- a/src/math/line.ts +++ b/src/math/line.ts @@ -108,6 +108,9 @@ export class LineSegment extends Line implements Collidable { } public collide(out: vec2, move: Movement, r: number): boolean { + if (this.distancePoint(move.p1) < 0) + return false; + const t = this.getNormal(vec2.create()); vec2.scale(t, t, -r); @@ -121,9 +124,6 @@ export class LineSegment extends Line implements Collidable { } private collideRef(out: vec2, move: Movement): boolean { - if (this.distancePoint(move.p1) < 0) - return false; - if (this.distancePoint(move.p2) >= 0) return false; -- cgit v1.2.3