gears.geometry: Fix rectangle intersection computation
Previously, when gears.geometry.rectangle.get_intersection() was called with two non-intersecting rectangles, it would return a negative width/height. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
4a42ed0d44
commit
2a57d944ba
|
@ -176,6 +176,9 @@ function gears.geometry.rectangle.get_intersection(a, b)
|
||||||
g.y = math.max(a.y, b.y)
|
g.y = math.max(a.y, b.y)
|
||||||
g.width = math.min(a.x + a.width, b.x + b.width) - g.x
|
g.width = math.min(a.x + a.width, b.x + b.width) - g.x
|
||||||
g.height = math.min(a.y + a.height, b.y + b.height) - g.y
|
g.height = math.min(a.y + a.height, b.y + b.height) - g.y
|
||||||
|
if g.width <= 0 or g.height <= 0 then
|
||||||
|
g.width, g.height = 0, 0
|
||||||
|
end
|
||||||
return g
|
return g
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue