mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(client/zones): break triangle creating loop of it is going to deadloop
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user