From 14dce291cde533b67f3bdcc65fbd899a1fa71561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Payol?= Date: Thu, 14 Feb 2019 01:49:14 +0100 Subject: [PATCH] Update Line.js Fraction was computed in the wrong order, representing the fraction of the collided line, not of the ray. --- src/shapes/Line.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shapes/Line.js b/src/shapes/Line.js index a3e6f25b..2469c6a9 100644 --- a/src/shapes/Line.js +++ b/src/shapes/Line.js @@ -83,7 +83,7 @@ Line.prototype.raycast = function(result, ray, position, angle){ vec2.toGlobalFrame(l0, l0, position, angle); vec2.toGlobalFrame(l1, l1, position, angle); - var fraction = vec2.getLineSegmentsIntersectionFraction(l0, l1, from, to); + var fraction = vec2.getLineSegmentsIntersectionFraction(from, to, l0, l1); if(fraction >= 0){ var normal = raycast_normal; vec2.rotate(normal, raycast_unit_y, angle); // todo: this should depend on which side the ray comes from