mirror of
https://github.com/vrld/HC.git
synced 2024-10-09 08:34:17 +00:00
Fix bug: Polygon:contains() fails for rectangles when point left of shape
This commit is contained in:
parent
36fb13a69a
commit
97b470b059
@ -344,8 +344,9 @@ function Polygon:contains(x,y)
|
||||
|
||||
local v = self.vertices
|
||||
local in_polygon = false
|
||||
for i = 1, #v - 1 do
|
||||
if cut_ray(v[i], v[i+1]) or cross_boundary(v[i], v[i+1]) then
|
||||
for i = 1, #v do
|
||||
local p, q = v[i], v[(i % #v) + 1]
|
||||
if cut_ray(p,q) or cross_boundary(p,q) then
|
||||
in_polygon = not in_polygon
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user