rig-parts 2.74.0 → 2.76.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.
- package/cli.ts +43 -13
- package/docs/AUTHORING.md +151 -16
- package/docs/STABILITY.md +92 -6
- package/package.json +2 -2
- package/src/check.ts +61 -35
- package/src/compose-seams.ts +476 -0
- package/src/layers.ts +73 -7
- package/src/scene.ts +191 -68
package/src/check.ts
CHANGED
|
@@ -3529,7 +3529,7 @@ export type CheckBarId = ReturnType<typeof checkBarIds>[number];
|
|
|
3529
3529
|
export interface CheckBarSkipReasons {
|
|
3530
3530
|
BREATH_VISIBLE?: 'no-eligible-region' | 'no-reading';
|
|
3531
3531
|
BLINK_NO_HOLE?: 'no-eye-parts' | 'no-blink-track' | 'no-reading';
|
|
3532
|
-
TIP_OVER_ROOT?: 'no-swing-parts' | 'no-reading';
|
|
3532
|
+
TIP_OVER_ROOT?: 'no-swing-parts' | 'below-travel-floor' | 'no-reading';
|
|
3533
3533
|
STILL_REGIONS_DARK?: 'no-eligible-region' | 'no-reading';
|
|
3534
3534
|
TEXTURE_STRETCH?: 'no-reading' | 'no-meshes' | 'no-visible-meshes';
|
|
3535
3535
|
}
|
|
@@ -7567,25 +7567,29 @@ export function runCheck(
|
|
|
7567
7567
|
}
|
|
7568
7568
|
loop = maxRgbDiff(idle.frames[0].image, last.image);
|
|
7569
7569
|
loopSet = idle;
|
|
7570
|
-
// The keyed loop (
|
|
7571
|
-
// the same way and rendered
|
|
7570
|
+
// The keyed loop (issues #183, #1704): with a physics constraint, the same rig and motion with every one left out,
|
|
7571
|
+
// built the same way and rendered at frames 0 and last.index only, is what frame 0 and the frame at the duration
|
|
7572
|
+
// are read from.
|
|
7572
7573
|
if (stripped !== null) {
|
|
7573
7574
|
loopPhysics = stripped.physics;
|
|
7574
7575
|
const what = 'the idle with its physics constraint(s) left out';
|
|
7575
|
-
const
|
|
7576
|
-
|
|
7576
|
+
const selected = last.index === 0 ? [0] : [0, last.index];
|
|
7577
|
+
const framesAt = selected.join(',');
|
|
7578
|
+
const lr = rigc(['render', '--candidate', keyedBuild(what), '--animation', 'idle', '--fps', String(IDLE_FPS), '--max', String(IDLE_MAX_PX), '--frames-at', framesAt, '--out', join(loopDir, 'frames')]);
|
|
7579
|
+
if (lr.status !== 0) refuseIfAny(rigcFailed(`render --animation idle --frames-at ${framesAt} (${what})`, lr, lr.out.split('\n').filter((l) => l.includes('FAIL') || l.includes('rigc:'))));
|
|
7577
7580
|
const kept = readFrameSet(join(loopDir, 'frames'));
|
|
7581
|
+
const keptFirst = kept.frames[0];
|
|
7578
7582
|
const keptLast = kept.frames[kept.frames.length - 1];
|
|
7579
|
-
if (kept.stride !== 1 || kept.
|
|
7583
|
+
if (kept.stride !== 1 || kept.sampled !== idle.sampled || kept.written !== selected.length || keptFirst?.index !== 0 || keptLast?.index !== last.index) {
|
|
7580
7584
|
refuseIfAny([
|
|
7581
7585
|
{
|
|
7582
7586
|
code: 'CHECK_LOOP_LAST_FRAME_AT_DURATION',
|
|
7583
|
-
object: `idle frame ${keptLast.name} (${what})`,
|
|
7587
|
+
object: `idle frame ${keptLast?.name ?? last.name} (${what})`,
|
|
7584
7588
|
detail: `rigc sampled ${kept.sampled} frame(s), wrote ${kept.written} at stride ${kept.stride}; the idle as written ends at ${last.name}, and the loop compares frame 0 with that frame`,
|
|
7585
7589
|
},
|
|
7586
7590
|
]);
|
|
7587
7591
|
}
|
|
7588
|
-
loop = maxRgbDiff(
|
|
7592
|
+
loop = maxRgbDiff(keptFirst.image, keptLast.image);
|
|
7589
7593
|
loopSet = kept;
|
|
7590
7594
|
}
|
|
7591
7595
|
if (!previewIdle) {
|
|
@@ -9122,6 +9126,15 @@ function torsoProblem(ps: readonly PartRecord[], tr: Exclude<TorsoBreath, { skip
|
|
|
9122
9126
|
};
|
|
9123
9127
|
}
|
|
9124
9128
|
|
|
9129
|
+
/** Typed per-row reason recorded alongside `unmeasured` in `TIP_OVER_ROOT.parts[]` (issue #1696). */
|
|
9130
|
+
export type TipUnmeasuredReason =
|
|
9131
|
+
| 'declared_not_swinging'
|
|
9132
|
+
| 'limb_segment'
|
|
9133
|
+
| 'hybrid_band'
|
|
9134
|
+
| 'no_attachment'
|
|
9135
|
+
| 'empty_half'
|
|
9136
|
+
| 'below_travel_floor';
|
|
9137
|
+
|
|
9125
9138
|
/** The scene file's exceptions to `TIP_OVER_ROOT` (issues #231, #245), and the file they were read from, which a refusal names. */
|
|
9126
9139
|
export interface TipExceptions {
|
|
9127
9140
|
path: string;
|
|
@@ -9374,11 +9387,11 @@ function tipLine(inp: FullInputs, geometryPath: string, frames: number, problems
|
|
|
9374
9387
|
}
|
|
9375
9388
|
const rows: Array<Record<string, unknown>> = [];
|
|
9376
9389
|
let measured = 0;
|
|
9377
|
-
let belowGrid = 0;
|
|
9378
9390
|
let failed = false;
|
|
9379
9391
|
for (const p of swing) {
|
|
9380
9392
|
if (excepted.not_swinging.includes(p.name)) {
|
|
9381
9393
|
const fromBuild = excepted.forwardedFrom?.not_swinging?.[p.name];
|
|
9394
|
+
const unmeasuredReason: TipUnmeasuredReason = 'declared_not_swinging';
|
|
9382
9395
|
rows.push({
|
|
9383
9396
|
...checkRow('TIP_OVER_ROOT.parts', 'part', false, [p.name]),
|
|
9384
9397
|
part: p.name,
|
|
@@ -9386,12 +9399,14 @@ function tipLine(inp: FullInputs, geometryPath: string, frames: number, problems
|
|
|
9386
9399
|
unmeasured: fromBuild !== undefined
|
|
9387
9400
|
? `declared not swinging by build "${fromBuild}" check/check.json (not_swinging), so it is not held to the bar`
|
|
9388
9401
|
: "declared not swinging by the scene file's not_swinging, so it is not held to the bar",
|
|
9402
|
+
unmeasured_reason: unmeasuredReason,
|
|
9389
9403
|
});
|
|
9390
9404
|
continue;
|
|
9391
9405
|
}
|
|
9392
9406
|
// Issue #349: a limb segment is rigid on its one bone and turns at its joint; it does not hang, so no tip trails a root.
|
|
9393
9407
|
if (p.limb !== undefined) {
|
|
9394
|
-
|
|
9408
|
+
const unmeasuredReason: TipUnmeasuredReason = p.limb.band !== undefined ? 'hybrid_band' : 'limb_segment';
|
|
9409
|
+
rows.push({ ...checkRow('TIP_OVER_ROOT.parts', 'part', false, [p.name]), part: p.name, unmeasured: p.limb.band !== undefined ? `a hybrid joint band (config.limbs.${p.limb.name}): it bends between adjacent carriers, does not hang, and is not held to the tip-over-root bar` : `a limb segment (config.limbs.${p.limb.name}), rigid on its one bone "${p.limb.bone}": it turns at its joint and does not hang, so it is not held to the bar`, unmeasured_reason: unmeasuredReason });
|
|
9395
9410
|
continue;
|
|
9396
9411
|
}
|
|
9397
9412
|
const rises = excepted.rises.includes(p.name);
|
|
@@ -9417,7 +9432,8 @@ function tipLine(inp: FullInputs, geometryPath: string, frames: number, problems
|
|
|
9417
9432
|
};
|
|
9418
9433
|
if (w.root === null || w.tip === null || c.root === null || c.tip === null) {
|
|
9419
9434
|
const half = w.root === null || c.root === null ? rootHalf : tipHalf;
|
|
9420
|
-
|
|
9435
|
+
const unmeasuredReason: TipUnmeasuredReason = shown[0] === null ? 'no_attachment' : 'empty_half';
|
|
9436
|
+
rows.push({ ...checkRow('TIP_OVER_ROOT.parts', 'part', false, [p.name]), part: p.name, ...said, unmeasured: shown[0] === null ? 'its slot shows no attachment on idle frame 0' : `on idle frame 0 the ${half} half of its box holds no art its attachment draws`, unmeasured_reason: unmeasuredReason });
|
|
9421
9437
|
continue;
|
|
9422
9438
|
}
|
|
9423
9439
|
// Issue #987: a half that does not move against its carrier, read at the line's precision, is 0 and not the
|
|
@@ -9431,11 +9447,12 @@ function tipLine(inp: FullInputs, geometryPath: string, frames: number, problems
|
|
|
9431
9447
|
rows.push({ ...checkRow('TIP_OVER_ROOT.parts', 'part', !ok && !(!rigid && hanging.onLink && Math.max(c.root, c.tip) < TIP_TRAVEL_FLOOR), [p.name]), part: p.name, ...said, hang_from: hang, root_rig_px: round3(t.root), tip_rig_px: round3(t.tip), ratio, world_root_rig_px: round3(w.root), world_tip_rig_px: round3(w.tip), world_ratio: worldRatio });
|
|
9432
9448
|
// Structural 0 / 0 stays a failure before the link-only magnitude policy (issue #994).
|
|
9433
9449
|
if (!rigid && hanging.onLink && Math.max(c.root, c.tip) < TIP_TRAVEL_FLOOR) {
|
|
9434
|
-
belowGrid++;
|
|
9435
9450
|
const excitation = carrierExcitation(inp.rig, idleGeo, hangFound);
|
|
9451
|
+
const unmeasuredReason: TipUnmeasuredReason = 'below_travel_floor';
|
|
9436
9452
|
rows[rows.length - 1] = { ...rows[rows.length - 1], travel_floor_rig_px: TIP_TRAVEL_FLOOR,
|
|
9437
9453
|
measured_driver: excitation === null ? 'unavailable' : excitation.driver ?? 'none',
|
|
9438
|
-
unmeasured: "below half a rig pixel: the motion does not show on the art's own grid"
|
|
9454
|
+
unmeasured: "below half a rig pixel: the motion does not show on the art's own grid",
|
|
9455
|
+
unmeasured_reason: unmeasuredReason };
|
|
9439
9456
|
continue;
|
|
9440
9457
|
}
|
|
9441
9458
|
measured++;
|
|
@@ -9508,8 +9525,9 @@ function tipLine(inp: FullInputs, geometryPath: string, frames: number, problems
|
|
|
9508
9525
|
const travel = r.travel_floor_rig_px === undefined ? '' : `; root ${String(r.root_rig_px)} rig px, tip ${String(r.tip_rig_px)} rig px, floor ${String(r.travel_floor_rig_px)} rig px; measured driver ${String(r.measured_driver)}`;
|
|
9509
9526
|
return `${String(r.part)}: ${String(r.unmeasured)}${travel}`;
|
|
9510
9527
|
});
|
|
9511
|
-
|
|
9512
|
-
|
|
9528
|
+
const skipCode = rows.length > 0 && rows.every((r) => r.unmeasured_reason === 'below_travel_floor') ? 'below-travel-floor' : 'no-reading';
|
|
9529
|
+
return { ...skipped(`none of ${quoteParts(swing)} could be measured: ${reasons.join('; ')}`, skipCode),
|
|
9530
|
+
...figures };
|
|
9513
9531
|
}
|
|
9514
9532
|
return { status: failed ? 'FAIL' : 'PASS', ...figures };
|
|
9515
9533
|
}
|
|
@@ -12034,23 +12052,24 @@ function measureOneComposedCharacter(
|
|
|
12034
12052
|
|
|
12035
12053
|
try {
|
|
12036
12054
|
const images = typeof inp.rig.images === 'string' ? resolve(inp.rigDir, inp.rig.images) : inp.rig.images;
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12055
|
+
// The composed idle already supplies the named bones, slots and frame
|
|
12056
|
+
// indices. A scoped build is only needed for another raster or animation
|
|
12057
|
+
// set. Keep its atlas packing because the raster checks measure pixels.
|
|
12058
|
+
const charIdle = ctx.idle;
|
|
12059
|
+
let scopedBuild: string | null = null;
|
|
12060
|
+
const ensureScopedBuild = (): string => {
|
|
12061
|
+
if (onlyCharacterInRig) return ctx.buildDir;
|
|
12062
|
+
if (scopedBuild !== null) return scopedBuild;
|
|
12063
|
+
const dir = join(scratchDir, 'build');
|
|
12041
12064
|
const rigFile = join(scratchDir, 'rig.json');
|
|
12042
12065
|
const motionFile = join(scratchDir, 'motion.json');
|
|
12043
12066
|
writeFileSync(rigFile, JSON.stringify({ ...charRig, images }));
|
|
12044
12067
|
writeFileSync(motionFile, JSON.stringify(charMotion));
|
|
12045
|
-
const b = rigc(['build', '--rig', rigFile, '--motion', motionFile, '--out',
|
|
12068
|
+
const b = rigc(['build', '--rig', rigFile, '--motion', motionFile, '--out', dir, ...packedBuildArgs(mode)]);
|
|
12046
12069
|
if (b.status !== 0) refuseIfAny(rigcFailed(`${packedBuildLabel(mode)} (character "${c.id}")`, b, buildGateLines(b.out)));
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
if (ir.status !== 0) refuseIfAny(rigcFailed(`render --animation idle --geometry (character "${c.id}")`, ir, ir.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12051
|
-
charIdle = readFrameSet(charIdleDir);
|
|
12052
|
-
}
|
|
12053
|
-
}
|
|
12070
|
+
scopedBuild = dir;
|
|
12071
|
+
return dir;
|
|
12072
|
+
};
|
|
12054
12073
|
|
|
12055
12074
|
const scaledParts: PartsFile = s === 1
|
|
12056
12075
|
? prefParts
|
|
@@ -12093,9 +12112,10 @@ function measureOneComposedCharacter(
|
|
|
12093
12112
|
const levelProblems: Problem[] = [];
|
|
12094
12113
|
if (feet.length > 0 && charAnimNames.length > 0) {
|
|
12095
12114
|
const levelScratch = join(scratchDir, 'level');
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12115
|
+
if (charStripped === null && charIdle !== null && charAnimNames.length === 1 && charAnimNames[0] === 'idle') {
|
|
12116
|
+
level = levelLine(feet, charRig, [{ animation: 'idle', set: charIdle, geometryPath: join(charIdle.dir, GEOMETRY_FILE) }], IDLE_FPS, 0, levelProblems);
|
|
12117
|
+
} else if (charStripped === null) {
|
|
12118
|
+
const fr = measured(['render', '--candidate', ensureScopedBuild(), '--folds', '--geometry', '--fps', String(IDLE_FPS), '--max', String(FOLD_RENDER_MAX), '--out', levelScratch]);
|
|
12099
12119
|
if (fr.status !== 0) refuseIfAny(rigcFailed(`render --folds --geometry --fps ${IDLE_FPS} (character "${c.id}")`, fr, fr.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12100
12120
|
const sets = readJson(join(levelScratch, 'frames.json'), []);
|
|
12101
12121
|
const listed = sets !== null && Array.isArray(sets.sets) ? sets.sets.filter(isRecord) : [];
|
|
@@ -12112,8 +12132,8 @@ function measureOneComposedCharacter(
|
|
|
12112
12132
|
mkdirSync(keyedDir, { recursive: true });
|
|
12113
12133
|
writeFileSync(join(keyedDir, 'rig.json'), JSON.stringify({ ...charStripped.rig, images }));
|
|
12114
12134
|
writeFileSync(join(keyedDir, 'motion.json'), JSON.stringify(charStripped.motion));
|
|
12115
|
-
const kb = rigc(['build', '--rig', join(keyedDir, 'rig.json'), '--motion', join(keyedDir, 'motion.json'), '--out', join(keyedDir, 'build'),
|
|
12116
|
-
if (kb.status !== 0) refuseIfAny(rigcFailed(
|
|
12135
|
+
const kb = rigc(['build', '--rig', join(keyedDir, 'rig.json'), '--motion', join(keyedDir, 'motion.json'), '--out', join(keyedDir, 'build'), '--profile', 'spine']);
|
|
12136
|
+
if (kb.status !== 0) refuseIfAny(rigcFailed(`build (character "${c.id}" level physics-off)`, kb, buildGateLines(kb.out)));
|
|
12117
12137
|
const frOff = rigc(['render', '--candidate', join(keyedDir, 'build'), '--folds', '--geometry', '--fps', String(IDLE_FPS), '--max', String(FOLD_RENDER_MAX), '--out', join(keyedDir, 'render')]);
|
|
12118
12138
|
if (frOff.status !== 0) refuseIfAny(rigcFailed(`render --folds --geometry (character "${c.id}" level physics-off)`, frOff, frOff.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12119
12139
|
const sets = readJson(join(keyedDir, 'render', 'frames.json'), []);
|
|
@@ -12145,7 +12165,7 @@ function measureOneComposedCharacter(
|
|
|
12145
12165
|
const isoDir = join(scratchDir, 'isolated');
|
|
12146
12166
|
const isolated = (label: string, ps: readonly PartRecord[]): FrameSet => {
|
|
12147
12167
|
const dir = join(isoDir, label);
|
|
12148
|
-
const r = measured(['render', '--candidate',
|
|
12168
|
+
const r = measured(['render', '--candidate', ensureScopedBuild(), '--animation', 'idle', '--fps', String(IDLE_FPS), '--max', String(IDLE_MAX_PX), '--slot', ps.map(p => p.name).join(','), '--out', dir]);
|
|
12149
12169
|
if (r.status !== 0) refuseIfAny(rigcFailed(`render --animation idle --slot ${ps.map(p => p.name).join(',')}`, r, r.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12150
12170
|
return readFrameSet(dir);
|
|
12151
12171
|
};
|
|
@@ -12225,7 +12245,7 @@ function measureOneComposedCharacter(
|
|
|
12225
12245
|
})),
|
|
12226
12246
|
}),
|
|
12227
12247
|
};
|
|
12228
|
-
physics = measurePhysicsContribution(charPhysicsRenderer,
|
|
12248
|
+
physics = measurePhysicsContribution(charPhysicsRenderer, ctx.buildDir, charRig, charMotion, prefParts.parts.map(p => ({
|
|
12229
12249
|
name: p.name,
|
|
12230
12250
|
w: p.w,
|
|
12231
12251
|
h: p.h,
|
|
@@ -12712,7 +12732,13 @@ const SILENT_SKIP_REASONS = new Set<CheckBarSkipReason>([
|
|
|
12712
12732
|
function aggregateCharacterBarOutcome(outcomes: readonly CheckBarOutcome[]): CheckBarOutcome {
|
|
12713
12733
|
if (outcomes.some(o => o.status === 'FAIL')) return { status: 'FAIL' };
|
|
12714
12734
|
if (outcomes.some(o => o.status === 'PASS')) return { status: 'PASS' };
|
|
12715
|
-
const
|
|
12735
|
+
const skips = outcomes.filter((o): o is Extract<CheckBarOutcome, { status: 'SKIP' }> => o.status === 'SKIP');
|
|
12736
|
+
if (skips.some(o => o.reason === 'no-reading') && skips.some(o => o.reason === 'below-travel-floor')) {
|
|
12737
|
+
return { status: 'SKIP', reason: 'no-reading' };
|
|
12738
|
+
}
|
|
12739
|
+
const reading = skips.find(o => o.reason === 'below-travel-floor' || o.reason === 'no-reading');
|
|
12740
|
+
if (reading !== undefined) return reading;
|
|
12741
|
+
const loud = skips.find(o => !SILENT_SKIP_REASONS.has(o.reason));
|
|
12716
12742
|
if (loud !== undefined) return loud;
|
|
12717
12743
|
return outcomes[0];
|
|
12718
12744
|
}
|