From 5bb8a09165cbde6cdb001cef546f27aa4c6a32a4 Mon Sep 17 00:00:00 2001 From: Fraser Graham Date: Mon, 21 Oct 2013 09:29:15 -0700 Subject: [PATCH] fixed rect intersection test --- vectorpoint.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vectorpoint.go b/vectorpoint.go index da29fa1..f9a45f0 100644 --- a/vectorpoint.go +++ b/vectorpoint.go @@ -86,19 +86,19 @@ func RectIntersection(r Rect2d, p Point2d, v Vector2d) (bool, bool, Point2d) { inside = true return collision, inside, Point2d{X: 0, Y: 0} } else { - wall_left, col1 := Intersection(p, r.A, v, Vector2d{X: 0, Y: r.B.Y}) + wall_left, col1 := Intersection(p, r.A, v, Vector2d{X: 0, Y: r.B.Y - r.A.Y}) if wall_left { return wall_left, inside, col1 } - wall_top, col2 := Intersection(p, r.A, v, Vector2d{X: r.B.X, Y: 0}) + wall_top, col2 := Intersection(p, r.A, v, Vector2d{X: r.B.X - r.A.X, Y: 0}) if wall_top { return wall_top, inside, col2 } - wall_right, col3 := Intersection(p, r.B, v, Vector2d{X: 0, Y: -r.B.Y}) + wall_right, col3 := Intersection(p, r.B, v, Vector2d{X: 0, Y: -r.B.Y + r.A.Y}) if wall_right { return wall_right, inside, col3 } - wall_bottom, col4 := Intersection(p, r.B, v, Vector2d{X: -r.B.X, Y: 0}) + wall_bottom, col4 := Intersection(p, r.B, v, Vector2d{X: -r.B.X + r.A.X, Y: 0}) if wall_bottom { return wall_bottom, inside, col4 }