Fix/custom drawings (#18)
Publish Release / build (push) Successful in 13s

Reviewed-on: #18
Co-authored-by: dutchie031 <timrorije@gmail.com>
This commit was merged in pull request #18.
This commit is contained in:
2026-08-17 09:32:01 +00:00
committed by dutchie031
parent 52f97f7c92
commit 8c75ba5027
11 changed files with 205 additions and 65 deletions
+43
View File
@@ -297,6 +297,49 @@ do -- INIT UTIL
return false
end
---@param points Array<Vec3>
---@return Array<Vec3>
function UTIL.getConvexHull3d(points)
if #points == 0 then
return {}
end
---comment
---@param a Vec3
---@param b Vec3
---@param c Vec3
---@return boolean
local function ccw(a, b, c)
return (b.z - a.z) * (c.x - a.x) > (b.x - a.x) * (c.z - a.z)
end
table.sort(points, function(left, right)
return left.z < right.z
end)
local hull = {}
-- lower hull
for _, point in pairs(points) do
while #hull >= 2 and not ccw(hull[#hull - 1], hull[#hull], point) do
table.remove(hull, #hull)
end
table.insert(hull, point)
end
-- upper hull
local t = #hull + 1
for i = #points, 1, -1 do
local point = points[i]
while #hull >= t and not ccw(hull[#hull - 1], hull[#hull], point) do
table.remove(hull, #hull)
end
table.insert(hull, point)
end
table.remove(hull, #hull)
return hull
end
---comment
---@param points Array<Vec2> points
---@return Array<Vec2> hullPoints