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
+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) }
|
||||
|
||||
Reference in new issue
Block a user