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