feat(client/zones): break triangle creating loop of it is going to deadloop

This commit is contained in:
DokaDoka
2023-01-13 16:08:37 +11:00
parent 0e052ed7c5
commit 6e10ebe464

View File

@@ -45,6 +45,7 @@ local function getTriangles(polygon)
local a, b, c = 1, 2, 3
local len = #points
local zValue = polygon[1].z
local count = 0
while len - #triangles > 2 do
if polygon:containsSegment(vec3(glm.segment2d.getPoint(polygon[a].xy, polygon[c].xy, 0.01), zValue), vec3(glm.segment2d.getPoint(polygon[a].xy, polygon[c].xy, 0.99), zValue)) then
@@ -58,6 +59,18 @@ local function getTriangles(polygon)
b = c
c = nextFreePoint(points, b, len)
end
count += 1
if count > len and #triangles == 0 then
print('The following polygon failed to be split into triangles for debug')
for k, v in pairs(polygon) do
print(k, v)
end
break
end
end
return triangles