remove local var

This commit is contained in:
Ben Cragg 2019-01-29 11:34:59 +00:00
parent 44d030b9ca
commit 23168ee324
1 changed files with 2 additions and 5 deletions

View File

@ -483,15 +483,12 @@ func (c Circle) Intersect(d Circle) Circle {
// - An edge of the Rect is a tangent to the Circle
func (c Circle) IntersectsRect(r Rect) bool {
// Checks if the c.Center is not in the diagonal quadrants of the rectangle
var grownR Rect
if (r.Min.X <= c.Center.X && c.Center.X <= r.Max.X) || (r.Min.Y <= c.Center.Y && c.Center.Y <= r.Max.Y) {
// 'grow' the Rect by c.Radius in each diagonal
grownR = Rect{
return Rect{
Min: r.Min.Sub(V(c.Radius, c.Radius)),
Max: r.Max.Add(V(c.Radius, c.Radius)),
}
return grownR.Contains(c.Center)
}.Contains(c.Center)
}
// The center is in the diagonal quadrants
return c.Center.To(r.Min).Len() <= c.Radius || c.Center.To(r.Max).Len() <= c.Radius