Fixing 0,0 being legit closest point
This commit is contained in:
parent
76534cb8d0
commit
5254b4eb62
|
@ -406,12 +406,12 @@ func (l Line) IntersectRect(r Rect) Vec {
|
|||
// - the point is contained by the rectangle
|
||||
// - the point is not the corner itself
|
||||
corners := r.Vertices()
|
||||
closest := ZV
|
||||
var closest *Vec
|
||||
closestCorner := corners[0]
|
||||
for _, c := range corners {
|
||||
cc := l.Closest(c)
|
||||
if closest == ZV || (closest.Len() > cc.Len() && r.Contains(cc)) {
|
||||
closest = cc
|
||||
if closest == nil || (closest.Len() > cc.Len() && r.Contains(cc)) {
|
||||
closest = &cc
|
||||
closestCorner = c
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue