@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/parts.ts
CHANGED
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
* - `refused_drift_px` — of those, the ones refused because See-through's
|
|
30
30
|
* pixel and the painting's disagreed by more than the drift limit;
|
|
31
31
|
* - `merged_px` — pixels brought in from the other run below the head crop;
|
|
32
|
+
* on a subset set's limb part, less those the set's exclusion (issue #587)
|
|
33
|
+
* cleared, so it counts the written PNG's (issue #603);
|
|
32
34
|
* - `seam_override_px` — pixels whose colour the seam pass replaced;
|
|
33
35
|
* - `fringe_pushed_back` — written only when not empty: the pixels of this
|
|
34
36
|
* part's fringe (alpha below 250) made transparent because the painting
|
|
@@ -163,6 +165,16 @@ export interface CapRecord {
|
|
|
163
165
|
* `right` the other; the two add up to `missing_px`. A full cap writes no key.
|
|
164
166
|
*/
|
|
165
167
|
short_px?: { left: number; right: number };
|
|
168
|
+
/**
|
|
169
|
+
* Issue #603, written only when above 0: the cap's pixels a subset set's
|
|
170
|
+
* exclusion (issue #587) cleared — pixels a base part the set does not
|
|
171
|
+
* replace covers at setup — each taken out of the count it was in
|
|
172
|
+
* (`layer_px`, `image_px`, `upper_px`, `lower_px`, `lower_kept_px`), so
|
|
173
|
+
* those counts are the written PNG's. The disc's pixels are then the
|
|
174
|
+
* counts above, `upper_px`, the lower half's and `excluded_px` together.
|
|
175
|
+
* A cap no exclusion touched writes no key.
|
|
176
|
+
*/
|
|
177
|
+
excluded_px?: number;
|
|
166
178
|
/**
|
|
167
179
|
* Issue #360, written only under the segment's `cap_shape: "disc"`: the
|
|
168
180
|
* shape; the cap's pixels taken from the upper segment's art where the
|
|
@@ -219,6 +231,7 @@ const CAP_KEYS = [
|
|
|
219
231
|
'image_layer',
|
|
220
232
|
'missing_px',
|
|
221
233
|
'short_px',
|
|
234
|
+
'excluded_px',
|
|
222
235
|
'shape',
|
|
223
236
|
'upper_px',
|
|
224
237
|
'lower_px',
|
|
@@ -631,51 +644,7 @@ function checkParts(raw: unknown, path: string): PartsFile {
|
|
|
631
644
|
fail('PARTS_FIELD_TYPE', `${object} "range"`, `is ${show(r)}; [min, max], two finite degrees from rest with min <= 0 <= max, is required — config.limbs' rule (CONFIG_LIMB_RANGE)`);
|
|
632
645
|
}
|
|
633
646
|
}
|
|
634
|
-
if ('cap' in q) {
|
|
635
|
-
const c = q.cap;
|
|
636
|
-
const co = typeof c === 'object' && c !== null && !Array.isArray(c) ? (c as Record<string, unknown>) : null;
|
|
637
|
-
const pt = (v: unknown, n: number): boolean => Array.isArray(v) && v.length === n && v.every((x) => typeof x === 'number' && Number.isFinite(x));
|
|
638
|
-
const ok =
|
|
639
|
-
co !== null &&
|
|
640
|
-
Object.keys(co).every((k) => (CAP_KEYS as readonly string[]).includes(k)) &&
|
|
641
|
-
pt(co.at, 2) &&
|
|
642
|
-
typeof co.width === 'number' &&
|
|
643
|
-
typeof co.radius === 'number' &&
|
|
644
|
-
pt(co.box, 4) &&
|
|
645
|
-
isCount(co.layer_px) &&
|
|
646
|
-
isCount(co.missing_px) &&
|
|
647
|
-
(!('image_px' in co) || isCount(co.image_px)) &&
|
|
648
|
-
(!('image_layer' in co) || ('image_px' in co && typeof co.image_layer === 'string' && co.image_layer !== '')) &&
|
|
649
|
-
// Issue #360: a disc cap carries its count, a feathered edge its band and count, and neither carries them alone.
|
|
650
|
-
('shape' in co ? (co.shape === 'disc' || co.shape === 'ball') && isCount(co.upper_px) : !('upper_px' in co) || (isCount(co.upper_px) && co.upper_px > 0)) &&
|
|
651
|
-
// Issue #579: a ball cap carries its lower half's three counts, its missing ones inside missing_px; no other cap carries them.
|
|
652
|
-
(co.shape === 'ball'
|
|
653
|
-
? isCount(co.lower_px) && isCount(co.lower_kept_px) && isCount(co.lower_missing_px) && isCount(co.missing_px) && co.lower_missing_px <= co.missing_px
|
|
654
|
-
: BALL_KEYS.every((k) => !(k in co))) &&
|
|
655
|
-
// Issue #557: the shortfall by side, when written, adds up to the missing pixels, and is never written for none.
|
|
656
|
-
(!('short_px' in co) || shortSides(co.short_px, co.missing_px)) &&
|
|
657
|
-
('edge' in co ? co.edge === 'feather' && typeof co.feather_radius === 'number' && Number.isFinite(co.feather_radius) && co.feather_radius >= 0 && isCount(co.feathered_px) : !('feather_radius' in co) && !('feathered_px' in co)) &&
|
|
658
|
-
// Issue #360 (item 14): a placed cut carries its band, line and counts, the line inside the band; none of them rides alone.
|
|
659
|
-
('cut_band' in co
|
|
660
|
-
? isCount(co.cut_band) &&
|
|
661
|
-
co.cut_band >= 1 &&
|
|
662
|
-
Number.isInteger(co.cut_offset) &&
|
|
663
|
-
Math.abs(co.cut_offset as number) <= co.cut_band &&
|
|
664
|
-
pt(co.cut_at, 2) &&
|
|
665
|
-
isCount(co.cut_crossed) &&
|
|
666
|
-
isCount(co.joint_crossed) &&
|
|
667
|
-
isCount(co.band_px) &&
|
|
668
|
-
(co.cut_crossed as number) <= (co.joint_crossed as number) &&
|
|
669
|
-
(!('stroke_luma_max' in co) || (isCount(co.stroke_luma_max) && co.stroke_luma_max <= 255))
|
|
670
|
-
: CUT_KEYS.every((k) => !(k in co)));
|
|
671
|
-
if (!ok) {
|
|
672
|
-
fail(
|
|
673
|
-
'PARTS_FIELD_TYPE',
|
|
674
|
-
`${object} "cap"`,
|
|
675
|
-
`is ${show(c)}; {at: [x, y], width, radius, box: [x, y, w, h], layer_px, image_px?, image_layer? (with image_px), missing_px, short_px? ({left, right}, adding up to missing_px, above 0), shape? ("disc" or "ball", with upper_px; "ball" with lower_px, lower_kept_px and lower_missing_px, at most missing_px; without it upper_px? above 0), edge? ("feather", with feather_radius and feathered_px), cut_band? (with cut_offset inside the band, cut_at, cut_crossed at most joint_crossed, band_px, stroke_luma_max? 0..255)} is required`,
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
}
|
|
647
|
+
if ('cap' in q) checkCap(q.cap, `${object} "cap"`, fail);
|
|
679
648
|
}
|
|
680
649
|
}
|
|
681
650
|
if ('scene' in o) {
|
|
@@ -698,11 +667,80 @@ function checkParts(raw: unknown, path: string): PartsFile {
|
|
|
698
667
|
if ('alternates' in o && !Array.isArray(o.alternates)) {
|
|
699
668
|
fail('PARTS_FIELD_TYPE', `${path} field "alternates"`, `is ${show(o.alternates)}; an array of alternate set records is required`);
|
|
700
669
|
}
|
|
670
|
+
if (Array.isArray(o.alternates)) {
|
|
671
|
+
// Issue #620: a set record's cap is a cap, so it is held to the base records' rule; the object names the set and the part.
|
|
672
|
+
o.alternates.forEach((a, i) => {
|
|
673
|
+
if (typeof a !== 'object' || a === null || Array.isArray(a)) return;
|
|
674
|
+
const set = a as Record<string, unknown>;
|
|
675
|
+
if (!Array.isArray(set.records)) return;
|
|
676
|
+
const at = `${path} alternates[${i}]${typeof set.name === 'string' ? ` (set "${set.name}")` : ''}`;
|
|
677
|
+
set.records.forEach((p, j) => {
|
|
678
|
+
if (typeof p !== 'object' || p === null || Array.isArray(p)) return;
|
|
679
|
+
const r = p as Record<string, unknown>;
|
|
680
|
+
const l = r[LIMB_KEY];
|
|
681
|
+
if (typeof l !== 'object' || l === null || Array.isArray(l) || !('cap' in l)) return;
|
|
682
|
+
const part = typeof r.name === 'string' ? `part "${r.name}"` : `records[${j}]`;
|
|
683
|
+
checkCap((l as Record<string, unknown>).cap, `${at} ${part} field "${LIMB_KEY}" "cap"`, fail);
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
}
|
|
701
687
|
refuseIfAny(problems);
|
|
702
688
|
return raw as PartsFile;
|
|
703
689
|
}
|
|
704
690
|
|
|
705
691
|
const isCount = (v: unknown): v is number => Number.isInteger(v) && (v as number) >= 0;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* A limb segment's `cap` record (issue #349, with #360's disc, edge and band, #557's short_px and #579's ball): every key
|
|
695
|
+
* a cap key, its fields of their kinds, and its counts consistent — one refusal naming `object` when any is not. A base
|
|
696
|
+
* part's cap and a set record's cap (issue #620) are held to this one rule.
|
|
697
|
+
*/
|
|
698
|
+
function checkCap(c: unknown, object: string, fail: (code: string, object: string, detail: string) => void): void {
|
|
699
|
+
const co = typeof c === 'object' && c !== null && !Array.isArray(c) ? (c as Record<string, unknown>) : null;
|
|
700
|
+
const pt = (v: unknown, n: number): boolean => Array.isArray(v) && v.length === n && v.every((x) => typeof x === 'number' && Number.isFinite(x));
|
|
701
|
+
const ok =
|
|
702
|
+
co !== null &&
|
|
703
|
+
Object.keys(co).every((k) => (CAP_KEYS as readonly string[]).includes(k)) &&
|
|
704
|
+
pt(co.at, 2) &&
|
|
705
|
+
typeof co.width === 'number' &&
|
|
706
|
+
typeof co.radius === 'number' &&
|
|
707
|
+
pt(co.box, 4) &&
|
|
708
|
+
isCount(co.layer_px) &&
|
|
709
|
+
isCount(co.missing_px) &&
|
|
710
|
+
(!('image_px' in co) || isCount(co.image_px)) &&
|
|
711
|
+
(!('image_layer' in co) || ('image_px' in co && typeof co.image_layer === 'string' && co.image_layer !== '')) &&
|
|
712
|
+
// Issue #360: a disc cap carries its count, a feathered edge its band and count, and neither carries them alone.
|
|
713
|
+
('shape' in co ? (co.shape === 'disc' || co.shape === 'ball') && isCount(co.upper_px) : !('upper_px' in co) || (isCount(co.upper_px) && co.upper_px > 0)) &&
|
|
714
|
+
// Issue #579: a ball cap carries its lower half's three counts, its missing ones inside missing_px; no other cap carries them.
|
|
715
|
+
(co.shape === 'ball'
|
|
716
|
+
? isCount(co.lower_px) && isCount(co.lower_kept_px) && isCount(co.lower_missing_px) && isCount(co.missing_px) && co.lower_missing_px <= co.missing_px
|
|
717
|
+
: BALL_KEYS.every((k) => !(k in co))) &&
|
|
718
|
+
// Issue #557: the shortfall by side, when written, adds up to the missing pixels, and is never written for none.
|
|
719
|
+
(!('short_px' in co) || shortSides(co.short_px, co.missing_px)) &&
|
|
720
|
+
// Issue #603: the pixels a set's exclusion took from the cap, written only when it took one.
|
|
721
|
+
(!('excluded_px' in co) || (isCount(co.excluded_px) && co.excluded_px > 0)) &&
|
|
722
|
+
('edge' in co ? co.edge === 'feather' && typeof co.feather_radius === 'number' && Number.isFinite(co.feather_radius) && co.feather_radius >= 0 && isCount(co.feathered_px) : !('feather_radius' in co) && !('feathered_px' in co)) &&
|
|
723
|
+
// Issue #360 (item 14): a placed cut carries its band, line and counts, the line inside the band; none of them rides alone.
|
|
724
|
+
('cut_band' in co
|
|
725
|
+
? isCount(co.cut_band) &&
|
|
726
|
+
co.cut_band >= 1 &&
|
|
727
|
+
Number.isInteger(co.cut_offset) &&
|
|
728
|
+
Math.abs(co.cut_offset as number) <= co.cut_band &&
|
|
729
|
+
pt(co.cut_at, 2) &&
|
|
730
|
+
isCount(co.cut_crossed) &&
|
|
731
|
+
isCount(co.joint_crossed) &&
|
|
732
|
+
isCount(co.band_px) &&
|
|
733
|
+
(co.cut_crossed as number) <= (co.joint_crossed as number) &&
|
|
734
|
+
(!('stroke_luma_max' in co) || (isCount(co.stroke_luma_max) && co.stroke_luma_max <= 255))
|
|
735
|
+
: CUT_KEYS.every((k) => !(k in co)));
|
|
736
|
+
if (!ok) {
|
|
737
|
+
fail(
|
|
738
|
+
'PARTS_FIELD_TYPE',
|
|
739
|
+
object,
|
|
740
|
+
`is ${show(c)}; {at: [x, y], width, radius, box: [x, y, w, h], layer_px, image_px?, image_layer? (with image_px), missing_px, short_px? ({left, right}, adding up to missing_px, above 0), excluded_px? (above 0), shape? ("disc" or "ball", with upper_px; "ball" with lower_px, lower_kept_px and lower_missing_px, at most missing_px; without it upper_px? above 0), edge? ("feather", with feather_radius and feathered_px), cut_band? (with cut_offset inside the band, cut_at, cut_crossed at most joint_crossed, band_px, stroke_luma_max? 0..255)} is required`,
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
706
744
|
/** Issue #557: a cap's `short_px` — `{left, right}`, two counts and no other key, adding up to `missing`, above 0. */
|
|
707
745
|
function shortSides(v: unknown, missing: unknown): boolean {
|
|
708
746
|
if (typeof v !== 'object' || v === null || Array.isArray(v)) return false;
|
package/src/propose.ts
CHANGED
|
@@ -146,7 +146,7 @@ import { type Mask, newMask, newRaster, type Raster } from './raster/types.ts';
|
|
|
146
146
|
import { npMean, npMedian, npPercentile, pyFixed, pyInt, pyIntList, pyRepr, pyRound, pyStrList } from './pyfmt.ts';
|
|
147
147
|
import type { JointState, RigJoint, RigJoints } from './keypoints.ts';
|
|
148
148
|
import { IDLE_FPS } from './motion.ts';
|
|
149
|
-
import { influenceFarthest } from './rig.ts';
|
|
149
|
+
import { FORK_SMOOTH_MAX_INFLUENCES, influenceFarthest } from './rig.ts';
|
|
150
150
|
import { type Segment as WeightSegment } from './weights.ts';
|
|
151
151
|
import { pyRound as roundTo } from './round.ts';
|
|
152
152
|
import { KEYPOINT_NAMES, type KeypointName } from './skeleton.ts';
|
|
@@ -3470,7 +3470,15 @@ export function proposeWithBasis(
|
|
|
3470
3470
|
radius = roundTo(farthest + INFLUENCE_RADIUS_CELLS * cell, 4);
|
|
3471
3471
|
radii.push({ kind: 'influence-radius', part: name, tag, radius, farthest: roundTo(farthest, 4), cells: INFLUENCE_RADIUS_CELLS, cell });
|
|
3472
3472
|
}
|
|
3473
|
-
|
|
3473
|
+
// Issue #615: under the recipe's `split.hold_tip` the mesh declares `hold_tip: true`, which the rig stage reads to
|
|
3474
|
+
// smooth the held fork as it smooths the lattice's, and `max` is raised to the lattice's smoothing cap
|
|
3475
|
+
// (FORK_SMOOTH_MAX_INFLUENCES, 8) as the lattice's `r` is raised to its grid — the rig stage caps the smoothing
|
|
3476
|
+
// at the declared max. On wind's bottomwear under a 60-degree hip sway (#615, rigc 2.60.0) the draft folds 41
|
|
3477
|
+
// frames at max 6, 23 smoothed at max 6, 3 at max 8 unsmoothed and 0 smoothed at max 8, against the lattice's 5.
|
|
3478
|
+
// A declared max above the cap is kept.
|
|
3479
|
+
const held = recipeOf(tag)?.split?.hold_tip === true;
|
|
3480
|
+
const max = held ? Math.max(decl.max, FORK_SMOOTH_MAX_INFLUENCES) : decl.max;
|
|
3481
|
+
meshes[name] = { influence: { cell, radius, across: decl.across, max, shape: decl.shape, ...(held ? { hold_tip: true as const } : {}) }, segments };
|
|
3474
3482
|
}
|
|
3475
3483
|
const constrained = clothConstraints.length === 0 ? {} : { constraints: clothConstraints };
|
|
3476
3484
|
return {
|
package/src/remesh.ts
CHANGED
|
@@ -50,6 +50,10 @@
|
|
|
50
50
|
* through `check` beside the input; every bar the input measured is measured on the revision, and no bar the
|
|
51
51
|
* input met is failed by it (`REMESH_CHECK_HELD`). `check`'s scope is the revision's scope, and the provenance
|
|
52
52
|
* quotes check's own physics line ({@link checkScope}) rather than presenting a green check as more than it read.
|
|
53
|
+
* Under `--input-check <input-check.json>` (issue #617) the input's check is not run again: the record an earlier
|
|
54
|
+
* `--record-input-check` wrote is reused when every row binding it to what that check reads is this run's
|
|
55
|
+
* ({@link inputCheckBoundProblems}), and refused by name otherwise (`REMESH_INPUT_CHECK_FILE`,
|
|
56
|
+
* `REMESH_INPUT_CHECK_BOUND`) before anything is built.
|
|
53
57
|
* 8. **The write**: `--out` receives the revision's files and {@link PROVENANCE_FILE} — spec {@link REMESH_SPEC}:
|
|
54
58
|
* the request, both versions, every input file's SHA-256, the target before and after, and both checks — with no
|
|
55
59
|
* path and no clock in it, so a second identical request writes the same bytes.
|
|
@@ -65,11 +69,14 @@ import { barsNotMet, type CheckReport, checkStatuses, type CheckStatus, checkSum
|
|
|
65
69
|
import { loadConfigAndAnimations } from './config.ts';
|
|
66
70
|
import { PartsError, type Problem, problemLine, refuseIfAny } from './errors.ts';
|
|
67
71
|
import { jsonValueSpan, scratchConfig } from './meshdraft.ts';
|
|
68
|
-
import { computeExactFrameTransforms } from './coords.ts';
|
|
72
|
+
import { type BoneTransform, computeExactFrameTransforms } from './coords.ts';
|
|
69
73
|
import { type PartsFile } from './parts.ts';
|
|
70
74
|
import { applyMeshEdit, type DeltaApplied, type DeltaPlant, deltaSourceProblems, type MeshEditDocument, readMeshEdit } from './remeshdelta.ts';
|
|
71
75
|
import { DEFAULT_IDLE_KEYS, type IdleKeys, type MeshAttachment, meshBoundBones, rigJsonText, type RigSpec } from './rig.ts';
|
|
76
|
+
import { readRequirements } from './requirements.ts';
|
|
72
77
|
import { pyRound } from './round.ts';
|
|
78
|
+
import { type RigSpec as RigcRigSpec } from 'rig-c/src/rig.ts';
|
|
79
|
+
import { expandStops } from 'rig-c/src/stop.ts';
|
|
73
80
|
|
|
74
81
|
/** The provenance file's spec. */
|
|
75
82
|
export const REMESH_SPEC = 'rig-parts-remesh/1';
|
|
@@ -107,6 +114,10 @@ export interface RemeshInput {
|
|
|
107
114
|
pageEdges?: PageEdges;
|
|
108
115
|
packShape?: PackShape;
|
|
109
116
|
requirements?: string;
|
|
117
|
+
/** Issue #617: a {@link INPUT_CHECK_FILE} an earlier run wrote over this input; its check is reused when it is bound to this run's input. */
|
|
118
|
+
inputCheck?: string;
|
|
119
|
+
/** Issue #617: write {@link INPUT_CHECK_FILE} into `out` beside the provenance. Without it, and without `inputCheck`, nothing written moves. */
|
|
120
|
+
recordInputCheck?: boolean;
|
|
110
121
|
}
|
|
111
122
|
|
|
112
123
|
/**
|
|
@@ -119,6 +130,10 @@ export interface RemeshPlant {
|
|
|
119
130
|
skipPreserve?: boolean;
|
|
120
131
|
/** Issue #526's mutants, handed to the delta's replay (`src/remeshdelta.ts`). */
|
|
121
132
|
delta?: DeltaPlant;
|
|
133
|
+
/** Issue #613's mutant: the setup frames read off `rig.json`'s bones as written, its `stops` not expanded. */
|
|
134
|
+
unexpandedStops?: boolean;
|
|
135
|
+
/** Issue #617's mutant: run just before check-input reads the input, after the first snapshot, to change a file under it. */
|
|
136
|
+
beforeInputCheck?: () => void;
|
|
122
137
|
}
|
|
123
138
|
|
|
124
139
|
/** The versions the provenance names: this package's and the rigc that gated the revision (its `--version` line). */
|
|
@@ -457,10 +472,234 @@ export function preservedProblems(input: FileTree, revision: FileTree, part: str
|
|
|
457
472
|
|
|
458
473
|
/** The codes the shared readings below refuse with, by the revising command that runs them (`remesh`, `retune`). */
|
|
459
474
|
export const REVISION_CODES = {
|
|
460
|
-
remesh: { inputPresent: 'REMESH_INPUT_PRESENT', inputWritten: 'REMESH_INPUT_WRITTEN', checkHeld: 'REMESH_CHECK_HELD' },
|
|
461
|
-
retune: { inputPresent: 'RETUNE_INPUT_PRESENT', inputWritten: 'RETUNE_INPUT_WRITTEN', checkHeld: 'RETUNE_CHECK_HELD' },
|
|
475
|
+
remesh: { inputPresent: 'REMESH_INPUT_PRESENT', inputWritten: 'REMESH_INPUT_WRITTEN', checkHeld: 'REMESH_CHECK_HELD', inputCheckFile: 'REMESH_INPUT_CHECK_FILE', inputCheckBound: 'REMESH_INPUT_CHECK_BOUND', inputCheckMoved: 'REMESH_INPUT_CHECK_MOVED', rigcGreen: 'REMESH_RIGC_GREEN' },
|
|
476
|
+
retune: { inputPresent: 'RETUNE_INPUT_PRESENT', inputWritten: 'RETUNE_INPUT_WRITTEN', checkHeld: 'RETUNE_CHECK_HELD', inputCheckFile: 'RETUNE_INPUT_CHECK_FILE', inputCheckBound: 'RETUNE_INPUT_CHECK_BOUND', inputCheckMoved: 'RETUNE_INPUT_CHECK_MOVED', rigcGreen: 'RETUNE_RIGC_GREEN' },
|
|
462
477
|
} as const;
|
|
463
478
|
|
|
479
|
+
// ---------------------------------------------------------------------------
|
|
480
|
+
// the recorded input check (issue #617)
|
|
481
|
+
// ---------------------------------------------------------------------------
|
|
482
|
+
|
|
483
|
+
/** The recorded input check's spec. */
|
|
484
|
+
export const INPUT_CHECK_SPEC = 'rig-parts-input-check/1';
|
|
485
|
+
|
|
486
|
+
/** The recorded input check, written into `--out` under `--record-input-check`, read by `--input-check`. */
|
|
487
|
+
export const INPUT_CHECK_FILE = 'input-check.json';
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Everything the input's `check` reads, as one record: the versions it ran under (this package's, and `rigc
|
|
491
|
+
* --version`'s whole output — the entry line and the Spine runtime beside it decide which validator gates), the pack
|
|
492
|
+
* mode and the requirements file it was given, and every file under the rig directory and the parts directory
|
|
493
|
+
* (`parts.json` and every file under `parts/`) by SHA-256. The directories are named as resolved because `check`'s
|
|
494
|
+
* own text can name them (a rig without an idle is skipped with `motion.json`'s path, `readCheckInputs`), so a check
|
|
495
|
+
* of the same bytes elsewhere is not the same record.
|
|
496
|
+
*/
|
|
497
|
+
export interface InputCheckBinding {
|
|
498
|
+
versions: { parts: string; rigc: string };
|
|
499
|
+
options: { page_edges: PageEdges; pack_shape: PackShape; requirements: { path: string; sha256: string } | null };
|
|
500
|
+
rig: { dir: string; files: HashRow[] };
|
|
501
|
+
parts: { dir: string; files: HashRow[] };
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** {@link INPUT_CHECK_FILE} (spec {@link INPUT_CHECK_SPEC}): the binding, then the input's check side as the provenance carries it. */
|
|
505
|
+
export interface InputCheckRecord extends InputCheckBinding {
|
|
506
|
+
spec: typeof INPUT_CHECK_SPEC;
|
|
507
|
+
check: CheckSide;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/** `rigc --version`'s whole output, trimmed, or a refusal under `op`'s rigc code: the record binds the rigc that measured. */
|
|
511
|
+
export function rigcVersionText(rigc: RigcRunner, op: 'remesh' | 'retune'): string {
|
|
512
|
+
const v = rigc(['--version']);
|
|
513
|
+
const out = v.out.trim();
|
|
514
|
+
if (v.status !== 0 || out === '') throw new PartsError([{ code: REVISION_CODES[op].rigcGreen, object: 'rigc --version', detail: `exited ${v.status}${rigcRanClause(v)}; the recorded input check binds the rigc that measured it, so its version is required` }]);
|
|
515
|
+
return out;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/** The binding of this run's input: what the input's `check` would read now ({@link InputCheckBinding}). */
|
|
519
|
+
export function inputCheckBinding(rigAt: string, tree: FileTree, partsDir: string, requirements: string | undefined, pageEdges: PageEdges, packShape: PackShape, versions: { parts: string; rigc: string }): InputCheckBinding {
|
|
520
|
+
const partsAt = resolve(partsDir);
|
|
521
|
+
const partsTree: FileTree = new Map();
|
|
522
|
+
const json = join(partsAt, 'parts.json');
|
|
523
|
+
if (existsSync(json) && statSync(json).isFile()) partsTree.set('parts.json', new Uint8Array(readFileSync(json)));
|
|
524
|
+
const pngs = join(partsAt, 'parts');
|
|
525
|
+
if (existsSync(pngs) && statSync(pngs).isDirectory()) for (const [k, b] of readTree(pngs)) partsTree.set(`parts/${k}`, b);
|
|
526
|
+
let req: { path: string; sha256: string } | null = null;
|
|
527
|
+
if (requirements !== undefined) {
|
|
528
|
+
readRequirements(requirements);
|
|
529
|
+
const at = resolve(requirements);
|
|
530
|
+
req = { path: at, sha256: sha256(new Uint8Array(readFileSync(at))) };
|
|
531
|
+
}
|
|
532
|
+
return {
|
|
533
|
+
versions: { parts: versions.parts, rigc: versions.rigc },
|
|
534
|
+
options: { page_edges: pageEdges, pack_shape: packShape, requirements: req },
|
|
535
|
+
rig: { dir: resolve(rigAt), files: hashRows(tree) },
|
|
536
|
+
parts: { dir: partsAt, files: hashRows(new Map([...partsTree].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))) },
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** The number of SHA-256 rows a binding holds: every rig file, every parts file, and the requirements file when there is one. */
|
|
541
|
+
export function inputCheckHashes(b: InputCheckBinding): number {
|
|
542
|
+
return b.rig.files.length + b.parts.files.length + (b.options.requirements === null ? 0 : 1);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** {@link INPUT_CHECK_FILE}'s text: the binding and the side, in the spec's key order. */
|
|
546
|
+
export function inputCheckText(b: InputCheckBinding, side: CheckSide): string {
|
|
547
|
+
const record: InputCheckRecord = { spec: INPUT_CHECK_SPEC, versions: b.versions, options: b.options, rig: b.rig, parts: b.parts, check: canonicalSide(side) };
|
|
548
|
+
return rigJsonText(record);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** A check side with its keys in the provenance's order, so a side read back writes the bytes a measured one does. */
|
|
552
|
+
function canonicalSide(s: CheckSide): CheckSide {
|
|
553
|
+
return { pass: s.pass, measured: [...s.measured], not_met: [...s.not_met], skipped: s.skipped.map((x) => ({ bar: x.bar, reason: x.reason })), physics: s.physics, line: s.line, status: { ...s.status } };
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const isStrings = (v: unknown): v is string[] => Array.isArray(v) && v.every((x) => typeof x === 'string');
|
|
557
|
+
const isRows = (v: unknown): v is HashRow[] => Array.isArray(v) && v.every((r) => isRecord(r) && typeof r.path === 'string' && typeof r.bytes === 'number' && typeof r.sha256 === 'string');
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Read {@link INPUT_CHECK_FILE} and hold it to its spec's shape; every field that is not of it is named in one
|
|
561
|
+
* refusal under `op`'s file code. Nothing in it is trusted past its shape: its binding is {@link inputCheckBoundProblems}'s.
|
|
562
|
+
*/
|
|
563
|
+
export function readInputCheck(path: string, op: 'remesh' | 'retune'): InputCheckRecord {
|
|
564
|
+
const code = REVISION_CODES[op].inputCheckFile;
|
|
565
|
+
const fail = (object: string, detail: string): Problem => ({ code, object, detail });
|
|
566
|
+
if (!existsSync(path) || !statSync(path).isFile()) throw new PartsError([fail(path, `no such file; --input-check takes the ${INPUT_CHECK_FILE} an earlier ${op} --record-input-check wrote over the same input`)]);
|
|
567
|
+
let raw: unknown;
|
|
568
|
+
try {
|
|
569
|
+
raw = JSON.parse(readFileSync(path, 'utf8'));
|
|
570
|
+
} catch (err) {
|
|
571
|
+
throw new PartsError([fail(path, `does not parse as JSON: ${(err as Error).message}`)]);
|
|
572
|
+
}
|
|
573
|
+
if (!isRecord(raw)) throw new PartsError([fail(path, `holds ${JSON.stringify(raw)?.slice(0, 40)}; one ${INPUT_CHECK_SPEC} object is required`)]);
|
|
574
|
+
if (raw.spec !== INPUT_CHECK_SPEC) throw new PartsError([fail(`${path} field "spec"`, `is ${JSON.stringify(raw.spec) ?? 'absent'}; "${INPUT_CHECK_SPEC}" is required`)]);
|
|
575
|
+
const out: Problem[] = [];
|
|
576
|
+
const field = (name: string, ok: boolean, want: string): void => {
|
|
577
|
+
if (!ok) out.push(fail(`${path} field "${name}"`, `is not ${want}`));
|
|
578
|
+
};
|
|
579
|
+
const v = raw.versions;
|
|
580
|
+
field('versions', isRecord(v) && typeof v.parts === 'string' && typeof v.rigc === 'string', '{ parts, rigc } as strings');
|
|
581
|
+
const o = raw.options;
|
|
582
|
+
const req = isRecord(o) ? o.requirements : undefined;
|
|
583
|
+
field('options', isRecord(o) && typeof o.page_edges === 'string' && typeof o.pack_shape === 'string' && (req === null || (isRecord(req) && typeof req.path === 'string' && typeof req.sha256 === 'string')), '{ page_edges, pack_shape, requirements: null or { path, sha256 } }');
|
|
584
|
+
for (const k of ['rig', 'parts'] as const) {
|
|
585
|
+
const t = raw[k];
|
|
586
|
+
field(k, isRecord(t) && typeof t.dir === 'string' && isRows(t.files), '{ dir, files: [{ path, bytes, sha256 }] }');
|
|
587
|
+
}
|
|
588
|
+
const c = raw.check;
|
|
589
|
+
const ok =
|
|
590
|
+
isRecord(c) &&
|
|
591
|
+
typeof c.pass === 'boolean' &&
|
|
592
|
+
isStrings(c.measured) &&
|
|
593
|
+
isStrings(c.not_met) &&
|
|
594
|
+
Array.isArray(c.skipped) &&
|
|
595
|
+
c.skipped.every((x) => isRecord(x) && typeof x.bar === 'string' && typeof x.reason === 'string') &&
|
|
596
|
+
(c.physics === null || typeof c.physics === 'string') &&
|
|
597
|
+
typeof c.line === 'string' &&
|
|
598
|
+
isRecord(c.status) &&
|
|
599
|
+
Object.values(c.status).every((x) => typeof x === 'string');
|
|
600
|
+
field('check', ok, 'a check side { pass, measured, not_met, skipped, physics, line, status } as remesh.json carries one');
|
|
601
|
+
refuseIfAny(out);
|
|
602
|
+
return raw as unknown as InputCheckRecord;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* The binding (issue #617): every row of the record against this run's — each version, each option, each directory,
|
|
607
|
+
* and each file by path, size and SHA-256, a row on one side only included. Each difference is one problem naming
|
|
608
|
+
* the record's row, the value it holds and the value this run's input requires; none means the record's check was
|
|
609
|
+
* measured on exactly what this run's check would read.
|
|
610
|
+
*/
|
|
611
|
+
export function inputCheckBoundProblems(recorded: InputCheckBinding, now: InputCheckBinding, path: string, op: 'remesh' | 'retune'): Problem[] {
|
|
612
|
+
const code = REVISION_CODES[op].inputCheckBound;
|
|
613
|
+
const out: Problem[] = [];
|
|
614
|
+
const moved = (row: string, found: unknown, required: unknown, why: string): void => {
|
|
615
|
+
out.push({ code, object: `${path} ${row}`, detail: `is ${JSON.stringify(found)}; this run's input requires ${JSON.stringify(required)} — ${why}, so the recorded check is not this input's and nothing was written` });
|
|
616
|
+
};
|
|
617
|
+
if (recorded.versions.parts !== now.versions.parts) moved('versions.parts', recorded.versions.parts, now.versions.parts, 'the check was measured by another version of this package');
|
|
618
|
+
if (recorded.versions.rigc !== now.versions.rigc) moved('versions.rigc', recorded.versions.rigc, now.versions.rigc, 'the check was measured under another rigc');
|
|
619
|
+
if (recorded.options.page_edges !== now.options.page_edges) moved('options.page_edges', recorded.options.page_edges, now.options.page_edges, 'the check packed its pages another way');
|
|
620
|
+
if (recorded.options.pack_shape !== now.options.pack_shape) moved('options.pack_shape', recorded.options.pack_shape, now.options.pack_shape, 'the check packed its pages another way');
|
|
621
|
+
const ra = recorded.options.requirements;
|
|
622
|
+
const rb = now.options.requirements;
|
|
623
|
+
if (ra === null || rb === null) {
|
|
624
|
+
if (ra !== rb) moved('options.requirements', ra, rb, 'the check measured another set of declared requirements');
|
|
625
|
+
} else {
|
|
626
|
+
if (ra.path !== rb.path) moved('options.requirements.path', ra.path, rb.path, 'the check read its requirements from another file');
|
|
627
|
+
if (ra.sha256 !== rb.sha256) moved('options.requirements.sha256', ra.sha256, rb.sha256, 'the check read other requirements bytes');
|
|
628
|
+
}
|
|
629
|
+
for (const k of ['rig', 'parts'] as const) {
|
|
630
|
+
if (recorded[k].dir !== now[k].dir) moved(`${k}.dir`, recorded[k].dir, now[k].dir, `the check read another ${k} directory`);
|
|
631
|
+
const a = new Map(recorded[k].files.map((r) => [r.path, r]));
|
|
632
|
+
const b = new Map(now[k].files.map((r) => [r.path, r]));
|
|
633
|
+
for (const p of [...new Set([...a.keys(), ...b.keys()])].sort()) {
|
|
634
|
+
const x = a.get(p);
|
|
635
|
+
const y = b.get(p);
|
|
636
|
+
const row = `${k}.files "${p}"`;
|
|
637
|
+
if (x === undefined) moved(row, 'absent', y?.sha256, `the input holds ${p} (${y?.bytes} bytes), which the check did not read`);
|
|
638
|
+
else if (y === undefined) moved(row, x.sha256, 'absent', `the check read ${p}, which the input no longer holds`);
|
|
639
|
+
else if (x.sha256 !== y.sha256 || x.bytes !== y.bytes) moved(row, `${x.bytes} bytes sha256 ${x.sha256}`, `${y.bytes} bytes sha256 ${y.sha256}`, `the input's ${p} is not the bytes the check read`);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return out;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/** The line a reused input check prints in place of check-input's lines. */
|
|
646
|
+
export function inputCheckReusedLine(path: string, b: InputCheckBinding): string {
|
|
647
|
+
const req = b.options.requirements === null ? 0 : 1;
|
|
648
|
+
return ` check-input: not run — ${path} (${INPUT_CHECK_SPEC}) is bound to this input by ${inputCheckHashes(b)} sha256 row(s) (rig ${b.rig.files.length}, parts ${b.parts.files.length}, requirements ${req}), parts ${b.versions.parts}, rigc ${b.versions.rigc.split('\n')[0]}, page edges ${b.options.page_edges}, pack shape ${b.options.pack_shape}; the input's check side is the recorded one`;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Steps 1's reading of `--input-check` and `--record-input-check` for both revising commands: the binding of this
|
|
653
|
+
* run's input when either is asked for (one `rigc --version`), and the recorded side when the record is bound to it.
|
|
654
|
+
* Neither asked for, nothing is read and null is returned for both.
|
|
655
|
+
*/
|
|
656
|
+
export function inputCheckOf(
|
|
657
|
+
req: { inputCheck?: string; recordInputCheck?: boolean; requirements?: string; parts: string },
|
|
658
|
+
rigAt: string,
|
|
659
|
+
tree: FileTree,
|
|
660
|
+
pageEdges: PageEdges,
|
|
661
|
+
packShape: PackShape,
|
|
662
|
+
partsVersion: string,
|
|
663
|
+
rigc: RigcRunner,
|
|
664
|
+
op: 'remesh' | 'retune',
|
|
665
|
+
): { binding: InputCheckBinding | null; reused: CheckSide | null } {
|
|
666
|
+
if (req.inputCheck === undefined && req.recordInputCheck !== true) return { binding: null, reused: null };
|
|
667
|
+
const recorded = req.inputCheck === undefined ? null : readInputCheck(req.inputCheck, op);
|
|
668
|
+
const binding = inputCheckBinding(rigAt, tree, req.parts, req.requirements, pageEdges, packShape, { parts: partsVersion, rigc: rigcVersionText(rigc, op) });
|
|
669
|
+
if (recorded === null) return { binding, reused: null };
|
|
670
|
+
refuseIfAny(inputCheckBoundProblems(recorded, binding, req.inputCheck as string, op));
|
|
671
|
+
return { binding, reused: canonicalSide(recorded.check) };
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* The second snapshot (issue #617): the input as the record's first snapshot read it, hashed again by
|
|
676
|
+
* {@link inputCheckBinding} right after check-input has read it. The two snapshots bracket the check, so a record is
|
|
677
|
+
* written only when the bytes the check measured are the bytes its rows name; a file that moved in between is named
|
|
678
|
+
* with both digests under `op`'s moved code.
|
|
679
|
+
*/
|
|
680
|
+
export function inputCheckMovedProblems(first: InputCheckBinding, req: { requirements?: string; parts: string }, rigAt: string, op: 'remesh' | 'retune'): Problem[] {
|
|
681
|
+
const code = REVISION_CODES[op].inputCheckMoved;
|
|
682
|
+
const second = inputCheckBinding(rigAt, readTree(rigAt), req.parts, req.requirements, first.options.page_edges, first.options.pack_shape, first.versions);
|
|
683
|
+
const out: Problem[] = [];
|
|
684
|
+
const row = (r: HashRow | undefined): string => (r === undefined ? 'absent' : `${r.bytes} bytes sha256 ${r.sha256}`);
|
|
685
|
+
const moved = (object: string, before: string, after: string): void => {
|
|
686
|
+
out.push({ code, object, detail: `was ${before} when the input was first hashed and is ${after} after check-input read it; the check may have measured bytes the record's rows do not name, so neither the record nor the revision is written` });
|
|
687
|
+
};
|
|
688
|
+
const ra = first.options.requirements;
|
|
689
|
+
const rb = second.options.requirements;
|
|
690
|
+
if (ra !== null && rb !== null && ra.sha256 !== rb.sha256) moved(ra.path, `sha256 ${ra.sha256}`, `sha256 ${rb.sha256}`);
|
|
691
|
+
for (const k of ['rig', 'parts'] as const) {
|
|
692
|
+
const a = new Map(first[k].files.map((r) => [r.path, r]));
|
|
693
|
+
const b = new Map(second[k].files.map((r) => [r.path, r]));
|
|
694
|
+
for (const p of [...new Set([...a.keys(), ...b.keys()])].sort()) {
|
|
695
|
+
const x = a.get(p);
|
|
696
|
+
const y = b.get(p);
|
|
697
|
+
if (x === undefined || y === undefined || x.sha256 !== y.sha256 || x.bytes !== y.bytes) moved(join(first[k].dir, p), row(x), row(y));
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return out;
|
|
701
|
+
}
|
|
702
|
+
|
|
464
703
|
/** One side of the check block, read off a check report. */
|
|
465
704
|
export function checkSide(r: CheckReport): CheckSide {
|
|
466
705
|
return {
|
|
@@ -531,6 +770,53 @@ export function modelAttachmentHash(modelText: string, part: string): string | n
|
|
|
531
770
|
return entry === undefined ? null : createHash('sha256').update(JSON.stringify(entry)).digest('hex');
|
|
532
771
|
}
|
|
533
772
|
|
|
773
|
+
/**
|
|
774
|
+
* The setup frames a delta's crop px are read through (issue #613): the input's bones as rigc's rig reader reads them.
|
|
775
|
+
* That reader expands `stops` before it resolves a single parent (rig-c's `expandStops`, `src/stop.ts`), and the
|
|
776
|
+
* expansion generates a drawn link `<link>_d` per stopped link that `rig` hangs the next link, and every slot and
|
|
777
|
+
* weight on the link, from — so a rig with stops names parents its own `bones` array does not declare, and evaluating
|
|
778
|
+
* that array as written throws in rig-c's `evaluate`. Here the expansion is rig-c's own call, as `check` makes it for
|
|
779
|
+
* the loop (`withoutPhysics`); a rig without `stops` is the array as written, the same object, so its frames and
|
|
780
|
+
* every byte read through them are what they were. Nothing is reordered: rigc refuses a parent declared after its
|
|
781
|
+
* child (`CE_RIG_BONE_PARENT_ORDER`), so a parent this walk finds after its child, or nowhere, is refused by name
|
|
782
|
+
* (`REMESH_BONE_ORDER`) rather than sorted into an order rigc would not load; and any other throw from the
|
|
783
|
+
* expansion or the evaluation is named with rig-c's own sentence (`REMESH_BONES_POSED`). On the delta path both sit
|
|
784
|
+
* behind rigc's gate over the input, which refuses either first, so reaching one means rigc and its library read the
|
|
785
|
+
* same bones apart. `unexpanded` is the mutant: the bones as written.
|
|
786
|
+
*/
|
|
787
|
+
export function deltaFrames(rig: Json, where: string, unexpanded = false): Map<string, BoneTransform> | Problem[] {
|
|
788
|
+
let bones: RigSpec['bones'];
|
|
789
|
+
try {
|
|
790
|
+
bones = (unexpanded || !Array.isArray(rig.stops) ? (rig as unknown as RigSpec) : (expandStops(rig as unknown as RigcRigSpec, where) as unknown as RigSpec)).bones;
|
|
791
|
+
} catch (err) {
|
|
792
|
+
if (!(err instanceof Error)) throw err;
|
|
793
|
+
return [{ code: 'REMESH_BONES_POSED', object: `${where} stops`, detail: `rig-c's expansion refuses them: ${err.message}; the delta's crop px are read through the setup frames of the bones the expansion lays out, so nothing was written` }];
|
|
794
|
+
}
|
|
795
|
+
const at = new Map<string, number>();
|
|
796
|
+
for (const [i, b] of bones.entries()) if (!at.has(b.name)) at.set(b.name, i);
|
|
797
|
+
const out: Problem[] = [];
|
|
798
|
+
const seen = new Set<string>();
|
|
799
|
+
for (const [i, b] of bones.entries()) {
|
|
800
|
+
const parent = b.parent;
|
|
801
|
+
if (parent !== undefined && parent !== '' && !seen.has(parent)) {
|
|
802
|
+
const later = at.get(parent);
|
|
803
|
+
out.push({
|
|
804
|
+
code: 'REMESH_BONE_ORDER',
|
|
805
|
+
object: `${where} bones[${i}] "${b.name}"`,
|
|
806
|
+
detail: `names parent "${parent}", which ${later === undefined ? `no bone declares${Array.isArray(rig.stops) && !unexpanded ? ' after rig-c expands the rig\'s stops' : ''}` : `is declared after it, at bones[${later}]`}; a parent declared before its child is required, as rigc's rig reader resolves it (CE_RIG_BONE_PARENT_ORDER), and nothing was written`,
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
seen.add(b.name);
|
|
810
|
+
}
|
|
811
|
+
if (out.length > 0) return out;
|
|
812
|
+
try {
|
|
813
|
+
return computeExactFrameTransforms(bones);
|
|
814
|
+
} catch (err) {
|
|
815
|
+
if (!(err instanceof Error)) throw err;
|
|
816
|
+
return [{ code: 'REMESH_BONES_POSED', object: `${where} bones`, detail: `rig-c cannot pose them at the setup pose: ${err.message}; the delta's crop px are read through those frames, so nothing was written` }];
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
534
820
|
/**
|
|
535
821
|
* Step 1's tree rules: the files `rig` writes are present, and the ones the splice rewrites (`spliced`) are this
|
|
536
822
|
* writer's bytes. `op` names the revising command, whose codes these are (`retune` splices `rig.json` and `motion.json`).
|
|
@@ -605,6 +891,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
605
891
|
const tree = readTree(rigAt);
|
|
606
892
|
refuseIfAny(inputTreeProblems(tree, input.rig));
|
|
607
893
|
if ((input.mesh === undefined) === (input.delta === undefined)) throw new Error('remeshStage: exactly one of mesh, delta is required');
|
|
894
|
+
const recorded = inputCheckOf(input, rigAt, tree, pageEdges, packShape, versions.parts, rigc, 'remesh');
|
|
608
895
|
const meshReq = input.mesh === undefined ? null : readMeshRequest(input.mesh);
|
|
609
896
|
const deltaReq = input.delta === undefined ? null : readDeltaRequest(input.delta);
|
|
610
897
|
const configText = readFileSync(input.config, 'utf8');
|
|
@@ -678,7 +965,8 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
678
965
|
const partsFile = JSON.parse(readFileSync(join(input.parts, 'parts.json'), 'utf8')) as PartsFile;
|
|
679
966
|
const rec = partsFile.parts.find((p) => p.name === part);
|
|
680
967
|
if (rec === undefined) throw new PartsError([{ code: 'REMESH_DELTA_SOURCE', object: `${input.parts}/parts.json`, detail: `names no part "${part}"; its box is where rig placed the image, which the delta's crop px are read against` }]);
|
|
681
|
-
const world =
|
|
968
|
+
const world = deltaFrames(inRig, `${input.rig}/rig.json`, plant.unexpandedStops === true);
|
|
969
|
+
if (Array.isArray(world)) throw new PartsError(world);
|
|
682
970
|
const r = applyMeshEdit({ part, attachment: inAtt, box: [rec.x, rec.y], rigSize: [partsFile.rig_size[0], partsFile.rig_size[1]], world }, doc, deltaPath, plant.delta);
|
|
683
971
|
if (Array.isArray(r)) throw new PartsError(r);
|
|
684
972
|
const row = rowOf(inReport, part);
|
|
@@ -713,9 +1001,16 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
713
1001
|
}
|
|
714
1002
|
const checkOf = (rig: string, name: string): CheckReport =>
|
|
715
1003
|
checkStage({ rig, parts: input.parts, out: join(scratch, name), pageEdges, packShape, ...(input.requirements === undefined ? {} : { requirements: input.requirements }) }, rigc, checkBin, (l) => log(`[${name}] ${l}`));
|
|
716
|
-
|
|
1004
|
+
if (recorded.reused !== null) log(inputCheckReusedLine(input.inputCheck as string, recorded.binding as InputCheckBinding));
|
|
1005
|
+
let inSide: CheckSide;
|
|
1006
|
+
if (recorded.reused !== null) inSide = recorded.reused;
|
|
1007
|
+
else {
|
|
1008
|
+
plant.beforeInputCheck?.();
|
|
1009
|
+
inSide = checkSide(checkOf(rigAt, 'check-input'));
|
|
1010
|
+
if (recorded.binding !== null) refuseIfAny(inputCheckMovedProblems(recorded.binding, input, rigAt, 'remesh'));
|
|
1011
|
+
}
|
|
717
1012
|
const revCheck = checkOf(staged, 'check-revision');
|
|
718
|
-
const sides = { input:
|
|
1013
|
+
const sides = { input: inSide, revision: checkSide(revCheck) };
|
|
719
1014
|
refuseIfAny(checkHeldProblems(sides.input, sides.revision, revCheck.problems));
|
|
720
1015
|
const scope = checkScope(sides.revision.physics);
|
|
721
1016
|
log(` check: input ${sides.input.pass ? 'PASS' : `FAIL (${sides.input.not_met.join(', ')})`}, revision ${sides.revision.pass ? 'PASS' : `FAIL (${sides.revision.not_met.join(', ')})`}, the same ${sides.revision.measured.length} bar(s) measured; ${scope}`);
|
|
@@ -743,6 +1038,11 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
743
1038
|
}
|
|
744
1039
|
writeFileSync(join(outAt, PROVENANCE_FILE), rigJsonText(provenance));
|
|
745
1040
|
written.push(PROVENANCE_FILE);
|
|
1041
|
+
if (input.recordInputCheck === true) {
|
|
1042
|
+
writeFileSync(join(outAt, INPUT_CHECK_FILE), inputCheckText(recorded.binding as InputCheckBinding, sides.input));
|
|
1043
|
+
written.push(INPUT_CHECK_FILE);
|
|
1044
|
+
log(` recorded: the input's check in ${INPUT_CHECK_FILE}, bound by ${inputCheckHashes(recorded.binding as InputCheckBinding)} sha256 row(s); pass it as --input-check to a later remesh or retune of ${input.rig}`);
|
|
1045
|
+
}
|
|
746
1046
|
log(' file sha256 (input) sha256 (revision)');
|
|
747
1047
|
const inHash = new Map(hashRows(tree).map((r) => [r.path, r.sha256]));
|
|
748
1048
|
for (const r of provenance.revision) log(` ${r.path.padEnd(40)} ${(inHash.get(r.path) ?? 'absent').slice(0, 16)} ${r.sha256.slice(0, 16)}${inHash.get(r.path) === r.sha256 ? '' : ' (spliced)'}`);
|