model/blend: rig data docs section and snippet (docs_blend: control bone, collection, damped track, widget), header; type fixes; rebuild

This commit is contained in:
4DBug committed 2026-11-02 21:57:10 -06:00
1 parent 4231149f3e
commit 9a15a71b4a
15 files changed
+2950 -580

No files matched your search

+12 -1
View File
@@ -1,5 +1,6 @@
# Docs inputs for the .blend section of docs/guide/scene.md (tools/fixtures.py; tools/docs_check.py explains the
# inputs): a small rig saved zstd-compressed by the nixpkgs Blender (a two-bone armature, a skinned cylinder with a
# inputs): a small rig saved zstd-compressed by the nixpkgs Blender (a two-bone armature with a control bone in a bone
# collection, a damped track constraint and an edge-only custom shape outside the scene, a skinned cylinder with a
# shape key, a bone action and a Principled material).
# tests/gen/docs_blend.luau { files = { ["rig.blend"] = bytes }, vars = { riggedBlendBytes = "rig.blend" } }
import importlib.util, os, shutil, subprocess, tempfile
@@ -19,7 +20,16 @@ a = arm.edit_bones.new("lower")
a.head, a.tail = (0, 0, 0), (0, 0, 1)
b = arm.edit_bones.new("upper")
b.head, b.tail, b.parent, b.use_connect = (0, 0, 1), (0, 0, 2), a, True
c = arm.edit_bones.new("ctrl")
c.head, c.tail, c.use_deform = (0.5, 0, 2), (0.5, 0, 2.5), False
bpy.ops.object.mode_set(mode="OBJECT")
arm.collections.new("Controls").assign(arm.bones["ctrl"])
ring = bpy.data.meshes.new("WGT_ring")
ring.from_pydata([(math.cos(k * math.pi / 4), math.sin(k * math.pi / 4), 0) for k in range(8)], [(k, (k + 1) % 8) for k in range(8)], [])
bpy.data.collections.new("Widgets").objects.link(bpy.data.objects.new("WGT_ring", ring))
rig.pose.bones["ctrl"].custom_shape = bpy.data.objects["WGT_ring"]
track = rig.pose.bones["upper"].constraints.new("DAMPED_TRACK")
track.target, track.subtarget = rig, "ctrl"
ring = [(math.cos(k * math.pi / 3) * 0.3, math.sin(k * math.pi / 3) * 0.3) for k in range(6)]
verts = [(x, y, z) for z in (0, 1, 2) for x, y in ring]
faces = [(r * 6 + k, r * 6 + (k + 1) % 6, (r + 1) * 6 + (k + 1) % 6, (r + 1) * 6 + k) for r in range(2) for k in range(6)]
@@ -41,6 +51,7 @@ for i in range(18):
up.add([i], (i // 6) * 0.5, "REPLACE")
tube.shape_key_add(name="Basis")
bulge = tube.shape_key_add(name="Bulge")
bulge.slider_max = 2.0
for p in bulge.data:
p.co = (p.co[0] * 1.4, p.co[1] * 1.4, p.co[2])
pb = rig.pose.bones["upper"]