merge ws/blendrig2

This commit is contained in:
4DBug committed 2026-11-02 23:58:36 -06:00
commit b4e1ffebd4
15 files changed
+1683 -560

No files matched your search

+65 -11
View File
@@ -178,16 +178,30 @@ local REQUIRED: { [string]: { string } } = {
IK = { "chain_count", "pole_target", "pole_subtarget", "pole_angle", "use_tail", "use_stretch", "iterations", "weight" },
COPY_ROTATION = { "use_x", "use_y", "use_z", "invert_x", "invert_y", "invert_z", "mix_mode", "euler_order" },
COPY_LOCATION = { "use_x", "use_y", "use_z", "invert_x", "invert_y", "invert_z", "use_offset", "head_tail" },
COPY_SCALE = { "use_x", "use_y", "use_z", "use_offset", "power" },
COPY_SCALE = { "use_x", "use_y", "use_z", "use_offset", "power", "use_add", "use_make_uniform" },
COPY_TRANSFORMS = { "mix_mode", "head_tail" },
DAMPED_TRACK = { "track_axis", "head_tail" },
LIMIT_ROTATION = { "use_limit_x", "use_limit_y", "use_limit_z", "min_x", "max_x", "min_z", "max_z", "use_transform_limit" },
LIMIT_LOCATION = { "use_min_x", "use_max_x", "use_min_z", "use_max_z", "min_x", "max_x", "min_z", "max_z", "use_transform_limit" },
CHILD_OF = { "inverse_matrix", "use_location_x", "use_rotation_y", "use_scale_x", "use_scale_z", "set_inverse_pending" },
ACTION = { "action", "transform_channel", "frame_start", "frame_end", "min", "max", "mix_mode", "use_bone_object_action", "use_eval_time", "eval_time" },
TRANSFORM = { "map_from", "map_to", "map_to_x_from", "map_to_y_from", "map_to_z_from", "use_motion_extrapolate", "from_rotation_mode",
"to_euler_order", "mix_mode", "mix_mode_rot", "mix_mode_scale", "from_min_x", "from_max_z", "to_min_y", "to_max_x",
"from_min_y_rot", "from_max_x_rot", "to_min_z_rot", "to_max_y_rot", "from_min_x_scale", "from_max_y_scale", "to_min_x_scale", "to_max_y_scale" },
STRETCH_TO = { "rest_length", "bulge", "volume", "keep_axis", "use_bulge_min", "use_bulge_max", "bulge_min", "bulge_max", "bulge_smooth" },
ARMATURE = { "use_deform_preserve_volume", "use_bone_envelopes", "use_current_location", "targets" },
FLOOR = { "floor_location", "offset", "use_rotation" },
LIMIT_DISTANCE = { "distance", "limit_mode" },
TRACK_TO = { "track_axis", "up_axis", "use_target_z" },
LOCKED_TRACK = { "track_axis", "lock_axis" },
}
local BONE_KEYS = { "inherit_scale", "use_inherit_rotation", "use_local_location", "use_relative_parent", "bbone_segments",
"bbone_x", "bbone_z", "bbone_easein", "bbone_easeout", "bbone_rollin", "bbone_rollout", "bbone_curveinx", "bbone_curveinz",
"bbone_curveoutx", "bbone_curveoutz", "bbone_scalein", "bbone_scaleout", "bbone_handle_type_start", "bbone_handle_type_end",
"bbone_custom_handle_start", "bbone_custom_handle_end", "use_endroll_as_inroll", "bbone_mapping_mode" }
local COMMON = { "type", "name", "influence", "mute", "target", "subtarget", "owner_space", "target_space" }
local checked = { rigs = 0, constraints = 0, worlds = 0, meshes = 0, normals = 0, weights = 0, shapes = 0, frames = 0, skinned = 0, curves = 0, materials = 0, cameras = 0, lights = 0 }
local checked = { actions = 0, rigs = 0, constraints = 0, worlds = 0, meshes = 0, normals = 0, weights = 0, shapes = 0, frames = 0, skinned = 0, curves = 0, materials = 0, cameras = 0, lights = 0 }
local samples = {}
t:check(#Sets.old >= 4, "the old demo files were fetched (" .. #Sets.old .. ")")
@@ -544,13 +558,10 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do
for k, s in scene.skins do
t:eq(#s.joints, #gl.skins[k].joints, label .. ": skin joints")
end
-- bones at the saved frame (the rest pose here)
for armName, list in ref.armatures do
local aw = W[objects[armName]]
for _, b in list do
local j = bones[b.name]
t:check(j and nearList(W[j], Scene.mul(aw, b["local"]), 1e-4), label .. ": bone " .. b.name)
end
-- bones at the saved frame: the saved pose (constraints muted in the reference)
for key, want in ref.posedBones do
local j = bones[string.match(key, "/(.+)$")]
t:check(j and nearList(W[j], want, 1e-4), label .. ": bone " .. key)
end
-- rig data against bpy (Blender 5.x reads the old files through its versioning: layers and bone groups as
-- collections, bone group colours as bone colours)
@@ -567,6 +578,18 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do
local g = got[k]
if k == "target" or k == "pole_target" or k == "custom_shape" then
g = nameOf(g)
elseif k == "targets" and type(g) == "table" then
local named = {}
for i, x in g do
named[i] = { target = nameOf(x.target), subtarget = x.subtarget, weight = x.weight }
end
local ok = #named == #want[k]
for i, x in want[k] do
local y = named[i] or {}
ok = ok and y.target == x.target and (y.subtarget or "") == x.subtarget and near(y.weight or -1, x.weight, 1e-5)
end
t:check(ok, what .. " targets")
continue
end
t:check(same(g, want[k], 1e-5), what .. " " .. k .. ": got " .. tostring(g) .. ", want " .. tostring(want[k]))
end
@@ -582,7 +605,8 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do
end
local POSE_KEYS = { "custom_shape", "custom_shape_transform", "custom_shape_translation", "custom_shape_rotation_euler",
"custom_shape_scale_xyz", "use_custom_shape_bone_size", "lock_location", "lock_rotation", "lock_rotation_w",
"lock_rotations_4d", "lock_scale", "rotation_mode", "ik_stretch" }
"lock_rotations_4d", "lock_scale", "rotation_mode", "ik_stretch", "location", "rotation_quaternion", "rotation_euler",
"rotation_axis_angle", "scale" }
for _, a in { "x", "y", "z" } do
for _, k in { "lock_ik_", "use_ik_limit_", "ik_min_", "ik_max_", "ik_stiffness_" } do
table.insert(POSE_KEYS, k .. a)
@@ -605,6 +629,13 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do
compareColor(e.color, b.color, what)
compareColor(e.pose_color, b.pose.color, what .. " pose")
compareTable(e, b.pose, POSE_KEYS, what)
local bk = {}
for _, k in BONE_KEYS do
if b.bone[k] ~= nil then
table.insert(bk, k)
end
end
compareTable(e, b.bone, bk, what)
t:eq(#e.constraints, #b.pose.constraints, what .. " constraints")
for k, rc in b.pose.constraints do
local c = e.constraints[k] or {}
@@ -653,6 +684,29 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do
end
t:check(next(shapes) == nil, label .. ": every custom shape is listed")
end
-- every action, raw: frame range, f-curves, keyframe points (bpy's first layer / strip / channel bag)
for name, ra in if src.version >= 250 then ref.allActions or {} else {} do -- older files: IPOs Blender converts on load
local a = scene.meta.blend and scene.meta.blend.actions and scene.meta.blend.actions[name]
t:check(a and nearList(a.frame_range, ra.frame_range, 1e-5), label .. ": action " .. name .. " frame range")
if not a then
continue
end
t:eq(#a.curves, #ra.curves, label .. ": action " .. name .. " curves")
for k, rc in ra.curves do
local c = a.curves[k] or { keys = {} }
local what = label .. ": action " .. name .. " " .. rc.data_path .. "[" .. rc.array_index .. "]"
t:check(c.data_path == rc.data_path and c.array_index == rc.array_index and c.extrapolation == rc.extrapolation, what)
local bone, prop = string.match(rc.data_path, '^pose%.bones%["(.-)"%]%.([%w_]+)$')
t:check(c.bone == bone and c.path == (prop or rc.data_path), what .. " bone / path")
t:eq(#c.keys, #rc.keys, what .. " keys")
for q, rk in rc.keys do
local ck = c.keys[q] or {}
t:check(nearList(ck.co, rk.co, 1e-5) and nearList(ck.handle_left, rk.handle_left, 1e-4) and nearList(ck.handle_right, rk.handle_right, 1e-4)
and ck.interpolation == rk.interpolation and ck.easing == rk.easing, what .. " key " .. q)
end
checked.actions += 1
end
end
-- f-curves through the evaluator, at every half frame (bezier, linear, constant, extrapolation)
local file = assert(Blend.open(buffer.fromstring(c.data)))
for _, o in ref.objects do
@@ -797,7 +851,7 @@ for _, tag in { "old", "279", "293", "35", "41", "cur" } do
end
end
end
t:note("checked: %d rigs, %d constraints", checked.rigs, checked.constraints)
t:note("checked: %d rigs, %d constraints, %d raw action curves", checked.rigs, checked.constraints, checked.actions)
t:note("checked: %d world matrices, %d meshes, %d corner normal sets, %d weight sets, %d shape key sets, %d f-curves, %d posed frames, %d skinned frames, %d materials, %d cameras, %d lights",
checked.worlds, checked.meshes, checked.normals, checked.weights, checked.shapes, checked.curves, checked.frames, checked.skinned, checked.materials, checked.cameras, checked.lights)