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