math/line: use center point for behind-wall check
Fixes collision in case of rounding errors.
This commit is contained in:
parent
fd59aaa55c
commit
3469b37b1b
1 changed files with 3 additions and 3 deletions
|
@ -108,6 +108,9 @@ export class LineSegment extends Line implements Collidable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public collide(out: vec2, move: Movement, r: number): boolean {
|
public collide(out: vec2, move: Movement, r: number): boolean {
|
||||||
|
if (this.distancePoint(move.p1) < 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);
|
||||||
|
|
||||||
|
@ -121,9 +124,6 @@ export class LineSegment extends Line implements Collidable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private collideRef(out: vec2, move: Movement): boolean {
|
private collideRef(out: vec2, move: Movement): boolean {
|
||||||
if (this.distancePoint(move.p1) < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (this.distancePoint(move.p2) >= 0)
|
if (this.distancePoint(move.p2) >= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Reference in a new issue