summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-11-05 22:19:07 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-11-05 22:19:07 +0100
commit3469b37b1b748a9a7d907cd26ec13266eec380fa (patch)
treeb2b38f4cdbf0b5533dbaae5ceac4419f68ccc20a /src
parentfd59aaa55c39c583af86f4dc059cbe9cedd085d2 (diff)
downloadrpgedit-3469b37b1b748a9a7d907cd26ec13266eec380fa.tar
rpgedit-3469b37b1b748a9a7d907cd26ec13266eec380fa.zip
math/line: use center point for behind-wall check
Fixes collision in case of rounding errors.
Diffstat (limited to 'src')
-rw-r--r--src/math/line.ts6
1 files changed, 3 insertions, 3 deletions
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;