@rig-c/parts 1.83.1 → 1.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,94 @@
1
+ /** Explicit art-joint measurements on a fixed skeleton (issue #880). */
2
+ import { refuseIfAny, type Problem } from './errors.ts';
3
+ import { cropToSpineY } from './coords.ts';
4
+ import { edgeLength } from './length.ts';
5
+
6
+ export interface ArtJoint {
7
+ name: string;
8
+ bone: string;
9
+ /** Measured art point in stage pixels, x right and y down. */
10
+ at: [number, number];
11
+ }
12
+ export interface FixedSkeleton {
13
+ /** Where the independent art measurements came from; never interpreted. */
14
+ source: string;
15
+ joints: ArtJoint[];
16
+ /** Maximum Euclidean distance in stage pixels. Absent means measurement only. */
17
+ within_px?: number;
18
+ }
19
+ const object = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
20
+ const finite = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
21
+ const free = (k: string, v: unknown): boolean => (k.startsWith('x-') && k.length > 2) || ((k === 'note' || k.endsWith('_note')) && typeof v === 'string');
22
+
23
+ /** Validate without deriving any art point, bone correspondence or limit. */
24
+ export function fixedSkeletonProblems(value: unknown, at: string): Problem[] {
25
+ const problems: Problem[] = [];
26
+ const fail = (where: string, detail: string): void => { problems.push({ code: 'REQUIREMENTS_FIELD', object: where, detail }); };
27
+ const keys = (v: Record<string, unknown>, allowed: string[], where: string): void => {
28
+ for (const k of Object.keys(v)) if (!allowed.includes(k) && !free(k, v[k])) fail(`${where}.${k}`, `is unknown; fields are ${allowed.join(', ')}`);
29
+ };
30
+ if (!object(value)) return [{ code: 'REQUIREMENTS_FIELD', object: at, detail: 'requires {source, joints, within_px?}; omit fixed_skeleton for a rig without this declaration' }];
31
+ keys(value, ['source', 'joints', 'within_px'], at);
32
+ if (typeof value.source !== 'string' || value.source.trim() === '') fail(`${at}.source`, 'requires the provenance of the independent art-joint measurements as nonempty text');
33
+ if ('within_px' in value && (!finite(value.within_px) || value.within_px < 0)) fail(`${at}.within_px`, `is ${JSON.stringify(value.within_px)}; a finite nonnegative stage-pixel limit is required, or omit it for a SKIP-class measurement`);
34
+ if (!Array.isArray(value.joints) || value.joints.length === 0) fail(`${at}.joints`, 'requires a nonempty list of {name, bone, at: [x, y]} measured on the art in stage pixels (x right, y down)');
35
+ else {
36
+ const seen = new Set<string>();
37
+ value.joints.forEach((joint, i) => {
38
+ const where = `${at}.joints[${i}]`;
39
+ if (!object(joint)) { fail(where, 'requires {name, bone, at: [x, y]}'); return; }
40
+ keys(joint, ['name', 'bone', 'at'], where);
41
+ for (const k of ['name', 'bone']) if (typeof joint[k] !== 'string' || joint[k].trim() === '') fail(`${where}.${k}`, 'requires a nonempty name');
42
+ if (typeof joint.name === 'string') {
43
+ if (seen.has(joint.name)) fail(`${where}.name`, `declares joint "${joint.name}" twice; each measured joint is declared once`);
44
+ seen.add(joint.name);
45
+ }
46
+ if (!Array.isArray(joint.at) || joint.at.length !== 2 || !joint.at.every(finite)) fail(`${where}.at`, 'requires a finite [x, y] measured on the art in stage pixels (x right, y down)');
47
+ });
48
+ }
49
+ return problems;
50
+ }
51
+
52
+ export const ART_JOINT_LINE = 'ART_JOINT_DISTANCE';
53
+ export interface ArtJointRow extends ArtJoint {
54
+ /** Bone origin in the same stage-pixel space as at. */
55
+ bone_at: [number, number];
56
+ distance_px: number;
57
+ status: 'PASS' | 'FAIL' | 'SKIP';
58
+ }
59
+ export interface ArtJointLine {
60
+ status: 'PASS' | 'FAIL' | 'SKIP';
61
+ instrument: 'rigc-geometry/1 setup.bones';
62
+ source: string;
63
+ within_px: number | null;
64
+ joints: ArtJointRow[];
65
+ reason?: string;
66
+ }
67
+
68
+ /** Compare independent art points to renderer setup origins, never animation frame zero. */
69
+ export function artJointLine(
70
+ fixed: FixedSkeleton,
71
+ stage: { x: number; y: number; height: number },
72
+ setup: (bone: string) => { worldX: number; worldY: number },
73
+ problems: Problem[],
74
+ ): ArtJointLine {
75
+ refuseIfAny(fixedSkeletonProblems(fixed, 'fixed_skeleton'));
76
+ const limit = fixed.within_px;
77
+ const joints = fixed.joints.map<ArtJointRow>(j => {
78
+ const world = setup(j.bone);
79
+ if (!Number.isFinite(world.worldX) || !Number.isFinite(world.worldY)) refuseIfAny([{ code: 'CHECK_ART_JOINT_MEASURED', object: `joint "${j.name}" (bone "${j.bone}")`, detail: 'has no finite renderer setup origin; a missing position is never a zero distance' }]);
80
+ const boneAt: [number, number] = [world.worldX - stage.x, cropToSpineY(world.worldY - stage.y, stage.height)];
81
+ const distance = edgeLength(j.at[0] - boneAt[0], j.at[1] - boneAt[1]);
82
+ if (!Number.isFinite(distance)) refuseIfAny([{ code: 'CHECK_ART_JOINT_MEASURED', object: `joint "${j.name}" (bone "${j.bone}")`, detail: 'has no finite art-to-setup distance; finite stage-pixel coordinates are required' }]);
83
+ const status = limit === undefined ? 'SKIP' : distance > limit ? 'FAIL' : 'PASS';
84
+ if (status === 'FAIL') problems.push({ code: 'CHECK_ART_JOINT_DISTANCE', object: `joint "${j.name}" (bone "${j.bone}")`, detail: `art at [${j.at.join(', ')}] is ${distance} stage px from setup origin [${boneAt.join(', ')}]; distance <= declared fixed_skeleton.within_px ${limit} px is required — correct the art measurement/correspondence if wrong, or supply art aligned to the fixed skeleton; bones are not moved` });
85
+ return { name: j.name, bone: j.bone, at: [...j.at] as [number, number], bone_at: boneAt, distance_px: distance, status };
86
+ });
87
+ return { status: limit === undefined ? 'SKIP' : joints.some(j => j.status === 'FAIL') ? 'FAIL' : 'PASS', instrument: 'rigc-geometry/1 setup.bones', source: fixed.source, within_px: limit ?? null, joints,
88
+ ...(limit === undefined ? { reason: 'fixed_skeleton.within_px is absent; distances are measured, no limit is invented and no joint passes' } : {}) };
89
+ }
90
+
91
+ export function artJointLines(line: ArtJointLine): string[] {
92
+ return [`${ART_JOINT_LINE}: ${line.status}${line.reason === undefined ? '' : ` — ${line.reason}`}; source ${JSON.stringify(line.source)}; ${line.instrument}`,
93
+ ...line.joints.map(j => `${ART_JOINT_LINE}: joint "${j.name}" (bone "${j.bone}") ${j.status} — art [${j.at.join(', ')}], setup [${j.bone_at.join(', ')}], distance ${j.distance_px} px; ${line.within_px === null ? 'no declared limit (SKIP)' : `limit <= ${line.within_px} px`}`)];
94
+ }
package/src/assemble.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { unionTakenSources } from './takesource.ts';
2
+ import { authoredUnitDepths, type AuthoredUnitDepth } from './authoredunit.ts';
2
3
  import { paintingExtensionMasks, paintingExtensionProblems, type PaintingExtension } from './paintingextension.ts';
3
4
  import { AUTOMATIC_WRITERS as AW, compactValueBaseline, pixelProvenance, rgbaEqual, type ValueBaseline } from './provenance.ts';
4
5
  import { bindDepthRun, copyDepthMaterial, registerDepthRun, transportPartDepth, type DepthConfig, type RegisteredDepth } from './depthsheets.ts';
@@ -317,6 +318,11 @@ export function singleRunPadRecord(single: boolean, sourceW: number, sourceH: nu
317
318
  }
318
319
 
319
320
  export interface AssembleInput {
321
+ /** Turn context for the exact part/carrier declarations, never an exemption flag. */
322
+ turn?: TurnSpec;
323
+ regions?: Record<string, RegionSpec>;
324
+ meshes?: Record<string, MeshSpec>;
325
+ motion?: CharacterConfig['motion'];
320
326
  depth?: DepthConfig;
321
327
  /** Config-relative user sheet paths; caller supplies its actual base. */
322
328
  depthBase?: string;
@@ -4638,6 +4644,7 @@ export function checkSingleRun(full: LayerSet, plan: readonly PlanEntry[] | null
4638
4644
  */
4639
4645
  export function assemble(input: AssembleInput): AssembleResult {
4640
4646
  const { source, extend, patches, seamRule, projectRule } = input;
4647
+ const authoredDepths = input.depth === undefined ? new Map<string, AuthoredUnitDepth>() : authoredUnitDepths(input);
4641
4648
  if (input.paintingExtension !== undefined) refuseIfAny(paintingExtensionProblems(input.paintingExtension));
4642
4649
  const single = input.single === true;
4643
4650
  const frame = checkGeometry(
@@ -5541,7 +5548,8 @@ export function assemble(input: AssembleInput): AssembleResult {
5541
5548
  const limbIndex = limb === undefined ? -1 : lim.parts.findIndex(q => q.record.name === limb.name && q.record.segment === limb.segment);
5542
5549
  const upperIndex = limb === undefined ? -1 : lim.parts.findIndex(q => q.record.name === limb.name && q.record.segment === limb.segment - 1);
5543
5550
  const capSource = limbIndex < 0 ? null : lim.capFrom[limbIndex];
5544
- const scalar = transportPartDepth(record, image, registeredDepth, {
5551
+ const authoredDepth = authoredDepths.get(name);
5552
+ const scalar = authoredDepth === undefined ? transportPartDepth(record, image, registeredDepth, {
5545
5553
  map: run => runMap(frame, run), width: W, extend: extendKeys, owner: trace.from,
5546
5554
  ring: trace.ring.data, region: region?.data ?? null,
5547
5555
  copiedSource: (x, y) => {
@@ -5552,7 +5560,7 @@ export function assemble(input: AssembleInput): AssembleResult {
5552
5560
  return { key: e < 0 ? upper.key : upper.extendKeys[e], ring: upper.trace.ring.data[p] !== 0 };
5553
5561
  },
5554
5562
  ...((limb?.cap?.image_px ?? 0) > 0 || (limb?.cap?.lower_px ?? 0) > 0 ? { unsupported: `cap copies ${(limb?.cap?.image_px ?? 0) + (limb?.cap?.lower_px ?? 0)} pixels from a separate cap image whose scalar grid is undeclared` } : {}),
5555
- });
5563
+ }) : undefined;
5556
5564
  if (capSource !== null && upperIndex >= 0 && capSource.codes.some(code => code === CAP_FROM_UPPER)) {
5557
5565
  const upper = limbPieces[upperIndex];
5558
5566
  const keys = [upper.key, ...upper.extendKeys.filter((_, i) => upper.trace.from.some(v => v === i))];
@@ -5573,7 +5581,11 @@ export function assemble(input: AssembleInput): AssembleResult {
5573
5581
 
5574
5582
 
5575
5583
  seamOverride(placed, srcr, seamRule, seamRule === 'silhouette' ? silhouette : null, keepInOrder, input.turnMovingPair ?? null, (i, p) => { writersInOrder[i][p] = AW.seamOverride; });
5576
- placed.forEach((p, i) => { p.record.provenance = pixelProvenance(p.image, p.record.x, p.record.y, W, writersInOrder[i], editNames, 0, valueBaselines.get(p.record.from) ?? null); });
5584
+ placed.forEach((p, i) => {
5585
+ p.record.provenance = pixelProvenance(p.image, p.record.x, p.record.y, W, writersInOrder[i], editNames, 0, valueBaselines.get(p.record.from) ?? null);
5586
+ const depth = authoredDepths.get(p.record.name);
5587
+ if (depth !== undefined) p.record.provenance.depth = depth;
5588
+ });
5577
5589
  // Provenance is now numbers/labels only. No later raster/figure operation
5578
5590
  // reads report buffers; release all aliases before recomposite/error work.
5579
5591
  valueBaselines.clear();
@@ -6487,6 +6499,7 @@ export function stageFields(
6487
6499
  regions?: Record<string, RegionSpec>;
6488
6500
  constraints?: ConfigConstraint[];
6489
6501
  turn?: TurnSpec;
6502
+ motion?: CharacterConfig['motion'];
6490
6503
  },
6491
6504
  single: { w: number; h: number } | null = null,
6492
6505
  ): {
@@ -6512,6 +6525,10 @@ export function stageFields(
6512
6525
  /** Base painting only; named final parts, explicit band and path bound (#848). */
6513
6526
  paintingExtension?: readonly PaintingExtension[];
6514
6527
  turnMovingPair?: (a: string, b: string) => boolean;
6528
+ turn?: TurnSpec;
6529
+ regions?: Record<string, RegionSpec>;
6530
+ meshes?: Record<string, MeshSpec>;
6531
+ motion?: CharacterConfig['motion'];
6515
6532
  } {
6516
6533
  const problems: Problem[] = [];
6517
6534
  if (cfg.seethrough === undefined) {
@@ -6535,6 +6552,7 @@ export function stageFields(
6535
6552
  ...(cfg.assemble.keep_under_occluders === undefined ? {} : { keepUnderOccluders: cfg.assemble.keep_under_occluders }),
6536
6553
  ...(cfg.assemble.extend_painting === undefined ? {} : { paintingExtension: cfg.assemble.extend_painting }),
6537
6554
  ...(turnMovingPair === null ? {} : { turnMovingPair }),
6555
+ ...(cfg.turn === undefined ? {} : { turn: cfg.turn, regions: cfg.regions, meshes: cfg.meshes, motion: cfg.motion }),
6538
6556
  rigScale: cfg.assemble.rig_scale,
6539
6557
  plan: cfg.assemble.plan,
6540
6558
  extend: cfg.assemble.extend_below_crop ?? [],
@@ -0,0 +1,61 @@
1
+ /** Fully explicit unit consumers may omit their unused scalar transport (#877). */
2
+ import type { MeshSpec, Motion, RegionSpec, TurnSpec } from './config.ts';
3
+ import { turnUnitBone } from './turn.ts';
4
+
5
+ export interface AuthoredUnitDepth {
6
+ kind: 'authored-unit';
7
+ /** An absent bone means the part override, which covers every carried piece. */
8
+ values: Array<{ group: 'head' | 'body'; bone?: string; value: number }>;
9
+ }
10
+
11
+ export function authoredUnitDepths(cfg: {
12
+ turn?: TurnSpec;
13
+ regions?: Record<string, RegionSpec>;
14
+ meshes?: Record<string, MeshSpec>;
15
+ motion?: Pick<Motion, 'blink'>;
16
+ }): ReadonlyMap<string, AuthoredUnitDepth> {
17
+ const out = new Map<string, AuthoredUnitDepth>();
18
+ const turn = cfg.turn;
19
+ if (turn === undefined || turn === null || typeof turn !== 'object' || Array.isArray(turn)) return out;
20
+ const groups = [
21
+ { group: 'head' as const, roles: turn.roles, depths: turn.unitDepths },
22
+ { group: 'body' as const, roles: turn.body?.roles, depths: turn.body?.unitDepths ?? turn.unitDepths },
23
+ ];
24
+ const number = (table: Record<string, number> | undefined, name: string): number | undefined => {
25
+ const value = table !== undefined && Object.hasOwn(table, name) ? table[name] : undefined;
26
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
27
+ };
28
+ const parts = new Set(groups.flatMap(g => Object.keys(g.roles ?? {})));
29
+ for (const part of parts) {
30
+ const values: AuthoredUnitDepth['values'] = [];
31
+ let complete = true;
32
+ for (const g of groups) {
33
+ if (g.roles === undefined || !Object.hasOwn(g.roles, part)) continue;
34
+ if (g.roles[part] !== 'unit') { complete = false; break; }
35
+ const explicitPart = number(g.depths, part);
36
+ if (explicitPart !== undefined) { values.push({ group: g.group, value: explicitPart }); continue; }
37
+ const region = cfg.regions?.[part];
38
+ const bone = typeof region === 'string' ? region : region?.bone;
39
+ // Match the producer's actual unit carrier, not a mesh segment's bone.
40
+ const bones = cfg.meshes !== undefined && Object.hasOwn(cfg.meshes, part)
41
+ ? [turnUnitBone(part)]
42
+ : typeof bone === 'string' && bone.length > 0 ? [bone] : [];
43
+ if (cfg.meshes?.[part] === undefined) {
44
+ const still = cfg.motion?.blink?.still?.[part];
45
+ if (still !== undefined) {
46
+ if (typeof still.bone !== 'string' || still.bone.length === 0) { complete = false; break; }
47
+ bones.push(still.bone);
48
+ }
49
+ }
50
+ if (bones.length === 0) { complete = false; break; }
51
+ for (const name of new Set(bones)) {
52
+ const value = number(g.depths, name);
53
+ if (value === undefined) { complete = false; break; }
54
+ values.push({ group: g.group, bone: name, value });
55
+ }
56
+ if (!complete) break;
57
+ }
58
+ if (complete && values.length > 0) out.set(part, { kind: 'authored-unit', values });
59
+ }
60
+ return out;
61
+ }
package/src/build.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ART_JOINT_LINE, artJointLines } from './artjoints.ts';
1
2
  import { applyTakenLayers } from './takelayers.ts';
2
3
  import { ownershipLines, provenanceLines } from './provenance.ts';
3
4
  import { readSourceDepth } from './depthsheets.ts';
@@ -665,6 +666,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
665
666
  ...(fields.headFaceUnderfill === undefined ? {} : { headFaceUnderfill: fields.headFaceUnderfill }),
666
667
  ...(fields.yieldRefused === undefined ? {} : { yieldRefused: fields.yieldRefused }),
667
668
  ...(fields.turnMovingPair === undefined ? {} : { turnMovingPair: fields.turnMovingPair }),
669
+ ...(fields.turn === undefined ? {} : { turn: fields.turn, regions: fields.regions, meshes: fields.meshes, motion: fields.motion }),
668
670
  seamRule: input.seam,
669
671
  projectRule: input.project,
670
672
  ...(altExclude.length === 0 ? {} : { exclude: altExclude }),
@@ -1940,6 +1942,8 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
1940
1942
  if (vsSource !== undefined) log(` ${judgementLine(SOURCE_LINE, vsSource)}`);
1941
1943
  const windBand = fig[WIND_BAND_LINE];
1942
1944
  if (windBand !== undefined) for (const l of windBandLines(windBand)) log(` ${l}`);
1945
+ const artJoints = fig[ART_JOINT_LINE];
1946
+ if (artJoints !== undefined) for (const line of artJointLines(artJoints)) log(` ${line}`);
1943
1947
  if (r.requirements !== null) {
1944
1948
  for (const [name, line] of Object.entries(r.requirements.lines)) log(` ${requirementText(name, line)}`);
1945
1949
  log(` ${summaryText(r.requirements.summary)}`);
package/src/check.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ART_JOINT_LINE, artJointLine, type ArtJointLine } from './artjoints.ts';
1
2
  import { baseAnchorMoves, type AnchorRegion } from './baseanchor.ts';
2
3
  /**
3
4
  * The check stage: build a rig through rig-c, gate it under both
@@ -2694,6 +2695,8 @@ export interface CheckFigures {
2694
2695
  config?: InputFileRecord;
2695
2696
  /** Written only under `--requirements` (issue #93): the file's fps, the summary, and one line per declared requirement, by name. */
2696
2697
  requirements?: RequirementsBlock;
2698
+ /** Issue #880: only when requirements declares fixed_skeleton. */
2699
+ [ART_JOINT_LINE]?: ArtJointLine;
2697
2700
  PASS: boolean;
2698
2701
  }
2699
2702
 
@@ -2940,7 +2943,7 @@ export function barsNotMet(fig: Readonly<Record<string, unknown>>): string[] {
2940
2943
  isRecord(fig.sets) &&
2941
2944
  Object.values(fig.sets).some((s) => isRecord(s) && typeof s.seam_mean === 'number' && typeof s.seam_px_over_40 === 'number' && seamFails(s.seam_mean, s.seam_px_over_40, typeof s.seam_frame_scale === 'number' ? s.seam_frame_scale : 1));
2942
2945
  if ((typeof fig.seam_mean === 'number' && typeof fig.seam_px_over_40 === 'number' && seamFails(fig.seam_mean, fig.seam_px_over_40, scale)) || setFailed) out.push('seam');
2943
- for (const n of [...JUDGEMENT_LINES, FOLD_LINE, LEVEL_LINE, STRESS_LINE, LIMB_LINE, SWEEP_LINE]) {
2946
+ for (const n of [...JUDGEMENT_LINES, FOLD_LINE, LEVEL_LINE, STRESS_LINE, LIMB_LINE, SWEEP_LINE, ART_JOINT_LINE]) {
2944
2947
  const l = fig[n];
2945
2948
  if (typeof l === 'object' && l !== null && (l as { status?: unknown }).status === 'FAIL') out.push(n);
2946
2949
  }
@@ -3049,7 +3052,7 @@ export function checkStatuses(fig: CheckFigures): Record<string, CheckStatus> {
3049
3052
  const bar = (name: string, measured: boolean): CheckStatus => (!measured ? 'SKIP' : notMet.includes(name) ? 'FAIL' : 'PASS');
3050
3053
  const out: Record<string, CheckStatus> = { gate: bar('gate', true), loop: bar('loop', fig.loop_max_diff !== null), seam: bar('seam', fig.seam_mean !== null) };
3051
3054
  for (const n of JUDGEMENT_LINES) out[n] = fig[n].status;
3052
- for (const n of [FOLD_LINE, LEVEL_LINE, STRESS_LINE, LIMB_LINE, SWEEP_LINE, MOTION_SEAM_LINE, CLOTH_LINE, ...REPORTED_LINES, SOURCE_LINE, WIND_BAND_LINE] as const) {
3055
+ for (const n of [FOLD_LINE, LEVEL_LINE, STRESS_LINE, LIMB_LINE, SWEEP_LINE, MOTION_SEAM_LINE, CLOTH_LINE, ...REPORTED_LINES, SOURCE_LINE, WIND_BAND_LINE, ART_JOINT_LINE] as const) {
3053
3056
  const l = fig[n];
3054
3057
  if (l !== undefined) out[n] = l.status;
3055
3058
  }
@@ -6402,7 +6405,9 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
6402
6405
  const setsFigures: Record<string, SetCheckFigures> = {};
6403
6406
  // Issue #671: a failing set's hint, read with its seam; never written to check.json.
6404
6407
  const setHints = new Map<string, string>();
6405
- if (inp.parts !== null || inp.source !== null) {
6408
+ const fixedSkeleton = reqFile?.fixed_skeleton;
6409
+ let artJoints: ArtJointLine | null = null;
6410
+ if (inp.parts !== null || inp.source !== null || fixedSkeleton !== undefined) {
6406
6411
  try {
6407
6412
  mkdirSync(stillDir, { recursive: true });
6408
6413
  const images = typeof inp.rig.images === 'string' ? resolve(inp.rigDir, inp.rig.images) : inp.rig.images;
@@ -6426,9 +6431,18 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
6426
6431
  if (sb.status !== 0) refuseIfAny(rigcFailed('build (the setup-pose still)', sb, buildGateLines(sb.out)));
6427
6432
  // The stage is the parts' canvas wherever parts.json is read (CHECK_RIG_STAGE_IS_THE_CANVAS), so this is its longest side.
6428
6433
  const maxSide = Math.ceil(Math.max(inp.stage.width, inp.stage.height));
6429
- const sr = rigc(['render', '--candidate', join(stillDir, 'build'), '--animation', 'still', '--fps', String(STILL_FPS), '--max', String(maxSide), '--out', join(stillDir, 'render')]);
6434
+ const sr = rigc(['render', '--candidate', join(stillDir, 'build'), '--animation', 'still', '--fps', String(STILL_FPS), '--max', String(maxSide), ...(fixedSkeleton === undefined ? [] : ['--geometry']), '--out', join(stillDir, 'render')]);
6430
6435
  if (sr.status !== 0) refuseIfAny(rigcFailed('render (the setup-pose still)', sr, sr.out.split('\n').filter((l) => l.includes('FAIL'))));
6431
6436
  const stillSet = readFrameSet(join(stillDir, 'render'));
6437
+ if (fixedSkeleton !== undefined) {
6438
+ const geometryPath = join(stillSet.dir, GEOMETRY_FILE);
6439
+ const geometry = readGeometry(geometryPath, stillSet.written);
6440
+ artJoints = artJointLine(fixedSkeleton, inp.stage, bone => {
6441
+ const track = boneTrackOf(geometry, geometryPath, stillSet, bone);
6442
+ if (typeof track === 'string') return geometryProblem(geometryPath, track);
6443
+ return track.setup;
6444
+ }, problems);
6445
+ }
6432
6446
  seamViewport = stillSet.viewport;
6433
6447
  if (keepStills) cpSync(join(stillDir, 'render'), inp.parts === null ? keptDir : join(out, 'setup_still_auto'), { recursive: true });
6434
6448
  if (inp.parts !== null) {
@@ -6621,6 +6635,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
6621
6635
  ...(Object.keys(skipped).length === 0 ? {} : { skipped }),
6622
6636
  ...(Object.keys(setsFigures).length === 0 ? {} : { sets: setsFigures }),
6623
6637
  ...(config === undefined ? {} : { config }),
6638
+ ...(artJoints === null ? {} : { [ART_JOINT_LINE]: artJoints }),
6624
6639
  ...(reqBlock === null ? {} : { requirements: reqBlock }),
6625
6640
  PASS: false,
6626
6641
  };
@@ -6684,6 +6699,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
6684
6699
  }
6685
6700
  // Issues #320, #333: the fold bar is counted where it is written — on every rig whose motion holds an animation.
6686
6701
  if (folds !== null) tally(FOLD_LINE, null);
6702
+ if (artJoints !== null) tally(ART_JOINT_LINE, artJoints.status === 'SKIP' ? (artJoints.reason ?? 'no declared limit') : null);
6687
6703
  // Issue #348: the level bar where it is written; a line whose every foot no frame posed says SKIP and is not measured.
6688
6704
  if (level !== null) tally(LEVEL_LINE, level.status === 'SKIP' ? (level.reason ?? '') : null);
6689
6705
  // Issue #347: the stress bar is counted where it is written — on every rig with a handwear part and an idle.
package/src/parts.ts CHANGED
@@ -503,7 +503,8 @@ function checkOwnership(raw: unknown, object: string, fail: (code: string, objec
503
503
 
504
504
  function orderedProvenance(p: PixelProvenance): PixelProvenance {
505
505
  return { unchanged_layer_px: p.unchanged_layer_px, hand_px: p.hand_px, automatic_px: p.automatic_px,
506
- edits: p.edits.map(e => ({ edit: e.edit, px: e.px })), automatic: p.automatic.map(e => ({ stage: e.stage, px: e.px })) };
506
+ edits: p.edits.map(e => ({ edit: e.edit, px: e.px })), automatic: p.automatic.map(e => ({ stage: e.stage, px: e.px })),
507
+ ...(p.depth === undefined ? {} : { depth: { kind: p.depth.kind, values: p.depth.values.map(v => ({ group: v.group, ...(v.bone === undefined ? {} : { bone: v.bone }), value: v.value })) } }) };
507
508
  }
508
509
 
509
510
  function serializePartList(parts: readonly PartRecord[]): Array<Record<string, unknown>> {
@@ -591,13 +592,13 @@ function show(v: unknown): string {
591
592
  }
592
593
 
593
594
  /** The same optional measurement contract for base and alternate records. */
594
- function checkProvenance(raw: unknown, opaque: unknown, object: string, fail: (code: string, object: string, detail: string) => void): void {
595
+ function checkProvenance(raw: unknown, opaque: unknown, object: string, fail: (code: string, object: string, detail: string) => void, hasScalar = false): void {
595
596
  const v = raw as PixelProvenance | null;
596
597
  const count = (n: unknown): boolean => Number.isSafeInteger(n) && (n as number) >= 0;
597
598
  const edit = (name: string): boolean => /^(cuts\[\d+\]|patches\[\d+\])$/.test(name) ||
598
599
  (/^(full|head):author:/.test(name) && readFrom(name) !== null);
599
600
  const shape = v !== null && typeof v === 'object' && !Array.isArray(v) &&
600
- Object.keys(v).sort().join(',') === 'automatic,automatic_px,edits,hand_px,unchanged_layer_px' &&
601
+ Object.keys(v).filter(k => k !== 'depth').sort().join(',') === 'automatic,automatic_px,edits,hand_px,unchanged_layer_px' &&
601
602
  [v.unchanged_layer_px, v.hand_px, v.automatic_px].every(count) && Array.isArray(v.edits) && Array.isArray(v.automatic) &&
602
603
  v.edits.every(e => e !== null && typeof e === 'object' && Object.keys(e).sort().join(',') === 'edit,px' && typeof e.edit === 'string' && edit(e.edit) && count(e.px) && e.px > 0) &&
603
604
  v.automatic.every(e => e !== null && typeof e === 'object' && Object.keys(e).sort().join(',') === 'px,stage' && typeof e.stage === 'string' && Object.hasOwn(AUTOMATIC_WRITERS, e.stage) && count(e.px) && e.px > 0) &&
@@ -612,6 +613,18 @@ function checkProvenance(raw: unknown, opaque: unknown, object: string, fail: (c
612
613
  const hand = p.edits.reduce((n, e) => n + e.px, 0), automatic = p.automatic.reduce((n, e) => n + e.px, 0);
613
614
  fail('PARTS_COUNTS_ADD_UP', object, `unchanged_layer_px ${p.unchanged_layer_px} + hand_px ${p.hand_px} + automatic_px ${p.automatic_px} = ${total}; opaque_px ${opaque} is required; edit subtotal ${hand} (hand_px ${p.hand_px} required), stage subtotal ${automatic} (automatic_px ${p.automatic_px} required)`);
614
615
  }
616
+ if (v !== null && typeof v === 'object' && 'depth' in v) {
617
+ const d = v.depth;
618
+ const valid = !hasScalar && d !== null && typeof d === 'object' && !Array.isArray(d) &&
619
+ Object.keys(d).sort().join(',') === 'kind,values' && d.kind === 'authored-unit' && Array.isArray(d.values) && d.values.length > 0 &&
620
+ d.values.every(q => q !== null && typeof q === 'object' && !Array.isArray(q) &&
621
+ Object.keys(q).sort().join(',') === (Object.hasOwn(q, 'bone') ? 'bone,group,value' : 'group,value') &&
622
+ (q.group === 'head' || q.group === 'body') && typeof q.value === 'number' && Number.isFinite(q.value) &&
623
+ (!Object.hasOwn(q, 'bone') || (typeof q.bone === 'string' && q.bone.length > 0))) &&
624
+ new Set(d.values.map(q => `${q.group}:${q.bone ?? ''}`)).size === d.values.length &&
625
+ d.values.every(q => q.bone !== undefined || d.values.filter(r => r.group === q.group).length === 1);
626
+ if (!valid) fail('PARTS_FIELD_TYPE', object + ' depth', 'requires authored-unit with nonempty distinct head/body finite values, optional nonempty bone names, and no transported scalar reference');
627
+ }
615
628
  }
616
629
 
617
630
  function checkParts(raw: unknown, path: string): PartsFile {
@@ -675,7 +688,7 @@ function checkParts(raw: unknown, path: string): PartsFile {
675
688
  if (k in r && !(Number.isInteger(r[k]) && (r[k] as number) >= 0)) fail('PARTS_FIELD_TYPE', `${label} field "${k}"`, `is ${show(r[k])}; a non-negative integer is required`);
676
689
  }
677
690
  const count = (k: string): number | null => (Number.isInteger(r[k]) && (r[k] as number) >= 0 ? (r[k] as number) : null);
678
- if ('provenance' in r) checkProvenance(r.provenance, r.opaque_px, label + ' provenance', fail);
691
+ if ('provenance' in r) checkProvenance(r.provenance, r.opaque_px, label + ' provenance', fail, 'depth' in r);
679
692
  checkPaintingExtensionCount(r, label, fail);
680
693
  const [op, vis, occ, vnp] = ['opaque_px', 'visible_px', 'occluded_px', 'visible_not_projected_px'].map(count);
681
694
  if (held.length === VISIBILITY_KEYS.length && op !== null && vis !== null && occ !== null && vnp !== null) {
@@ -828,7 +841,7 @@ function checkParts(raw: unknown, path: string): PartsFile {
828
841
  if (typeof p !== 'object' || p === null || Array.isArray(p)) return;
829
842
  const r = p as Record<string, unknown>;
830
843
  const part817 = typeof r.name === 'string' ? `part "${r.name}"` : `records[${j}]`;
831
- if ('provenance' in r) checkProvenance(r.provenance, r.opaque_px, `${at} ${part817} provenance`, fail);
844
+ if ('provenance' in r) checkProvenance(r.provenance, r.opaque_px, `${at} ${part817} provenance`, fail, 'depth' in r);
832
845
  checkPaintingExtensionCount(r, `${at} ${part817}`, fail);
833
846
  const l = r[LIMB_KEY];
834
847
  if (typeof l !== 'object' || l === null || Array.isArray(l) || !('cap' in l)) return;
package/src/provenance.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Report-only last-writer accounting over final output pixels (#817). */
2
2
  import { OPAQUE_ALPHA_ABOVE } from './layers.ts';
3
3
  import type { PartRecord } from './parts.ts';
4
+ import type { AuthoredUnitDepth } from './authoredunit.ts';
4
5
  import { crop, type Raster } from './raster/index.ts';
5
6
 
6
7
  /** Negative IDs distinguish automatic writes from positive, config-indexed hand edits. */
@@ -11,6 +12,8 @@ export const AUTOMATIC_WRITERS = {
11
12
  } as const;
12
13
  export type AutomaticWriter = keyof typeof AUTOMATIC_WRITERS;
13
14
  export interface PixelProvenance {
15
+ /** Scalar transport omitted only for fully explicit unit consumers (#877). */
16
+ depth?: AuthoredUnitDepth;
14
17
  unchanged_layer_px: number;
15
18
  hand_px: number;
16
19
  automatic_px: number;
@@ -83,7 +86,7 @@ export function provenanceLines(parts: readonly PartRecord[]): string[] {
83
86
  opaque += p.opaque_px; unchanged += v.unchanged_layer_px; automatic += v.automatic_px; hand += v.hand_px;
84
87
  for (const e of v.edits) edits.set(e.edit, (edits.get(e.edit) ?? 0) + e.px);
85
88
  for (const e of v.automatic) stages.set(e.stage, (stages.get(e.stage) ?? 0) + e.px);
86
- lines.push(` provenance: part "${p.name}" (${p.from}) opaque ${p.opaque_px} = unchanged layer ${v.unchanged_layer_px} + hand ${v.hand_px} + automatic ${v.automatic_px}; edits ${detail(new Map(v.edits.map(e => [e.edit, e.px])))}; stages ${detail(new Map(v.automatic.map(e => [e.stage, e.px])))}`);
89
+ lines.push(` provenance: part "${p.name}" (${p.from}) opaque ${p.opaque_px} = unchanged layer ${v.unchanged_layer_px} + hand ${v.hand_px} + automatic ${v.automatic_px}; edits ${detail(new Map(v.edits.map(e => [e.edit, e.px])))}; stages ${detail(new Map(v.automatic.map(e => [e.stage, e.px])))}${v.depth === undefined ? '' : `; depth authored-unit ${v.depth.values.map(d => `${d.group}/${d.bone ?? p.name}=${d.value}`).join(', ')}`}`);
87
90
  }
88
91
  lines.push(` provenance total: opaque ${opaque} = unchanged layer ${unchanged} + hand ${hand} + automatic ${automatic}; edits ${detail(edits)}; stages ${detail(stages)}; output pixels, including copies in separate parts; value equality first; last value-changing stage wins`);
89
92
  return lines;
@@ -1,3 +1,4 @@
1
+ import { fixedSkeletonProblems, type FixedSkeleton } from './artjoints.ts';
1
2
  /**
2
3
  * What a scene requires of a rig's motion, declared in a file `check` is given
3
4
  * (`--requirements`, issue #93, increment 2 of #87) and measured from the
@@ -190,6 +191,8 @@ export interface RequirementsFile {
190
191
  * not declared: no fold in a named animation is meant.
191
192
  */
192
193
  may_fold: MayFold[];
194
+ /** Issue #880: an explicit fixed-skeleton art comparison, absent on other rigs. */
195
+ fixed_skeleton?: FixedSkeleton;
193
196
  }
194
197
 
195
198
  /** One declared fold (issue #320): a slot, a named animation, and why the fold is the art's. */
@@ -280,7 +283,8 @@ export function readRequirements(path: string): RequirementsFile {
280
283
  problems.push({ code: 'REQUIREMENTS_SELF_TARGET', object: `${label} field "target"`, detail });
281
284
  };
282
285
  if (raw.spec !== REQUIREMENTS_SPEC) field(`${at} field "spec"`, `is ${JSON.stringify(raw.spec)}; ${JSON.stringify(REQUIREMENTS_SPEC)} is required`);
283
- for (const k of Object.keys(raw)) if (!['spec', 'fps', 'targets', 'requirements', ...EXCEPTION_LISTS, 'may_fold'].includes(k) && !freeKey(k, raw[k])) field(`${at} field "${k}"`, 'is not a field this format reads (spec, fps, targets, requirements, not_planted, not_swinging, rises, rests, may_fold; note or *_note as a string; x-<name> as a record)');
286
+ for (const k of Object.keys(raw)) if (!['spec', 'fps', 'targets', 'requirements', ...EXCEPTION_LISTS, 'may_fold', 'fixed_skeleton'].includes(k) && !freeKey(k, raw[k])) field(`${at} field "${k}"`, 'is not a field this format reads (spec, fps, targets, requirements, not_planted, not_swinging, rises, rests, may_fold, fixed_skeleton; note or *_note as a string; x-<name> as a record)');
287
+ if ('fixed_skeleton' in raw) problems.push(...fixedSkeletonProblems(raw.fixed_skeleton, `${at} fixed_skeleton`));
284
288
  let fps = NaN;
285
289
  if (!(finite(raw.fps) && raw.fps > 0)) field(`${at} field "fps"`, `is ${JSON.stringify(raw.fps)}; a positive number of frames per second is required — every named animation is sampled at it, and there is no default`);
286
290
  else fps = raw.fps;
@@ -464,7 +468,7 @@ export function readRequirements(path: string): RequirementsFile {
464
468
  }
465
469
  }
466
470
  refuseIfAny(problems);
467
- return { path: at, fps, targets, requirements, not_planted: lists.not_planted, not_swinging: lists.not_swinging, rises: lists.rises, rests: lists.rests, may_fold: mayFold };
471
+ return { path: at, fps, targets, requirements, not_planted: lists.not_planted, not_swinging: lists.not_swinging, rises: lists.rises, rests: lists.rests, may_fold: mayFold, ...(raw.fixed_skeleton === undefined ? {} : { fixed_skeleton: raw.fixed_skeleton as FixedSkeleton }) };
468
472
  }
469
473
 
470
474
  // ---------------------------------------------------------------------------
@@ -542,6 +546,7 @@ export function resolveRequirements(file: RequirementsFile, rig: Record<string,
542
546
  const target = (object: string, t: TargetRef): void => {
543
547
  if ('bone' in t) bone(`${object} target`, t.bone);
544
548
  };
549
+ for (const j of file.fixed_skeleton?.joints ?? []) bone(`fixed_skeleton joint "${j.name}"`, j.bone);
545
550
  for (const r of file.requirements) {
546
551
  const object = `requirement "${r.name}" (${r.kind})`;
547
552
  animation(object, r.animation);
package/src/rig.ts CHANGED
@@ -3668,6 +3668,7 @@ export function buildWaistPairSource(
3668
3668
  hasAlternateFaceSet,
3669
3669
  surfaceMeshes: turnSurfaceMeshes(cfg, rig, parts.rig_size),
3670
3670
  neighbourMeshes: turnNeighbourMeshes(cfg, rig, parts, new Map(outImages)),
3671
+ coverageMeshes: cfg.turn.body === undefined ? undefined : turnNeighbourMeshes(cfg, rig, parts, new Map(outImages), true),
3671
3672
  });
3672
3673
  }
3673
3674
  bindFaceSurfaceDeform(motion, (merged) => {
@@ -4206,13 +4207,13 @@ function turnSurfaceMeshes(cfg: CharacterConfig, rig: RigSpec, canvas: readonly
4206
4207
  }
4207
4208
 
4208
4209
  /** Actual shown support; Core's own grid topology is inspection metadata only. */
4209
- export function turnNeighbourMeshes(cfg: CharacterConfig, rig: RigSpec, parts: PartsFile, emittedImages: ReadonlyMap<string, Raster>) {
4210
+ export function turnNeighbourMeshes(cfg: CharacterConfig, rig: RigSpec, parts: PartsFile, emittedImages: ReadonlyMap<string, Raster>, coverage = false) {
4210
4211
  const meshes: NonNullable<Parameters<typeof buildDepth25DTurn>[2]['neighbourMeshes']>[number][] = [];
4211
4212
  const canvas = parts.rig_size;
4212
4213
  const aliases = new Map<string, string>((rig.stops ?? []).flatMap(s => s.links.map(link => [`${link}_d`, link])));
4213
4214
  const world = computeWorldTransforms(rig.bones.map(b => b.parent === undefined ? b : { ...b, parent: aliases.get(b.parent) ?? b.parent }));
4214
- for (const part of new Set([...Object.keys(cfg.turn?.roles ?? {}), ...Object.keys(cfg.turn?.body?.roles ?? {})])) {
4215
- if (cfg.meshes[part] !== undefined && [cfg.turn?.roles?.[part], cfg.turn?.body?.roles?.[part]].includes('surface')) continue;
4215
+ for (const part of new Set([...Object.keys(cfg.turn?.roles ?? {}), ...Object.keys(cfg.turn?.body?.roles ?? {}), ...(coverage ? parts.parts.map(p => p.name) : [])])) {
4216
+ if (!coverage && cfg.meshes[part] !== undefined && [cfg.turn?.roles?.[part], cfg.turn?.body?.roles?.[part]].includes('surface')) continue;
4216
4217
  const record = parts.parts.find(p => p.name === part);
4217
4218
  if (record === undefined) continue;
4218
4219
  const split = cfg.regions[part] !== undefined && cfg.motion.blink?.still?.[part] !== undefined
package/src/turn.ts CHANGED
@@ -37,6 +37,7 @@ import { turnOverlapOwners } from './turnoverlap.ts';
37
37
  import { sampleTurnTriangleField, turnTriangleCoordinates } from './turnfield.ts';
38
38
  import { PartsError } from './errors.ts';
39
39
  import { f32 } from '@rig-c/core/compile';
40
+ import { warnUncoveredBodyTurn } from './turncoverage.ts';
40
41
  import { evaluateDeformTransform } from '@rig-c/core/src/deformgen.ts';
41
42
 
42
43
  /**
@@ -1505,6 +1506,8 @@ export interface Depth25DTurnOptions {
1505
1506
  }>;
1506
1507
  /** Final weighted unit/rear drawings are support only, never surface targets. */
1507
1508
  neighbourMeshes?: Depth25DTurnOptions['surfaceMeshes'];
1509
+ /** Shown setup geometry for coverage diagnostics only; never a role opt-in. */
1510
+ coverageMeshes?: Depth25DTurnOptions['surfaceMeshes'];
1508
1511
  }
1509
1512
 
1510
1513
  interface Depth25DGroupSpec {
@@ -2216,4 +2219,5 @@ export function buildDepth25DTurn(
2216
2219
  }
2217
2220
 
2218
2221
  refuseIfAny(problems);
2222
+ if (opts.warnings !== undefined) warnUncoveredBodyTurn(rig, motion, opts);
2219
2223
  }