tests/ops: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:51:09 -05:00
1 parent 9d80ee11b9
commit 75ddfb4068
5 files changed
+7 -58

No files matched your search

+2 -15
View File
@@ -1,8 +1,4 @@
-- ops/MeshOps tests: triangulate (strips, fans, convex / concave / degenerate n-gons), transform (normals by the inverse
-- transpose, mirrors flip the winding), computeNormals (smooth sphere normals = the radial direction, flat cube normals),
-- computeTangents (orthogonal, unit, handedness), weld / unweld, bounds, merge (instances baked, mixed attributes),
-- scale / setUnit / setUp, greedy voxel meshing (exposed face area, winding, the checkerboard worst case), errors.
-- Analytic references (closed forms); the format tests check merge / bounds against assimp and trimesh.
-- ops/MeshOps tests against analytic references (closed forms).
local T = require("@tests/T")
local MeshOps = require("@rosetta/ops/MeshOps")
local Types = require("@rosetta/Types")
@@ -52,7 +48,6 @@ local function area(prim: any): number
return total
end
-- a unit cube as 6 quads (polygons), 24 corners
local function cube(): Types.Primitive
local P = {}
local faces = {
@@ -76,7 +71,6 @@ local function cube(): Types.Primitive
return { attributes = { POSITION = f32(P, 3) }, indices = u32(ind), faces = u32(sizes), mode = "polygons" }
end
-- triangulate
do
local c = cube()
local tri = MeshOps.triangulate(c) :: any
@@ -95,7 +89,6 @@ do
end
end
t:check(outward, "triangulated winding keeps the faces outward")
-- strips and fans
local P = f32({ 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 2, 0, 1, 2, 0 }, 3)
local strip = MeshOps.triangulate({ attributes = { POSITION = P }, mode = "triangle_strip" }) :: any
t:check(table.concat(idx(strip.indices), ",") == "0,1,2,2,1,3,2,3,4,4,3,5", "strip unrolled with alternating winding")
@@ -130,7 +123,6 @@ do
t:check(MeshOps.triangulate(lines) == lines, "lines come back unchanged")
end
-- transform
do
local tri = MeshOps.triangulate(cube()) :: any
MeshOps.computeNormals(MeshOps.unweld(tri))
@@ -173,7 +165,6 @@ do
t:check(e and e.code == Err.ARG, "transform: a bad matrix")
end
-- normals, tangents on a UV sphere
do
local rings, segs = 16, 32
local P, UV, ind = {}, {}, {}
@@ -253,7 +244,6 @@ do
t:check(axis, "flat cube normals are axis-aligned")
end
-- weld
do
local soup = MeshOps.unweld(MeshOps.triangulate(cube()) :: any) :: any
t:eq(soup.attributes.POSITION.count, 36, "unwelded cube: 36 vertices")
@@ -271,7 +261,6 @@ do
t:eq(positionsOnly.attributes.POSITION.count, 8, "positionsOnly: 8")
end
-- merge, bounds
do
local s = S.new()
local tri = MeshOps.triangulate(cube()) :: any
@@ -301,11 +290,10 @@ do
t:check(e and e.code == Err.ARG, "merge junk")
end
-- units and up axis
do
local s = S.fromPrimitive(MeshOps.triangulate(cube()) :: any)
s.nodes[1].translation = { 1, 2, 3 }
s.meta.unit = 0.01 -- centimetres
s.meta.unit = 0.01
MeshOps.setUnit(s, 1)
local lo, hi = MeshOps.bounds(s)
t:check(lo and near(lo[1], 0.01) and near(hi[1], 0.02) and near(lo[3], 0.03), "cm -> m")
@@ -318,7 +306,6 @@ do
t:check(MeshOps.setUp(s, "x" :: any) == nil, "setUp: bad axis")
end
-- greedy voxels
do
local v = Types.Voxels.new(4, 4, 4)
for x = 0, 3 do