math/line: explicitly allow movement away from line segments

This commit is contained in:
Matthias Schiffer 2018-11-05 22:41:05 +01:00
parent 3469b37b1b
commit ae7674181e
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -111,6 +111,9 @@ export class LineSegment extends Line implements Collidable {
if (this.distancePoint(move.p1) < 0) if (this.distancePoint(move.p1) < 0)
return false; return false;
if (crossz(move.v, this.v) < 0)
return false;
const t = this.getNormal(vec2.create()); const t = this.getNormal(vec2.create());
vec2.scale(t, t, -r); vec2.scale(t, t, -r);