tests/model: comments: specs only
This commit is contained in:
1 parent
5f7f6005f6
commit
fe7566cbba
37 files changed
+72
-440
No files matched your search
+3
-22
@@ -1,9 +1,5 @@
|
||||
-- model/3ds tests: assimp's 3DS test models (meshes, materials, textures, keyframer hierarchies, pivots, camera /
|
||||
-- target / rotation animation, cameras, lights) and assimp's 3DS exporter output, against assimp (meshes, faces,
|
||||
-- corners, materials, animations, cameras, lights, world bounds); the keyframer placing every mesh where its mesh
|
||||
-- matrix says; round trips through our writer (world triangles, materials, textures, cameras, lights, sampled
|
||||
-- animation) for the reference files and for glTF sample models; assimp reading our files like the originals
|
||||
-- (3ds_xcheck); errors; the fuzz no-throw pass. Fixtures: tools/fixtures/3ds.py.
|
||||
-- model/3ds tests: assimp's 3DS models and exporter output against assimp; round trips; assimp reading ours.
|
||||
-- Fixtures: tools/fixtures/3ds.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local ThreeDs = require("@rosetta/model/3ds")
|
||||
@@ -32,7 +28,6 @@ local function near(a: number, b: number, eps: number): boolean
|
||||
return math.abs(a - b) <= eps * math.max(1, math.abs(a), math.abs(b))
|
||||
end
|
||||
|
||||
-- placed primitives, triangles, corners
|
||||
local function counts(scene: any): (number, number, number)
|
||||
local prims, faces, corners = 0, 0, 0
|
||||
local seen = {}
|
||||
@@ -92,9 +87,7 @@ local function bstr(lo: any, hi: any): string
|
||||
return string.format("(%.4g %.4g %.4g) (%.4g %.4g %.4g)", lo[1], lo[2], lo[3], hi[1], hi[2], hi[3])
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
-- assimp ignores the camera / light frame of their children (CameraRollAnimWithChildObject: a box linked to the
|
||||
-- camera); our bounds follow the mesh matrices there (checked below)
|
||||
-- assimp ignores the camera / light frame of their children (CameraRollAnimWithChildObject); ours follow the mesh matrices
|
||||
local ASSIMP_BOUNDS_DIFFER = { ["assimp/models/CameraRollAnimWithChildObject.3ds"] = true }
|
||||
local function boundsDiffer(i: number): boolean
|
||||
return ASSIMP_BOUNDS_DIFFER[Cases[i].name] == true
|
||||
@@ -172,7 +165,6 @@ do
|
||||
t:note("%d keyframer scenes match their stored vertices", n)
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ round trips
|
||||
local function triArea(prim: any): number
|
||||
local P = S.reader(prim.attributes.POSITION) :: any
|
||||
local I = S.reader(prim.indices) :: any
|
||||
@@ -187,7 +179,6 @@ local function triArea(prim: any): number
|
||||
return area
|
||||
end
|
||||
|
||||
-- the world matrices of the nodes with a camera / light, in tree order
|
||||
local function worldOf(s: any, field: string): { { number } }
|
||||
local out = {}
|
||||
local function visit(i: number, parent: { number })
|
||||
@@ -206,7 +197,6 @@ local function worldOf(s: any, field: string): { { number } }
|
||||
return out
|
||||
end
|
||||
|
||||
-- channel value at a time (LINEAR / STEP; quaternions lerped the short way)
|
||||
local function evalCh(ch: any, time: number, comps: number): { number }
|
||||
local IN, OUT = S.reader(ch.input) :: any, S.reader(ch.output) :: any
|
||||
local n = ch.input.count
|
||||
@@ -243,7 +233,6 @@ local function evalCh(ch: any, time: number, comps: number): { number }
|
||||
return v(n - 1)
|
||||
end
|
||||
|
||||
-- the world matrix of every named node at a time (animations[1] applied)
|
||||
local function posed(s: any, time: number): { [string]: { number } }
|
||||
local byNode: { [number]: { [string]: any } } = {}
|
||||
local anim = s.animations[1]
|
||||
@@ -349,7 +338,6 @@ local function compare(a: any, b: any, label: string, eps: number, animTimes: {
|
||||
t:check(near(hfov(c), hfov(c2), 1e-5), label .. ": camera " .. k .. " fov")
|
||||
end
|
||||
end
|
||||
-- one timeline: the first animation's node transforms
|
||||
local trs = false
|
||||
for _, ch in (if a.animations[1] then a.animations[1].channels else {}) :: { any } do
|
||||
trs = trs or ch.path ~= "weights"
|
||||
@@ -406,7 +394,6 @@ for i, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- glTF sample models through 3DS
|
||||
local gltfScenes = {}
|
||||
local ng = 0
|
||||
for gi, g in Picks do
|
||||
@@ -435,8 +422,6 @@ for gi, g in Picks do
|
||||
end
|
||||
t:note("%d reference files and %d glTF models through our writer and back", nrt, ng)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ cross-check
|
||||
-- assimp reads our files like the originals
|
||||
local nx = 0
|
||||
for _, x in Xcheck do
|
||||
local a = x.assimp
|
||||
@@ -468,7 +453,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read back by assimp", nx)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ details
|
||||
do
|
||||
local byName = {}
|
||||
for i, c in Cases do
|
||||
@@ -530,7 +514,6 @@ do
|
||||
end
|
||||
t:check(types.point and types.spot, "omni and spot lights")
|
||||
end
|
||||
-- the api
|
||||
local s = F.load(Cases[1].data)
|
||||
t:check(s and s.kind == "scene" and s.meta.source.format == "3ds", "F.load detects 3DS")
|
||||
local viaApi = F.save(s, nil, { format = "3ds" })
|
||||
@@ -564,7 +547,6 @@ do
|
||||
t:eq(back.nodes[2].name, "copy", "instance name")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local empty = decode("MM\6\0\0\0")
|
||||
t:check(empty and #empty.meshes == 0 and #empty.nodes == 0, "an empty main chunk: an empty scene")
|
||||
@@ -581,7 +563,6 @@ do
|
||||
t:eq(ThreeDs.sniff(Bytes.reader(buffer.fromstring("MM junk junk junk"))), 0, "sniff junk")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Cases do
|
||||
|
||||
+2
-17
@@ -1,9 +1,5 @@
|
||||
-- model/3mf tests: the lib3mf test suite and SDK files, assimp's box.3mf and files from assimp's / trimesh's 3MF
|
||||
-- exporters against lib3mf (world triangles, area, bounds through build items and components; unit), assimp and
|
||||
-- trimesh; our writer's output read back by lib3mf / assimp / trimesh (3mf_xcheck); round trips through our own reader
|
||||
-- (materials, vertex colours, textures, hierarchy, units); hand-written packages for per-corner colour / texture
|
||||
-- groups, composite and multiproperties, components across model parts (p:path), units; error codes; the fuzz
|
||||
-- no-throw pass. Fixtures: tools/fixtures/3mf.py.
|
||||
-- model/3mf tests: lib3mf's suite and SDK files, assimp and trimesh exports, against lib3mf, assimp and trimesh.
|
||||
-- Fixtures: tools/fixtures/3mf.py.
|
||||
local T = require("@tests/T")
|
||||
local ThreeMf = require("@rosetta/model/3mf")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -28,7 +24,6 @@ local function near(a: number, b: number, eps: number): boolean
|
||||
return math.abs(a - b) <= eps * math.max(1, math.abs(a), math.abs(b))
|
||||
end
|
||||
|
||||
-- world-space triangles, area and bounds of every placed primitive
|
||||
local function metrics(scene: any): (number, number, { number }, { number })
|
||||
local tris, area = 0, 0
|
||||
local lo, hi = { math.huge, math.huge, math.huge }, { -math.huge, -math.huge, -math.huge }
|
||||
@@ -75,7 +70,6 @@ local function boundsNear(lo: { number }, hi: { number }, rmin: { number }, rmax
|
||||
return true
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
local UNIT_NAMES = { micron = 1e-6, millimeter = 1e-3, centimeter = 1e-2, inch = 0.0254, foot = 0.3048, meter = 1 }
|
||||
local refCount, rejectedOk, unsupported = 0, 0, 0
|
||||
local byIndex = {}
|
||||
@@ -115,7 +109,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files: %d against lib3mf, %d rejected by lib3mf (decoded without throwing), %d secure content (UNSUPPORTED)", #Cases, refCount, rejectedOk, unsupported)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ our output read back
|
||||
local xchecked, withTextures = 0, 0
|
||||
for _, x in Xcheck do
|
||||
local c = Cases[x.case]
|
||||
@@ -159,7 +152,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read back by lib3mf / assimp / trimesh like the originals (%d with textures)", xchecked, withTextures)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ round trips (ours)
|
||||
local rts = 0
|
||||
for i, c in Cases do
|
||||
local scene = byIndex[i]
|
||||
@@ -173,7 +165,6 @@ for i, c in Cases do
|
||||
t:eq(a2, a1, c.name .. ": round trip triangles")
|
||||
t:check(near(b2, b1, 1e-6), c.name .. ": round trip area")
|
||||
t:eq(back.meta.unit, scene.meta.unit, c.name .. ": round trip unit")
|
||||
-- textures: the same bytes
|
||||
local used = 0
|
||||
for _, m in back.materials do
|
||||
if m.baseColorTexture then
|
||||
@@ -186,7 +177,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d round trips through our writer", rts)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ hand-written packages
|
||||
local function package(model: string, extra: { [string]: string }?): buffer
|
||||
local w = Zip.writer()
|
||||
w:add("[Content_Types].xml", '<?xml version="1.0"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="model" ContentType="application/vnd.ms-package.3dmanufacturing-3dmodel+xml"/></Types>', { method = "store" })
|
||||
@@ -232,7 +222,6 @@ do -- per-corner colours: vertex 0 has two different colours -> split
|
||||
t:check(math.abs(col[8] - 128 / 255) < 1e-6, "colours: alpha kept linear")
|
||||
t:eq(s.nodes[1].matrix[13], 10, "colours: transform tx")
|
||||
t:eq(s.nodes[1].matrix[15], 30, "colours: transform tz")
|
||||
-- through our writer and back: the same colours
|
||||
local back = decode((ThreeMf.encode(s)))
|
||||
local col2 = f32s(back.meshes[1].primitives[1].attributes.COLOR_0)
|
||||
local same = #col2 == #col
|
||||
@@ -285,7 +274,6 @@ do -- base materials, object defaults, composite, multiproperties, textures
|
||||
t:eq(s.materials[prims[4].material].name, "half", "materials: multiproperties -> first layer")
|
||||
t:eq(prims[4].indices.count, 6, "materials: multi and base 'half' share a primitive")
|
||||
t:check(math.abs(s.materials[prims[4].material].baseColor[1] - half ^ 2.4) < 1e-6, "materials: sRGB -> linear")
|
||||
-- round trip: texture + materials survive
|
||||
local out = assert(ThreeMf.encode(s))
|
||||
local back = assert(decode(out))
|
||||
local tm = nil
|
||||
@@ -375,7 +363,6 @@ do -- a Scene built by hand: strips, fans, polygons, vertex colours + texture co
|
||||
t:check(select(2, ThreeMf.encode({} :: any)).code == Err.ARG, "encode: not a scene")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e1 = decode("not a zip at all")
|
||||
t:check(e1 and e1.code ~= nil, "errors: not a zip")
|
||||
@@ -395,13 +382,11 @@ do
|
||||
t:eq(e6 and e6.code, Err.LIMIT, "errors: maxVertices")
|
||||
table.insert(samples, package(bad))
|
||||
table.insert(samples, package(cyc))
|
||||
-- sniff
|
||||
t:eq(ThreeMf.sniff(Bytes.reader(package(bad))), 0.95, "sniff: a 3MF package")
|
||||
t:eq(ThreeMf.sniff(Bytes.reader((w:finish()))), 0, "sniff: another zip")
|
||||
t:eq(ThreeMf.sniff(Bytes.reader(buffer.fromstring("solid x"))), 0, "sniff: not a zip")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
for _, c in Cases do
|
||||
if #c.data < 20000 then
|
||||
|
||||
+4
-11
@@ -1,6 +1,4 @@
|
||||
-- tests/model/_rbx: helpers shared by the model/rbxm and model/rbxmx tests: instance paths (the scheme of the lune dump
|
||||
-- in tools/fixtures/rbxmx.py), our property values in lune's canonical form, a dump comparison, a deep tree comparison,
|
||||
-- and a tree with a value of every type built from scratch.
|
||||
-- tests/model/_rbx: helpers shared by the rbxm and rbxmx tests (instance paths as in tools/fixtures/rbxmx.py's lune dump).
|
||||
local Rbx = require("@rosetta/codecs/model/Rbx")
|
||||
|
||||
local H = {}
|
||||
@@ -17,7 +15,7 @@ local function hex(s: string): string
|
||||
end))
|
||||
end
|
||||
|
||||
-- paths(tree) -> { [path] = instance }, { [instance] = path }: names joined with "/", "#k" for the k-th sibling of a name
|
||||
-- names joined with "/", "#k" for the k-th sibling of a name
|
||||
function H.paths(tree: any): ({ [string]: any }, { [any]: string })
|
||||
local byPath, ofInst = {}, {}
|
||||
local function walk(list: { any }, prefix: string)
|
||||
@@ -54,7 +52,6 @@ local function numbers(t: string, v: any): { number }?
|
||||
return v
|
||||
end
|
||||
|
||||
-- same(ours: Value, want: lune canon, pathOf, propName) -> ok, detail
|
||||
function H.same(v: any, want: any, pathOf: { [any]: string }, pname: string): (boolean, string)
|
||||
local t = if v then v.type else "nil"
|
||||
local x = if v then v.value else nil
|
||||
@@ -101,7 +98,6 @@ function H.same(v: any, want: any, pathOf: { [any]: string }, pname: string): (b
|
||||
return true, ""
|
||||
end
|
||||
|
||||
-- compare(t, tree, dump, label) -> properties compared: every instance / property of a lune dump against our tree
|
||||
function H.compare(t: any, tree: any, dump: any, label: string): number
|
||||
local byPath, pathOf = H.paths(tree)
|
||||
local n = 0
|
||||
@@ -121,7 +117,7 @@ function H.compare(t: any, tree: any, dump: any, label: string): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- the type family a value compares under (a binary file has one string type; XML writes BrickColor as an int)
|
||||
-- a binary file has one string type; XML writes BrickColor as an int
|
||||
local FAMILY: { [string]: string } = {
|
||||
String = "string",
|
||||
BinaryString = "string",
|
||||
@@ -135,7 +131,6 @@ local function family(t: string): string
|
||||
return FAMILY[t] or t
|
||||
end
|
||||
|
||||
-- equal(a, b, pathA, pathB) -> ok, where: values compared deeply (Refs / Content objects by path)
|
||||
local function equal(a: any, b: any, pa: { [any]: string }, pb: { [any]: string }): boolean
|
||||
if type(a) ~= type(b) then
|
||||
return false
|
||||
@@ -161,8 +156,7 @@ local function equal(a: any, b: any, pa: { [any]: string }, pb: { [any]: string
|
||||
return true
|
||||
end
|
||||
|
||||
-- sameTree(t, a, b, label, opts?) -> instances compared: class, name, children and every property (opts.loose:
|
||||
-- string / int families compare as one type, properties only b has are allowed when another instance of the class has them in a; opts.skipRaw: Raw values are not compared)
|
||||
-- opts.loose: string / int families compare as one type; properties only b has are allowed when another instance of the class has them in a
|
||||
function H.sameTree(t: any, a: any, b: any, label: string, opts: any?): number
|
||||
local o = opts or {}
|
||||
local pa = select(2, H.paths(a))
|
||||
@@ -222,7 +216,6 @@ function H.sameTree(t: any, a: any, b: any, label: string, opts: any?): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- everything() -> a model with one value of every type (and several instances per class)
|
||||
function H.everything(): any
|
||||
local tree = Rbx.tree()
|
||||
local root = Rbx.add(tree, Rbx.instance("Model", "Everything"))
|
||||
|
||||
+3
-10
@@ -1,5 +1,4 @@
|
||||
-- tests/model/_soup: helpers for the game model tests: a primitive's triangle soup (positions, morph target frames,
|
||||
-- texture coordinates in index order) and a tolerant comparison against assimp's soup.
|
||||
-- tests/model/_soup: triangle soups of a primitive and a tolerant comparison against assimp's soup.
|
||||
local Types = require("@rosetta/Types")
|
||||
|
||||
local Soup = {}
|
||||
@@ -20,8 +19,7 @@ function Soup.positions(prim: any, target: number?): buffer
|
||||
return out
|
||||
end
|
||||
|
||||
-- uvs(prim, set?, flip?) -> { u, v, ... } of the corners in index order (flip: v -> 1 - v, assimp's convention;
|
||||
-- "neg": v -> -v, assimp's Half-Life loader)
|
||||
-- flip: v -> 1 - v (assimp's convention); "neg": v -> -v (assimp's Half-Life loader)
|
||||
function Soup.uvs(prim: any, set: number?, flip: (boolean | string)?): { number }
|
||||
local tc = Types.Scene.reader(prim.attributes["TEXCOORD_" .. (set or 0)]) :: any
|
||||
local idx = prim.indices
|
||||
@@ -34,7 +32,6 @@ function Soup.uvs(prim: any, set: number?, flip: (boolean | string)?): { number
|
||||
return out
|
||||
end
|
||||
|
||||
-- close(a: buffer f32 | {number}, b: {number}, tol) -> true | false, first index that differs
|
||||
function Soup.close(a: any, b: { number }, tol: number): (boolean, number?)
|
||||
local n = if type(a) == "buffer" then buffer.len(a) // 4 else #a
|
||||
if n ~= #b then
|
||||
@@ -49,9 +46,7 @@ function Soup.close(a: any, b: { number }, tol: number): (boolean, number?)
|
||||
return true, nil
|
||||
end
|
||||
|
||||
-- triangles(a, b, tol, stride?) -> true when the triangle lists a and b (flat numbers, stride per corner: 3 for
|
||||
-- positions, 2 for texture coordinates) hold the same triangles in the same order, each up to a cyclic rotation of
|
||||
-- its corners (assimp rotates them); false, the first differing triangle otherwise
|
||||
-- triangles compare up to a cyclic rotation of their corners (assimp rotates them)
|
||||
function Soup.triangles(a: { number }, b: { number }, tol: number, stride: number?): (boolean, number?)
|
||||
local s = stride or 3
|
||||
if #a ~= #b then
|
||||
@@ -82,7 +77,6 @@ function Soup.triangles(a: { number }, b: { number }, tol: number, stride: numbe
|
||||
return true, nil
|
||||
end
|
||||
|
||||
-- list(buf) -> the f32 values of a buffer as numbers
|
||||
function Soup.list(b: buffer): { number }
|
||||
local out = table.create(buffer.len(b) // 4)
|
||||
for i = 0, buffer.len(b) // 4 - 1 do
|
||||
@@ -91,7 +85,6 @@ function Soup.list(b: buffer): { number }
|
||||
return out
|
||||
end
|
||||
|
||||
-- slice(list, from, n) -> n values from index from (1-based)
|
||||
function Soup.slice(list: { number }, from: number, n: number): { number }
|
||||
return table.move(list, from, from + n - 1, 1, table.create(n))
|
||||
end
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- tests/model/_vrml_common: helpers shared by the VRML and X3D tests (tests/model/vrml.luau, x3d.luau): counts over
|
||||
-- placed primitives (instances count, as the reference readers count them) and world bounds that include lines and
|
||||
-- points (MeshOps.merge skips them).
|
||||
-- tests/model/_vrml_common: VRML / X3D counts as the reference readers count them; bounds include lines and points.
|
||||
local Types = require("@rosetta/Types")
|
||||
|
||||
local C = {}
|
||||
|
||||
+2
-10
@@ -1,8 +1,5 @@
|
||||
-- model/b3d tests: assimp's Blitz3D models (WusonBlitz, dwarf2, turtle1) and generated files (textures, brushes,
|
||||
-- vertex colours, two UV sets, nested rotated / scaled / mirrored nodes, pivots, master brushes, bones, keys + ANIM)
|
||||
-- against assimp (meshes, faces, materials, animations, channels, bones; world bounds, triangle area and signed
|
||||
-- volume from its PreTransformVertices export: the left- to right-handed conversion and the winding) and the counts
|
||||
-- the generator wrote; the skin's bind pose; error codes; the fuzz no-throw pass. Fixtures: tools/fixtures/b3d.py.
|
||||
-- model/b3d tests: assimp's Blitz3D models and generated files against assimp (PreTransformVertices export).
|
||||
-- Fixtures: tools/fixtures/b3d.py.
|
||||
local T = require("@tests/T")
|
||||
local B3d = require("@rosetta/model/b3d")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -28,7 +25,6 @@ local function near(a: number, b: number, eps: number): boolean
|
||||
return math.abs(a - b) <= eps * math.max(1, math.abs(a), math.abs(b))
|
||||
end
|
||||
|
||||
-- world triangles of the merged scene: area and signed volume
|
||||
local function measure(prim: any): (number, number)
|
||||
local get = assert(Types.Scene.reader(prim.attributes.POSITION))
|
||||
local idx = prim.indices and Types.Scene.reader(prim.indices)
|
||||
@@ -76,7 +72,6 @@ local function boneCount(scene: any): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ cases
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
local scene, err = decode(c.data, { files = c.files })
|
||||
@@ -119,7 +114,6 @@ for _, c in Cases do
|
||||
if not (c.want and c.want.mirrored) then
|
||||
t:check(near(vol, a.volume, 1e-3), string.format("%s: signed volume %.6g (assimp %.6g)", c.name, vol, a.volume))
|
||||
end
|
||||
-- textures resolved through files
|
||||
for _, tex in scene.textures do
|
||||
local base = string.match(tex.uri, "([^/\\]+)$")
|
||||
t:check((tex.data ~= nil) == (c.files[base] ~= nil), c.name .. ": texture data " .. tostring(tex.uri))
|
||||
@@ -203,7 +197,6 @@ for _, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e = decode("BB3D\4\0\0\0\1\0\0\0")
|
||||
t:check(e and e.code == Err.CORRUPT, "no NODE: CORRUPT")
|
||||
@@ -218,7 +211,6 @@ do
|
||||
t:check(e3 and e3.code == Err.LIMIT, "maxVertices: LIMIT")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
t:fuzz("decode", function(b: buffer)
|
||||
local s = B3d.decode(Bytes.reader(b))
|
||||
if s then
|
||||
|
||||
+2
-12
@@ -1,8 +1,4 @@
|
||||
-- model/bsp tests: Quake 1, Half-Life, Quake II and Quake III maps written by tools/fixtures/bsp.py: every model's
|
||||
-- triangles per texture (positions, normals, texture coordinates against the documented rules), counter-clockwise
|
||||
-- about the face normals, embedded textures (Quake through the palette, Half-Life through its own), WAD / .wal
|
||||
-- textures as URIs, entities; Quake III: polygon / mesh faces against assimp's soup (of a .pk3) and the writer,
|
||||
-- lightmaps, vertex colours, a tessellated patch; errors; the fuzz pass.
|
||||
-- model/bsp tests: generated Quake 1 / Half-Life / Quake II / Quake III maps; Quake III faces against assimp.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Bsp = require("@rosetta/model/bsp")
|
||||
@@ -81,7 +77,6 @@ local function brush(label: string, c: any, opts: any)
|
||||
return s
|
||||
end
|
||||
|
||||
-- 1. Quake 1, Half-Life
|
||||
do
|
||||
local q1 = brush("q1", Fx.q1, { palette = Fx.q1.palette })
|
||||
t:eq(Crc32.of(q1.textures[1].image.pixels), Fx.q1.textures[1], "q1: embedded texture through the palette")
|
||||
@@ -94,7 +89,6 @@ do
|
||||
t:eq(grey.meta.source.palette, false, "q1 without a palette: grey")
|
||||
end
|
||||
|
||||
-- 2. Quake II
|
||||
do
|
||||
local q2 = brush("q2", Fx.q2, { files = { ["textures/brick.wal"] = Fx.q2.wal } })
|
||||
t:eq(q2.textures[1].uri, "textures/brick.wal", "q2: .wal URI")
|
||||
@@ -102,7 +96,6 @@ do
|
||||
t:eq(q2.materials[2].extras.bsp.texels, true, "q2: texel coordinates without the .wal")
|
||||
end
|
||||
|
||||
-- 3. Quake III
|
||||
do
|
||||
local q = Fx.q3
|
||||
local s, err = Bsp.decode(Bytes.reader(buffer.fromstring(q.data)))
|
||||
@@ -137,7 +130,6 @@ do
|
||||
t:check(windingOk(prim), "q3: " .. key .. " counter-clockwise about the normals")
|
||||
end
|
||||
end
|
||||
-- assimp: the polygon / mesh faces
|
||||
local all = {}
|
||||
local apos = q.assimp.pos
|
||||
for _, mesh in s.meshes do
|
||||
@@ -153,8 +145,7 @@ do
|
||||
end
|
||||
end
|
||||
t:eq(q.assimp.faces, 6, "q3: assimp reads the 3 quads")
|
||||
-- compare triangle sets: every assimp triangle is one of ours (up to corner rotation); assimp keeps the stored
|
||||
-- clockwise order, we reverse it
|
||||
-- every assimp triangle is one of ours (up to corner rotation): assimp keeps the stored clockwise order, we reverse it
|
||||
local found = 0
|
||||
for k = 0, #apos // 9 - 1 do
|
||||
local tri = Soup.slice(apos, k * 9 + 1, 9)
|
||||
@@ -198,7 +189,6 @@ do
|
||||
t:check(lean ~= nil, "q3: patchLevel 1")
|
||||
end
|
||||
|
||||
-- 4. errors, fuzz
|
||||
do
|
||||
local _, e1 = Bsp.decode(Bytes.reader(buffer.fromstring(string.sub(Fx.q1.data, 1, 100))))
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "truncated: " .. tostring(e1))
|
||||
|
||||
+2
-16
@@ -1,10 +1,5 @@
|
||||
-- model/dae tests: assimp's Collada test models (triangles / polylist / polygons / tristrips, UTF-16 and BOM files,
|
||||
-- decimal commas, 2 UV sets, vertex colours, instance_node, cameras, lights, nested / clipped / full-rotation
|
||||
-- animations, skins, .zae) and glTF samples exported by assimp's Collada exporter, against `assimp info -r` (meshes,
|
||||
-- faces, bounds in assimp's space, materials, animations, cameras, lights), and against the glTF originals read by
|
||||
-- model/gltf (skinned rest-pose bounds, joints, every LINEAR animation key); our writer's output read back by assimp
|
||||
-- (dae_xcheck) and by us (round trips, .dae and .zae); polygons kept with triangulate = false; textures decoded lazily
|
||||
-- at the api layer; errors; the fuzz no-throw pass. Fixtures: tools/fixtures/dae.py.
|
||||
-- model/dae tests: assimp's Collada models and exports against `assimp info -r` and the glTF originals.
|
||||
-- Fixtures: tools/fixtures/dae.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Dae = require("@rosetta/model/dae")
|
||||
@@ -68,7 +63,6 @@ local function counts(scene: any): (number, number)
|
||||
end
|
||||
|
||||
local function inverse(m: { number }): { number }
|
||||
-- general 4x4 inverse (column-major; cofactors)
|
||||
local inv = table.create(16, 0)
|
||||
local a = m
|
||||
inv[1] = a[6] * a[11] * a[16] - a[6] * a[12] * a[15] - a[10] * a[7] * a[16] + a[10] * a[8] * a[15] + a[14] * a[7] * a[12] - a[14] * a[8] * a[11]
|
||||
@@ -145,7 +139,6 @@ local function assimpBounds(scene: any, written: boolean?): ({ number }?, { numb
|
||||
return lo, hi
|
||||
end
|
||||
|
||||
-- world matrices (correct order) of every node
|
||||
local function worlds(scene: any): { [number]: { number } }
|
||||
local w = {}
|
||||
local function visit(i: number, parent: { number })
|
||||
@@ -222,7 +215,6 @@ local function lightCount(scene: any): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- a channel's value at time tm (LINEAR; rotations nlerped)
|
||||
local function channelAt(ch: any, tm: number): { number }
|
||||
local inp, out = Scene.reader(ch.input) :: any, Scene.reader(ch.output) :: any
|
||||
local n, c = ch.input.count, ch.output.components
|
||||
@@ -280,7 +272,6 @@ for i, c in Cases do
|
||||
t:eq(#scene.animations, ref.animations, c.name .. ": animations (assimp)")
|
||||
checked.assimp += 1
|
||||
end
|
||||
-- against the glTF original of an assimp export
|
||||
if c.gltf then
|
||||
local g, gerr = Gltf.decode(Bytes.reader(buffer.fromstring(c.gltf)), { files = c.gltfFiles })
|
||||
t:check(g, c.name .. ": gltf original: " .. tostring(gerr))
|
||||
@@ -374,7 +365,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:check(worst >= math.cos(math.rad(45)) - 1e-6, "full rotations: subdivided (worst dot " .. worst .. ")")
|
||||
end
|
||||
-- round trip through our writer (.dae, and .zae for a few)
|
||||
local tri = decode(c.data, { files = c.files })
|
||||
decoded[i] = tri
|
||||
local files = {}
|
||||
@@ -413,7 +403,6 @@ for i, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- assimp reads what we wrote like the source
|
||||
for _, x in Xcheck do
|
||||
local src = decoded[x.case]
|
||||
local ref = x.assimp
|
||||
@@ -432,7 +421,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
end
|
||||
|
||||
-- polygons: kept or fan-triangulated
|
||||
local function case(name: string): any
|
||||
for i, c in Cases do
|
||||
if string.find(c.name, name, 1, true) then
|
||||
@@ -540,7 +528,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- api: F.load by content / extension
|
||||
do
|
||||
local c = case("cube_tristrips")
|
||||
if c then
|
||||
@@ -551,7 +538,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e1 = decode('<?xml version="1.0"?><root/>')
|
||||
t:check(e1 and e1.code == Err.CORRUPT, "not COLLADA: CORRUPT")
|
||||
|
||||
+2
-20
@@ -1,10 +1,5 @@
|
||||
-- model/fbx tests: assimp's FBX test models (binary 7.4 / 7.5, ASCII 7.4 - 7.7, embedded textures, skeletons,
|
||||
-- animation), Blender's exporter (materials, textures, colours, skin, shape keys, animation, camera, lights) and
|
||||
-- assimp's exporters (binary and ASCII), against assimp (meshes, polygons, vertices, world bounds, materials,
|
||||
-- animations, cameras, lights) and Blender's importer (meshes, polygons, materials, bones, shape keys, cameras,
|
||||
-- lights, images); round trips through our writer (binary and ASCII) and glTF sample models through FBX (world
|
||||
-- triangles, materials, textures, skins, morph targets, sampled animation, cameras, lights); assimp and Blender
|
||||
-- reading our files like the originals (fbx_xcheck); errors; the fuzz no-throw pass. Fixtures: tools/fixtures/fbx.py.
|
||||
-- model/fbx tests: assimp's FBX models, Blender and assimp exports, against assimp and Blender's importer.
|
||||
-- Fixtures: tools/fixtures/fbx.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Fbx = require("@rosetta/model/fbx")
|
||||
@@ -51,7 +46,6 @@ local function triArea(prim: any): number
|
||||
return area
|
||||
end
|
||||
|
||||
-- assimp-like counts: placed primitives, polygons, corners
|
||||
local function counts(scene: any): (number, number, number)
|
||||
local prims, faces, verts = 0, 0, 0
|
||||
local seen = {}
|
||||
@@ -109,7 +103,6 @@ local function boundsMatch(lo: { number }, hi: { number }, want: any, eps: numbe
|
||||
return eq({ lo[1], lo[3], -hi[2] }, { hi[1], hi[3], -lo[2] }, want.min, want.max)
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
local checked = { assimp = 0, blender = 0, roundTrips = 0, failed = 0 }
|
||||
local scenes = {}
|
||||
for i, c in Cases do
|
||||
@@ -152,8 +145,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files: %d against assimp, %d against Blender, %d rejected by both", #Cases, checked.assimp, checked.blender, checked.failed)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ round trips
|
||||
-- world triangles (area, count, bounds), materials, textures, skins, morph targets, animation samples, cameras, lights
|
||||
local function compare(a: any, b: any, label: string, eps: number)
|
||||
local ma, mb = MeshOps.merge(a), MeshOps.merge(b)
|
||||
local na = if ma and ma.indices then ma.indices.count // 3 else 0
|
||||
@@ -281,7 +272,6 @@ local function compare(a: any, b: any, label: string, eps: number)
|
||||
for ai, an in a.animations do
|
||||
local bn = b.animations[ai]
|
||||
if bn then
|
||||
-- channels by node name + path
|
||||
local byKey = {}
|
||||
for _, ch in an.channels do
|
||||
byKey[(a.nodes[ch.node].name or "") .. "/" .. ch.path] = ch
|
||||
@@ -336,7 +326,6 @@ for i, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- glTF sample models through FBX
|
||||
local ng = 0
|
||||
for _, g in GltfCases do
|
||||
local scene, gerr = Gltf.decode(Bytes.reader(buffer.fromstring(g.data)), { files = g.files })
|
||||
@@ -365,8 +354,6 @@ for _, g in GltfCases do
|
||||
end
|
||||
t:note("%d round trips of the reference files (binary + ASCII), %d glTF models through FBX", checked.roundTrips, ng)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ cross-check
|
||||
-- assimp and Blender read our files like the originals
|
||||
local nx = 0
|
||||
for _, x in Xcheck do
|
||||
local c = Cases[x.case]
|
||||
@@ -403,7 +390,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read back by assimp / Blender like the originals", nx)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ details
|
||||
do
|
||||
local byName = {}
|
||||
for i, c in Cases do
|
||||
@@ -463,10 +449,8 @@ do
|
||||
t:check(emb.textures[1] and emb.textures[1].data and emb.meta.source.binary == false, "ASCII: base64 embedded texture")
|
||||
t:eq(emb.meta.up, "z", "3ds Max: Z up")
|
||||
end
|
||||
-- polygons kept / triangulated
|
||||
local box = decode(Cases[2].data)
|
||||
t:check(box.meshes[1].primitives[1].mode == "triangles", "triangulated by default")
|
||||
-- through the api
|
||||
local s = F.load(Cases[2].data)
|
||||
t:check(s and s.kind == "scene" and s.meta.source.format == "fbx", "F.load detects binary FBX")
|
||||
local viaApi = F.save(s, nil, { format = "fbx" })
|
||||
@@ -493,7 +477,6 @@ do
|
||||
t:check(qb and qb.meshes[1].primitives[1].faces.count == 1 and qb.meshes[1].primitives[1].indices.count == 4, "a quad stays one polygon")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e1 = decode("; FBX 6.1.0 project file\nFBXHeaderExtension: {\n\tFBXVersion: 6100\n}\n")
|
||||
t:check(e1 and e1.code == Err.UNSUPPORTED, "FBX 6: " .. tostring(e1))
|
||||
@@ -514,7 +497,6 @@ do
|
||||
t:check(e8 and e8.code == Err.ARG, "encode version 6100")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Cases do
|
||||
|
||||
+2
-13
@@ -1,9 +1,5 @@
|
||||
-- model/gltf tests: Khronos glTF-Sample-Assets models (JSON with external / embedded buffers, GLB, sparse, interleaved,
|
||||
-- quantized, morph targets, skins, animations, cameras, lights, texture transforms, material extensions), gltfpack
|
||||
-- quantized variants and assimp's exporter output, against assimp (meshes, faces, bounds, animations, cameras,
|
||||
-- lights) and trimesh (area, triangles); full-structure round trips through GLB, embedded .gltf and external files;
|
||||
-- assimp / trimesh reading our output (gltf_xcheck); textures decoded lazily at the api layer; errors; the fuzz
|
||||
-- no-throw pass. Fixtures: tools/fixtures/gltf.py.
|
||||
-- model/gltf tests: glTF-Sample-Assets, gltfpack and assimp output against assimp and trimesh; round trips.
|
||||
-- Fixtures: tools/fixtures/gltf.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Gltf = require("@rosetta/model/gltf")
|
||||
@@ -76,7 +72,6 @@ local function counts(scene: any): (number, number)
|
||||
return prims, faces
|
||||
end
|
||||
|
||||
-- every value of two scenes equal (buffers by content), meta skipped
|
||||
local function same(a: any, b: any, path: string, seen: { [any]: boolean }?, skip: { [string]: boolean }?): (boolean, string?)
|
||||
local s = seen or {}
|
||||
local sk = skip or { meta = true, extras = true }
|
||||
@@ -154,7 +149,6 @@ for i, c in Cases do
|
||||
end
|
||||
checked.trimesh += 1
|
||||
end
|
||||
-- round trips: GLB, embedded .gltf, external files
|
||||
local glb, gerr = Gltf.encode(scene, { binary = true })
|
||||
t:check(glb, c.name .. ": encode glb: " .. tostring(gerr))
|
||||
local back = decode(glb)
|
||||
@@ -179,7 +173,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files: %d against assimp, %d against trimesh, %d round trips", #Cases, checked.assimp, checked.trimesh, checked.roundTrips)
|
||||
|
||||
-- the reference tools read our files like the originals
|
||||
local nx = 0
|
||||
for _, x in Xcheck do
|
||||
local c = Cases[x.case]
|
||||
@@ -202,7 +195,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read back by assimp / trimesh like the originals", nx)
|
||||
|
||||
-- details
|
||||
do
|
||||
local function load(name: string): any
|
||||
local c = byName[name]
|
||||
@@ -298,7 +290,6 @@ do
|
||||
local out = Gltf.encode(s2, { binary = true }) :: buffer
|
||||
local back = decode(out)
|
||||
t:check(back and back.meshes[1].primitives[1].indices.count == 6 and back.meshes[1].primitives[1].attributes.COLOR_0.type == "unorm8", "polygons fan-triangulated, unorm8 VEC3 colours (padded stride)")
|
||||
-- through the api: the destination's extension picks GLB
|
||||
local viaApi = F.save(s2, nil, { format = "glb" })
|
||||
t:check(viaApi and buffer.readstring(viaApi, 0, 4) == "glTF", "F.save format glb")
|
||||
local viaApi2 = F.save(s2, nil, { format = "gltf" })
|
||||
@@ -307,7 +298,6 @@ do
|
||||
t:check(loaded and loaded.kind == "scene" and loaded.meta.source.format == "gltf", "F.load detects GLB")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e = decode("{ not json")
|
||||
t:check(e and (e.code == Err.CORRUPT or e.code == Err.TRUNCATED), "bad JSON: " .. tostring(e))
|
||||
@@ -330,7 +320,6 @@ do
|
||||
t:check(e8 and e8.code == Err.ARG, "encode a short accessor: " .. tostring(e8))
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
-- model/gltf KHR_draco_mesh_compression tests: the Khronos samples compressed by draco_transcoder (two quantizations),
|
||||
-- Draco's and assimp's Draco glTF files. Every Draco primitive against libdraco's decode of its buffer view (points,
|
||||
-- faces, index and attribute CRCs); the transcoded files against their uncompressed sources (meshes, primitives,
|
||||
-- nodes, materials, skins, animations, triangles, world bounds within the quantization step); the scene saved back
|
||||
-- (uncompressed, without the extension) and reloaded; the fuzz no-throw pass. Fixtures: tools/fixtures/gltf_draco.py.
|
||||
-- model/gltf KHR_draco_mesh_compression tests: Draco primitives against libdraco, transcoded files against their sources.
|
||||
-- Fixtures: tools/fixtures/gltf_draco.py.
|
||||
local T = require("@tests/T")
|
||||
local Gltf = require("@rosetta/model/gltf")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -62,7 +59,6 @@ for _, c in Cases do
|
||||
checked.prims += 1
|
||||
end
|
||||
end
|
||||
-- against the uncompressed source
|
||||
local o = c.original
|
||||
if o then
|
||||
local orig, oerr = decode(o.data, o.files)
|
||||
@@ -95,7 +91,6 @@ for _, c in Cases do
|
||||
checked.originals += 1
|
||||
end
|
||||
end
|
||||
-- saved back without the extension
|
||||
local glb = Gltf.encode(scene, { binary = true })
|
||||
t:check(glb, c.name .. ": encode")
|
||||
if glb then
|
||||
|
||||
+2
-14
@@ -1,8 +1,5 @@
|
||||
-- model/iqm tests: assimp's mrfixit.iqm against assimp (meshes, triangles, vertices, materials, bind pose bounds), an
|
||||
-- independent Python reader (joints, anims) and the bounds the IQM tool stored per frame (our decoded skeleton and
|
||||
-- animation, skinned here, must reproduce them); writer round trips (mrfixit, glTF sample models with and without
|
||||
-- skins) read back by our reader, by assimp and by the Python reader, whose skinning of our files must match ours;
|
||||
-- errors; the fuzz no-throw pass. Fixtures: tools/fixtures/iqm.py.
|
||||
-- model/iqm tests: mrfixit.iqm against assimp, a Python reader and the IQM tool's stored per-frame bounds.
|
||||
-- Fixtures: tools/fixtures/iqm.py.
|
||||
local T = require("@tests/T")
|
||||
local Iqm = require("@rosetta/model/iqm")
|
||||
local Gltf = require("@rosetta/model/gltf")
|
||||
@@ -31,7 +28,6 @@ t:check(Iqm.caps.decode and Iqm.caps.encode, "caps")
|
||||
local function near(a: number, b: number, eps: number): boolean
|
||||
return math.abs(a - b) <= eps * math.max(1, math.abs(a), math.abs(b))
|
||||
end
|
||||
-- the largest coordinate difference between two boxes
|
||||
local function boxDiff(lo: { number }, hi: { number }, want: any): number
|
||||
local d = 0
|
||||
for k = 1, 3 do
|
||||
@@ -64,7 +60,6 @@ local function counts(scene: any): (number, number, number)
|
||||
return prims, tris, verts
|
||||
end
|
||||
|
||||
-- the bounding box of every mesh vertex, skinned with the scene's skins at time t of anim (nil: the rest pose)
|
||||
local function skinnedBounds(scene: any, anim: any?, time: number): ({ number }, { number })
|
||||
local pose = if anim then Sampler.pose(scene, anim, time) else nil
|
||||
local parent = {}
|
||||
@@ -149,7 +144,6 @@ local function xcheck(name: string): any
|
||||
return nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ mrfixit
|
||||
local fixit = Cases[1]
|
||||
local scene, err = decode(fixit.data)
|
||||
t:check(scene, "mrfixit: decode " .. tostring(err))
|
||||
@@ -190,14 +184,12 @@ do
|
||||
t:check(scene.meta.source.bounds and #scene.meta.source.bounds == ref.frames, "mrfixit: bounds block read")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ round trips
|
||||
do
|
||||
local out = assert(Iqm.encode(scene))
|
||||
local back = assert(decode(out))
|
||||
local p1, t1, v1 = counts(scene)
|
||||
local p2, t2, v2 = counts(back)
|
||||
t:check(p1 == p2 and t1 == t2 and v1 == v2, "round trip: counts")
|
||||
-- positions and indices exact
|
||||
local same = true
|
||||
for mi, m in scene.meshes do
|
||||
local a, b = m.primitives[1], back.meshes[mi].primitives[1]
|
||||
@@ -235,7 +227,6 @@ do
|
||||
end
|
||||
end
|
||||
t:check(worst < 2e-3, "round trip: the animation skins the same (worst " .. worst .. ")")
|
||||
-- assimp and the Python reader on our file
|
||||
local x = assert(xcheck("rt_mrfixit.iqm"), "xcheck rt_mrfixit")
|
||||
t:eq(x.assimp.faces, fixit.assimp.faces, "round trip: assimp triangles")
|
||||
t:eq(x.assimp.vertices, fixit.assimp.vertices, "round trip: assimp vertices")
|
||||
@@ -250,7 +241,6 @@ do
|
||||
t:check(w3 < 1e-4, "round trip: our bounds block matches the Python skinning (worst " .. w3 .. ")")
|
||||
end
|
||||
|
||||
-- glTF sample models through the writer
|
||||
for _, p in Picks do
|
||||
local g = assert(Gltf.decode(Bytes.reader(buffer.fromstring(p.data)), { files = p.files }))
|
||||
local out, e = Iqm.encode(g)
|
||||
@@ -283,7 +273,6 @@ for _, p in Picks do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e1 = decode("INTERQUAKEMODEL\0")
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "short: " .. tostring(e1))
|
||||
@@ -303,7 +292,6 @@ do
|
||||
t:eq(Iqm.sniff(Bytes.reader(buffer.fromstring(fixit.data))), 1, "sniff")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local small = assert(Iqm.encode(assert(Gltf.decode(Bytes.reader(buffer.fromstring(Picks[2].data)), { files = Picks[2].files }))))
|
||||
local samples = { small, string.sub(fixit.data, 1, 20000) }
|
||||
|
||||
+2
-15
@@ -1,11 +1,5 @@
|
||||
-- model/ldraw tests: hand-written LDraw files (a brick of primitives found through library paths, an MPD with
|
||||
-- embedded parts and sub-models, BFC CW / CCW / INVERTNEXT / NOCLIP / uncertified files, mirrored references, colours
|
||||
-- 16 / 24 / direct / local !COLOUR, optional lines, a missing part, a self-reference, bad lines, CRLF) and real library
|
||||
-- parts and models (3001, 3062b, 4073, 3626c, car.ldr, pyramid.ldr) against an independent expansion in the generator
|
||||
-- (world triangles per colour, double-sided faces, lines, area, signed volume of the one-sided faces, bounds, missing
|
||||
-- files) and LeoCAD's OBJ export (bounds, area); node / flattened / un-flipped scenes agree; mesh sharing; the
|
||||
-- built-in colour table against LDConfig.ldr; resolve; error codes; the fuzz no-throw pass. Fixtures:
|
||||
-- tools/fixtures/ldraw.py.
|
||||
-- model/ldraw tests: hand-written and real LDraw files against the generator's own expansion and LeoCAD's OBJ export.
|
||||
-- Fixtures: tools/fixtures/ldraw.py.
|
||||
local T = require("@tests/T")
|
||||
local Ldraw = require("@rosetta/model/ldraw")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -33,7 +27,6 @@ t:check(Ldraw.sniff(Bytes.reader(buffer.fromstring("0 FILE main.ldr\n1 16 0 0 0
|
||||
t:check(Ldraw.sniff(Bytes.reader(buffer.fromstring("0 x\n1 16 0 0 0 1 0 0 0 1 0 0 0 1 3001.dat\n"))) >= 0.8, "sniff LDR")
|
||||
t:eq(Ldraw.sniff(Bytes.reader(buffer.fromstring("solid cube\n facet normal 0 0 1\n"))), 0, "sniff other")
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ colour table
|
||||
do
|
||||
local tbl = Ldraw.colors()
|
||||
local bad = 0
|
||||
@@ -48,7 +41,6 @@ do
|
||||
t:check(over[4].rgb == 0x010203 and over[4].edge == 0 and over[4].name == "Mine", "ldconfig overrides")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ measuring
|
||||
type Stats = { triangles: number, lines: number, optional: number, ds: number, area: number, volume: number, colours: { [number]: number } }
|
||||
|
||||
local function det3(m: { number }): number
|
||||
@@ -120,7 +112,6 @@ local function compare(label: string, s: Stats, w: any)
|
||||
t:check(near(s.volume, w.volume, 1e-5), string.format("%s: signed volume %.6f / %.6f", label, s.volume, w.volume))
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ cases
|
||||
local samples = {}
|
||||
local lib: any = nil
|
||||
for _, c in Cases do
|
||||
@@ -172,12 +163,10 @@ for _, c in Cases do
|
||||
table.insert(steps, scene.nodes[ci].extras.ldraw.step)
|
||||
end
|
||||
t:eq(table.concat(steps, ","), "1,1,1,2", "two.ldr: steps")
|
||||
-- through resolve instead of files
|
||||
local viaResolve = assert(decode(c.data, { resolve = function(uri: string): any
|
||||
return c.files[uri]
|
||||
end }))
|
||||
t:eq(measure(viaResolve).triangles, w.triangles, "two.ldr: resolve")
|
||||
-- optional lines on request
|
||||
local withOpt = assert(decode(c.data, { files = c.files, optionalLines = true, lines = false }))
|
||||
local so = measure(withOpt)
|
||||
t:check(so.optional == w.optional and so.lines == 0, "two.ldr: optional lines only")
|
||||
@@ -202,7 +191,6 @@ for _, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e = decode("")
|
||||
t:check(e and e.code == Err.CORRUPT, "empty: CORRUPT")
|
||||
@@ -214,7 +202,6 @@ do
|
||||
t:check(e and e.code == Err.LIMIT, "maxDepth: LIMIT")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
t:fuzz("decode", function(b: buffer)
|
||||
local s = Ldraw.decode(Bytes.reader(b), { files = lib, optionalLines = true })
|
||||
if s then
|
||||
|
||||
+2
-11
@@ -1,7 +1,5 @@
|
||||
-- model/lwo tests: assimp's LightWave test models (LWO2, LWOB, Modo LXOB) against assimp (meshes per layer and
|
||||
-- surface, polygons, corners, materials, world bounds); layer hierarchy and pivots, UV / colour / normal maps,
|
||||
-- surfaces and image blocks; a hand-built LWO2 (VMAD splits, MORF / SPOT targets, weight maps, lines, points, skipped
|
||||
-- curves, PTCH flag, derived surface, XREF clip); errors; the fuzz no-throw pass. Fixtures: tools/fixtures/lwo.py.
|
||||
-- model/lwo tests: assimp's LightWave models (LWO2, LWOB, LXOB) against assimp, and a hand-built LWO2.
|
||||
-- Fixtures: tools/fixtures/lwo.py.
|
||||
local T = require("@tests/T")
|
||||
local Lwo = require("@rosetta/model/lwo")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -25,7 +23,6 @@ local function near(a: number, b: number, eps: number): boolean
|
||||
return math.abs(a - b) <= eps * math.max(1, math.abs(a), math.abs(b))
|
||||
end
|
||||
|
||||
-- assimp's counts: one mesh per (layer, surface), polygons, corners
|
||||
local function counts(scene: any): (number, number, number)
|
||||
local meshes, faces, corners = 0, 0, 0
|
||||
for _, m in scene.meshes do
|
||||
@@ -52,7 +49,6 @@ local function find(name: string): any
|
||||
return nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ assimp
|
||||
local checked, scenes = 0, {}
|
||||
for i, c in Cases do
|
||||
local a = c.assimp
|
||||
@@ -77,7 +73,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:check(ok, string.format("%s: world bounds (assimp) %s / %s", c.name, if lo then table.concat(lo, " ") else "-", if hi then table.concat(hi, " ") else "-"))
|
||||
end
|
||||
-- triangulated: the same corners as triangles
|
||||
local tri = decode(c.data)
|
||||
t:check(tri and tri.meshes[1] and tri.meshes[1].primitives[1].mode ~= "polygons", c.name .. ": triangulated by default")
|
||||
checked += 1
|
||||
@@ -86,7 +81,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files checked against assimp", checked)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ details
|
||||
do
|
||||
local c = find("models/LWO2/hierarchy.lwo")
|
||||
local s = decode(c.data)
|
||||
@@ -159,7 +153,6 @@ do
|
||||
t:check(sb.materials[1].extras.lwo.glos ~= nil, "LWOB glossiness")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ hand-built LWO2
|
||||
local function be16(n: number): string
|
||||
return string.char(bit32.band(bit32.rshift(n, 8), 255), bit32.band(n, 255))
|
||||
end
|
||||
@@ -278,7 +271,6 @@ do
|
||||
t:check(ux * vy - uy * vx < 0, "hand-built: facing kept (LightWave +z normal -> glTF -z)")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e1 = decode("FORM\0\0\0\4LWO3")
|
||||
t:check(e1 and e1.code == Err.UNSUPPORTED, "LWO3: " .. tostring(e1))
|
||||
@@ -295,7 +287,6 @@ do
|
||||
t:eq(Lwo.sniff(Bytes.reader(buffer.fromstring("FORM\0\0\0\4AIFF"))), 0, "sniff AIFF")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = { quadFile() }
|
||||
for _, c in Cases do
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
-- model/mca tests: region files with 1.18+ chunks (each compression: zlib, gzip, stored, LZ4 block streams),
|
||||
-- 1.16 / 1.13 / 1.12 chunks (palettes non-spanning and spanning, numeric ids with Add nibbles) and an external .mcc
|
||||
-- chunk: every cell of the assembled grid against the fixture (a CRC of the cell texts), placement, the chunk list,
|
||||
-- block entities, opts.chunks / opts.area / maxCells, Mca.list / Mca.chunk, detection, errors and the fuzz pass.
|
||||
-- model/mca tests: region files of every chunk version and compression against the fixture's cell texts.
|
||||
-- Fixtures: tools/fixtures/mca.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
@@ -85,7 +82,6 @@ for _, c in Fx.regions do
|
||||
t:check(air > 0 and air < buffer.len(v.data), c.name .. ": colour grid")
|
||||
end
|
||||
|
||||
-- details on the 1.18+ region
|
||||
do
|
||||
local c = Fx.regions[1]
|
||||
local list = assert(Mca.list(reader(c.data)))
|
||||
@@ -94,7 +90,6 @@ do
|
||||
t:check(nbt and nbt.xPos == 3 and nbt.Status == "minecraft:full", "Mca.chunk")
|
||||
t:eq(comp, "lz4", "Mca.chunk compression")
|
||||
t:eq(Mca.chunk(reader(c.data), 9, 9), nil, "absent chunk")
|
||||
-- only some chunks / an area
|
||||
local one = assert(Mca.decode(reader(c.data), { chunks = { { 1, 0 } }, keepNbt = false }))
|
||||
t:eq(table.concat((one.voxels :: { Types.Voxels })[1].size, ","), "16,48,16", "opts.chunks")
|
||||
t:eq(one.meta.source.chunks[1].nbt, nil, "keepNbt = false")
|
||||
@@ -128,7 +123,6 @@ do
|
||||
t:check(F.save(viaApi, nil, { format = "schem" }) ~= nil, "region -> .schem")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local ext = Fx.regions[3]
|
||||
local _, e1 = Mca.decode(reader(ext.data))
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
-- model/md2 tests: MD2 files written by tools/fixtures/md2.py decode to assimp's frame-0 triangle soup (positions,
|
||||
-- texture coordinates) and to the writer's exact positions for every frame (base + morph target deltas), frame
|
||||
-- groups as animations, skins as texture URIs, opts.frame / morph = false, errors, the fuzz pass.
|
||||
-- model/md2 tests: generated MD2 files against assimp's frame-0 soup and the writer's exact frames.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Md2 = require("@rosetta/model/md2")
|
||||
@@ -19,12 +17,10 @@ for _, c in Fx do
|
||||
t:eq(F.detect(c.data), "md2", c.name .. ": F.detect")
|
||||
local prim = s.meshes[1].primitives[1]
|
||||
t:eq(prim.indices.count, c.tris * 3, c.name .. ": triangles")
|
||||
-- assimp, frame 0
|
||||
local ok, at = Soup.close(Soup.positions(prim), c.assimp.pos, 1e-5)
|
||||
t:check(ok, c.name .. ": positions against assimp (" .. tostring(at) .. ")")
|
||||
local uok, uat = Soup.close(Soup.uvs(prim, 0, true), c.assimp.uv, 1e-6)
|
||||
t:check(uok, c.name .. ": texture coordinates against assimp (" .. tostring(uat) .. ")")
|
||||
-- every frame, exact
|
||||
t:eq(Crc32.of(Soup.positions(prim)), c.crcs[1], c.name .. ": frame 1 exact")
|
||||
for k = 1, c.frames do
|
||||
local f = Soup.positions(prim, k)
|
||||
@@ -41,7 +37,6 @@ for _, c in Fx do
|
||||
end)(), 1e-5)
|
||||
t:check(fok, c.name .. ": morph target " .. k .. " = frame " .. k)
|
||||
end
|
||||
-- animations from the frame names
|
||||
local groups = {}
|
||||
for _, a in s.animations do
|
||||
table.insert(groups, a.name)
|
||||
@@ -52,7 +47,6 @@ for _, c in Fx do
|
||||
t:eq(table.concat(groups, ","), "stand,run,attack,pain", c.name .. ": animation groups")
|
||||
t:eq(s.animations[2].channels[1].input.count, 4, c.name .. ": run has 4 keys")
|
||||
end
|
||||
-- skins
|
||||
t:eq(#s.textures, #c.skins, c.name .. ": skins")
|
||||
if #c.skins > 0 then
|
||||
t:eq(s.textures[1].uri, c.skins[1], c.name .. ": skin uri")
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
-- model/md3 tests: MD3 files written by tools/fixtures/md3.py (several surfaces, frames, tags) decode to assimp's
|
||||
-- frame-0 triangle soup (every surface: positions, texture coordinates) and to the writer's exact positions and
|
||||
-- normals for every frame, shaders as texture URIs, tags as nodes with their per-frame channels, errors, the fuzz
|
||||
-- pass.
|
||||
-- model/md3 tests: generated MD3 files against assimp's frame-0 soup and the writer's exact frames and tags.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Md3 = require("@rosetta/model/md3")
|
||||
@@ -34,8 +31,7 @@ for _, c in Fx do
|
||||
t:eq(F.detect(c.data), "md3", c.name .. ": F.detect")
|
||||
local prims = s.meshes[1].primitives
|
||||
t:eq(#prims, #c.surfaces, c.name .. ": a primitive per surface")
|
||||
-- assimp: every surface's frame 0 (assimp orders the meshes differently and rotates triangle corners: match each
|
||||
-- assimp mesh to the surface whose triangles it holds)
|
||||
-- assimp orders the meshes differently and rotates triangle corners: match each mesh to the surface holding its triangles
|
||||
t:eq(c.assimp.meshes, #c.surfaces, c.name .. ": assimp meshes")
|
||||
local matched = 0
|
||||
for mi, m in c.assimp.per do
|
||||
@@ -67,7 +63,6 @@ for _, c in Fx do
|
||||
t:eq(#prims[si].targets, c.frames, c.name .. ": morph targets")
|
||||
end
|
||||
end
|
||||
-- tags
|
||||
local ntags = #c.tags // c.frames
|
||||
t:eq(#s.meta.source.tags, ntags, c.name .. ": tags")
|
||||
for _, tg in c.tags do
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
-- model/md5 tests: an .md5mesh and two .md5anim files written by tools/fixtures/md5.py: the bind pose against
|
||||
-- assimp's triangle soup (positions, texture coordinates) and the writer's exact weighted positions, the joints'
|
||||
-- model-space pose through the node tree, weights, animations through opts.files / opts.resolve (every frame's
|
||||
-- parent-relative pose), a standalone .md5anim, missing animations, errors, the fuzz pass.
|
||||
-- model/md5 tests: generated .md5mesh / .md5anim files against assimp's bind-pose soup and the writer's poses.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Md5 = require("@rosetta/model/md5")
|
||||
@@ -35,7 +32,6 @@ local s, err = Md5.decode(Bytes.reader(buffer.fromstring(M.data)), { anims = { "
|
||||
t:check(s, "md5mesh: " .. tostring(err))
|
||||
t:eq(F.detect(M.data), "md5", "F.detect")
|
||||
|
||||
-- 1. geometry
|
||||
do
|
||||
local prims = s.meshes[1].primitives
|
||||
t:eq(#prims, #M.positions, "a primitive per mesh")
|
||||
@@ -63,7 +59,6 @@ do
|
||||
t:eq(matched, #M.positions, "every mesh matches assimp's bind pose")
|
||||
end
|
||||
|
||||
-- 2. skeleton: the model-space joint poses through the node tree
|
||||
do
|
||||
local skin = s.skins[1]
|
||||
t:eq(#skin.joints, #M.joints, "joints")
|
||||
@@ -87,7 +82,6 @@ do
|
||||
t:check(s.meshes[1].primitives[1].attributes.JOINTS_0 ~= nil, "skinned")
|
||||
end
|
||||
|
||||
-- 3. animations
|
||||
local function checkAnim(scene: any, a: any, anim: any, label: string)
|
||||
t:eq(anim.name, a.name, label .. ": name")
|
||||
local byNode = {}
|
||||
@@ -132,7 +126,6 @@ do
|
||||
t:check(e and e.code == Err.UNSUPPORTED, "missing animation")
|
||||
local skip = Md5.decode(Bytes.reader(buffer.fromstring(M.data)), { anims = { "run.md5anim" }, skipMissing = true }) :: any
|
||||
t:check(skip and #skip.animations == 0, "skipMissing")
|
||||
-- a standalone .md5anim
|
||||
local a = Fx.anims[2]
|
||||
local alone = Md5.decode(Bytes.reader(buffer.fromstring(a.data)), { name = "models/walk.md5anim" }) :: any
|
||||
t:check(alone and #alone.skins == 1, "md5anim alone: skeleton")
|
||||
@@ -140,7 +133,6 @@ do
|
||||
t:eq(alone.meta.source.kind, "anim", "md5anim alone: kind")
|
||||
end
|
||||
|
||||
-- 4. errors, fuzz
|
||||
do
|
||||
local _, e1 = Md5.decode(Bytes.reader(buffer.fromstring("MD5Version 11\n")))
|
||||
t:check(e1 and e1.code == Err.UNSUPPORTED, "version 11")
|
||||
|
||||
+1
-12
@@ -1,8 +1,4 @@
|
||||
-- model/mdl tests: a Quake 1 and a Half-Life 1 model written by tools/fixtures/mdl.py. Quake: assimp's frame-0
|
||||
-- triangle soup (positions, texture coordinates), every frame exact, skins through opts.palette / opts.resolve /
|
||||
-- the grey ramp, frame-name animations. Half-Life: assimp's bind-pose soup per mesh (positions, texture
|
||||
-- coordinates), the bones' TRS, the skin, every sequence's animation values against the writer's, textures with
|
||||
-- their palettes, the skin family. Errors and the fuzz pass.
|
||||
-- model/mdl tests: generated Quake 1 and Half-Life 1 models against assimp's soups and the writer's values.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Mdl = require("@rosetta/model/mdl")
|
||||
@@ -24,7 +20,6 @@ local function near(a: { number }, b: { number }, tol: number): boolean
|
||||
return true
|
||||
end
|
||||
|
||||
-- assimp mesh mi of a soup -> positions, uvs
|
||||
local function assimpMesh(a: any, mi: number): ({ number }, { number }, number)
|
||||
local m = a.per[mi]
|
||||
local nextStart = if a.per[mi + 1] then a.per[mi + 1].start else a.faces
|
||||
@@ -32,7 +27,6 @@ local function assimpMesh(a: any, mi: number): ({ number }, { number }, number)
|
||||
return Soup.slice(a.pos, m.start * 9 + 1, nf * 9), Soup.slice(a.uv, m.start * 6 + 1, nf * 6), nf
|
||||
end
|
||||
|
||||
-- 1. Quake
|
||||
do
|
||||
local q = Fx.quake
|
||||
local s, err = Mdl.decode(Bytes.reader(buffer.fromstring(q.data)), { palette = q.palette })
|
||||
@@ -69,7 +63,6 @@ do
|
||||
t:eq(grey.meta.source.palette, false, "quake: meta.source.palette")
|
||||
end
|
||||
|
||||
-- 2. Half-Life
|
||||
do
|
||||
local h = Fx.halflife
|
||||
local s, err = Mdl.decode(Bytes.reader(buffer.fromstring(h.data)))
|
||||
@@ -95,7 +88,6 @@ do
|
||||
t:eq(p.indices.count, h.tris[i] * 3, "halflife: mesh " .. i .. " triangles")
|
||||
t:check(p.attributes.JOINTS_0 and p.attributes.WEIGHTS_0, "halflife: skinned")
|
||||
end
|
||||
-- bones
|
||||
local skin = s.skins[1]
|
||||
t:eq(#skin.joints, #h.bones, "halflife: joints")
|
||||
for i, bn in h.bones do
|
||||
@@ -103,7 +95,6 @@ do
|
||||
t:eq(node.name, bn.name, "halflife: bone name " .. i)
|
||||
t:check(near(node.translation, bn.t, 1e-6) and near(node.rotation, bn.q, 1e-6), "halflife: bone " .. bn.name .. " TRS")
|
||||
end
|
||||
-- animations
|
||||
t:eq(#s.animations, #h.sequences, "halflife: sequences")
|
||||
for si, sq in h.sequences do
|
||||
local a = s.animations[si]
|
||||
@@ -129,7 +120,6 @@ do
|
||||
end
|
||||
t:check(ok, "halflife: " .. sq.name .. ": every value against the writer")
|
||||
end
|
||||
-- textures, skin family 0
|
||||
for i, tx in h.textures do
|
||||
t:eq(s.textures[i].name, tx.name, "halflife: texture name")
|
||||
t:eq(Crc32.of(s.textures[i].image.pixels), tx.crc, "halflife: texture " .. i .. " through its palette")
|
||||
@@ -138,7 +128,6 @@ do
|
||||
t:eq(mesh.primitives[2].material, 2, "halflife: mesh 2 -> skin ref 1 -> texture 2")
|
||||
end
|
||||
|
||||
-- 3. errors, fuzz
|
||||
do
|
||||
local _, e1 = Mdl.decode(Bytes.reader(buffer.fromstring(string.sub(Fx.quake.data, 1, 200))))
|
||||
t:check(e1 and (e1.code == Err.TRUNCATED or e1.code == Err.CORRUPT), "quake truncated: " .. tostring(e1))
|
||||
|
||||
+2
-15
@@ -1,9 +1,5 @@
|
||||
-- model/ms3d tests: assimp's MilkShape 3D test models (groups, materials, textures, version 4 with and without the
|
||||
-- sub-versioned blocks) against assimp (meshes, faces, corners, materials, world bounds); round trips through our
|
||||
-- writer, of those files and of glTF sample models (world triangles, materials, textures, skins: joints, inverse bind
|
||||
-- matrices, skinned vertices; animation sampled through the skeleton); assimp reading our files (meshes, faces,
|
||||
-- bones, animations, bounds: ms3d_xcheck); comments and extras; errors; the fuzz no-throw pass. Fixtures:
|
||||
-- tools/fixtures/ms3d.py.
|
||||
-- model/ms3d tests: assimp's MilkShape 3D models against assimp; round trips; assimp reading ours.
|
||||
-- Fixtures: tools/fixtures/ms3d.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Ms3d = require("@rosetta/model/ms3d")
|
||||
@@ -84,7 +80,6 @@ local function bones(scene: any): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
local scenes = {}
|
||||
for i, c in Cases do
|
||||
local scene, err = decode(c.data)
|
||||
@@ -107,8 +102,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files against assimp", #Cases)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ round trips
|
||||
-- skinned world positions at a time: the skeleton posed by animations[1], vertices blended by their joints
|
||||
local function skinnedPositions(s: any, time: number): { number }
|
||||
local byNode: { [number]: { [string]: any } } = {}
|
||||
for _, ch in (if s.animations[1] then s.animations[1].channels else {}) :: { any } do
|
||||
@@ -250,7 +243,6 @@ local function compare(a: any, b: any, label: string, eps: number)
|
||||
if a.skins[1] then
|
||||
t:eq(#b.skins[1].joints, #a.skins[1].joints, label .. ": joints")
|
||||
end
|
||||
-- the same posed triangles (the corners in order) at a few times
|
||||
for _, time in { 0, 0.3, 0.75, 1.2, 2.5, 4 } do
|
||||
local pa, pb = skinnedPositions(a, time), skinnedPositions(b, time)
|
||||
local ok = #pa == #pb
|
||||
@@ -315,7 +307,6 @@ for gi, g in Picks do
|
||||
end
|
||||
t:note("%d reference files and %d glTF models through our writer and back", #Cases, ng)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ cross-check
|
||||
local nx = 0
|
||||
for _, x in Xcheck do
|
||||
local a = x.assimp
|
||||
@@ -339,7 +330,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read back by assimp", nx)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ details
|
||||
do
|
||||
local byName = {}
|
||||
for i, c in Cases do
|
||||
@@ -359,7 +349,6 @@ do
|
||||
t:eq(mats.meta.source.vertexVersion, 3, "vertex extras subversion 3")
|
||||
t:check(mats.materials[2].extras.ms3d.shininess > 0, "shininess in extras")
|
||||
end
|
||||
-- a skinned scene by hand: two joints, comments, weights split between them
|
||||
local gl = gltfScenes[3]
|
||||
if gl then
|
||||
local out = Ms3d.encode(gl) :: buffer
|
||||
@@ -388,7 +377,6 @@ do
|
||||
t:check(viaApi and buffer.readstring(viaApi, 0, 10) == "MS3D000000", "F.save format ms3d")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local data = Cases[2].data
|
||||
local _, e1 = decode(string.sub(data, 1, 100))
|
||||
@@ -404,7 +392,6 @@ do
|
||||
t:eq(Ms3d.sniff(Bytes.reader(buffer.fromstring(data))), 1, "sniff")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
+2
-15
@@ -1,8 +1,5 @@
|
||||
-- model/obj tests: OBJ / MTL files (materials and texture maps, objects and groups, n-gons, negative indices, vertex
|
||||
-- colours, continuations, lines and points, a concave polygon, assimp's exporter output) against assimp (meshes,
|
||||
-- vertices, faces, bounds, materials) and trimesh (area, triangles); MTL mapping; ear clipping (MeshOps) against the
|
||||
-- exact polygon area; round trips through the writer, and assimp / trimesh reading our output (obj_xcheck); errors;
|
||||
-- the fuzz no-throw pass. Fixtures: tools/fixtures/obj.py.
|
||||
-- model/obj tests: OBJ / MTL files against assimp and trimesh; ear clipping against the exact polygon area.
|
||||
-- Fixtures: tools/fixtures/obj.py.
|
||||
local T = require("@tests/T")
|
||||
local Obj = require("@rosetta/model/obj")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -87,7 +84,6 @@ for _, c in Cases do
|
||||
if #scene.materials > 0 then
|
||||
t:eq(#scene.materials, c.assimp.materials, c.name .. ": materials (assimp)")
|
||||
end
|
||||
-- round trip through our writer
|
||||
local files = {}
|
||||
local out, eerr = Obj.encode(scene, { name = "rt.obj", files = files })
|
||||
t:check(out, c.name .. ": encode: " .. tostring(eerr))
|
||||
@@ -110,7 +106,6 @@ for _, c in Cases do
|
||||
t:eq(#back.materials, #scene.materials, c.name .. ": round trip materials")
|
||||
end
|
||||
|
||||
-- the reference tools read our output like the original
|
||||
for _, x in Xcheck do
|
||||
local orig = byName[string.sub(x.name, 4)]
|
||||
t:check(orig ~= nil, x.name .. ": a case")
|
||||
@@ -128,7 +123,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d files match assimp / trimesh; %d of our files read back by assimp / trimesh", #Cases, #Xcheck)
|
||||
|
||||
-- the cube in detail: nodes, materials, textures
|
||||
do
|
||||
local c = byName["cube.obj"]
|
||||
local s = decode(c.data, { files = c.files })
|
||||
@@ -146,7 +140,6 @@ do
|
||||
t:check(red.extras.obj.values.Ns[1] == 50 and red.extras.obj.values.illum[1] == 2, "Phong values in extras")
|
||||
t:check(blue.baseColor[4] == 0.5 and blue.alphaMode == "blend" and blue.roughness == 0.25 and blue.metallic == 1 and blue.emissive[3] == 0.3, "blue: d, Pr, Pm, Ke")
|
||||
t:check(s.nodes[root.children[1]].extras.obj.smoothing == "1", "smoothing group kept")
|
||||
-- the uv flip
|
||||
local top = s.meshes[s.nodes[root.children[1]].mesh].primitives[1]
|
||||
t:check(top.attributes.TEXCOORD_0 ~= nil and buffer.readf32(top.attributes.TEXCOORD_0.data, 4) == 1, "vt 0 0 -> (0, 1) (top-left origin)")
|
||||
local s2 = decode(c.data, { files = c.files, flipV = false })
|
||||
@@ -155,7 +148,6 @@ do
|
||||
-- without the MTL: named default materials, the library listed as missing
|
||||
local s3 = decode(c.data)
|
||||
t:check(#s3.materials == 2 and s3.meta.source.missingMtl[1] == "cube.mtl", "missing mtllib")
|
||||
-- through opts.mtl / resolve
|
||||
local s4 = decode(c.data, { mtl = c.files["cube.mtl"] })
|
||||
t:check(s4.materials[1].baseColor[1] == 1 and s4.textures[1].data == nil, "opts.mtl (texture bytes not found)")
|
||||
local asked = {}
|
||||
@@ -164,7 +156,6 @@ do
|
||||
return c.files[uri]
|
||||
end })
|
||||
t:check(s5.materials[2].baseColor[4] == 0.5 and table.find(asked, "cube.mtl") and table.find(asked, "textures/tex.png"), "opts.resolve")
|
||||
-- the MTL written back keeps the maps and their options
|
||||
local files = {}
|
||||
Obj.encode(s, { name = "x.obj", files = files })
|
||||
local mtl = files["x.mtl"]
|
||||
@@ -183,14 +174,12 @@ do
|
||||
t:check(near(triArea(tri), c.polygonArea, 1e-9), "ear clipping area " .. triArea(tri) .. " = " .. c.polygonArea)
|
||||
local fan = MeshOps.triangulate(p, { method = "fan" }) :: any
|
||||
t:check(near(triArea(fan), c.trimesh.area, 1e-9), "fan area = trimesh's (fan) area")
|
||||
-- n-gons written as n-gons
|
||||
local out = Obj.encode(s) :: buffer
|
||||
t:check(string.find(buffer.tostring(out), "\nf 7 8 9 10 11 12 13 14", 1, true) ~= nil, "an octagon written as one face")
|
||||
local back = decode(out, { triangulate = false })
|
||||
t:eq(back.meshes[1].primitives[1].faces.count, 2, "polygons round trip")
|
||||
end
|
||||
|
||||
-- lines and points
|
||||
do
|
||||
local s = decode(byName["wire.obj"].data)
|
||||
local modes = {}
|
||||
@@ -200,7 +189,6 @@ do
|
||||
t:check(modes.lines and modes.lines.indices.count == 8 and modes.points and modes.triangles, "l (polyline -> 4 segments), p, f")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e = decode("v 0 0 0\nf 1 2 3\n")
|
||||
t:check(e and e.code == Err.CORRUPT, "index out of range: " .. tostring(e))
|
||||
@@ -216,7 +204,6 @@ do
|
||||
t:check(empty and #empty.nodes == 0, "an empty file is an empty scene")
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
+2
-12
@@ -1,9 +1,5 @@
|
||||
-- model/off tests: OFF files written by trimesh and by the generator (COFF integer / float colours, RGB / RGBA, NOFF,
|
||||
-- STOFF, STCNOFF, face colours, colormap indices, comments, counts on the header line, CRLF, tabs, n-gons, a point
|
||||
-- cloud) against the values they were written from (positions cross-checked with trimesh); our encoder's output read
|
||||
-- back by trimesh, assimp and the generator's reader (verdicts from the fixture step); round trips (polygons,
|
||||
-- triangles, face colours, scenes); the contract, error codes and the fuzz no-throw pass. Fixtures:
|
||||
-- tools/fixtures/off.py.
|
||||
-- model/off tests: trimesh and generated OFF files against the values they were written from; trimesh / assimp read ours.
|
||||
-- Fixtures: tools/fixtures/off.py.
|
||||
local T = require("@tests/T")
|
||||
local Off = require("@rosetta/model/off")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -27,13 +23,11 @@ local function same(a: any, b: any): boolean
|
||||
return a.type == b.type and a.components == b.components and a.count == b.count and buffer.tostring(a.data) == buffer.tostring(b.data)
|
||||
end
|
||||
|
||||
-- 1. the contract
|
||||
t:eq(Off.name, "off", "name")
|
||||
t:eq(Off.category, "model", "category")
|
||||
t:check(table.find(Off.extensions, "off") ~= nil, "extensions")
|
||||
t:check(Off.caps.decode and Off.caps.encode, "caps")
|
||||
|
||||
-- 2. every fixture against the values it was written from; 3. round trips
|
||||
for _, c in Fx.cases do
|
||||
local label = c.name
|
||||
local scene, err = decode(c.data)
|
||||
@@ -70,7 +64,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
end
|
||||
t:eq(Off.sniff(Bytes.reader(buffer.fromstring(c.data))), 0.9, label .. ": sniff")
|
||||
-- polygons kept
|
||||
local poly = decode(c.data, { triangulate = false })
|
||||
local pp = poly.meshes[1].primitives[1]
|
||||
if c.faces > 0 and not c.allTri then
|
||||
@@ -106,7 +99,6 @@ for _, v in Fx.ours do
|
||||
end
|
||||
t:note("%d encodings read back by trimesh, assimp and the generator", #Fx.ours)
|
||||
|
||||
-- the encoder scenes: decode(encode()) gives the scene back (identity transforms)
|
||||
local function build(spec: any): Types.Scene
|
||||
local scene = Types.Scene.new()
|
||||
for i, m in spec.meshes do
|
||||
@@ -160,7 +152,6 @@ do
|
||||
t:check(string.find(cm, "STCNOFF\n# made here\n", 1, true) ~= nil, "comment option")
|
||||
end
|
||||
|
||||
-- 4. error codes
|
||||
do
|
||||
local function code(s: string, opts: any?): string?
|
||||
local _, e = decode(s, opts)
|
||||
@@ -193,7 +184,6 @@ do
|
||||
t:eq(Off.sniff(Bytes.reader(buffer.fromstring("solid x\n"))), 0, "sniff an STL")
|
||||
end
|
||||
|
||||
-- 5. fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Fx.cases do
|
||||
|
||||
+2
-15
@@ -1,9 +1,5 @@
|
||||
-- model/ply tests: files written by plyfile (ascii / binary LE / BE, every property type and spelling, odd orders,
|
||||
-- n-gons up to 300 vertices, face properties and lists, extra elements, comments, point clouds) and by assimp, against
|
||||
-- plyfile's reading mapped to the Scene conventions (CRC-32 of every attribute, the indices triangulated or as
|
||||
-- polygons, face data, raw elements); our encoder's output read back by plyfile and assimp (verdicts from the fixture
|
||||
-- step); round trips in every encoding (fixtures and generated scenes, polygons and points); the contract, error
|
||||
-- codes, the fuzz no-throw pass and a binary decode throughput note. Fixtures: tools/fixtures/ply.py.
|
||||
-- model/ply tests: plyfile and assimp files against plyfile's reading (CRC-32 per attribute); plyfile / assimp read ours.
|
||||
-- Fixtures: tools/fixtures/ply.py.
|
||||
local T = require("@tests/T")
|
||||
local Ply = require("@rosetta/model/ply")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -22,13 +18,11 @@ end
|
||||
|
||||
local ENCODINGS = { "ascii", "binary_little_endian", "binary_big_endian" }
|
||||
|
||||
-- 1. the contract
|
||||
t:eq(Ply.name, "ply", "name")
|
||||
t:eq(Ply.category, "model", "category")
|
||||
t:check(table.find(Ply.extensions, "ply") ~= nil, "extensions")
|
||||
t:check(Ply.caps.decode and Ply.caps.encode, "caps")
|
||||
|
||||
-- a decoded scene against a reference case (triangulated)
|
||||
local function verify(scene: any, c: any, label: string)
|
||||
t:check(scene.kind == "scene" and #scene.meshes == 1 and #scene.meshes[1].primitives == 1, label .. ": one primitive")
|
||||
local p = scene.meshes[1].primitives[1]
|
||||
@@ -101,7 +95,6 @@ local function verify(scene: any, c: any, label: string)
|
||||
end
|
||||
end
|
||||
|
||||
-- 2. every fixture against plyfile; 3. round trips of every fixture in every encoding
|
||||
for _, c in Fx.cases do
|
||||
local label = c.name
|
||||
local scene, err = decode(c.data)
|
||||
@@ -116,7 +109,6 @@ for _, c in Fx.cases do
|
||||
buffer.writestring(big, 4, c.data)
|
||||
local s2 = Ply.decode(Bytes.reader(big, 4, #c.data))
|
||||
t:check(s2 and Crc32.of(s2.meshes[1].primitives[1].attributes.POSITION.data) == c.attrs.POSITION.crc, label .. ": decode from a sub-range")
|
||||
-- polygons kept
|
||||
local poly = decode(c.data, { triangulate = false })
|
||||
local pp = poly.meshes[1].primitives[1]
|
||||
if c.faces > 0 and not c.allTri then
|
||||
@@ -144,7 +136,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
end
|
||||
verify(back, cc, label .. " -> " .. enc)
|
||||
-- polygons in, polygons out
|
||||
local pout = Ply.encode(poly, { format = enc }) :: buffer
|
||||
local pback = decode(pout, { triangulate = false })
|
||||
verify(decode(pout), c, label .. " -> " .. enc .. " (polygons)")
|
||||
@@ -169,7 +160,6 @@ for _, v in Fx.ours do
|
||||
end
|
||||
t:note("%d encodings read back by plyfile and assimp", #Fx.ours)
|
||||
|
||||
-- the encoder scenes: decode(encode()) against the properties computed by the generator
|
||||
local function build(spec: any): Types.Scene
|
||||
local scene = Types.Scene.new()
|
||||
for i, m in spec.meshes do
|
||||
@@ -263,7 +253,6 @@ for _, spec in Scenes do
|
||||
end
|
||||
end
|
||||
|
||||
-- options and meta: comments, extra elements written back, faceAttributes of a triangulated mesh
|
||||
do
|
||||
local scene = build(Scenes[1])
|
||||
scene.meta.ply = { comments = { "first" }, objInfo = { "info line" } }
|
||||
@@ -282,7 +271,6 @@ do
|
||||
t:eq(decode(Ply.encode(bare) :: buffer).meta.source.vertices, 20, "a scene without nodes")
|
||||
end
|
||||
|
||||
-- 4. error codes
|
||||
do
|
||||
local function code(s: string, opts: any?): string?
|
||||
local _, e = decode(s, opts)
|
||||
@@ -323,7 +311,6 @@ do
|
||||
t:check(a2 and a2.code == Err.ARG, "no POSITION: " .. tostring(a2))
|
||||
end
|
||||
|
||||
-- 5. fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Fx.cases do
|
||||
|
||||
+2
-10
@@ -1,8 +1,5 @@
|
||||
-- model/pmx tests: assimp's MMD model (Alicia_blade.pmx) and synthetic PMX 2.0 / 2.1 models (UTF-16 / UTF-8, index
|
||||
-- sizes 1 / 2 / 4, additional UVs, BDEF1 / BDEF2 / BDEF4 / SDEF / QDEF, every morph type, IK / inherit / axis bones,
|
||||
-- display frames, rigid bodies, joints) against assimp (meshes, faces per mesh, materials, bones, world bounds) and the
|
||||
-- generator's facts (vertices, weights, bones, morphs, textures); the same models as PMD against their PMX decode;
|
||||
-- errors; the fuzz no-throw pass. Fixtures: tools/fixtures/pmx.py.
|
||||
-- model/pmx tests: assimp's Alicia_blade.pmx and generated PMX 2.0 / 2.1 / PMD models against assimp and the generator.
|
||||
-- Fixtures: tools/fixtures/pmx.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Pmx = require("@rosetta/model/pmx")
|
||||
@@ -55,7 +52,6 @@ local function findVertex(scene: any, pos: { number }, uv: { number }): (any, nu
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
local scenes = {}
|
||||
local checked = { assimp = 0, expect = 0 }
|
||||
for i, c in Cases do
|
||||
@@ -167,7 +163,6 @@ do
|
||||
local skin = s.skins[1]
|
||||
local ok = true
|
||||
local world = {}
|
||||
-- world matrices by walking from the root
|
||||
local function walk(n: number, parent: { number })
|
||||
local w = Types.Scene.mul(parent, Types.Scene.nodeMatrix(s.nodes[n]))
|
||||
world[n] = w
|
||||
@@ -186,7 +181,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ PMD
|
||||
for _, c in Pmds do
|
||||
local s, err = decode(c.data)
|
||||
t:check(s, c.name .. ": decode: " .. tostring(err))
|
||||
@@ -215,7 +209,6 @@ for _, c in Pmds do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ api, errors
|
||||
do
|
||||
local c = Cases[2]
|
||||
t:eq(F.detect(c.data), "pmx", "F.detect pmx")
|
||||
@@ -240,7 +233,6 @@ do
|
||||
t:check(e7 and (e7.code == Err.TRUNCATED or e7.code == Err.CORRUPT), "PMD truncated: " .. tostring(e7))
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
+2
-7
@@ -1,7 +1,5 @@
|
||||
-- model/qb tests: Qubicle Binary files with every option (RGBA / BGRA, left- / right-handed, RLE or not, visibility
|
||||
-- masks, more than 255 colours) against the reference reader / writer of the fixture (exact colours of every cell,
|
||||
-- names, positions), the indexed palette view, our encodings read back by the reference (same settings, flipped
|
||||
-- settings, palette grids with computed masks), the api, error codes and the fuzz pass. Fixtures: tools/fixtures/qb.py.
|
||||
-- model/qb tests: Qubicle Binary files of every option against the fixture's reference reader / writer.
|
||||
-- Fixtures: tools/fixtures/qb.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Qb = require("@rosetta/model/qb")
|
||||
@@ -62,7 +60,6 @@ for _, c in Fx.cases do
|
||||
t:eq(F.detect(c.data), "qb", c.name .. ": detect")
|
||||
end
|
||||
|
||||
-- our encodings, read by the reference
|
||||
for name, want in Fx.ours do
|
||||
local base = string.match(name, "^(case%d)_")
|
||||
if base then
|
||||
@@ -100,7 +97,6 @@ do
|
||||
t:eq(buffer.readu8(colors, 0 * 4 + 3), 1 + 2 + 16 + 64, "corner cell mask (left, bottom, back)")
|
||||
end
|
||||
|
||||
-- api and conversion to .vox
|
||||
do
|
||||
local s = assert(F.load(Fx.cases[1].data))
|
||||
t:check(s.kind == "scene", "F.load")
|
||||
@@ -108,7 +104,6 @@ do
|
||||
t:check(F.save(s, nil, { format = "schem" }) ~= nil, "qb -> schem")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e1 = dec("\1\1\0\0")
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "truncated header")
|
||||
|
||||
+1
-12
@@ -1,7 +1,4 @@
|
||||
-- model/rbxm tests: binary models and places built by rojo 7.7 and lune 0.11 (rbx-dom) decode to the values lune reads
|
||||
-- from them (every property the files hold); the binary decode equals the decode of the XML twin; Zstandard and raw
|
||||
-- chunk variants; an unknown chunk and an unknown property type round trip raw; our rbxm output read back by lune
|
||||
-- equals the original (fixture verdicts); round trips of a tree with every type; options, errors and the fuzz pass.
|
||||
-- model/rbxm tests: rojo 7.7 / lune 0.11 binary models and places against lune's reading and their XML twins.
|
||||
-- Fixtures: tools/fixtures/rbxmx.py.
|
||||
local T = require("@tests/T")
|
||||
local Rbxm = require("@rosetta/model/rbxm")
|
||||
@@ -33,7 +30,6 @@ local function file(name: string): any
|
||||
error("no fixture " .. name)
|
||||
end
|
||||
|
||||
-- every binary reference file against lune's reading of it, and against the decode of its XML twin
|
||||
local nprops = 0
|
||||
local trees: { [string]: any } = {}
|
||||
for _, f in Fx.files do
|
||||
@@ -109,7 +105,6 @@ do
|
||||
t:eq(#Rbx.list(tree), 1 + 12 + 2 + 120, "every instance")
|
||||
end
|
||||
|
||||
-- chunk variants: Zstandard, raw, an unknown chunk and an unknown property type
|
||||
do
|
||||
local base = trees["model.rbxm"]
|
||||
t:eq(table.concat(base.meta.source.compression, ","), "lz4,none", "rojo: lz4 chunks (END raw)")
|
||||
@@ -153,7 +148,6 @@ do
|
||||
t:check(edited and not still, "a raw column is dropped when its class changes")
|
||||
end
|
||||
|
||||
-- our encoder: lune reads our rbxm back to the same values (tools/fixtures/rbxmx.py)
|
||||
local nours = 0
|
||||
for _, v in Ours do
|
||||
if string.sub(v.name, -5) == "/rbxm" then
|
||||
@@ -163,7 +157,6 @@ for _, v in Ours do
|
||||
end
|
||||
t:note("%d of our rbxm files read back by lune", nours)
|
||||
|
||||
-- round trips: every reference file, and a tree with every type
|
||||
for name, tree in trees do
|
||||
local out, err = Rbxm.encode(tree)
|
||||
t:check(out ~= nil, name .. ": encode " .. tostring(err))
|
||||
@@ -183,7 +176,6 @@ do
|
||||
H.sameTree(t, tree, back2, "every type, raw chunks", { loose = true })
|
||||
t:eq(table.concat(back2.meta.source.compression, ","), "none", "compression = none")
|
||||
t:check(buffer.len(raw) > buffer.len(out), "lz4 chunks are smaller")
|
||||
-- through XML and back
|
||||
local viaXml = Rbxmx.decode(Bytes.reader(Rbxmx.encode(back) :: buffer))
|
||||
H.sameTree(t, tree, decode(Rbxm.encode(viaXml) :: buffer), "every type via rbxmx", { loose = true })
|
||||
-- a place: roots marked as services
|
||||
@@ -198,7 +190,6 @@ do
|
||||
t:eq(decode(Rbxm.encode(tree) :: buffer).metadata.ExplicitAutoJoints, "true", "META")
|
||||
end
|
||||
|
||||
-- sniff, errors
|
||||
do
|
||||
local data = file("model.rbxm").data
|
||||
t:eq(Rbxm.sniff(Bytes.reader(buffer.fromstring(data))), 1, "sniff")
|
||||
@@ -240,7 +231,6 @@ do
|
||||
t:check(e8 and e8.code == Err.CORRUPT, "a cycle: " .. tostring(e8))
|
||||
end
|
||||
|
||||
-- through the api: detection (variant: rbxl for places), load, save, convert
|
||||
do
|
||||
local F = require("@rosetta")
|
||||
t:eq(F.detect(file("place.rbxl").data), "rbxl", "detect a place")
|
||||
@@ -257,7 +247,6 @@ do
|
||||
t:eq(F.detect(l), "rbxl", "save as rbxl marks services")
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = { file("model-raw.rbxm").data, Rbxm.encode(H.everything(), { compression = "none" }) :: buffer, Rbxm.encode(H.everything()) :: buffer }
|
||||
t:fuzz("decode", function(b: buffer)
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
-- model/rbxmx tests: XML models and places built by rojo 7.7 and lune 0.11 (rbx-dom) decode to the values lune reads
|
||||
-- from them; our rbxmx output read back by lune equals the original (fixture verdicts); round trips of every reference
|
||||
-- file and of a tree with every type; XML specifics (BinaryString, CDATA, packed Color3, INF / NAN, unknown property
|
||||
-- tags kept raw, referents, SharedStrings, floats written exactly); errors and the fuzz pass.
|
||||
-- model/rbxmx tests: rojo 7.7 / lune 0.11 XML models and places against lune's reading; lune reads ours.
|
||||
-- Fixtures: tools/fixtures/rbxmx.py.
|
||||
local T = require("@tests/T")
|
||||
local Rbxmx = require("@rosetta/model/rbxmx")
|
||||
@@ -86,7 +83,6 @@ do
|
||||
t:check(not string.find(flat, "\n <Item", 1, true) and decode(flat) ~= nil, "indent = 0")
|
||||
end
|
||||
|
||||
-- XML specifics
|
||||
do
|
||||
local doc = [==[<?xml version="1.0" encoding="utf-8"?>
|
||||
<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" version="4">
|
||||
@@ -161,7 +157,6 @@ do
|
||||
t:eq(fb.C.value[1], buffer.readf32(v, 0), "f32 exact")
|
||||
end
|
||||
|
||||
-- sniff, errors
|
||||
do
|
||||
local data = Fx.files[2].data
|
||||
t:eq(Rbxmx.sniff(Bytes.reader(buffer.fromstring(data))), 1, "sniff")
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
-- model/robloxmesh tests: meshes of every version written by the fixture's spec writer (1.00 / 1.01 ASCII, 2.00 with
|
||||
-- 36- and 40-byte vertices, 3.00 / 3.01 LODs, 4.00 / 4.01 / 5.00 skinned with one and several subsets, 5.00 FACS,
|
||||
-- 6.00 / 7.00 chunked) decode to the values they were written from (attribute CRCs, LOD index CRCs, global joints and
|
||||
-- weights, bone names / parents / world transforms, FACS, raw chunks); a COREMESH v2 that is not a Draco stream is CORRUPT; our 2.00 /
|
||||
-- 4.00 output read back by the fixture's reader (verdicts); round trips; errors and the fuzz pass.
|
||||
-- model/robloxmesh tests: meshes of every version from the fixture's spec writer against the values written.
|
||||
-- Fixtures: tools/fixtures/robloxmesh.py.
|
||||
local T = require("@tests/T")
|
||||
local RobloxMesh = require("@rosetta/model/robloxmesh")
|
||||
@@ -24,7 +20,6 @@ local function decode(data: any, opts: any?): (any, any)
|
||||
return RobloxMesh.decode(Bytes.reader(if type(data) == "string" then buffer.fromstring(data) else data), opts)
|
||||
end
|
||||
|
||||
-- a world matrix of node i (parents through the children lists)
|
||||
local function world(scene: any, i: number): { number }
|
||||
local parent = {}
|
||||
for k, n in scene.nodes do
|
||||
@@ -119,7 +114,6 @@ for _, v in Fx.ours do
|
||||
end
|
||||
t:note("%d of our files read back by the fixture's reader", #Fx.ours)
|
||||
|
||||
-- round trips through our encoder
|
||||
do
|
||||
for _, name in { "v2.00-40", "v4.00-lods", "v4.00-40bones", "v6.00" } do
|
||||
local c
|
||||
@@ -164,7 +158,6 @@ do
|
||||
t:check(qa.COLOR_0 == nil, "white / no colours: 36-byte vertices")
|
||||
end
|
||||
|
||||
-- sniff, errors
|
||||
do
|
||||
local c = Fx.cases[3]
|
||||
t:eq(RobloxMesh.sniff(Bytes.reader(buffer.fromstring(c.data))), 1, "sniff")
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
-- model/robloxmesh with a Draco-compressed COREMESH (6.00 / 7.00, COREMESH v2): draco_encoder streams of a UV sphere
|
||||
-- (normals, uvs) and a coloured PLY at three compression levels, wrapped in the chunk layout. Positions, normals,
|
||||
-- uvs, colours and indices match libdraco's decode byte for byte, and the scene equals the decode of the same mesh
|
||||
-- written with a plain COREMESH v1; corrupt streams fail without throwing (fuzz). Fixtures:
|
||||
-- tools/fixtures/robloxmesh_draco.py.
|
||||
-- model/robloxmesh Draco COREMESH v2 tests: draco_encoder streams against libdraco's decode, byte for byte.
|
||||
-- Fixtures: tools/fixtures/robloxmesh_draco.py.
|
||||
local T = require("@tests/T")
|
||||
local RobloxMesh = require("@rosetta/model/robloxmesh")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -43,7 +40,6 @@ for _, c in Cases do
|
||||
t:eq(Crc32.of(a[name].data), Crc32.of(pp.attributes[name].data), c.name .. ": " .. name .. " like COREMESH v1")
|
||||
end
|
||||
t:eq(Crc32.of(prim.indices.data), Crc32.of(pp.indices.data), c.name .. ": indices like COREMESH v1")
|
||||
-- written back as 2.00 and read again
|
||||
local back = assert(decode(buffer.tostring(assert(RobloxMesh.encode(scene)))))
|
||||
t:eq(back.meshes[1].primitives[1].indices.count, c.faces * 3, c.name .. ": round trip")
|
||||
if #c.data < 3000 then
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
-- model/schematic tests: .litematic files written by litemapy (several regions, negative sizes, a 40-state palette,
|
||||
-- tile entities), Sponge .schem v2 (litemapy) and v1 / v3 (nbtlib, by the spec; two-byte varints), MCEdit
|
||||
-- .schematic (legacy ids + data, WorldEdit AddBlocks, a Schematica name table): every cell's block state, placement,
|
||||
-- block entities; our re-encodings give the same NBT for the same variant, and the reference readers (litemapy /
|
||||
-- nbtlib, in the fixture step) read our output, across variants and from colour-only grids, to the same cells;
|
||||
-- detection, the api, error codes and the fuzz pass. Fixtures: tools/fixtures/schematic.py.
|
||||
-- model/schematic tests: litemapy / nbtlib-written .litematic, .schem v1-v3 and MCEdit .schematic files; they read ours.
|
||||
-- Fixtures: tools/fixtures/schematic.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Schematic = require("@rosetta/model/schematic")
|
||||
@@ -61,7 +57,6 @@ local function sameRegion(got: any, want: any, label: string)
|
||||
end
|
||||
end
|
||||
|
||||
-- 1. reference files
|
||||
local decoded: { [string]: Types.Scene } = {}
|
||||
for _, c in Fx.cases do
|
||||
local scene, err = dec(c.data)
|
||||
@@ -108,13 +103,11 @@ for _, c in Fx.cases do
|
||||
for i, r in regions(again) do
|
||||
sameRegion(r, regs[i], c.name .. " again region " .. i)
|
||||
end
|
||||
-- api: detection by content (the flavour) and loading
|
||||
t:eq(F.detect(c.data), c.variant, c.name .. ": F.detect")
|
||||
local viaApi = F.load(c.data)
|
||||
t:check(viaApi and viaApi.kind == "scene", c.name .. ": F.load")
|
||||
end
|
||||
|
||||
-- 2. our encodings read back by litemapy / nbtlib (fixture step)
|
||||
local outputs: { [string]: () -> (buffer?, any) } = {}
|
||||
local function colorGrid(): Types.Voxels
|
||||
local v = Types.Voxels.new(4, 3, 2)
|
||||
@@ -156,7 +149,6 @@ for name, ref in Ours do
|
||||
count += 1
|
||||
end
|
||||
t:eq(count, 14, "every output checked")
|
||||
-- the source cells survive the conversions
|
||||
do
|
||||
local function cellsVia(name: string): string
|
||||
return regions(assert(dec(assert(outputs[name]()))))[1].cells
|
||||
@@ -177,7 +169,6 @@ do
|
||||
t:eq(first[4], "minecraft:light_blue_stained_glass", "translucent blue -> stained glass")
|
||||
end
|
||||
|
||||
-- 3. through the api
|
||||
do
|
||||
local scene = assert(F.load(Fx.cases[1].data, { name = "x.litematic" }))
|
||||
local schem = assert(F.save(scene, nil, { format = "schem" })) :: buffer
|
||||
@@ -193,7 +184,6 @@ do
|
||||
t:check(F.save(g, nil, { format = "schem" }) ~= nil, "save a bare Voxels")
|
||||
end
|
||||
|
||||
-- 4. errors
|
||||
do
|
||||
local _, e1 = dec(assert(Nbt.encode(Nbt.compound({ a = 1 }, { "a" }))))
|
||||
t:check(e1 and e1.code == Err.CORRUPT, "not a schematic")
|
||||
@@ -208,7 +198,7 @@ do
|
||||
t:check(e5 and e5.code == Err.TRUNCATED, "short Blocks")
|
||||
end
|
||||
|
||||
-- 5. fuzz (the uncompressed NBT too, so mutations reach the layouts, not just gzip's CRC)
|
||||
-- fuzz the uncompressed NBT too, so mutations reach the layouts, not just gzip's CRC
|
||||
local samples = {}
|
||||
for _, c in Fx.cases do
|
||||
local s = assert(dec(c.data))
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
-- model/smd tests: SMD files written by tools/fixtures/smd.py decode to assimp's triangle soup (positions, texture
|
||||
-- coordinates per material) and to the writer's exact values (bind pose TRS, per-vertex weights and joints, every
|
||||
-- skeleton frame of the animation); an animation-only SMD; our writer's output re-read by us (same soup, weights,
|
||||
-- poses) and by assimp (faces, bones); errors; the fuzz pass. Fixtures: tools/fixtures/smd.py.
|
||||
-- model/smd tests: generated SMD files against assimp's soup and the writer's exact values; assimp reads ours.
|
||||
-- Fixtures: tools/fixtures/smd.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Smd = require("@rosetta/model/smd")
|
||||
@@ -120,7 +118,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
t:eq(matched, #c.materials, c.name .. ": every material mesh matches assimp's positions")
|
||||
end
|
||||
-- our writer, read back by us
|
||||
local out = Smd.encode(s) :: buffer
|
||||
local back, berr = Smd.decode(Bytes.reader(out))
|
||||
t:check(back, c.name .. ": re-read our SMD: " .. tostring(berr))
|
||||
@@ -133,7 +130,6 @@ for _, c in Fx.cases do
|
||||
only.tris = {}
|
||||
check(anim, only, c.name .. " (written animation)")
|
||||
end
|
||||
-- assimp reads our output
|
||||
local ours = Fx.ours[c.name]
|
||||
if ours and #c.tris > 0 then
|
||||
t:eq(ours.faces, #c.tris, c.name .. ": assimp reads our triangles")
|
||||
|
||||
+2
-14
@@ -1,8 +1,5 @@
|
||||
-- model/stl tests: files made by trimesh, assimp and by hand (binary starting with "solid", VisCAM / Magics colours,
|
||||
-- raw attribute words, odd ASCII, several solids, quads, no endsolid, trailing bytes) against trimesh's raw reader
|
||||
-- (CRC-32 of the f32 vertices / normals, area, bounds), our encoder's output read back by trimesh and assimp (verdicts
|
||||
-- from the fixture step), round trips of every encoding and option, the contract, error codes, the fuzz no-throw pass
|
||||
-- and a binary decode throughput note. Fixtures: tools/fixtures/stl.py.
|
||||
-- model/stl tests: trimesh, assimp and hand-made STL files against trimesh's raw reader; trimesh / assimp read ours.
|
||||
-- Fixtures: tools/fixtures/stl.py.
|
||||
local T = require("@tests/T")
|
||||
local Stl = require("@rosetta/model/stl")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -19,7 +16,6 @@ local function decode(data: any, opts: any?): (any, any)
|
||||
return Stl.decode(Bytes.reader(b), opts)
|
||||
end
|
||||
|
||||
-- every primitive's accessor `name` concatenated (nil when a primitive lacks it)
|
||||
local function concat(scene: any, name: string): buffer?
|
||||
local parts = {}
|
||||
for _, p in scene.meshes[1].primitives do
|
||||
@@ -32,13 +28,11 @@ local function concat(scene: any, name: string): buffer?
|
||||
return buffer.fromstring(table.concat(parts))
|
||||
end
|
||||
|
||||
-- 1. the contract
|
||||
t:eq(Stl.name, "stl", "name")
|
||||
t:eq(Stl.category, "model", "category")
|
||||
t:check(table.find(Stl.extensions, "stl") ~= nil, "extensions")
|
||||
t:check(Stl.caps.decode and Stl.caps.encode, "caps")
|
||||
|
||||
-- 2. every fixture against the reference
|
||||
for _, c in Fx.cases do
|
||||
local label = c.name
|
||||
local scene, err = decode(c.data)
|
||||
@@ -115,7 +109,6 @@ for _, c in Fx.cases do
|
||||
t:eq(prims[i].attributes.POSITION.count, c.solidFacets[i] * 3, label .. ": solid facets")
|
||||
end
|
||||
end
|
||||
-- inside a bigger buffer (the Reader's range)
|
||||
local big = buffer.create(#c.data + 11)
|
||||
buffer.writestring(big, 5, c.data)
|
||||
local s2 = Stl.decode(Bytes.reader(big, 5, #c.data))
|
||||
@@ -148,13 +141,11 @@ for _, c in Fx.cases do
|
||||
end
|
||||
t:note("%d files match trimesh / the generator", #Fx.cases)
|
||||
|
||||
-- 3. the reference tools read our output
|
||||
for _, v in Fx.ours do
|
||||
t:check(v.ok, "trimesh / assimp read our " .. v.name .. ": " .. v.detail)
|
||||
end
|
||||
t:note("%d encodings read back by trimesh and assimp", #Fx.ours)
|
||||
|
||||
-- round trips of the encoder scenes: world-space soup as the generator computed it, colour words, idempotence
|
||||
local function acc(s: string, ty: string, comps: number, count: number): Types.Accessor
|
||||
return Types.Scene.accessor(buffer.fromstring(s), ty, comps, count)
|
||||
end
|
||||
@@ -237,7 +228,6 @@ for _, spec in Scenes do
|
||||
t:check(buffer.tostring(again) == buffer.tostring(out :: buffer), label .. ": re-encode is identical")
|
||||
end
|
||||
end
|
||||
-- options: header, name, computed vs attribute normals
|
||||
do
|
||||
local scene = build(Scenes[1])
|
||||
local out = Stl.encode(scene, { header = "my header", ascii = false }) :: buffer
|
||||
@@ -258,7 +248,6 @@ do
|
||||
t:eq(buffer.len(Stl.encode(bare) :: buffer), 84 + 50 * 60, "a scene without nodes")
|
||||
end
|
||||
|
||||
-- 4. error codes
|
||||
do
|
||||
local cube = Fx.cases[1].data
|
||||
local _, e1 = decode(string.sub(cube, 1, 84 + 50 * 3 + 7))
|
||||
@@ -302,7 +291,6 @@ do
|
||||
t:eq(Stl.sniff(Bytes.reader(buffer.fromstring("ply\nformat ascii 1.0\n"))), 0, "sniff a PLY")
|
||||
end
|
||||
|
||||
-- 5. fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Fx.cases do
|
||||
|
||||
+3
-27
@@ -1,10 +1,5 @@
|
||||
-- model/usda tests: stages authored with OpenUSD's API (every xform op kind / order, pivots, resetXformStack,
|
||||
-- primvar interpolations, holes, leftHanded, n-gons, UsdPreviewSurface networks, GeomSubsets, inherited bindings,
|
||||
-- cameras, lights, time samples, a USDZ package, a USDC file), a hand-written grammar test, assimp's USD models
|
||||
-- (usda + usdc converted by Sdf), Blender 5 exports of glTF samples - all against OpenUSD (pxr: world transforms,
|
||||
-- triangles, area and bounds per mesh, bound materials, PreviewSurface inputs and textures, cameras, lights, xform time
|
||||
-- samples); OpenUSD's schema layers parse-only (prim spec counts); round trips through our writer (stable text) and
|
||||
-- pxr reading our output (usda_xcheck); the api; errors; the fuzz no-throw pass. Fixtures: tools/fixtures/usda.py.
|
||||
-- model/usda tests: OpenUSD-authored stages, assimp's USD models and Blender exports against OpenUSD (pxr).
|
||||
-- Fixtures: tools/fixtures/usda.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Usda = require("@rosetta/model/usda")
|
||||
@@ -42,8 +37,6 @@ local function nearAll(a: { number }, b: { number }, eps: number): boolean
|
||||
return true
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ scene helpers
|
||||
-- a node's channels evaluated at time s (seconds): translation / rotation / scale overrides
|
||||
local function animated(scene: any, s: number?): { [number]: any }
|
||||
local out: { [number]: any } = {}
|
||||
if not s then
|
||||
@@ -79,7 +72,6 @@ local function animated(scene: any, s: number?): { [number]: any }
|
||||
return out
|
||||
end
|
||||
|
||||
-- world matrices of every node (at animation time s when given)
|
||||
local function worlds(scene: any, s: number?): { [number]: { number } }
|
||||
local over = animated(scene, s)
|
||||
local out: { [number]: { number } } = {}
|
||||
@@ -118,7 +110,6 @@ local function byPath(scene: any): { [string]: number }
|
||||
return out
|
||||
end
|
||||
|
||||
-- triangles, world area and bounds of a node's mesh (or of everything: node = nil)
|
||||
local function geometry(scene: any, ws: { [number]: { number } }, only: number?): (number, number, { number }, { number })
|
||||
local tris, area = 0, 0
|
||||
local lo, hi = { math.huge, math.huge, math.huge }, { -math.huge, -math.huge, -math.huge }
|
||||
@@ -152,7 +143,6 @@ local function geometry(scene: any, ws: { [number]: { number } }, only: number?)
|
||||
return tris, area, lo, hi
|
||||
end
|
||||
|
||||
-- pxr's totals over every mesh
|
||||
local function refTotals(ref: any): (number, number, { number }, { number })
|
||||
local tris, area = 0, 0
|
||||
local lo, hi = { math.huge, math.huge, math.huge }, { -math.huge, -math.huge, -math.huge }
|
||||
@@ -172,7 +162,6 @@ end
|
||||
local LIGHT_TYPES = { DistantLight = "directional", SphereLight = "point", RectLight = "spot", DiskLight = "spot" }
|
||||
local SKIP_TYPES = { Skeleton = true, SkelRoot = true }
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ against pxr
|
||||
local decoded: { [number]: any } = {}
|
||||
local counts = { xforms = 0, meshes = 0, materials = 0, cameras = 0, lights = 0, samples = 0, textures = 0 }
|
||||
for ci, c in Cases do
|
||||
@@ -206,7 +195,6 @@ for ci, c in Cases do
|
||||
end
|
||||
end
|
||||
end
|
||||
-- meshes
|
||||
for _, m in ref.meshes do
|
||||
local ni = paths[m.path]
|
||||
local node = ni and scene.nodes[ni]
|
||||
@@ -236,7 +224,6 @@ for ci, c in Cases do
|
||||
counts.meshes += 1
|
||||
end
|
||||
end
|
||||
-- cameras
|
||||
for _, cam in ref.cameras do
|
||||
local ni = paths[cam.path]
|
||||
local camera = ni and scene.nodes[ni].camera and scene.cameras[scene.nodes[ni].camera]
|
||||
@@ -252,7 +239,6 @@ for ci, c in Cases do
|
||||
counts.cameras += 1
|
||||
end
|
||||
end
|
||||
-- lights
|
||||
for _, l in ref.lights do
|
||||
local ni = paths[l.path]
|
||||
local light = ni and scene.nodes[ni].light and scene.lights[scene.nodes[ni].light]
|
||||
@@ -267,7 +253,6 @@ for ci, c in Cases do
|
||||
counts.lights += 1
|
||||
end
|
||||
end
|
||||
-- materials
|
||||
local mats = {}
|
||||
for _, m in scene.materials do
|
||||
if m.extras and m.extras.usd and m.extras.usd.path then
|
||||
@@ -311,7 +296,6 @@ for ci, c in Cases do
|
||||
counts.materials += 1
|
||||
end
|
||||
end
|
||||
-- xform time samples
|
||||
for _, a in ref.anim do
|
||||
local ni = paths[a.path]
|
||||
for _, smp in a.samples do
|
||||
@@ -330,7 +314,6 @@ for ci, c in Cases do
|
||||
end
|
||||
t:note("%d files against pxr: %d transforms, %d meshes, %d materials (%d textures), %d cameras, %d lights, %d time samples", #Cases, counts.xforms, counts.meshes, counts.materials, counts.textures, counts.cameras, counts.lights, counts.samples)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ specific facts
|
||||
do
|
||||
local hand
|
||||
for ci, c in Cases do
|
||||
@@ -382,7 +365,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ parse-only
|
||||
for _, s in Specs do
|
||||
local layer, err = Usda.parse(s.data)
|
||||
t:check(layer, s.name .. ": parse: " .. tostring(err))
|
||||
@@ -400,7 +382,6 @@ for _, s in Specs do
|
||||
end
|
||||
t:note("%d OpenUSD schema layers parsed", #Specs)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ round trips
|
||||
local rt = 0
|
||||
local texts: { [number]: string } = {}
|
||||
for ci = 1, #Cases do
|
||||
@@ -440,8 +421,7 @@ for ci = 1, #Cases do
|
||||
t:check(near(x2, y2, 1e-4) and nearAll(x3, y3, 1e-4), string.format("%s: round trip animation at %g s", name, s))
|
||||
end
|
||||
end
|
||||
-- our text is stable: after one cycle (a scene with several roots gains a "root" prim), writing what we
|
||||
-- read from our own output gives the same text
|
||||
-- a scene with several roots gains a "root" prim on the first cycle; after that our text is stable
|
||||
local again = Usda.encode(back, { files = {}, name = "rt.usda" }) :: buffer
|
||||
local third = Usda.encode((decode(again)), { files = {}, name = "rt.usda" }) :: buffer
|
||||
t:eq(buffer.tostring(third), buffer.tostring(again), name .. ": stable text")
|
||||
@@ -451,7 +431,6 @@ for ci = 1, #Cases do
|
||||
end
|
||||
t:note("%d round trips", rt)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ pxr reads our output
|
||||
local xc = 0
|
||||
for _, x in Xcheck do
|
||||
local scene = decoded[x.case]
|
||||
@@ -500,7 +479,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read back by pxr like the originals", xc)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ api
|
||||
do
|
||||
local scene, err = F.model.load(Cases[1].data)
|
||||
t:check(scene and scene.meta.source.format == "usda", "api: F.model.load sniffs usda: " .. tostring(err))
|
||||
@@ -511,7 +489,6 @@ do
|
||||
t:eq(F.detect(Cases[1].data), "usda", "api: detect")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e1 = decode("#usda 1.0\ndef Xform \"a\" {\n")
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "truncated prim: " .. tostring(e1))
|
||||
@@ -530,7 +507,6 @@ do
|
||||
t:check(e7 and e7.code == Err.CORRUPT, "nesting limit")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
if #c.data < 40000 then
|
||||
|
||||
+2
-12
@@ -1,8 +1,5 @@
|
||||
-- model/vox tests: MagicaVoxel files (ephtracy samples, opengametools scene files saved by MagicaVoxel 0.99.x) and
|
||||
-- synthetic files with every chunk type, against an independent reader (tools/fixtures/vox.py): grids (CRC), palette,
|
||||
-- the default palette (parsed from the spec text), scene graph world transforms (rotations, mirrors, nesting), layers,
|
||||
-- materials, notes, cameras, render objects; greedy meshes (MeshOps) against the exposed face count; round trips
|
||||
-- through the writer; error codes; the fuzz no-throw pass. Fixtures: tools/fixtures/vox.py.
|
||||
-- model/vox tests: MagicaVoxel and synthetic files against an independent reader; greedy meshes against the exposed face count.
|
||||
-- Fixtures: tools/fixtures/vox.py.
|
||||
local T = require("@tests/T")
|
||||
local Vox = require("@rosetta/model/vox")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -20,7 +17,6 @@ local function decode(data: any, opts: any?): (any, any)
|
||||
return Vox.decode(Bytes.reader(b), opts)
|
||||
end
|
||||
|
||||
-- the contract
|
||||
t:eq(Vox.name, "vox", "name")
|
||||
t:eq(Vox.category, "model", "category")
|
||||
t:check(Vox.extensions[1] == "vox" and Vox.caps.decode and Vox.caps.encode, "contract")
|
||||
@@ -57,7 +53,6 @@ local function countKeys(tbl: any): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- shape nodes depth first with world matrices (column-major 4x4)
|
||||
local function shapes(scene: any): { any }
|
||||
local out = {}
|
||||
local function walk(i: number, parent: { number })
|
||||
@@ -121,7 +116,6 @@ local function checkScene(scene: any, c: any, label: string)
|
||||
end
|
||||
end
|
||||
|
||||
-- area and winding of a greedy mesh
|
||||
local function meshFacts(prim: any): (number, boolean, number)
|
||||
local pos, nrm = prim.attributes.POSITION.data, prim.attributes.NORMAL.data
|
||||
local ind = prim.indices.data
|
||||
@@ -166,7 +160,6 @@ for _, c in Cases do
|
||||
totalQuads += tris // 2
|
||||
totalFaces += m.faces
|
||||
end
|
||||
-- round trip through the writer
|
||||
local out, eerr = Vox.encode(scene)
|
||||
t:check(out, label .. ": encode: " .. tostring(eerr))
|
||||
local back, berr = Vox.decode(Bytes.reader(out :: buffer))
|
||||
@@ -181,7 +174,6 @@ for _, c in Cases do
|
||||
end
|
||||
t:note("%d files: grids, palettes, scene graphs and round trips match; greedy: %d quads for %d faces", #Cases, totalQuads, totalFaces)
|
||||
|
||||
-- the synthetic scene in detail: names, hidden, layers, animation frames, materials, notes, IMAP, unknown chunks
|
||||
do
|
||||
local c
|
||||
for _, x in Cases do
|
||||
@@ -246,7 +238,6 @@ do
|
||||
t:eq(prim.indices.count, 72, "two separate cubes: 12 quads")
|
||||
end
|
||||
|
||||
-- errors
|
||||
do
|
||||
local _, e = decode("nope")
|
||||
t:check(e and e.code == Err.CORRUPT, "junk: " .. tostring(e))
|
||||
@@ -268,7 +259,6 @@ do
|
||||
t:check(e7 and e7.code == Err.ARG, "voxelsToPrimitive of junk")
|
||||
end
|
||||
|
||||
-- fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
+2
-15
@@ -1,10 +1,5 @@
|
||||
-- model/vrml tests: assimp's WRL test models (HelloWorld, Wuson, the MotionCaptureROM animation), scenes and glTF
|
||||
-- samples written by VTK's VRML exporter, and hand-written feature files (PROTO, DEF / USE, per-face colours and
|
||||
-- separate indices, primitives, ElevationGrid, Extrusion, Switch, LOD, lights, viewpoints, ROUTE animations,
|
||||
-- PixelTexture, Inline), against VTK's vtkVRMLImporter (polygons, points, world bounds where VTK's transforms are
|
||||
-- right) and exact expectations; the writer: round trips of every case and of glTF sample models (world triangles,
|
||||
-- materials, textures, cameras, lights, animation samples), VTK reading our files like the originals; errors; the
|
||||
-- fuzz no-throw pass. Fixtures: tools/fixtures/vrml.py.
|
||||
-- model/vrml tests: assimp's WRL models, VTK exports and hand-written files against vtkVRMLImporter and exact values.
|
||||
-- Fixtures: tools/fixtures/vrml.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Vrml = require("@rosetta/model/vrml")
|
||||
@@ -31,7 +26,6 @@ t:eq(Vrml.name, "vrml", "name")
|
||||
t:eq(Vrml.category, "model", "category")
|
||||
t:check(Vrml.caps.decode and Vrml.caps.encode, "contract")
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
local scenes, byName = {}, {}
|
||||
local checked = { vtk = 0, bounds = 0, none = 0 }
|
||||
for i, c in Cases do
|
||||
@@ -60,7 +54,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files: %d against VTK (%d with bounds), %d VTK cannot read", #Cases, checked.vtk, checked.bounds, checked.none)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ exact expectations
|
||||
local function prims(scene: any): { any }
|
||||
local out = {}
|
||||
for _, pl in Types.Scene.flatten(scene) do
|
||||
@@ -228,7 +221,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ writer
|
||||
local function compare(a: any, b: any, label: string)
|
||||
local sa, sb = C.stats(a), C.stats(b)
|
||||
t:eq(sb.prims, sa.prims, label .. ": placed primitives")
|
||||
@@ -274,7 +266,6 @@ for i, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- glTF samples through VRML: world triangles, materials, textures, cameras, lights, animation samples
|
||||
local gltfScenes = {}
|
||||
for i, c in GltfCases do
|
||||
local g = Gltf.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files })
|
||||
@@ -305,7 +296,6 @@ for i, c in GltfCases do
|
||||
t:check(t2.data and buffer.tostring(t2.data) == buffer.tostring(tex.data), c.name .. ": texture " .. k .. " bytes")
|
||||
end
|
||||
end
|
||||
-- animations: the translation / rotation / scale channels, sampled at their keys
|
||||
local want = 0
|
||||
for _, a in g.animations do
|
||||
for _, ch in a.channels do
|
||||
@@ -323,7 +313,6 @@ for i, c in GltfCases do
|
||||
end
|
||||
t:note("%d round trips", rt)
|
||||
|
||||
-- VTK reads our files like the originals
|
||||
local xc = 0
|
||||
for _, x in Xcheck do
|
||||
local v = x.vtk
|
||||
@@ -344,7 +333,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read by VTK", xc)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ api, options, errors
|
||||
do
|
||||
local text = Cases[1].data
|
||||
t:eq(F.detect(text), "vrml", "F.detect")
|
||||
@@ -390,7 +378,6 @@ do
|
||||
t:check(q and q.meshes[1].primitives[1].faces.count == 1 and q.nodes[1].name == "quad", "a quad stays one polygon, names kept")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
+2
-12
@@ -1,8 +1,5 @@
|
||||
-- model/x tests: assimp's DirectX test models (text, binary 32-bit, MSZIP-compressed binary) and variants made by
|
||||
-- tools/fixtures/x.py (binary with 64-bit floats, MSZIP-compressed text), against assimp (meshes per material, faces,
|
||||
-- corners, materials, animations, bones, world bounds); frames, materials and textures, vertex colours, skins
|
||||
-- (influences, inverse bind matrices against the bind pose), animation keys (the rotation convention against the
|
||||
-- bind pose); an inline text file; errors; the fuzz no-throw pass. Fixtures: tools/fixtures/x.py.
|
||||
-- model/x tests: assimp's DirectX models and generated variants (64-bit floats, MSZIP text) against assimp.
|
||||
-- Fixtures: tools/fixtures/x.py.
|
||||
local T = require("@tests/T")
|
||||
local X = require("@rosetta/model/x")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -75,7 +72,6 @@ local function boundsMatch(lo: { number }?, hi: { number }?, a: any, eps: number
|
||||
return true
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ assimp
|
||||
local scenes, byName = {}, {}
|
||||
local checked = 0
|
||||
for i, c in Cases do
|
||||
@@ -105,7 +101,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files checked against assimp", checked)
|
||||
|
||||
-- variants decode like their originals
|
||||
for _, c in Cases do
|
||||
if c.of then
|
||||
local a, b = scenes[c.name], scenes[c.of]
|
||||
@@ -121,7 +116,6 @@ for _, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ details
|
||||
do
|
||||
local s = scenes["models/kwxport_test_cubewithvcolors.x"]
|
||||
local p = s.meshes[1].primitives[1]
|
||||
@@ -135,7 +129,6 @@ do
|
||||
t:eq(v.meta.source.floatSize, 64, "64-bit floats")
|
||||
end
|
||||
do
|
||||
-- textures: uri names, TEXCOORD_0
|
||||
local s = scenes["models/test.x"]
|
||||
local any = false
|
||||
for _, m in s.materials do
|
||||
@@ -225,7 +218,6 @@ do
|
||||
t:check(total > 0 and same >= total * 0.5, string.format("first rotation keys match the bind pose (%d / %d)", same, total))
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ inline file
|
||||
local CUBE = [[xof 0303txt 0032
|
||||
// a quad and a triangle, two materials, one animated frame
|
||||
Material Red { 1.0; 0.0; 0.0; 1.0;; 10.0; 0.5; 0.5; 0.5;; 0.0; 0.0; 0.0;; TextureFilename { "tex\\red.png"; } }
|
||||
@@ -275,7 +267,6 @@ do
|
||||
t:eq(tri.meshes[1].primitives[1].indices.count, 6, "inline: quad fan-triangulated")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e1 = decode("xof 0303txt 00")
|
||||
t:check(e1 and e1.code == Err.TRUNCATED, "short: " .. tostring(e1))
|
||||
@@ -294,7 +285,6 @@ do
|
||||
t:eq(X.sniff(Bytes.reader(buffer.fromstring(CUBE))), 1, "sniff")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = { CUBE }
|
||||
for _, c in Cases do
|
||||
|
||||
+2
-12
@@ -1,9 +1,5 @@
|
||||
-- model/x3d tests: assimp's X3D / X3DV / X3DB test models, scenes and glTF samples written by VTK's X3D exporter and
|
||||
-- by assimp's X3D exporter, and hand-written feature files (the X3D triangle / quad / line sets, ColorRGBA,
|
||||
-- ProtoDeclare / ProtoInstance with SFNode defaults, PhysicalMaterial, UnlitMaterial, OrthoViewpoint, ROUTE
|
||||
-- animation, UNIT, the classic encoding's header statements), against assimp's X3D reader (meshes, faces, materials,
|
||||
-- world bounds) and exact expectations; .x3dv against the same model as .x3d; the writer (XML and classic): round
|
||||
-- trips, and assimp reading our X3D like the originals; errors; the fuzz no-throw pass. Fixtures: tools/fixtures/x3d.py.
|
||||
-- model/x3d tests: assimp's X3D models, VTK / assimp exports and hand-written files against assimp and exact values.
|
||||
-- Fixtures: tools/fixtures/x3d.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local X3d = require("@rosetta/model/x3d")
|
||||
@@ -34,7 +30,6 @@ t:check(X3d.caps.decode and X3d.caps.encode, "contract")
|
||||
-- exporter writes points and lines as 1- / 2-vertex faces (not valid IndexedFaceSet faces, dropped here)
|
||||
local QUIRK = { ["assimp/X3D/ComputerKeyboard.x3d"] = "all", ["assimp-export/assimp_MeshPrimitiveModes.x3d"] = "all" }
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ reference files
|
||||
local scenes, byName = {}, {}
|
||||
local checked = { assimp = 0, none = 0 }
|
||||
for i, c in Cases do
|
||||
@@ -73,7 +68,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d files: %d against assimp, %d without a reference", #Cases, checked.assimp, checked.none)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ exact expectations
|
||||
do
|
||||
local kb = byName["assimp/X3D/ComputerKeyboard.x3d"]
|
||||
if kb then
|
||||
@@ -177,7 +171,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ writer
|
||||
local function compare(a: any, b: any, label: string)
|
||||
local sa, sb = C.stats(a), C.stats(b)
|
||||
t:eq(sb.prims, sa.prims, label .. ": placed primitives")
|
||||
@@ -215,7 +208,6 @@ for i, c in Cases do
|
||||
end
|
||||
t:note("%d round trips", rt)
|
||||
|
||||
-- assimp reads our X3D like the source
|
||||
local sources: { [string]: { any } } = { xcase = {}, wcase = {}, xgltf = {} }
|
||||
for i, c in Cases do
|
||||
sources.xcase[i] = { scenes[i], c }
|
||||
@@ -260,7 +252,6 @@ for _, x in Xcheck do
|
||||
end
|
||||
t:note("%d of our files read by assimp (%d skipped: empty nodes)", xc, skipped)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ api, errors
|
||||
do
|
||||
local hw = Cases[2]
|
||||
t:eq(F.detect(hw.data), "x3d", "F.detect .x3d")
|
||||
@@ -288,7 +279,6 @@ do
|
||||
t:check(us and #u.meshes == 2 and us.prims == 3 and near(us.hi[1], 6, 1e-9) and near(us.hi[2], 2, 1e-6), "USE / containerField / Switch in XML")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Cases do
|
||||
|
||||
Reference in new issue
Block a user