model/blend: Blender 1.6x-2.0x files (big-endian, 32-bit, TFace / MCol, IPO curves, additive dsize), easing curves, owner-scoped address lookup; containers/Blend tests; docs section; bench line

This commit is contained in:
4DBug committed 2026-11-01 19:23:28 -06:00
1 parent 2e82b7d0af
commit 3c8d5e99d7
14 files changed
+766 -110

No files matched your search

+10 -15
View File
@@ -185,15 +185,10 @@ function Prim.cornerNormals(poly: MeshT.Poly, fn: buffer, ang: buffer, fans: Fan
local r = readu32(fanId, c * 4)
local x, y, z = readf32(acc, r * 12), readf32(acc, r * 12 + 4), readf32(acc, r * 12 + 8)
local l = sqrt(x * x + y * y + z * z)
if l > 1e-20 then
x, y, z = x / l, y / l, z / l
else
local fi = readu32(fans.face, c * 4)
x, y, z = readf32(fn, fi * 12), readf32(fn, fi * 12 + 4), readf32(fn, fi * 12 + 8)
end
writef32(out, c * 12, x)
writef32(out, c * 12 + 4, y)
writef32(out, c * 12 + 8, z)
local fi = readu32(fans.face, c * 4)
writef32(out, c * 12, if l > 1e-20 then x / l else readf32(fn, fi * 12))
writef32(out, c * 12 + 4, if l > 1e-20 then y / l else readf32(fn, fi * 12 + 4))
writef32(out, c * 12 + 8, if l > 1e-20 then z / l else readf32(fn, fi * 12 + 8))
end
return out, fanId
end
@@ -231,7 +226,7 @@ local function triangulate(poly: MeshT.Poly, fi: number, fnx: number, fny: numbe
elseif ay >= az then
cu, cv, sign = 2, 0, fny
end
local ring = table.create(n * 2)
local ring = table.create(n * 2) :: { number }
for c = s0, s1 - 1 do
local v = readu32(poly.cornerVert, c * 4)
local u, w = readf32(poly.pos, (v * 3 + cu) * 4), readf32(poly.pos, (v * 3 + cv) * 4)
@@ -284,7 +279,7 @@ function Prim.build(poly: MeshT.Poly, slots: { number }, opts: Options?, skin: S
table.insert(g, fi)
end
table.sort(order)
local cornerColors, pointColors = {}, {}
local cornerColors: { MeshT.Color }, pointColors: { MeshT.Color } = {}, {}
for _, c in poly.colors do
table.insert(if c.domain == "corner" then cornerColors else pointColors, c)
end
@@ -367,7 +362,7 @@ function Prim.build(poly: MeshT.Poly, slots: { number }, opts: Options?, skin: S
ci += 1
end
if skin and poly.weights then
local lists = table.create(n)
local lists = table.create(n) :: { { number } }
for i = 1, n do
local src = poly.weights[vsrc[i] + 1] or {}
local l = {}
@@ -415,17 +410,17 @@ function Prim.build(poly: MeshT.Poly, slots: { number }, opts: Options?, skin: S
end
if shapes and ref and #shapes > 1 then
local base = shapes[ref].data
local targets = {}
local targets: { { [string]: Types.Accessor } } = {}
for k, s in shapes do
if k ~= ref then
local t = table.create(n * 3)
local t = table.create(n * 3) :: { number }
for i = 1, n do
local v = vsrc[i]
for c = 0, 2 do
t[(i - 1) * 3 + c + 1] = readf32(s.data, (v * 3 + c) * 4) - readf32(base, (v * 3 + c) * 4)
end
end
table.insert(targets, { POSITION = accessor(t, 3) })
table.insert(targets, { POSITION = accessor(t, 3) } :: { [string]: Types.Accessor })
end
end
prim.targets = targets