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

+51 -2
View File
@@ -3,8 +3,10 @@
# generation (MFace legacy save, MPoly / MLoop, attribute layers, AttributeStorage), gzip and zstd compression, the
# 5.0 header, layered actions. Reference values come from the current Blender opening each file
# (tools/fixtures/_blend_ref.py: bpy values plus its glTF exporter's output). An old Blender that does not run is
# skipped (its cases are missing; the test notes it).
# tests/gen/blend_<ver>.luau { { name, data, ref } }
# skipped (its cases are missing; the test notes it). Plus a few Blender 1.6x / 2.0x files from download.blender.org's
# old demos (fetched, never committed; 32-bit pointers, big-endian SGI / PowerPC files among them), with references
# from Blender 4.1 (5.0 dropped big-endian files).
# tests/gen/blend_<ver>.luau { { name, data, ref } } (<ver>: 279, 293, 35, 41, cur, old)
# tests/gen/blend_files.luau sibling files the scenes refer to ({ ["outside.png"] = bytes })
import json, os, shutil, subprocess, tempfile
@@ -18,6 +20,52 @@ OLD = [
]
OLD_DEMOS = "https://download.blender.org/demo/old_demos/"
OLD_FILES = ["escher.blend", "hairball.blend", "nmesh.blend", "relative.blend", "demo2.04.blend.gz"]
def old_samples(ctx, tmp):
import gzip, urllib.request
out = os.path.join(tmp, "olddemos")
os.makedirs(out)
files = []
for f in OLD_FILES:
try:
with urllib.request.urlopen(OLD_DEMOS + f, timeout=60) as r:
data = r.read()
except OSError as e:
print("blend: could not fetch %s: %s" % (f, e))
continue
if f.endswith(".gz"):
data = gzip.decompress(data)
f = f[:-3].replace("2.04", "204")
with open(os.path.join(out, f), "wb") as fh:
fh.write(data)
files.append(os.path.join(out, f))
if not files:
return []
refdir = os.path.join(tmp, "oldref")
os.makedirs(refdir)
ref = os.path.join(ctx.root, "tools", "fixtures", "_blend_ref.py")
ok, log = run(["nix", "shell"] + OLD[3][1] + ["-c", "blender", "-b", "--factory-startup", "--python", ref, "--", json.dumps(files), refdir])
cases = []
for p in files:
rp = os.path.join(refdir, os.path.basename(p) + ".json")
if not os.path.exists(rp):
continue
r = json.load(open(rp))
if r.get("error"):
continue
g = r.get("gltf")
if g:
for k in ("bufferViews", "asset", "scene", "scenes", "extensionsUsed", "samplers"):
g.pop(k, None)
cases.append({"name": "old/" + os.path.basename(p), "data": open(p, "rb").read(), "ref": clean(r)})
if not cases:
print("blend: Blender 4.1 gave no reference for the old demos: " + log[-400:])
return cases
def env():
e = dict(os.environ)
e.pop("LD_LIBRARY_PATH", None) # the host's alsa / pipewire libraries need a newer glibc than old Blenders have
@@ -87,6 +135,7 @@ def generate(ctx):
for tag, _ in OLD + [("cur", None)]:
if tag not in made:
ctx.emit("blend_" + tag, [])
ctx.emit("blend_old", old_samples(ctx, tmp))
ctx.emit("blend_files", {"outside.png": sibling or b""})
ctx.emit("blend_versions", sorted(made.keys()))
shutil.rmtree(tmp, ignore_errors=True)