@rig-c/parts 1.53.0 → 1.55.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 +40 -7
- package/docs/AUTHORING.md +60 -10
- package/docs/STABILITY.md +6 -5
- package/package.json +1 -1
- package/src/assemble.ts +769 -8
- package/src/build.ts +117 -9
- package/src/check.ts +43 -12
- package/src/cloth.ts +10 -3
- package/src/config.ts +27 -6
- package/src/parts.ts +83 -45
- package/src/propose.ts +10 -2
- package/src/remesh.ts +306 -6
- package/src/retune.ts +25 -3
- package/src/rig.ts +18 -6
package/src/build.ts
CHANGED
|
@@ -44,7 +44,7 @@ import { createHash } from 'node:crypto';
|
|
|
44
44
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
45
45
|
import { dirname, join, resolve } from 'node:path';
|
|
46
46
|
import { type AnimFrame, EncodeError, encodeApng, encodeIndexedApng, INDEXED_DEFAULTS } from './apng.ts';
|
|
47
|
-
import { assemble, type AssembleResult, cutLines, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, driftLine, limbLines, FIGURE_MASK_FILE, figuresLine, holeKindsLine, holeLines, measureRecomposite, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, stageFields, uncoveredLine } from './assemble.ts';
|
|
47
|
+
import { assemble, type AssembleResult, cutLines, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, driftLine, limbLines, FIGURE_MASK_FILE, figuresLine, holeKindsLine, holeLines, measureRecomposite, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, stageFields, uncoveredLine } from './assemble.ts';
|
|
48
48
|
import { allocationClause, type Reducer, stageBClause, unboundedClause } from './automesh.ts';
|
|
49
49
|
import { residualClause } from './autoenvelope.ts';
|
|
50
50
|
import { type AutoMotionCase, failingRows, idleSchedule, localRow, motionClause, motionDeformation, motionDocument, motionInput, motionRowText, motionStimulus, motionVerdict, noStimulusProblem, type ReplayCandidate, runComparison, sourceSelfFailure, stimulusMotion, withStimulus } from './automotion.ts';
|
|
@@ -71,8 +71,8 @@ import {
|
|
|
71
71
|
splitSchedule,
|
|
72
72
|
untestedIntervals,
|
|
73
73
|
} from './autoreplay.ts';
|
|
74
|
-
import { besideIdleLine, checkSummaryLine, CLOTH_LINE, type ClothLine, clothWarnText, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamWarnText, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, readCheckEnvironment, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR } from './check.ts';
|
|
75
|
-
import { type Cut, type Extend, type Limb,
|
|
74
|
+
import { besideIdleLine, checkSummaryLine, inputFileRecord, type InputFileRecord, CLOTH_LINE, type ClothLine, clothWarnText, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamWarnText, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, readCheckEnvironment, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR } from './check.ts';
|
|
75
|
+
import { type Cut, type Extend, type Limb, loadConfigAndAnimations, loadConfigWithBytes, loadEarlyConfig, type Patch, type PlanEntry } from './config.ts';
|
|
76
76
|
import { failLine, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
77
77
|
import type { MeshQualityReport, MotionSchedule } from 'rig-c/mesh';
|
|
78
78
|
import { encodeGif } from './gif.ts';
|
|
@@ -83,6 +83,10 @@ import { placeBoneEntriesForSkeleton, poseBoneEntriesForDrawn, REGISTER_OFFSET_B
|
|
|
83
83
|
import { type AlternatePartsRecord, type PartRecord, readParts, type RecompositeRecord, type SingleRunPad, tagOf, writeParts } from './parts.ts';
|
|
84
84
|
import { encodePngBytes, readPng, writePng } from './raster/png.ts';
|
|
85
85
|
import type { Raster } from './raster/types.ts';
|
|
86
|
+
import { type Mask, newMask } from './raster/types.ts';
|
|
87
|
+
import { type OtherLimbs, splitLines, type SplitCount } from './assemble.ts';
|
|
88
|
+
import type { BoneEntry } from './config.ts';
|
|
89
|
+
import { OPAQUE_ALPHA_ABOVE } from './layers.ts';
|
|
86
90
|
import { readRequirements, type RequirementLine, summaryText } from './requirements.ts';
|
|
87
91
|
import { type AutoMeshReport, buildRig, DEFAULT_IDLE_KEYS, type FaceAxis, type IdleKeys, type MeshReport, type RigCommand, rigJsonText, type RigOutput, type RigSpec, SETS_FILE, type StrayCleared, type TurnRow } from './rig.ts';
|
|
88
92
|
import { KEYPOINT_NAMES, type KeypointName, type PosePoints } from './skeleton.ts';
|
|
@@ -159,6 +163,26 @@ export interface AssembleStageInput {
|
|
|
159
163
|
* selftest's control that shows a foreshortened segment refused under it.
|
|
160
164
|
*/
|
|
161
165
|
altPlacement?: 'skeleton' | 'angles';
|
|
166
|
+
/**
|
|
167
|
+
* What a subset set's limb parts take under a base part the set does not replace (issue #587): `"base"` (the
|
|
168
|
+
* default, the only one the CLI runs) excludes the pixels that base part covers at setup ({@link setExclusions});
|
|
169
|
+
* `"none"` takes them, the rule before #587 — kept for the selftest's control that shows the count go red under it.
|
|
170
|
+
*/
|
|
171
|
+
setExclusion?: 'base' | 'none';
|
|
172
|
+
/**
|
|
173
|
+
* What a subset set's limb parts keep of a layer of more than one island when the set names one limb side (issue
|
|
174
|
+
* #588): `"joints"` (the default, the only one the CLI runs) the island the segment's joints fall on
|
|
175
|
+
* ({@link setIslandSources}); `"all"` every island, the rule before #588 — kept for the selftest's control that
|
|
176
|
+
* shows the island count go red under it.
|
|
177
|
+
*/
|
|
178
|
+
setIslands?: 'joints' | 'all';
|
|
179
|
+
/**
|
|
180
|
+
* How a subset set's limb parts share a layer of one island with a limb the set does not carry (issue #609):
|
|
181
|
+
* `"nearest"` (the default, the only one the CLI runs) by the nearest segment line in the set's pose, the other limb
|
|
182
|
+
* placed by the set's skeleton ({@link OtherLimbs}); `"connectivity"` every pixel on the set's limb, the rule before
|
|
183
|
+
* #609 — kept for the selftest's control that shows the second-limb share go red under it.
|
|
184
|
+
*/
|
|
185
|
+
setSplit?: 'nearest' | 'connectivity';
|
|
162
186
|
}
|
|
163
187
|
|
|
164
188
|
/** Where the assemble stage writes: `parts.json`, the directory of part PNGs, the recomposite, and its error map. */
|
|
@@ -314,7 +338,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
314
338
|
}
|
|
315
339
|
|
|
316
340
|
const altProblems: Problem[] = [];
|
|
317
|
-
const altBuilt: Array<{ record: AlternatePartsRecord; images: Array<{ name: string; image: Raster }
|
|
341
|
+
const altBuilt: Array<{ record: AlternatePartsRecord; images: Array<{ name: string; image: Raster }>; excluded: ExcludedCount[]; islands: IslandCount[]; splits: SplitCount[] }> = [];
|
|
318
342
|
const baseSlots = result.parts.parts.map((p) => p.name);
|
|
319
343
|
for (const alt of mergedAlts) {
|
|
320
344
|
if (alt.source === undefined || alt.full === undefined) {
|
|
@@ -457,6 +481,16 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
457
481
|
let altBones = fields.bones;
|
|
458
482
|
let altDrawnLength: Record<string, number> | undefined;
|
|
459
483
|
let altRegistration: { offset: [number, number]; scale: number } | undefined;
|
|
484
|
+
// Issue #588: a subset set that names one limb side keeps, of a layer that holds more than one island, the one its joints fall on.
|
|
485
|
+
const altIslands = alt.parts === undefined || input.setIslands === 'all' ? [] : setIslandSources(fields.limbs ?? {}, altLimbs);
|
|
486
|
+
// Issue #609: the limbs of those layers the set does not carry — the other leg of a two-leg layer.
|
|
487
|
+
const otherLimbs: Record<string, Limb> =
|
|
488
|
+
input.setSplit === 'connectivity'
|
|
489
|
+
? {}
|
|
490
|
+
: Object.fromEntries(Object.entries(fields.limbs ?? {}).filter(([ln, l]) => !(ln in altLimbs) && l.segments.some((sg) => altIslands.includes(sg.from))));
|
|
491
|
+
const otherBones = new Set(Object.values(otherLimbs).flatMap((l) => l.segments.map((sg) => sg.bone)));
|
|
492
|
+
// The bones the set places: by its skeleton, or by the angles it states; every other bone keeps the base's place unless an ancestor moved.
|
|
493
|
+
const setPlaced = new Set<string>();
|
|
460
494
|
if (Object.keys(altLimbs).length > 0 && fields.bones !== undefined && (altSkeleton !== undefined || alt.drawn !== undefined)) {
|
|
461
495
|
const coveredLimbBones = new Set(Object.values(altLimbs).flatMap((l) => l.segments.map((sg) => sg.bone)));
|
|
462
496
|
const limbDrawn: Record<string, number> = {};
|
|
@@ -497,11 +531,23 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
497
531
|
}
|
|
498
532
|
altRegistration = { offset: [reg.offset[0], reg.offset[1]], scale: reg.scale };
|
|
499
533
|
altDrawnLength = skeletonDrawnLength(fields.bones, coveredLimbBones, joints);
|
|
500
|
-
|
|
534
|
+
// Issue #609: the other limb of a shared layer stands at the set's own keypoints too, so its segment line is the
|
|
535
|
+
// set's; the skeleton file holds them. Only its place widens: drawn and drawnLength stay the covered bones'.
|
|
536
|
+
const placed = new Set([...coveredLimbBones, ...[...otherBones].filter((b) => SKELETON_LIMB_BONES.some(([t]) => t === b))]);
|
|
537
|
+
for (const b of placed) if (SKELETON_LIMB_BONES.some(([t]) => t === b)) setPlaced.add(b);
|
|
538
|
+
altBones = placeBoneEntriesForSkeleton(fields.bones, placed, joints, limbDrawn);
|
|
501
539
|
} else {
|
|
502
540
|
altBones = poseBoneEntriesForDrawn(fields.bones, limbDrawn);
|
|
503
541
|
}
|
|
542
|
+
for (const b of Object.keys(limbDrawn)) setPlaced.add(b);
|
|
504
543
|
}
|
|
544
|
+
const altOthers = Object.keys(otherLimbs).length === 0 ? undefined : otherLimbsOf(otherLimbs, setPlaced, fields.bones ?? [], result.images, result.parts.rig_size, altSkeleton !== undefined ? 'skeleton' : alt.drawn !== undefined ? 'drawn' : 'none');
|
|
545
|
+
// Issue #587: a subset set's limb part takes nothing a base part it does not replace covers at setup.
|
|
546
|
+
const [exW, exH] = result.parts.rig_size;
|
|
547
|
+
const altExclude =
|
|
548
|
+
alt.parts === undefined || input.setExclusion === 'none'
|
|
549
|
+
? []
|
|
550
|
+
: setExclusions(result.images, exW, exH, Object.values(altLimbs).flatMap((l) => l.segments.map((sg) => sg.part)), new Set([...coveredSet, ...hidesSet]));
|
|
505
551
|
let altRes: ReturnType<typeof assemble>;
|
|
506
552
|
try {
|
|
507
553
|
altRes = assemble({
|
|
@@ -522,6 +568,9 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
522
568
|
...(fields.headFaceUnderfill === undefined ? {} : { headFaceUnderfill: fields.headFaceUnderfill }),
|
|
523
569
|
seamRule: input.seam,
|
|
524
570
|
projectRule: input.project,
|
|
571
|
+
...(altExclude.length === 0 ? {} : { exclude: altExclude }),
|
|
572
|
+
...(altIslands.length === 0 ? {} : { limbIslands: altIslands }),
|
|
573
|
+
...(altOthers === undefined ? {} : { otherLimbs: altOthers }),
|
|
525
574
|
});
|
|
526
575
|
} catch (err) {
|
|
527
576
|
if (err instanceof PartsError) {
|
|
@@ -569,6 +618,9 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
569
618
|
...(altRegistration === undefined ? {} : { registration: altRegistration }),
|
|
570
619
|
},
|
|
571
620
|
images: keptImages,
|
|
621
|
+
excluded: altRes.excluded,
|
|
622
|
+
islands: altRes.islands,
|
|
623
|
+
splits: altRes.splits,
|
|
572
624
|
});
|
|
573
625
|
}
|
|
574
626
|
refuseIfAny(altProblems);
|
|
@@ -630,10 +682,60 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
630
682
|
if (result.figures.uncoveredErrorPx > 0) log(holeKindsLine(result.holeKinds, scene));
|
|
631
683
|
for (const u of result.uncovered) log(uncoveredLine(u, scene));
|
|
632
684
|
for (const d of result.drift) log(driftLine(d));
|
|
685
|
+
// Issue #588: per subset set, one line per limb part cut from a layer of more than one island, then (issue #587) one
|
|
686
|
+
// per limb part and base part over it that took a pixel. None otherwise.
|
|
687
|
+
// Issue #609: then one per limb part cut from a layer of one island that also holds a limb the set does not carry.
|
|
688
|
+
for (const b of altBuilt) for (const l of [...islandLines(b.record.name, b.islands), ...splitLines(b.record.name, b.splits), ...excludedLines(b.record.name, b.excluded)]) log(l);
|
|
633
689
|
log(`wrote ${outs.partsJson}, ${result.images.length} PNG(s) in ${outs.partsDir}, ${outs.recomposite}, ${outs.errorMap} (uncovered error px red, covered error px blue, the painting grey)${figurePath === null ? '' : `, ${figurePath} (the figure, white, the recomposite was read inside)`}`);
|
|
634
690
|
return result;
|
|
635
691
|
}
|
|
636
692
|
|
|
693
|
+
/**
|
|
694
|
+
* Issue #609: what a subset set says of the limbs of its shared layers it does not carry ({@link OtherLimbs}). A bone
|
|
695
|
+
* is placed by the set when the set places it (`setPlaced`: its skeleton's table bones, its drawn bones) or an
|
|
696
|
+
* ancestor of it — the rule `placeBoneEntriesForSkeleton` and `poseBoneEntriesForDrawn` move a child by; any other
|
|
697
|
+
* bone keeps the base's place, which is not the set's, so a limb with one is `unposed`. The base art is each limb's
|
|
698
|
+
* base parts at alpha above `OPAQUE_ALPHA_ABOVE`, at their `parts.json` x, y.
|
|
699
|
+
*/
|
|
700
|
+
function otherLimbsOf(
|
|
701
|
+
limbs: Readonly<Record<string, Limb>>,
|
|
702
|
+
setPlaced: ReadonlySet<string>,
|
|
703
|
+
bones: readonly BoneEntry[],
|
|
704
|
+
base: ReadonlyArray<{ record: PartRecord; image: Raster }>,
|
|
705
|
+
rigSize: readonly [number, number],
|
|
706
|
+
pose: OtherLimbs['pose'],
|
|
707
|
+
): OtherLimbs {
|
|
708
|
+
const parent = new Map<string, string>();
|
|
709
|
+
for (const b of bones) {
|
|
710
|
+
if ('chain' in b) b.points.forEach((_, k) => parent.set(`${b.chain}${k}`, k === 0 ? b.parent : `${b.chain}${k - 1}`));
|
|
711
|
+
else parent.set(b.name, b.parent);
|
|
712
|
+
}
|
|
713
|
+
const placed = (b: string): boolean => {
|
|
714
|
+
for (let at: string | undefined = b, n = 0; at !== undefined && n <= parent.size; at = parent.get(at), n++) if (setPlaced.has(at)) return true;
|
|
715
|
+
return false;
|
|
716
|
+
};
|
|
717
|
+
const [W, H] = rigSize;
|
|
718
|
+
const unposed: Record<string, string[]> = {};
|
|
719
|
+
const baseArt: Record<string, Mask> = {};
|
|
720
|
+
for (const [ln, l] of Object.entries(limbs)) {
|
|
721
|
+
unposed[ln] = l.segments.map((sg) => sg.bone).filter((b) => !placed(b));
|
|
722
|
+
const names = new Set(l.segments.map((sg) => sg.part));
|
|
723
|
+
const m = newMask(W, H);
|
|
724
|
+
for (const { record, image } of base) {
|
|
725
|
+
if (!names.has(record.name)) continue;
|
|
726
|
+
for (let y = 0; y < image.height; y++) {
|
|
727
|
+
for (let x = 0; x < image.width; x++) {
|
|
728
|
+
const rx = record.x + x;
|
|
729
|
+
const ry = record.y + y;
|
|
730
|
+
if (rx >= 0 && ry >= 0 && rx < W && ry < H && image.data[(y * image.width + x) * 4 + 3] > OPAQUE_ALPHA_ABOVE) m.data[ry * W + rx] = 1;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
baseArt[ln] = m;
|
|
735
|
+
}
|
|
736
|
+
return { limbs, unposed, baseArt, drawOrder: base.map((q) => q.record.name), pose };
|
|
737
|
+
}
|
|
738
|
+
|
|
637
739
|
/**
|
|
638
740
|
* The line `assemble` prints under `one run:` when the file was padded (issue
|
|
639
741
|
* #366): its size, the square and the four margins, and that `parts.json`'s
|
|
@@ -1368,6 +1470,8 @@ export interface CheckStageInput {
|
|
|
1368
1470
|
requirements?: string;
|
|
1369
1471
|
/** The path `check.json`'s `requirements.file` records (issue #556): `config.requirements` as declared when build read it from the config; absent, `requirements` as given. */
|
|
1370
1472
|
requirementsAs?: string;
|
|
1473
|
+
/** The config `build` read (issue #607), recorded as `check.json`'s `config`; absent, no key is written, as `check` alone writes none. */
|
|
1474
|
+
config?: InputFileRecord;
|
|
1371
1475
|
/**
|
|
1372
1476
|
* `check --seam-pairs` (issue #202): split the seam's counted pixels by pair
|
|
1373
1477
|
* and draw each pair's picture even when the bar passes. A failing seam is
|
|
@@ -1527,7 +1631,7 @@ export function sweepCheckLines(line: SweepLine, steps: ReadonlyMap<string, { le
|
|
|
1527
1631
|
return [
|
|
1528
1632
|
`${SWEEP_LINE}: ${line.status} — ${line.joints.length} joint(s) bent to their declared range's ends and middle${line.physics_left_out === 0 ? '' : `, ${line.physics_left_out} physics constraint(s) left out`}; at each, the pose against the same pose with the joint's own art drawn under the limb, on the rest-pose seam's bar (mean |d| <= ${line.bar.mean.toFixed(1)}, <= ${line.bar.rig_px_over_40} rig px over ${line.bar.level})${s === null ? '' : ` at frame scale ${s}`}`,
|
|
1529
1633
|
...line.joints.flatMap((j) => {
|
|
1530
|
-
const head = `joint "${j.joint}" (${j.limb}, "${j.part}" on "${j.bone}", range [${j.range.join(', ')}]${j.shape === '
|
|
1634
|
+
const head = `joint "${j.joint}" (${j.limb}, "${j.part}" on "${j.bone}", range [${j.range.join(', ')}]${j.shape === undefined ? '' : `, cap_shape "${j.shape}": no pixel over ${line.bar.level} in the disc`})`;
|
|
1531
1635
|
if (j.unread !== undefined) return [`${head}: FAIL — not read: ${j.unread}`];
|
|
1532
1636
|
// Issue #557: the contour step, a reading on every row (check.json carries it only for a short cap).
|
|
1533
1637
|
return j.poses.map((p) => {
|
|
@@ -1592,7 +1696,7 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
|
|
|
1592
1696
|
const entryLine = versionLines.find((l) => l.startsWith('entry:'));
|
|
1593
1697
|
log(` ${rigcIdentity(bin, v)}${entryLine === undefined ? '' : `; ${entryLine}`}`);
|
|
1594
1698
|
const mode: PackMode = { pageEdges: input.pageEdges ?? DEFAULT_PAGE_EDGES, packShape: input.packShape ?? DEFAULT_PACK_SHAPE };
|
|
1595
|
-
const r = runCheck(input.rig, input.out, rigc, input.parts, mode, input.source, input.requirements, input.seamPairs === true, input.keepStills === true, input.set, input.allSets === true, input.environment, input.requirementsAs);
|
|
1699
|
+
const r = runCheck(input.rig, input.out, rigc, input.parts, mode, input.source, input.requirements, input.seamPairs === true, input.keepStills === true, input.set, input.allSets === true, input.environment, input.requirementsAs, input.config);
|
|
1596
1700
|
if (r.figures.environment !== undefined) log(` ${environmentLine(r.figures.environment)}`);
|
|
1597
1701
|
log(` gate rig-play (rigc ${packedBuildLabel(mode)}), verbatim:`);
|
|
1598
1702
|
for (const l of r.gateHtml) log(l);
|
|
@@ -2078,13 +2182,17 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
|
|
|
2078
2182
|
log(`rig-parts build: ${input.config} -> ${out}, seam rule ${input.seam}, projection rule ${input.project}, page edges ${input.pageEdges}, pack shape ${input.packShape ?? DEFAULT_PACK_SHAPE}${idleKeys === DEFAULT_IDLE_KEYS ? '' : `, idle keys ${idleKeys}`}${input.loop ? `, with the idle loop${input.leadIn === undefined ? '' : ` after a lead-in of ${input.leadIn} period(s)`}` : ''}`);
|
|
2079
2183
|
|
|
2080
2184
|
let req: BuildRequirements | null = null;
|
|
2185
|
+
let configRecord: InputFileRecord | null = null;
|
|
2081
2186
|
try {
|
|
2082
2187
|
// build runs rig next, which needs the whole config, so the full loader is
|
|
2083
2188
|
// asked first: a config rig would refuse is refused before assemble writes
|
|
2084
2189
|
// anything, and under [assemble], as it was before the stage had its own
|
|
2085
2190
|
// narrower door.
|
|
2086
2191
|
// Issue #556: the flag, or the config's declaration when there is none; both naming other bytes is refused here.
|
|
2087
|
-
|
|
2192
|
+
// Issue #607: the bytes this read parsed are the ones check.json's config record hashes, under the path as typed.
|
|
2193
|
+
const loaded = loadConfigWithBytes(input.config);
|
|
2194
|
+
configRecord = inputFileRecord(loaded.bytes, input.config);
|
|
2195
|
+
req = buildRequirements(input.requirements, loaded.config.requirements, input.config);
|
|
2088
2196
|
// The same for the requirements file's own shape; its names resolve against the rig, in the check, before it builds.
|
|
2089
2197
|
if (req !== null) readRequirements(req.read);
|
|
2090
2198
|
// And the schedule (issue #538), by rigc's own reader, as check reads it.
|
|
@@ -2106,7 +2214,7 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
|
|
|
2106
2214
|
|
|
2107
2215
|
let report: CheckReport;
|
|
2108
2216
|
try {
|
|
2109
|
-
report = checkStage({ rig: join(out, 'rig'), parts: out, out: join(out, 'check'), pageEdges: input.pageEdges, packShape: input.packShape, ...(req === null ? {} : { requirements: req.read, requirementsAs: req.recorded }), seamPairs: input.seamPairs === true, keepStills: input.keepStills === true, ...(input.set === undefined ? {} : { set: input.set }), allSets: input.allSets === true, ...(input.environment === undefined ? {} : { environment: input.environment }) }, run.check, run.checkBin, prefixed('check'));
|
|
2217
|
+
report = checkStage({ rig: join(out, 'rig'), parts: out, out: join(out, 'check'), pageEdges: input.pageEdges, packShape: input.packShape, ...(req === null ? {} : { requirements: req.read, requirementsAs: req.recorded }), seamPairs: input.seamPairs === true, keepStills: input.keepStills === true, ...(input.set === undefined ? {} : { set: input.set }), allSets: input.allSets === true, ...(input.environment === undefined ? {} : { environment: input.environment }), ...(configRecord === null ? {} : { config: configRecord }) }, run.check, run.checkBin, prefixed('check'));
|
|
2110
2218
|
} catch (err) {
|
|
2111
2219
|
return refused('check', err);
|
|
2112
2220
|
}
|
package/src/check.ts
CHANGED
|
@@ -1888,6 +1888,12 @@ export interface CheckFigures {
|
|
|
1888
1888
|
skipped?: { loop?: string; seam?: string };
|
|
1889
1889
|
/** Written only under `--set` or `--all-sets` (issue #454): each checked alternate set's setup-pose seam and recomposite figures, keyed by set name. */
|
|
1890
1890
|
sets?: Record<string, SetCheckFigures>;
|
|
1891
|
+
/**
|
|
1892
|
+
* Written only by `build` (issue #607): the config it read, the path as `--config` was typed and the sha256 of the
|
|
1893
|
+
* bytes its full loader parsed ({@link inputFileRecord}), just before the requirements block. Provenance, not a
|
|
1894
|
+
* bar; `check` and `compose` read no config and write no key.
|
|
1895
|
+
*/
|
|
1896
|
+
config?: InputFileRecord;
|
|
1891
1897
|
/** Written only under `--requirements` (issue #93): the file's fps, the summary, and one line per declared requirement, by name. */
|
|
1892
1898
|
requirements?: RequirementsBlock;
|
|
1893
1899
|
PASS: boolean;
|
|
@@ -2018,7 +2024,15 @@ export const LIMB_LINE = 'LIMB_ONE_BONE';
|
|
|
2018
2024
|
* {@link SEAM_PX_LEVEL}: the disc is the cap's whole claim, so one uncovered
|
|
2019
2025
|
* pixel of it is one too many. The level is the seam's; the count's bar is
|
|
2020
2026
|
* the card's ("the joint disc holds no background pixel"), not a figure
|
|
2021
|
-
* measured here. Its row says `shape: "disc"
|
|
2027
|
+
* measured here. Its row says `shape: "disc"`.
|
|
2028
|
+
* - **So is a ball** (issue #598). A joint whose cap record says
|
|
2029
|
+
* `shape: "ball"` (`cap_shape: "ball"`, issue #579) is held to the same
|
|
2030
|
+
* rule over the same comparison, and its row says `shape: "ball"`. The
|
|
2031
|
+
* comparison already reads the whole disc — the underlay is the limb's art
|
|
2032
|
+
* at rest inside the disc on both sides of the joint line — and the whole
|
|
2033
|
+
* disc is what a ball writes (its lower half into the lower piece), so the
|
|
2034
|
+
* rule reads both halves: a ball whose lower half the art does not give
|
|
2035
|
+
* shows it at a bend. No row of a rig without `"disc"` or `"ball"` changes.
|
|
2022
2036
|
* - **Opt-in by construction.** Written only when `parts.json` holds a limb
|
|
2023
2037
|
* record with a `range`; a rig without one renders nothing more and writes
|
|
2024
2038
|
* what it wrote.
|
|
@@ -3070,8 +3084,8 @@ export interface SweepJoint {
|
|
|
3070
3084
|
range: [number, number];
|
|
3071
3085
|
at: [number, number];
|
|
3072
3086
|
radius: number;
|
|
3073
|
-
/**
|
|
3074
|
-
|
|
3087
|
+
/** Issues #360 and #598: the cap's record says `shape: "disc"` or `"ball"` — the disc is held to no pixel uncovered ({@link sweepLine}). */
|
|
3088
|
+
shape?: 'disc' | 'ball';
|
|
3075
3089
|
/** Issue #557: the upper segment's bone (the limb record one segment up), whose direction the contour step is read across; null when parts.json has none. */
|
|
3076
3090
|
upperBone?: string | null;
|
|
3077
3091
|
/** Issue #557: the cap's record carries `short_px` — the step is then written into check.json ({@link SweepPose}). */
|
|
@@ -3094,7 +3108,7 @@ export function sweepJoints(parts: PartsFile): SweepJoint[] {
|
|
|
3094
3108
|
range: [l.range[0], l.range[1]],
|
|
3095
3109
|
at: [l.cap.at[0], l.cap.at[1]],
|
|
3096
3110
|
radius: l.cap.radius,
|
|
3097
|
-
...(l.cap.shape ===
|
|
3111
|
+
...(l.cap.shape === undefined ? {} : { shape: l.cap.shape }),
|
|
3098
3112
|
upperBone: up,
|
|
3099
3113
|
...(l.cap.short_px === undefined ? {} : { short: { left: l.cap.short_px.left, right: l.cap.short_px.right } }),
|
|
3100
3114
|
});
|
|
@@ -3325,8 +3339,8 @@ export interface SweepRow {
|
|
|
3325
3339
|
range: [number, number];
|
|
3326
3340
|
at: [number, number];
|
|
3327
3341
|
radius: number;
|
|
3328
|
-
/**
|
|
3329
|
-
shape?: 'disc';
|
|
3342
|
+
/** Issues #360 and #598: written only for a joint whose cap is `cap_shape: "disc"` or `"ball"`, held to no pixel over the level in its disc. */
|
|
3343
|
+
shape?: 'disc' | 'ball';
|
|
3330
3344
|
under_px: number;
|
|
3331
3345
|
status: 'PASS' | 'FAIL';
|
|
3332
3346
|
poses: SweepPose[];
|
|
@@ -3363,7 +3377,7 @@ export function sweepLine(
|
|
|
3363
3377
|
const seen: { grid: FrameSet | null } = { grid: null };
|
|
3364
3378
|
const rows: SweepRow[] = joints.map((j, i) => {
|
|
3365
3379
|
const object = (at: string): string => `joint "${j.joint}" (config.limbs.${j.limb} segment ${j.segment}, part "${j.part}", bone "${j.bone}") ${at}`;
|
|
3366
|
-
const head = { part: j.part, limb: j.limb, segment: j.segment, joint: j.joint, bone: j.bone, range: j.range, at: j.at, radius: j.radius, ...(j.
|
|
3380
|
+
const head = { part: j.part, limb: j.limb, segment: j.segment, joint: j.joint, bone: j.bone, range: j.range, at: j.at, radius: j.radius, ...(j.shape === undefined ? {} : { shape: j.shape }), under_px: underPx[i] };
|
|
3367
3381
|
const why = unread[i];
|
|
3368
3382
|
if (why !== null) {
|
|
3369
3383
|
problems.push({ code: `CHECK_${SWEEP_LINE}`, object: object(`over its range [${j.range.join(', ')}]`), detail: `is not read: ${why}; a joint not read is not a pass` });
|
|
@@ -3388,8 +3402,8 @@ export function sweepLine(
|
|
|
3388
3402
|
const f = seamFigures(under.frames[0].image, bare.frames[0].image, { x: 0, y: 0, width: vp.pixelWidth, height: vp.pixelHeight }, vp, bare.background, { sx: 1, sy: 1, tx: 0, ty: 0 });
|
|
3389
3403
|
const mean = round3(f.mean);
|
|
3390
3404
|
const scale = round6(vp.scale);
|
|
3391
|
-
//
|
|
3392
|
-
const discFail = j.
|
|
3405
|
+
// Issues #360 and #598: a disc or ball cap promises the disc covered at every pose, so one pixel over the level there is a FAIL of its own.
|
|
3406
|
+
const discFail = j.shape !== undefined && f.over40 > 0 && !seamFails(mean, f.over40, scale);
|
|
3393
3407
|
const fail = seamFails(mean, f.over40, scale) || discFail;
|
|
3394
3408
|
if (discFail) {
|
|
3395
3409
|
problems.push({
|
|
@@ -3397,7 +3411,7 @@ export function sweepLine(
|
|
|
3397
3411
|
object: object(`bent ${a}°`),
|
|
3398
3412
|
detail:
|
|
3399
3413
|
`${f.over40} frame px over ${SEAM_PX_LEVEL} (${f.over80} over ${SEAM_PX_LEVEL_HIGH}) at frame scale ${scale}, mean |d| ${mean}/255, against the same pose with the joint's own art drawn under the limb (${underPx[i]} px, the disc of radius ${j.radius} px about [${j.at.join(', ')}]); ` +
|
|
3400
|
-
`the cap is cap_shape "
|
|
3414
|
+
`the cap is cap_shape "${j.shape}", which promises the disc covered at every pose${j.shape === 'ball' ? ', on both sides of the joint line' : ''} — no pixel of it over ${SEAM_PX_LEVEL}, under the rest-pose seam's bar as well — and the bend shows what lies behind the limb there: a cap pixel the art did not give ("limb cap:" counts them as missing), or a pixel cleared from "${j.part}" after assemble wrote it`,
|
|
3401
3415
|
});
|
|
3402
3416
|
} else if (fail) {
|
|
3403
3417
|
problems.push({
|
|
@@ -3922,7 +3936,7 @@ export function environmentLine(env: CheckEnvironment): string {
|
|
|
3922
3936
|
* MEASURABLE is a problem. Without it nothing here reads, writes or prints
|
|
3923
3937
|
* anything it did not before.
|
|
3924
3938
|
*/
|
|
3925
|
-
export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string, requirementsAs: string | undefined = requirements): CheckReport {
|
|
3939
|
+
export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string, requirementsAs: string | undefined = requirements, config?: InputFileRecord): CheckReport {
|
|
3926
3940
|
let inp: CheckInputs;
|
|
3927
3941
|
let reqFile: RequirementsFile | null = null;
|
|
3928
3942
|
let reqRecord: RequirementsFileRecord | null = null;
|
|
@@ -4575,6 +4589,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
4575
4589
|
...(sourceRead === null ? {} : { [SOURCE_LINE]: sourceRead }),
|
|
4576
4590
|
...(Object.keys(skipped).length === 0 ? {} : { skipped }),
|
|
4577
4591
|
...(Object.keys(setsFigures).length === 0 ? {} : { sets: setsFigures }),
|
|
4592
|
+
...(config === undefined ? {} : { config }),
|
|
4578
4593
|
...(reqBlock === null ? {} : { requirements: reqBlock }),
|
|
4579
4594
|
PASS: false,
|
|
4580
4595
|
};
|
|
@@ -4685,7 +4700,23 @@ export interface RequirementsFileRecord {
|
|
|
4685
4700
|
export function requirementsFileRecord(path: string, recorded: string): RequirementsFileRecord {
|
|
4686
4701
|
const bytes = readFileSync(resolve(path));
|
|
4687
4702
|
const raw = JSON.parse(bytes.toString('utf8')) as Record<string, unknown>;
|
|
4688
|
-
return {
|
|
4703
|
+
return { ...inputFileRecord(bytes, recorded), keys: Object.keys(raw) };
|
|
4704
|
+
}
|
|
4705
|
+
|
|
4706
|
+
/**
|
|
4707
|
+
* An input file as `check.json` records it — the path as the caller wrote it,
|
|
4708
|
+
* never resolved, then the sha256 of the bytes read — in the order the
|
|
4709
|
+
* requirements record (issue #556) opens with; `build`'s `config` record
|
|
4710
|
+
* (issue #607) is this and nothing more.
|
|
4711
|
+
*/
|
|
4712
|
+
export interface InputFileRecord {
|
|
4713
|
+
path: string;
|
|
4714
|
+
sha256: string;
|
|
4715
|
+
}
|
|
4716
|
+
|
|
4717
|
+
/** The {@link InputFileRecord} of `bytes`, recorded as `recorded`: the one place a record's digest is taken. */
|
|
4718
|
+
export function inputFileRecord(bytes: Uint8Array, recorded: string): InputFileRecord {
|
|
4719
|
+
return { path: recorded, sha256: createHash('sha256').update(bytes).digest('hex') };
|
|
4689
4720
|
}
|
|
4690
4721
|
|
|
4691
4722
|
/** The throwaway copies' specs and builds, under `--out`; removed before the stage returns. */
|
package/src/cloth.ts
CHANGED
|
@@ -105,7 +105,9 @@ export interface ClothRecipe {
|
|
|
105
105
|
* Issue #518: draft the parts this recipe meshes in the influence mode (`meshes.<part>.influence`, issue #378) rather
|
|
106
106
|
* than on a lattice: `across`, `max` and `shape` as declared (no default — the reading that fixed the radius did not
|
|
107
107
|
* vary them), `cell` the lattice cell the part would have had, and `radius` as declared or, absent, drafted as
|
|
108
|
-
* {@link INFLUENCE_RADIUS_CELLS} cells past the part's farthest lattice vertex from its nearest link.
|
|
108
|
+
* {@link INFLUENCE_RADIUS_CELLS} cells past the part's farthest lattice vertex from its nearest link. Issue #615:
|
|
109
|
+
* under `split.hold_tip: true` the drafted mesh also declares `hold_tip: true` and `max` at least 8 (the lattice's
|
|
110
|
+
* held-fork smoothing cap), so the rig stage smooths its shares as it smooths the lattice's.
|
|
109
111
|
*/
|
|
110
112
|
influence?: { across: boolean; max: number; shape: 'linear' | 'smooth'; radius?: number };
|
|
111
113
|
}
|
|
@@ -116,8 +118,13 @@ export interface ClothRecipe {
|
|
|
116
118
|
* cloth fixture and the public `wind` example (8 covered parts, `render --folds` with the physics on under wind
|
|
117
119
|
* +1 -> -1 -> calm and a hip sway of 8 and 30 degrees, max 6, across, smooth): farthest + 2 to + 6 cells read 0
|
|
118
120
|
* folded frames on every part, + 2 at the window's edge on one front-hair part, and a fold returned at 8-11 cells on
|
|
119
|
-
* another.
|
|
120
|
-
*
|
|
121
|
+
* another. That reading counted folds only. Read against `check` as well (the rig as built under the same wind
|
|
122
|
+
* schedule, the three covered `wind` parts at the same number of cells), + 4 is the ceiling: `wind` `bottomwear`'s
|
|
123
|
+
* `CHECK_TIP_OVER_ROOT` ratio is 1.898 on the lattice, 1.801 at + 2 cells, 1.590 at + 3 and 1.471 at + 4, under the
|
|
124
|
+
* floor 1.4725, and 1.351 at + 6 (#513, rig-parts 1.52.0, rigc 2.60.0; the lattice, + 3 and + 4 read again on
|
|
125
|
+
* rig-parts 1.54.0, rigc 2.60.0 with the same figures, #599). The window that holds both is + 2 to + 3 cells, and 3 is
|
|
126
|
+
* its upper edge: one cell inside the fold edge, one under the check ceiling. [Hypothesis until a third subject: each
|
|
127
|
+
* edge rests on one part.] Past the floor alone the mesh folds more than its lattice, and a larger radius is not safer.
|
|
121
128
|
*/
|
|
122
129
|
export const INFLUENCE_RADIUS_CELLS = 3;
|
|
123
130
|
|
package/src/config.ts
CHANGED
|
@@ -328,9 +328,11 @@ export type MeshSpec = LatticeMeshSpec | ContourMeshSpec | AutoMeshSpec | Influe
|
|
|
328
328
|
* `buildSegmentsLattice` and `influenceShares` from `rig-c/mesh`, promised for this call (rig-c/core#1450), so the
|
|
329
329
|
* rule is core's and the mesh is written with explicit weights like every other mode (`src/rig.ts`). `segments`
|
|
330
330
|
* names the links as in every mode; each entry is one of rig-c's `bones` entries, which `across: false` keeps apart.
|
|
331
|
+
* `hold_tip: true` (issue #615, optional, written by `propose --cloth` from the recipe's `split.hold_tip`) smooths the
|
|
332
|
+
* pulled shares by the lattice's held-fork passes, capped at `max`; absent, the shares are rig-c's as pulled.
|
|
331
333
|
*/
|
|
332
334
|
export interface InfluenceMeshSpec {
|
|
333
|
-
influence: { cell: number; radius: number; across: boolean; max: number; shape: 'linear' | 'smooth' };
|
|
335
|
+
influence: { cell: number; radius: number; across: boolean; max: number; shape: 'linear' | 'smooth'; hold_tip?: true };
|
|
334
336
|
segments: Segment[];
|
|
335
337
|
}
|
|
336
338
|
|
|
@@ -1159,22 +1161,38 @@ function partNameOk(name: string): boolean {
|
|
|
1159
1161
|
// the loader
|
|
1160
1162
|
// ---------------------------------------------------------------------------
|
|
1161
1163
|
|
|
1162
|
-
/** The file as parsed JSON, or a refusal naming why not.
|
|
1163
|
-
function
|
|
1164
|
+
/** The file's bytes as read and as parsed JSON, or a refusal naming why not. Every loader reads through it. */
|
|
1165
|
+
function readConfigBytes(path: string): { raw: Json; bytes: Buffer } {
|
|
1164
1166
|
if (!existsSync(path)) refuseIfAny([{ code: 'CONFIG_FILE_PRESENT', object: path, detail: 'no such file' }]);
|
|
1167
|
+
const bytes = readFileSync(path);
|
|
1165
1168
|
let raw: Json;
|
|
1166
1169
|
try {
|
|
1167
|
-
raw = JSON.parse(
|
|
1170
|
+
raw = JSON.parse(bytes.toString('utf8'));
|
|
1168
1171
|
} catch (err) {
|
|
1169
1172
|
refuseIfAny([{ code: 'CONFIG_IS_JSON', object: path, detail: `does not parse as JSON: ${(err as Error).message}` }]);
|
|
1170
1173
|
}
|
|
1171
|
-
return raw;
|
|
1174
|
+
return { raw, bytes };
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
/** The file as parsed JSON, or a refusal naming why not. */
|
|
1178
|
+
function readConfigFile(path: string): Json {
|
|
1179
|
+
return readConfigBytes(path).raw;
|
|
1172
1180
|
}
|
|
1173
1181
|
|
|
1174
1182
|
export function loadConfig(path: string): CharacterConfig {
|
|
1175
1183
|
return loadConfigAndAnimations(path).config;
|
|
1176
1184
|
}
|
|
1177
1185
|
|
|
1186
|
+
/**
|
|
1187
|
+
* The full loader, with the bytes it parsed (issue #607): `build` hashes these
|
|
1188
|
+
* into `check.json`'s `config` record, so the digest is of the bytes this read
|
|
1189
|
+
* took, not of a later read of the same path.
|
|
1190
|
+
*/
|
|
1191
|
+
export function loadConfigWithBytes(path: string): { config: CharacterConfig; bytes: Buffer } {
|
|
1192
|
+
const { raw, bytes } = readConfigBytes(path);
|
|
1193
|
+
return { config: parseConfigFrom(raw, dirname(resolve(path))).config, bytes };
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1178
1196
|
/**
|
|
1179
1197
|
* The full loader with the file `motion.animations_from` names read beside it,
|
|
1180
1198
|
* relative to the config's directory: every problem in either is one refusal.
|
|
@@ -2476,8 +2494,11 @@ function checkInfluence(c: Check, at: string, m: Record<string, Json>): void {
|
|
|
2476
2494
|
for (const k of INFLUENCE_FOREIGN_FIELDS) {
|
|
2477
2495
|
if (k in m) c.fail('CONFIG_INFLUENCE_MODE', `${at}.${k}`, `is ${show(m[k])} on an influence mesh; it pulls each vertex by rig-c's influence (radius, across, max, shape), which reads no ${k} — remove ${k}`);
|
|
2478
2496
|
}
|
|
2479
|
-
const o = c.object(`${at}.influence`, m.influence, ['cell', 'radius', 'across', 'max', 'shape'], []);
|
|
2497
|
+
const o = c.object(`${at}.influence`, m.influence, ['cell', 'radius', 'across', 'max', 'shape'], ['hold_tip']);
|
|
2480
2498
|
if (o === null) return;
|
|
2499
|
+
// Issue #615: one spelling — true smooths the held fork, absent leaves the shares as pulled; false would be a second
|
|
2500
|
+
// spelling of absent, and a mesh_report row that echoes it would differ from the one written before the field existed.
|
|
2501
|
+
if ('hold_tip' in o && o.hold_tip !== true) c.fail('CONFIG_FIELD_TYPE', `${at}.influence.hold_tip`, `is ${show(o.hold_tip)}; true (the pulled shares smoothed across the held fork, capped at max) is required — remove hold_tip to keep the shares as rig-c pulls them`);
|
|
2481
2502
|
if ('cell' in o) c.int(`${at}.influence.cell`, o.cell, 1);
|
|
2482
2503
|
if ('radius' in o) c.number(`${at}.influence.radius`, o.radius, 'positive');
|
|
2483
2504
|
if ('across' in o && typeof o.across !== 'boolean') c.fail('CONFIG_FIELD_TYPE', `${at}.influence.across`, `is ${show(o.across)}; true (every link within radius pulls, across the segments entries) or false (only the links of the entry nearest the vertex) is required`);
|