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

+3 -2
View File
@@ -89,8 +89,9 @@ local function wire(v: Blend.View?): { [string]: { number } }?
if not v then
return nil
end
local out = {}
for key, field in { normal = "solid", select = "select", active = "active" } do
local out: { [string]: { number } } = {}
for _, pair in { { "normal", "solid" }, { "select", "select" }, { "active", "active" } } do
local key, field = pair[1], pair[2]
local fld = v.struct.byName[field]
local o = fld and v.offset + fld.offset
if not o or o + 3 > buffer.len(v.file.buf) then
+3 -5
View File
@@ -666,11 +666,9 @@ function Mesh.shapes(f: Blend.File, me: Blend.View, nv: number): ({ Shape }, num
else
index += 1
end
local name = kb:str("name")
if not name or name == "" then
-- unnamed in old files: named as Blender's 2.45 versioning does (Basis, Key 1, Key 2, ...)
name = if isRef then "Basis" else "Key " .. index
end
local stored = kb:str("name")
-- unnamed in old files: named as Blender's 2.45 versioning does (Basis, Key 1, Key 2, ...)
local name: string = if stored and stored ~= "" then stored elseif isRef then "Basis" else "Key " .. index
table.insert(out, {
name = name, value = kb:num("curval") or 0, relative = kb:num("relative") or 0, data = d,
mute = bit32.band(kb:num("flag") or 0, 1) ~= 0, -- KEYBLOCK_MUTE
+1 -1
View File
@@ -278,7 +278,7 @@ local function targetDeltas(poly: MeshT.Poly, vsrc: { number }, shapes: { MeshT.
local t = table.create(n * 3) :: { number }
for i = 1, n do
local v = vsrc[i]
local w = 1
local w: number = 1
if def then
w = 0
local list = poly.weights and poly.weights[v + 1] or {}
+8 -8
View File
@@ -3,8 +3,8 @@
-- or Base list before 2.8) with their transforms (euler orders, quaternion, axis angle, delta transforms, parent
-- inverse; bone parents), meshes (model/blend/Mesh, model/blend/Prim), materials (Principled BSDF node or the legacy
-- colour), images (packed bytes or external uris), cameras, lights (watts to candela / lux as Blender's glTF exporter
-- does: 683 lm/W, / 4 pi for point and spot), armatures (bones to joint nodes with the saved pose), skins, shape keys
-- and actions sampled into channels.
-- does: 683 lm/W, / 4 pi for point and spot), armatures (bones to joint nodes with the saved pose, rig data through
-- model/blend/Armature), skins, shape keys and actions sampled into channels.
local Blend = require("@rosetta/containers/Blend")
local Types = require("@rosetta/Types")
local Mat4 = require("@rosetta/codecs/model/Mat4")
@@ -417,16 +417,16 @@ local function groupNames(ob: Blend.View, me: Blend.View): { string }
end
local function shapeExtras(shapes: { Mesh.Shape }, ref: number?): ({ string }, { { [string]: any } })
local names, list = {}, {}
local names: { string }, list: { { [string]: any } } = {}, {}
for k, sh in shapes do
if k ~= ref then
table.insert(names, sh.name)
end
local rel = shapes[sh.relative + 1]
table.insert(list, {
name = sh.name, value = sh.value, slider_min = sh.min, slider_max = sh.max, mute = sh.mute,
relative_key = if rel then rel.name else nil, vertex_group = sh.vgroup,
})
local e: { [string]: any } = { name = sh.name, value = sh.value, slider_min = sh.min, slider_max = sh.max, mute = sh.mute }
e.relative_key = if rel then rel.name else nil
e.vertex_group = sh.vgroup
table.insert(list, e)
end
return names, list
end
@@ -474,7 +474,7 @@ local function meshOf(ctx: Ctx, ob: Blend.View, lines: boolean): (number?, ArmIn
end
if #shapes > 1 then
local names, list = shapeExtras(shapes, ref)
m.extras.targetNames = names
m.extras = { blend = extras, targetNames = names }
extras.shape_keys = list
extras.reference_key = if ref then shapes[ref].name else nil
end
+4 -2
View File
@@ -4,9 +4,10 @@
-- file's own SDNA). Supports: the scene's objects and collections, transforms with parent inverse and bone parents,
-- meshes of every storage generation (MFace, MPoly / MLoop, attribute layers, AttributeStorage) with UV maps, colour
-- attributes, custom normals, material slots; Principled BSDF materials; packed and external images; cameras; lights;
-- armatures, skins (vertex groups, top 4 weights), shape keys; actions sampled into channels.
-- armatures, skins (vertex groups, top 4 weights), shape keys (relative keys, vertex groups); actions sampled into
-- channels; rig data (bone collections / layers, colours, custom shapes, pose settings, constraint stacks) as extras.
-- Not supported: modifiers (listed in meta.source.modifiers), curves / text / metaballs / grease pencil / volumes,
-- NLA strips, drivers, constraints, f-curve modifiers, linked libraries, collection instances.
-- NLA strips, drivers, constraint evaluation, f-curve modifiers, linked libraries, collection instances.
-- ------------------------------------------------------------------------------------------------ requires
local Err = require("@rosetta/core/Err")
@@ -32,6 +33,7 @@ local BlendFormat = {
export type DecodeOptions = {
triangulate: boolean?, -- default true (false: "polygons" primitives)
flipV: boolean?, -- default true (glTF's top-left UV origin)
looseEdges: boolean?, -- edges outside faces as "lines" primitives (default false; always for custom shape widgets)
collections: boolean?, -- collections as nodes (default true)
scene: string?, -- a scene by name (default: the file's current scene)
sampleStep: number?, -- frames between animation samples (default 1)
+3 -2
View File
@@ -447,8 +447,9 @@ function Write.build(scene: Types.Scene, opts: Options?): (Out?, Err.Err?)
restore(g, mesh.extras)
local tn = mesh.extras and (mesh.extras :: any).targetNames
if type(tn) == "table" and #tn > 0 and g.extras == nil then
g.extras = object()
g.extras.targetNames = table.clone(tn)
local ex = object()
ex.targetNames = table.clone(tn)
g.extras = ex
end
table.insert(meshes, g)
end