@rig-c/parts 1.60.0 → 1.60.2
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/NOTICE.md +1 -1
- package/README.md +6 -3
- package/cli.ts +16 -23
- package/docs/AUTHORING.md +126 -11
- package/docs/PAINTING.md +2 -2
- package/docs/STABILITY.md +21 -4
- package/package.json +3 -1
- package/src/build.ts +31 -5
- package/src/check.ts +194 -43
- package/src/comfy/painting.ts +2 -1
- package/src/config.ts +74 -14
- package/src/configwrite.ts +56 -18
- package/src/diagnostics.ts +3 -2
- package/src/limblayout.ts +6 -4
- package/src/limbs.ts +18 -3
- package/src/limbslots.ts +17 -6
- package/src/propose.ts +4 -3
- package/src/remesh.ts +31 -7
- package/src/retune.ts +10 -8
- package/src/rig.ts +11 -5
- package/src/structure.ts +2 -1
- package/tools/alternate-cli.ts +25 -0
- package/tools/build-process.ts +206 -0
package/docs/STABILITY.md
CHANGED
|
@@ -127,7 +127,7 @@ part name, `[i]` an entry of a list):
|
|
|
127
127
|
- **seethrough** — required: `resolution`, `steps`, `seed`, `offload`; optional: `head_box`, `arm_split`
|
|
128
128
|
- **seethrough.arm_split** — required: `order`, and one of `x` or `line` (issue #439)
|
|
129
129
|
- **assemble** — required: `rig_scale`, `plan` (from plain `assemble` on); optional: `extend_below_crop`, `patches`, `cuts`, `alternates`, `head_face_underfill`
|
|
130
|
-
- **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `drawn`, `tips`, `front` (issues #454, #465, #652, #664)
|
|
130
|
+
- **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `anchor`, `drawn`, `tips`, `front` (issues #454, #465, #543, #652, #664)
|
|
131
131
|
- **assemble.extend_below_crop[i]** — required: `part`, `run`, `tag`
|
|
132
132
|
- **assemble.patches[i]** — required: `name`, `box`, `alpha`, `draw`
|
|
133
133
|
- **assemble.patches[i].draw**, when an object — required: `before`
|
|
@@ -142,7 +142,7 @@ part name, `[i]` an entry of a list):
|
|
|
142
142
|
- **bones[i]**, a chain — required: `chain`, `parent`, `points`, `tip`; optional: `link_inherit`
|
|
143
143
|
- **stops[i]** — required: `chain`, `against`, `at`, `inward`, `outward`; optional: `links`, `lower` (issue #404)
|
|
144
144
|
- **stops[i].lower** — required: `inward`, `outward`
|
|
145
|
-
- **meshes.<part>** — exactly one of `grid`, `contour`, `auto`, `influence`; required in every mode: `segments`, and `r` in every mode but `influence`, which refuses it; optional in every mode: `exponent`, `rule
|
|
145
|
+
- **meshes.<part>** — exactly one of `grid`, `contour`, `auto`, `influence`; required in every mode: `segments`, and `r` in every mode but `influence`, which refuses it; optional in every mode: `exponent`, `rule`, `gather` (issue #680, false only: preserve an exclusive non-segment rider's authored draw position without changing its binding; absent, output bytes unchanged); optional with `contour` or `auto`: `ribs`; optional with `grid` or `contour`: `influences` (issue #284; beside `auto` it is refused, CONFIG_INFLUENCES_MODE); optional with `grid`: `stray` (issue #303; beside `contour` or `auto` it is refused, CONFIG_STRAY_MODE)
|
|
146
146
|
- **meshes.<part>.influence** — required: `cell`, `radius`, `across`, `max`, `shape` (issue #378); optional: `hold_tip` (issue #615, the value true only); beside it `r`, `exponent`, `rule`, `influences`, `stray` and `ribs` are refused by name
|
|
147
147
|
- **meshes.<part>.influences** — optional, at least one: `maxInfluences` (a whole number, 1 or more, or null for no cap), `floor` ("cut" or "continuous")
|
|
148
148
|
- **meshes.<part>.ribs.<chain>** — required: `stations`
|
|
@@ -166,7 +166,7 @@ part name, `[i]` an entry of a list):
|
|
|
166
166
|
- **cloth.<tag>.split** — required: `at`, `into`; optional: `hold_tip`
|
|
167
167
|
- **cloth.<tag>.strength** — required: `trunk`, `branch`, `edge`
|
|
168
168
|
- **cloth.<tag>.swing** — required: `scales`
|
|
169
|
-
- **regions.<part>** — a bone name
|
|
169
|
+
- **regions.<part>** — a bone name, or `{bone, gather?}` with the same required bone name and optional `gather: false` (issue #680); absent, normal gathering and historical bytes are unchanged. An opt-out requires an exclusive non-segment limb rider ([named refusal](AUTHORING.md#RIG_GATHER_RIDER))
|
|
170
170
|
- **motion** — required: `duration`, `tracks`; optional: `blink`, `animations_from`
|
|
171
171
|
- **motion.tracks[i]**, a single track — required: `bone`, `prop`, `amp`, `period`, `phase`; optional: `base`
|
|
172
172
|
- **motion.tracks[i]**, a chain track — required: `chain`, `amps`, `period`, `phase`, `lag`
|
|
@@ -200,7 +200,7 @@ every number) are AUTHORING §3's tables, and the loader refuses any other by na
|
|
|
200
200
|
| `parts.json`, `parts/<name>.png` | `assemble`, `build` | one record per part: `from` (`<run>:<tag>` with a See-through v3 tag, `<run>:author:<label>` for a layer the author made — issue #256, read by no role rule — or `painting:<name>` for a patch), `cut_from` on a cut's piece only (the plan part it was cut from, issue #230), `limb` on a limb segment's part only (issue #349: `name`, `segment`, `of`, `bone`, and below a joint `joint`, `range` when the config segment declares one (issue #360), and `cap` — `at`, `width`, `radius`, `box`, `layer_px`, `image_px` with a cap image, `image_layer` after it when that image was a hidden-art layer — issue #359, `<run>:<layer>:hidden` — `missing_px`, `short_px` (`left`, `right`) after it only when `missing_px` is above 0 (issue #557, additive), `excluded_px` after them only on a subset set's limb part whose cap the set exclusion took a pixel of (issue #603, additive: each pixel taken out of the count it was in, so the cap's counts are the written PNG's), then `shape` and `upper_px` under the segment's `cap_shape` — `upper_px` without the shape only when the upper segment gave a pixel (issue #557, additive) — and after them `lower_px`, `lower_kept_px` and `lower_missing_px` under `cap_shape: "ball"` (issue #579, additive), and `edge`, `feather_radius` and `feathered_px` under its `edge`, and `cut_band`, `cut_offset`, `cut_at`, `cut_crossed`, `joint_crossed`, `band_px` and `stroke_luma_max` (when the band has a split) under its `cut_band`, issue #360), the box `x`, `y`, `w`, `h` (rig px), the pixel counts `src/parts.ts` documents (`opaque_px`, `visible_px`, `occluded_px`, `projected_core_px`, `source_px_taken`, `visible_not_projected_px`, `refused_drift_px`, `merged_px` — on a subset set's limb part counted after the set exclusion, issue #603 — `seam_override_px`, and `fringe_pushed_back` when not empty); `rig_size`, `scale_rig_per_source`, `ghost_px`, `recomposite`, and `scene` (`figure_alpha_above`, `figure_px`, `figure_mask`) under `config.scene` only, with the figure's mask `figure_rig.png` beside the recomposite (issue #242); `single_run_pad` (`file_size`, `side`, `left`, `top`) last, only for one run whose file is not the `seethrough.resolution` square (issue #366) |
|
|
201
201
|
| `rig/rig.json`, `rig/motion.json`, `rig/images/` | `rig`, `build`, `compose` | rig-c's rig spec and motion spec, `spec` `rigc-rig/1` and `rigc-motion/1`: the format is rig-c's, and this package writes only what rig-c's parser accepts; a bone carries `inherit` only where config.bones declares one, rig-c's mode name as written (issue #348) |
|
|
202
202
|
| `rig/mesh_report.json` | `rig`, `build` | one row per mesh: `part`, `vertices`, `triangles`, `hull`, `bones` (the sorted names the attachment's weights bind in the written `rig.json`, in every mode — since 1.49.1 (issue #536) a rig with `turn` or `stops` names the twins and `<link>_d` bones there, where the row named the segment bones they replace: a fix of a wrong name, not a format change; a rig with neither writes the bytes it wrote), `max_influences`, `mean_influences`, `art_coverage`, then `grid` (a lattice); `mode` "contour" with `params`, `contour`, `regions` (`params.maxEdge` and `contour.outlineCut` only when the mesh declares `contour.maxEdge`; `params.bridges` and `contour.bridges` — `islands`, `units`, `joins`, and `faint` only when an island was left out as faint — only when it declares `contour.bridges`); or `mode` "influence" with `influence` (as declared), `reach` (`farthest`, `at`, `nearest`, `capped`, `widest`) and `lattice` (rig-c's `SegmentsLatticeReport`: `cols`, `rows`, `artCells`, `keptCells`, `passes`, `islands`) (issue #378); or `mode` "auto" with `settings`, `source`, `result`, `residuals`, `worst_residual`, `worst_region`, `motion_amplitude`, `termination`, `weights`, `regions`, `deformation`, `quality_report` (rig-c's `mesh-quality-report/1` document whole), `motion_report`, and, only when they apply, `stray_cleared` (after `source`, when `source.stray` is declared), `skinning_residual` and `replay` (`AutoMeshReport` in `src/rig.ts`); in every mode, `exponent` when the mesh declares one (after `grid`, or after `mode`); `influences`, as declared, when a lattice or contour mesh declares it (after `exponent`, or where `exponent` would be); `stray` and `stray_cleared` when a lattice mesh declares `stray` (after `influences`, or where `influences` would be); `ribs` when a contour or auto mesh declares them (after `exponent`, or after `mode`), and then `contour.ribs` (`source.contour.ribs` in the automatic mode) |
|
|
203
|
-
| `check/check.json` and the rest of `check/` | `check`, `build`, `compose` | the reference's fields in its order (`gate_spine_html_green`, `rigc_entry`, `pack_mode`, `environment` after it under `--environment` only (issue #538, additive: `path` as given, `sha256`, `steps`), `loop_max_diff`, the seam figures — `seam_mean`, `seam_px_over_40`, `seam_px_over_80` and, from issue #216, `seam_frame_scale`, the frame scale the bar divides the count by), `loop_physics` after `loop_max_diff` when the rig declares a physics constraint, `seam_border` after the seam figures when `parts.json` declares a scene (issue #242), `seam_pairs` after the seam figures when the seam bar fails or `--seam-pairs` asks (each row's picture under `check/seam/`; `--keep-stills` leaves the setup-pose still and its `frames.json` under `check/setup_still/`), then the judgement lines (`BREATH_VISIBLE`, `BLINK_NO_HOLE`, `CHAIN_LAG`, `TIP_OVER_ROOT`, `STILL_REGIONS_DARK`, `TEXTURE_STRETCH`), `ANIMATIONS_DO_NOT_FOLD` after them when `motion.json` holds an animation, the idle included — on every rig with an idle since issue #333 (issues #320, #363: `status`, `animations`, `fps`, `physics_left_out`, `folding` — each `animation`, `slot`, `attachment`, `frames`, `worst_frame`, `worst_triangles`, `triangles`, `physics_on`, `physics_off`, `physics_constraints`, `declared`, `line` — `folding_undeclared`, `declared_not_folding`, `bar`), `FEET_STAY_LEVEL` after it when a `footwear` part rides a bone that hangs from another and `motion.json` holds an animation (issue #348: `status`, `reason` on a SKIP only, `animations`, `fps`, `physics_left_out`, `bar_degrees`, `bar`, `feet` — each `part`, `bone`, `hangs_from`, `status`, `frames_posed`, `worst`), `LIMB_ONE_BONE` after it (and after `STRESS_OFF_CHAIN` where that is written) when `parts.json` holds a limb segment's part (issue #349: `status`, `parts` — each `part`, `limb`, `bone`, `status`, `others`), `SEAM_OVER_RANGE` after it when a limb record carries a `range` (issue #360: `status`, `frame_scale`, `physics_left_out`, `bar` — `mean`, `rig_px_over_40`, `level` — and `joints`, each `part`, `limb`, `segment`, `joint`, `bone`, `range`, `at`, `radius`, `under_px`, `status`, `poses` — each `degrees`, `status`, `mean`, `px_over_40`, `px_over_80`, `rig_px_over_40`, and `step_px` (`left`, `right`) only on a joint whose cap record carries `short_px` (issue #557, additive) — and `unread` on a joint not read), `SEAM_OVER_MOTION` after it when `parts.json` holds a limb segment or `--requirements` a `seam` (issue #493, a warning and not a bar: `status` — `WARN`, `CLEAR` or `SKIP` — `reason` on a SKIP only, `fps`, `floor`, `pairs` — each `pair`, `a`, `b`, `declared`, and `unread` on a pair not read — `animations`, `warnings`, `rows` — each `pair`, `animation`, `status`, `drawn`, `banded`, `opens`, `px`, `max_px`, `under_floor`), `CLOTH_SETTLES` after it when the rig declares a physics constraint and has an idle (issue #501, a warning and not a bar: `status` — `WARN` or `CLEAR` — `fps`, `frames`, `duration`, `floor_rig_px_per_s`, `floor`, `levers`, `warnings`, `rows` — each `tip`, `root`, `links`, `point`, `settles_at`, `max_rig_px_per_s`, `min_rig_px_per_s`), `RECOMPOSITE_HOLES` (its first figure `declared_scene` when `parts.json` declares a scene), `SETUP_POSE_VS_SOURCE`, `skipped`, `config` under `build` only (issue #607, additive: `path` as `--config` was typed, `sha256` of the bytes the build read; `check` and `compose` read no config and write none), a `requirements` block under `--requirements` (or `build`'s `config.requirements`) — `file` first from issue #556, additive: `path` as typed or declared, `sha256`, `keys` — and `PASS`; `check/build/skeleton.json`, `.atlas` and `.png` are the packed artifact rig-c writes |
|
|
203
|
+
| `check/check.json` and the rest of `check/` | `check`, `build`, `compose` | the reference's fields in its order (`gate_spine_html_green`, `rigc_entry`, `pack_mode`, `environment` after it under `--environment` only (issue #538, additive: `path` as given, `sha256`, `steps`), `loop_max_diff`, the seam figures — `seam_mean`, `seam_px_over_40`, `seam_px_over_80` and, from issue #216, `seam_frame_scale`, the frame scale the bar divides the count by), `loop_physics` after `loop_max_diff` when the rig declares a physics constraint, `seam_border` after the seam figures when `parts.json` declares a scene (issue #242), `seam_pairs` after the seam figures when the seam bar fails or `--seam-pairs` asks (each row's picture under `check/seam/`; `--keep-stills` leaves the setup-pose still and its `frames.json` under `check/setup_still/`), then the judgement lines (`BREATH_VISIBLE`, `BLINK_NO_HOLE`, `CHAIN_LAG`, `TIP_OVER_ROOT`, `STILL_REGIONS_DARK`, `TEXTURE_STRETCH`), `ANIMATIONS_DO_NOT_FOLD` after them when `motion.json` holds an animation, the idle included — on every rig with an idle since issue #333 (issues #320, #363: `status`, `animations`, `fps`, `physics_left_out`, `folding` — each `animation`, `slot`, `attachment`, `frames`, `worst_frame`, `worst_triangles`, `triangles`, `physics_on`, `physics_off`, `physics_constraints`, `declared`, `line` — `folding_undeclared`, `declared_not_folding`, `bar`), `FEET_STAY_LEVEL` after it when a `footwear` part rides a bone that hangs from another and `motion.json` holds an animation (issue #348: `status`, `reason` on a SKIP only, `animations`, `fps`, `physics_left_out`, `bar_degrees`, `bar`, `feet` — each `part`, `bone`, `hangs_from`, `status`, `frames_posed`, `worst`), `LIMB_ONE_BONE` after it (and after `STRESS_OFF_CHAIN` where that is written) when `parts.json` holds a limb segment's part (issue #349: `status`, `parts` — each `part`, `limb`, `bone`, `status`, `others`), `SEAM_OVER_RANGE` after it when a limb record carries a `range` (issue #360: `status`, `frame_scale`, `physics_left_out`, `bar` — `mean`, `rig_px_over_40`, `level` — and `joints`, each `part`, `limb`, `segment`, `joint`, `bone`, `range`, `at`, `radius`, `under_px`, `status`, `poses` — each `degrees`, `status`, `mean`, `px_over_40`, `px_over_80`, `rig_px_over_40`, and `step_px` (`left`, `right`) only on a joint whose cap record carries `short_px` (issue #557, additive) — and `unread` on a joint not read), `SEAM_OVER_MOTION` after it when `parts.json` holds a limb segment or `--requirements` a `seam` (issue #493, a warning and not a bar: `status` — `WARN`, `CLEAR` or `SKIP` — `reason` on a SKIP only, `fps`, `floor`, `pairs` — each `pair`, `a`, `b`, `declared`, and `unread` on a pair not read — `animations`, `warnings`, `rows` — each `pair`, `animation`, `status`, `drawn`, `banded`, `opens`, `px`, `max_px`, `under_floor`; issue #591 adds optional `worlds` on physics rigs with readable declared pairs and animations: `default` and `still`, each `wind`, `gravity`, `status` (`REPORTED` or `SKIP`), `reason` on SKIP, `dir` only when rendered (relative to check.json: `seam_motion/default` or `seam_motion/still`, the complete retained render with frames.json and each animation's raw seam.json), and `rows` — pair, animation, status, drawn, banded, `gap` and `ghost`, each `max_px` and `worst` only; worst carries `index`, `px`, `cell`, `box`. Per-frame hits stay in the raw sidecars. These raw reference readings add no bar or warning and leave the custom environment reading unchanged), `CLOTH_SETTLES` after it when the rig declares a physics constraint and has an idle (issue #501, a warning and not a bar: `status` — `WARN` or `CLEAR` — `fps`, `frames`, `duration`, `floor_rig_px_per_s`, `floor`, `levers`, `warnings`, `rows` — each `tip`, `root`, `links`, `point`, `settles_at`, `max_rig_px_per_s`, `min_rig_px_per_s`), `RECOMPOSITE_HOLES` (its first figure `declared_scene` when `parts.json` declares a scene), `SETUP_POSE_VS_SOURCE`, `skipped`, `config` under `build` only (issue #607, additive: `path` as `--config` was typed, `sha256` of the bytes the build read; `check` and `compose` read no config and write none), a `requirements` block under `--requirements` (or `build`'s `config.requirements`) — `file` first from issue #556, additive: `path` as typed or declared, `sha256`, `keys` — and `PASS`; `check/build/skeleton.json`, `.atlas` and `.png` are the packed artifact rig-c writes |
|
|
204
204
|
| `layers.json`, `<index>_<name>.png` | `layers --export` | the wrapper form `layers` reads (issue #359): `width`, `height`, then `layers` — each `name`, `filename`, `left`, `top`, `right`, `bottom`, `depth_median` (the input's own; `null` for a PSD, the manifest's order then being the draw order) — drawn layers in draw order, then the hidden-art layers; a PNG's name is its index and its layer's name, and the manifest, not the file name, says which layer it is |
|
|
205
205
|
| the template `.psd` | `layers --template` | one empty layer per name `templateLayerNames` (`src/layers.ts`) holds, bottom first; the same canvas writes the same bytes |
|
|
206
206
|
| `proposal.json`, `render/landmarks*.png` | `propose` | the config's four rig sections, `constraints` with `--cloth` (issue #364: a physics constraint per tree link named `<bone>_physics`, a dangling end's `<bone>_translate`, and a skirt swing's transforms `<swing>_<tree>`), `turn` with `--full`/`--head`, `proposed_rig_scale` (issue #354), and `notes` |
|
|
@@ -214,6 +214,23 @@ every number) are AUTHORING §3's tables, and the loader refuses any other by na
|
|
|
214
214
|
| the scene report | `compose` | spec `spine-parts-scene-report/1` |
|
|
215
215
|
| `idle.png`, `idle-indexed.png`, `idle.gif` | `loop`, `build --loop` | APNG and GIF encodings of the rendered idle |
|
|
216
216
|
|
|
217
|
+
Skeleton alternate registration accepts an optional `anchor` mapping of one or
|
|
218
|
+
two body-18 keypoints to declared base-bone origins (issue #543). One pair holds
|
|
219
|
+
scale at 1; two determine scale and offset. The registration bars and painting
|
|
220
|
+
pixels are unchanged, and omitting the field retains torso registration.
|
|
221
|
+
|
|
222
|
+
Painting generation metadata includes `upscale: {model, then}` (issue #698),
|
|
223
|
+
read from the same `UPSCALE_MODEL` and `UPSCALE_THEN` constants as the graph.
|
|
224
|
+
This adds provenance; it does not change model selection.
|
|
225
|
+
|
|
226
|
+
Revision ancestry is additive (issue #531): a previous root `remesh.json` or
|
|
227
|
+
`retune.json` is preserved at `provenance/<command>-<sha256>.json`, and optional
|
|
228
|
+
`input.provenance` rows name its source, path, bytes and SHA-256. The chain survives
|
|
229
|
+
same-command and mixed-command revisions without changing their rig splice or
|
|
230
|
+
hold. `revision` rows name actual output bytes, including a new `input-check.json`
|
|
231
|
+
when recorded, and exclude the new root provenance itself. A first revision has
|
|
232
|
+
no parent rows. Hashes and names are deterministic.
|
|
233
|
+
|
|
217
234
|
Files authors write for this package, each with a spec id the reader holds:
|
|
218
235
|
`spine-parts-requirements/1` (`check --requirements`), `spine-parts-scene/1`
|
|
219
236
|
(`compose --scene`), `spine-parts-keypoints/1` (`propose --keypoints`),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/parts",
|
|
3
|
-
"version": "1.60.
|
|
3
|
+
"version": "1.60.2",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
"bin/rig-parts.cjs",
|
|
41
41
|
"cli.ts",
|
|
42
42
|
"tools/configwrite.ts",
|
|
43
|
+
"tools/build-process.ts",
|
|
44
|
+
"tools/alternate-cli.ts",
|
|
43
45
|
"src",
|
|
44
46
|
"workflows",
|
|
45
47
|
"docs/AUTHORING.md",
|
package/src/build.ts
CHANGED
|
@@ -338,6 +338,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
338
338
|
head_box?: [number, number, number, number];
|
|
339
339
|
cuts?: Cut[];
|
|
340
340
|
skeleton?: string;
|
|
341
|
+
anchor?: NonNullable<typeof cfg.assemble.alternates>[number]['anchor'];
|
|
341
342
|
drawn?: Record<string, number>;
|
|
342
343
|
tips?: Record<string, [number, number]>;
|
|
343
344
|
front?: string[];
|
|
@@ -355,6 +356,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
355
356
|
head_box: a.head_box,
|
|
356
357
|
cuts: a.cuts,
|
|
357
358
|
skeleton: a.skeleton === undefined ? undefined : resolve(configDir, a.skeleton),
|
|
359
|
+
anchor: a.anchor,
|
|
358
360
|
drawn: a.drawn,
|
|
359
361
|
tips: a.tips,
|
|
360
362
|
front: a.front,
|
|
@@ -544,7 +546,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
544
546
|
const placedBySkeleton = altSkeleton !== undefined && input.altPlacement !== 'angles' && SKELETON_LIMB_BONES.some(([b]) => coveredLimbBones.has(b));
|
|
545
547
|
if (placedBySkeleton && altSkeleton !== undefined) {
|
|
546
548
|
// Issue #539: the painting must sit where the base figure sits before its own joints are cut at.
|
|
547
|
-
const reg = registerSkeleton(fields.bones, altSkeleton);
|
|
549
|
+
const reg = registerSkeleton(fields.bones, altSkeleton, alt.anchor);
|
|
548
550
|
if (!reg.ok) {
|
|
549
551
|
const read = reg.anchors.map((a) => `${a.keypoint} on "${a.bone}"`).join(', ') || 'none';
|
|
550
552
|
altProblems.push({
|
|
@@ -1719,7 +1721,7 @@ export function sweepCheckLines(line: SweepLine, steps: ReadonlyMap<string, { le
|
|
|
1719
1721
|
* read nothing of (its SKIP) or the line could not read. A SKIP with nothing declared prints its reason alone.
|
|
1720
1722
|
*/
|
|
1721
1723
|
export function motionSeamLines(line: MotionSeamLine, plant: MotionSeamPlant = {}): string[] {
|
|
1722
|
-
if (line.status === 'SKIP' && line.rows.length === 0 && line.pairs.every((p) => p.unread === undefined)) return [`${MOTION_SEAM_LINE}: SKIP — ${String(line.reason)}`];
|
|
1724
|
+
if (line.worlds === undefined && line.status === 'SKIP' && line.rows.length === 0 && line.pairs.every((p) => p.unread === undefined)) return [`${MOTION_SEAM_LINE}: SKIP — ${String(line.reason)}`];
|
|
1723
1725
|
const read = `${line.pairs.length} declared pair(s) in ${line.animations.length} animation(s) (${line.animations.join(', ')}), read by rigc render --seam at ${line.fps} fps on the build as played`;
|
|
1724
1726
|
const head =
|
|
1725
1727
|
line.status === 'SKIP'
|
|
@@ -1731,6 +1733,20 @@ export function motionSeamLines(line: MotionSeamLine, plant: MotionSeamPlant = {
|
|
|
1731
1733
|
...line.rows.filter((r) => r.status === 'skip').map((r) => `seam "${r.pair}" in "${r.animation}": SKIP — rigc read no band on any of the ${r.drawn} frame(s) both slots draw, so there is no seam to read`),
|
|
1732
1734
|
...(plant.silent === true ? [] : line.rows.filter((r) => r.opens.length > 0).map(motionSeamWarnText)),
|
|
1733
1735
|
...line.rows.filter((r) => r.opens.length === 0 && r.under_floor.length > 0).map((r) => `seam "${r.pair}" in "${r.animation}": under the floor — rigc names ${r.under_floor.length} frame(s) open ${frameRuns(r.under_floor)}, each opening one cell thick`),
|
|
1736
|
+
...(line.worlds === undefined ? [] : (['default', 'still'] as const).flatMap(name => {
|
|
1737
|
+
const w = line.worlds?.[name];
|
|
1738
|
+
if (w === undefined) return [];
|
|
1739
|
+
const label = 'seam world "' + name + '"';
|
|
1740
|
+
const header = label + ' wind [' + w.wind.join(', ') + '], gravity [' + w.gravity.join(', ') + ']: ' + w.status +
|
|
1741
|
+
(w.status === 'SKIP' ? ' — ' + String(w.reason) : ' — raw gap/ghost cell counts, informational, not judged') +
|
|
1742
|
+
(w.dir === undefined ? '' : '; raw render: ' + w.dir);
|
|
1743
|
+
return [header, ...w.rows.map(r => {
|
|
1744
|
+
const head = label + ' "' + r.pair + '" in "' + r.animation + '": ';
|
|
1745
|
+
if (r.status === 'skip') return head + 'SKIP — rigc read no band';
|
|
1746
|
+
const at = (kind: typeof r.gap) => kind.worst === null ? 'none' : 'frame ' + kind.worst.index + ' (t = ' + kind.worst.index / line.fps + 's)';
|
|
1747
|
+
return head + 'gap ' + r.gap.max_px + ' cell(s), worst ' + at(r.gap) + '; ghost ' + r.ghost.max_px + ' cell(s), worst ' + at(r.ghost);
|
|
1748
|
+
})];
|
|
1749
|
+
})),
|
|
1734
1750
|
];
|
|
1735
1751
|
}
|
|
1736
1752
|
|
|
@@ -2181,9 +2197,18 @@ export function suppliedCheckFlag(flag: string): string | null {
|
|
|
2181
2197
|
* rig-c's launcher answers for; they are two fields so a caller can tell
|
|
2182
2198
|
* the stages' calls apart (the selftest counts them).
|
|
2183
2199
|
*/
|
|
2200
|
+
/** Stage implementations may run outside this process; only check has a returned value the driver reads. */
|
|
2201
|
+
export interface BuildStages {
|
|
2202
|
+
assemble: (input: AssembleStageInput, outputs: AssembleOutputs, log: Log) => void;
|
|
2203
|
+
rig: (input: RigStageInput, rigc: RigcRunner, scratch: string, log: Log) => void;
|
|
2204
|
+
check: typeof checkStage;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2184
2207
|
export interface BuildRunners {
|
|
2185
2208
|
rig: RigcRunner;
|
|
2186
2209
|
check: RigcRunner;
|
|
2210
|
+
/** The CLI isolates stages; API callers keep the same in-process functions by default. */
|
|
2211
|
+
stages?: BuildStages;
|
|
2187
2212
|
/** Where the check's rigc binary is, for its header line. */
|
|
2188
2213
|
checkBin: string;
|
|
2189
2214
|
/** A directory the rig stage may stage its gate in, and the loop its lead-in render after it; emptied before and after each. */
|
|
@@ -2234,6 +2259,7 @@ export function artifactPaths(buildDir: string, pack: readonly PackLine[]): stri
|
|
|
2234
2259
|
* rethrown: it is not a stage's message and must not be printed as one.
|
|
2235
2260
|
*/
|
|
2236
2261
|
export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResult {
|
|
2262
|
+
const stages: BuildStages = run.stages ?? { assemble: assembleStage, rig: rigStage, check: checkStage };
|
|
2237
2263
|
const prefixed = (stage: BuildStage): Log => (line) => log(`[${stage}] ${line}`);
|
|
2238
2264
|
const refused = (stage: BuildStage, err: unknown, check: CheckReport | null = null): BuildResult => {
|
|
2239
2265
|
if (!(err instanceof PartsError)) throw err;
|
|
@@ -2268,7 +2294,7 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
|
|
|
2268
2294
|
if (req !== null) readRequirements(req.read);
|
|
2269
2295
|
// And the schedule (issue #538), by rigc's own reader, as check reads it.
|
|
2270
2296
|
if (input.environment !== undefined) readCheckEnvironment(input.environment);
|
|
2271
|
-
|
|
2297
|
+
stages.assemble(
|
|
2272
2298
|
{ source: input.source, full: input.full, head: input.head, config: input.config, seam: input.seam, project: input.project, ...(input.alts === undefined ? {} : { alts: input.alts }) },
|
|
2273
2299
|
{ partsJson: join(out, 'parts.json'), partsDir: join(out, 'parts'), recomposite: join(out, 'recomposite_rig.png'), errorMap: join(out, ERROR_MAP_FILE) },
|
|
2274
2300
|
prefixed('assemble'),
|
|
@@ -2278,14 +2304,14 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
|
|
|
2278
2304
|
}
|
|
2279
2305
|
|
|
2280
2306
|
try {
|
|
2281
|
-
|
|
2307
|
+
stages.rig({ config: input.config, parts: out, out: join(out, 'rig'), idleKeys, pageEdges: input.pageEdges, packShape: input.packShape, command: 'build' }, run.rig, run.scratch, prefixed('rig'));
|
|
2282
2308
|
} catch (err) {
|
|
2283
2309
|
return refused('rig', err);
|
|
2284
2310
|
}
|
|
2285
2311
|
|
|
2286
2312
|
let report: CheckReport;
|
|
2287
2313
|
try {
|
|
2288
|
-
report =
|
|
2314
|
+
report = stages.check({ 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'));
|
|
2289
2315
|
} catch (err) {
|
|
2290
2316
|
return refused('check', err);
|
|
2291
2317
|
}
|
package/src/check.ts
CHANGED
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
* `TIME_SLACK`, issue #244).
|
|
79
79
|
*/
|
|
80
80
|
import { createHash } from 'node:crypto';
|
|
81
|
-
import { copyFileSync, cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
82
|
-
import { basename, delimiter, dirname, join, resolve } from 'node:path';
|
|
81
|
+
import { copyFileSync, cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
82
|
+
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
83
83
|
import { measureRecomposite, type RecompositeFigures, recompositeRecord, scenePhrase, sourceInRig } from './assemble.ts';
|
|
84
84
|
import { type BoneTransform, computeExactFrameTransforms, cropToSpineY, normaliseDegrees, toBoneLocal } from './coords.ts';
|
|
85
85
|
import { capBox, inDisc } from './limbs.ts';
|
|
@@ -160,7 +160,7 @@ import {
|
|
|
160
160
|
} from './requirements.ts';
|
|
161
161
|
import { RIG_BONE_INHERIT, type RigSpec as RigcRigSpec } from 'rig-c/src/rig.ts';
|
|
162
162
|
import { expandStops } from 'rig-c/src/stop.ts';
|
|
163
|
-
import { ENVIRONMENT_SPEC, EnvironmentError, readEnvironmentSchedule } from 'rig-c/src/environment.ts';
|
|
163
|
+
import { ENVIRONMENT_SPEC, EnvironmentError, environmentResponse, readEnvironmentSchedule } from 'rig-c/src/environment.ts';
|
|
164
164
|
import { alphaComposite } from './raster/composite.ts';
|
|
165
165
|
import { readPng, writePng } from './raster/png.ts';
|
|
166
166
|
import { newFloatImage, newRaster, type Raster } from './raster/types.ts';
|
|
@@ -465,53 +465,64 @@ export function readRigcEntry(versionOut: string): RigcEntryRecord {
|
|
|
465
465
|
throw new Error('unreachable');
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
+
/** Executable names, in selection order. Bun's rigc.bunx is a companion, never a command. */
|
|
469
|
+
function rigcPaths(directory: string, platform: 'win32' | 'posix'): string[] {
|
|
470
|
+
return (platform === 'win32' ? ['rigc', 'rigc.exe'] : ['rigc']).map(name => join(directory, name));
|
|
471
|
+
}
|
|
472
|
+
|
|
468
473
|
/**
|
|
469
|
-
* This package's own rigc
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
* `.claude/worktrees/`) whose own install is missing, cannot reach another tree's rigc. A miss is refused naming
|
|
473
|
-
* the one path looked at.
|
|
474
|
+
* This package's own rigc under root/node_modules/.bin and nowhere else: no ancestor or PATH.
|
|
475
|
+
* Windows Bun supplies rigc.exe and rigc.bunx; the executable keeps its own launcher's runtime gates.
|
|
476
|
+
* The optional platform argument lets the same discovery controls plant both install shapes.
|
|
474
477
|
*/
|
|
475
|
-
export function packageRigc(root: string): string {
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
478
|
+
export function packageRigc(root: string, platform: 'win32' | 'posix' = sep === '\\' ? 'win32' : 'posix'): string {
|
|
479
|
+
const paths = rigcPaths(join(resolve(root), 'node_modules', '.bin'), platform);
|
|
480
|
+
const bin = paths.find(path => existsSync(path));
|
|
481
|
+
if (bin !== undefined) return bin;
|
|
482
|
+
refuseIfAny([
|
|
483
|
+
{
|
|
484
|
+
code: 'CHECK_RIGC_PACKAGE',
|
|
485
|
+
object: paths[0],
|
|
486
|
+
detail: platform === 'win32'
|
|
487
|
+
? "none of " + paths.join(", ") + " exists; rigc.bunx alone is not executable; this package's own rigc is required here and no ancestor or PATH is searched (bun install puts it there)"
|
|
488
|
+
: `does not exist; this package's own rigc is required here and no other is looked for — not in a directory above ${resolve(root)}, not on PATH (\`bun install\` puts it there)`,
|
|
489
|
+
},
|
|
490
|
+
]);
|
|
491
|
+
return '';
|
|
487
492
|
}
|
|
488
493
|
|
|
489
494
|
/**
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
* the consumer's `node_modules/.bin`), then every directory on `PATH`. A miss
|
|
493
|
-
* is refused naming every place looked.
|
|
495
|
+
* Find rigc beside from or its ancestors, then on PATH. Windows also looks for rigc.exe;
|
|
496
|
+
* selecting it does not replace it with a compiler entry or another package's launcher.
|
|
494
497
|
*/
|
|
495
|
-
export function findRigc(from: string, pathVar: string): string {
|
|
498
|
+
export function findRigc(from: string, pathVar: string, platform: 'win32' | 'posix' = sep === '\\' ? 'win32' : 'posix'): string {
|
|
496
499
|
const looked: string[] = [];
|
|
500
|
+
let directories = 0;
|
|
497
501
|
let dir = resolve(from);
|
|
498
502
|
for (;;) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
503
|
+
directories++;
|
|
504
|
+
for (const bin of rigcPaths(join(dir, 'node_modules', '.bin'), platform)) {
|
|
505
|
+
looked.push(bin);
|
|
506
|
+
if (existsSync(bin)) return bin;
|
|
507
|
+
}
|
|
502
508
|
const up = dirname(dir);
|
|
503
509
|
if (up === dir) break;
|
|
504
510
|
dir = up;
|
|
505
511
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
512
|
+
const onPath: string[] = [];
|
|
513
|
+
for (const p of pathVar.split(delimiter).filter(s => s !== '')) {
|
|
514
|
+
for (const bin of rigcPaths(p, platform)) {
|
|
515
|
+
onPath.push(bin);
|
|
516
|
+
if (existsSync(bin)) return bin;
|
|
517
|
+
}
|
|
509
518
|
}
|
|
510
519
|
refuseIfAny([
|
|
511
520
|
{
|
|
512
521
|
code: 'CHECK_RIGC_PRESENT',
|
|
513
522
|
object: 'the rig-c CLI `rigc`',
|
|
514
|
-
detail:
|
|
523
|
+
detail: platform === 'win32'
|
|
524
|
+
? 'found at none of ' + looked.join(', ') + ' nor PATH candidates [' + onPath.join(', ') + ']; executable shapes rigc, rigc.exe were looked for; rigc.bunx alone is not executable; bun install supplies this dependency'
|
|
525
|
+
: `found at none of ${directories} node_modules/.bin/rigc path(s) from ${resolve(from)} up (nearest ${looked[0]}) nor on PATH; rig-c is this package's dependency — \`bun install\` puts it at node_modules/.bin/rigc`,
|
|
515
526
|
},
|
|
516
527
|
]);
|
|
517
528
|
return '';
|
|
@@ -3535,6 +3546,7 @@ export const MOTION_SEAM_LINE = 'SEAM_OVER_MOTION';
|
|
|
3535
3546
|
|
|
3536
3547
|
/** The seam reading's scratch build and renders, under `--out`; removed before the stage returns. */
|
|
3537
3548
|
const MOTION_SEAM_SCRATCH = '_seam_motion';
|
|
3549
|
+
const MOTION_SEAM_DIR = 'seam_motion';
|
|
3538
3550
|
|
|
3539
3551
|
/** rig-c's seam reading: the file it writes in each set's directory, and its format tag. */
|
|
3540
3552
|
export const SEAM_READING_FILE = 'seam.json';
|
|
@@ -3584,6 +3596,8 @@ export interface MotionSeamLine {
|
|
|
3584
3596
|
/** Rows with a frame over the floor: the WARN lines. */
|
|
3585
3597
|
warnings: number;
|
|
3586
3598
|
rows: MotionSeamRow[];
|
|
3599
|
+
/** Physics-only reference worlds (issue #591); do not participate in warnings or bars. */
|
|
3600
|
+
worlds?: MotionSeamWorlds;
|
|
3587
3601
|
}
|
|
3588
3602
|
|
|
3589
3603
|
/**
|
|
@@ -3640,7 +3654,109 @@ export interface MotionSeamPlant {
|
|
|
3640
3654
|
silent?: true;
|
|
3641
3655
|
}
|
|
3642
3656
|
|
|
3643
|
-
|
|
3657
|
+
|
|
3658
|
+
/** One raw opening, in rigc cells; its frame time is index / the line's fps. */
|
|
3659
|
+
export interface MotionSeamHit {
|
|
3660
|
+
index: number;
|
|
3661
|
+
px: number;
|
|
3662
|
+
cell: number;
|
|
3663
|
+
box: [number, number, number, number];
|
|
3664
|
+
}
|
|
3665
|
+
export interface MotionSeamWorldKind {
|
|
3666
|
+
max_px: number;
|
|
3667
|
+
worst: MotionSeamHit | null;
|
|
3668
|
+
}
|
|
3669
|
+
/** Raw gap and ghost readings, including cells under the warning floor. */
|
|
3670
|
+
export interface MotionSeamWorldRow {
|
|
3671
|
+
pair: string;
|
|
3672
|
+
animation: string;
|
|
3673
|
+
status: 'read' | 'skip';
|
|
3674
|
+
drawn: number;
|
|
3675
|
+
banded: number;
|
|
3676
|
+
gap: MotionSeamWorldKind;
|
|
3677
|
+
ghost: MotionSeamWorldKind;
|
|
3678
|
+
}
|
|
3679
|
+
export interface MotionSeamWorld {
|
|
3680
|
+
wind: [number, number];
|
|
3681
|
+
gravity: [number, number];
|
|
3682
|
+
status: 'REPORTED' | 'SKIP';
|
|
3683
|
+
reason?: string;
|
|
3684
|
+
/** Complete rigc render directory, relative to check.json; absent when not rendered. */
|
|
3685
|
+
dir?: string;
|
|
3686
|
+
rows: MotionSeamWorldRow[];
|
|
3687
|
+
}
|
|
3688
|
+
export interface MotionSeamWorlds {
|
|
3689
|
+
default: MotionSeamWorld;
|
|
3690
|
+
still: MotionSeamWorld;
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
/** No callback and no output for nonphysics; a wind no constraint answers is not measured. */
|
|
3694
|
+
export function motionSeamWorlds(physics: boolean, answersWind: boolean, read: (world: 'default' | 'still') => MotionSeamWorldRow[]): MotionSeamWorlds | undefined {
|
|
3695
|
+
if (!physics) return undefined;
|
|
3696
|
+
const world = (wind: [number, number], rows: MotionSeamWorldRow[], reason?: string): MotionSeamWorld => {
|
|
3697
|
+
const measured = rows.some(r => r.status === 'read');
|
|
3698
|
+
return { wind, gravity: [0, 1], status: measured ? 'REPORTED' : 'SKIP',
|
|
3699
|
+
...(measured ? {} : { reason: reason ?? 'rigc read no band on any frame of any declared pair in any animation' }), rows };
|
|
3700
|
+
};
|
|
3701
|
+
return {
|
|
3702
|
+
default: world([1, 0], read('default')),
|
|
3703
|
+
still: answersWind ? world([0, 0], read('still')) : world([0, 0], [], 'no physics constraint answers wind; still air is not separately measurable'),
|
|
3704
|
+
};
|
|
3705
|
+
}
|
|
3706
|
+
|
|
3707
|
+
/** The same validated sidecars as the warning, retaining the raw gap and ghost cells. */
|
|
3708
|
+
export function readMotionSeamWorldRows(dir: string, animations: readonly string[], fps: number, pairs: readonly MotionSeamPair[]): MotionSeamWorldRow[] {
|
|
3709
|
+
const rows: MotionSeamWorldRow[] = [];
|
|
3710
|
+
readMotionSeams(dir, animations, fps, pairs, {}, rows);
|
|
3711
|
+
return rows;
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
|
|
3715
|
+
/** Publish complete validated render directories with check.json; roll back if its writer fails. */
|
|
3716
|
+
export function publishMotionSeamWorlds(out: string, scratch: string, worlds: MotionSeamWorlds, publishCheck: () => void): void {
|
|
3717
|
+
const problems: Problem[] = [];
|
|
3718
|
+
const names = (['default', 'still'] as const).filter(name => worlds[name].dir !== undefined);
|
|
3719
|
+
for (const name of names) {
|
|
3720
|
+
const world = worlds[name];
|
|
3721
|
+
const home = join(scratch, name);
|
|
3722
|
+
if (world.dir !== MOTION_SEAM_DIR + '/' + name) problems.push({ code: 'FRAMES_SIDECAR', object: 'seam world ' + name, detail: 'raw directory reference must be ' + MOTION_SEAM_DIR + '/' + name });
|
|
3723
|
+
const manifest = readJson(join(home, 'frames.json'), problems);
|
|
3724
|
+
const sets = manifest !== null && Array.isArray(manifest.sets) ? manifest.sets.filter(isRecord) : [];
|
|
3725
|
+
for (const animation of new Set(world.rows.map(row => row.animation))) {
|
|
3726
|
+
const set = sets.find(item => item.animation === animation);
|
|
3727
|
+
const rawDir = set !== undefined && typeof set.dir === 'string' ? set.dir : null;
|
|
3728
|
+
const at = rawDir === null ? null : resolve(home, rawDir);
|
|
3729
|
+
const rel = at === null ? '..' : relative(home, at);
|
|
3730
|
+
if (rawDir === null || isAbsolute(rawDir) || at === null || isAbsolute(rel) || /^\.\.(?:[\\/]|$)/.test(rel) || !existsSync(join(at, SEAM_READING_FILE))) {
|
|
3731
|
+
problems.push({ code: 'FRAMES_SIDECAR', object: home, detail: 'animation ' + JSON.stringify(animation) + ' raw dir ' + JSON.stringify(rawDir) + ' must be relative, stay inside its render directory and hold seam.json' });
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
refuseIfAny(problems);
|
|
3736
|
+
const stage = join(scratch, '_publish');
|
|
3737
|
+
const previous = join(scratch, '_previous');
|
|
3738
|
+
const kept = join(out, MOTION_SEAM_DIR);
|
|
3739
|
+
const check = join(out, 'check.json');
|
|
3740
|
+
const previousCheck = existsSync(check) ? readFileSync(check) : null;
|
|
3741
|
+
mkdirSync(out, { recursive: true });
|
|
3742
|
+
mkdirSync(stage, { recursive: true });
|
|
3743
|
+
for (const name of names) renameSync(join(scratch, name), join(stage, name));
|
|
3744
|
+
const hadPrevious = existsSync(kept);
|
|
3745
|
+
if (hadPrevious) renameSync(kept, previous);
|
|
3746
|
+
try {
|
|
3747
|
+
renameSync(stage, kept);
|
|
3748
|
+
publishCheck();
|
|
3749
|
+
} catch (err) {
|
|
3750
|
+
rmSync(kept, { recursive: true, force: true });
|
|
3751
|
+
if (hadPrevious) renameSync(previous, kept);
|
|
3752
|
+
if (previousCheck === null) rmSync(check, { force: true });
|
|
3753
|
+
else writeFileSync(check, previousCheck);
|
|
3754
|
+
throw err;
|
|
3755
|
+
}
|
|
3756
|
+
rmSync(previous, { recursive: true, force: true });
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
type SeamHitRead = MotionSeamHit;
|
|
3644
3760
|
|
|
3645
3761
|
/**
|
|
3646
3762
|
* The rows of one `rigc render --seam` run over every animation: `frames.json`
|
|
@@ -3649,7 +3765,7 @@ type SeamHitRead = { index: number; px: number; cell: number; box: [number, numb
|
|
|
3649
3765
|
* file that is missing, a file that is not the animation's or not at the rate
|
|
3650
3766
|
* asked, a pair out of the flag's order, and a field of the wrong shape.
|
|
3651
3767
|
*/
|
|
3652
|
-
export function readMotionSeams(dir: string, animations: readonly string[], fps: number, pairs: readonly MotionSeamPair[], plant: MotionSeamPlant = {}): MotionSeamRow[] {
|
|
3768
|
+
export function readMotionSeams(dir: string, animations: readonly string[], fps: number, pairs: readonly MotionSeamPair[], plant: MotionSeamPlant = {}, worldRows?: MotionSeamWorldRow[]): MotionSeamRow[] {
|
|
3653
3769
|
const problems: Problem[] = [];
|
|
3654
3770
|
const bad = (object: string, detail: string): void => {
|
|
3655
3771
|
problems.push({ code: 'FRAMES_SIDECAR', object, detail });
|
|
@@ -3686,6 +3802,7 @@ export function readMotionSeams(dir: string, animations: readonly string[], fps:
|
|
|
3686
3802
|
return;
|
|
3687
3803
|
}
|
|
3688
3804
|
const over = new Map<number, number>();
|
|
3805
|
+
const kinds: Record<'gap' | 'ghost', MotionSeamWorldKind> = { gap: { max_px: 0, worst: null }, ghost: { max_px: 0, worst: null } };
|
|
3689
3806
|
for (const kind of ['gap', 'ghost'] as const) {
|
|
3690
3807
|
const k = p[kind];
|
|
3691
3808
|
const frames = isRecord(k) && Array.isArray(k.frames) ? k.frames.map(hitOf) : null;
|
|
@@ -3693,8 +3810,12 @@ export function readMotionSeams(dir: string, animations: readonly string[], fps:
|
|
|
3693
3810
|
bad(`${at} ${kind}`, 'is not { frames: [{ index, px, cell, box }…], spans, worst } as rigc-seam/1 writes it');
|
|
3694
3811
|
return;
|
|
3695
3812
|
}
|
|
3696
|
-
|
|
3813
|
+
const hits = frames as SeamHitRead[];
|
|
3814
|
+
const worst = hits.reduce<MotionSeamHit | null>((best, h) => best === null || h.px > best.px || (h.px === best.px && h.index < best.index) ? h : best, null);
|
|
3815
|
+
kinds[kind] = { max_px: worst?.px ?? 0, worst };
|
|
3816
|
+
for (const h of hits) if (plant.noFloor === true || openingOverFloor(h)) over.set(h.index, Math.max(over.get(h.index) ?? 0, h.px));
|
|
3697
3817
|
}
|
|
3818
|
+
worldRows?.push({ pair: want.pair, animation, status: p.status, drawn: p.drawn, banded: p.banded, gap: kinds.gap, ghost: kinds.ghost });
|
|
3698
3819
|
const opens = [...over.keys()].sort((x, y) => x - y);
|
|
3699
3820
|
rows.push({
|
|
3700
3821
|
pair: want.pair,
|
|
@@ -4070,13 +4191,15 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
4070
4191
|
const seamDir = join(out, SEAM_DIR);
|
|
4071
4192
|
const keptDir = join(out, STILL_DIR);
|
|
4072
4193
|
const foldDir = join(out, FOLD_SCRATCH);
|
|
4073
|
-
|
|
4194
|
+
const seamMotionDir = join(out, MOTION_SEAM_SCRATCH);
|
|
4195
|
+
for (const d of [buildDir, idleDir, stillDir, isoDir, loopDir, seamDir, keptDir, foldDir, seamMotionDir]) rmSync(d, { recursive: true, force: true });
|
|
4074
4196
|
const written: string[] = [];
|
|
4075
4197
|
const write = (name: string, data: string): void => {
|
|
4076
4198
|
writeFileSync(join(out, name), data);
|
|
4077
4199
|
written.push(name);
|
|
4078
4200
|
};
|
|
4079
4201
|
|
|
4202
|
+
try {
|
|
4080
4203
|
// 1. build, packed, under the policy profile
|
|
4081
4204
|
const build = rigc(['build', '--rig', inp.rigPath, '--motion', inp.motionPath, '--out', buildDir, ...packedBuildArgs(mode)]);
|
|
4082
4205
|
const gateHtml = buildGateLines(build.out);
|
|
@@ -4429,15 +4552,38 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
4429
4552
|
else if (animationNames.length === 0) motionSeam = motionSeamLine(pairs, [], fps, [], 'motion.json holds no animation to read the declared pairs in');
|
|
4430
4553
|
else if (read.length === 0) motionSeam = motionSeamLine(pairs, animationNames, fps, []);
|
|
4431
4554
|
else {
|
|
4432
|
-
const seamMotionDir = join(out, MOTION_SEAM_SCRATCH);
|
|
4433
4555
|
rmSync(seamMotionDir, { recursive: true, force: true });
|
|
4434
|
-
|
|
4556
|
+
{
|
|
4435
4557
|
const list = read.map((p) => `${p.a}:${p.b}`).join(',');
|
|
4436
|
-
const
|
|
4558
|
+
const activeDest = stripped === null ? seamMotionDir : join(seamMotionDir, env === null ? 'default' : 'active');
|
|
4559
|
+
const renderedWorlds = new Set<'default' | 'still'>();
|
|
4560
|
+
const r = measured(['render', '--candidate', buildDir, '--seam', list, '--fps', String(fps), '--max', String(FOLD_RENDER_MAX), '--out', activeDest]);
|
|
4437
4561
|
if (r.status !== 0) refuseIfAny(rigcFailed(`render --seam ${list} --fps ${fps}`, r, r.out.split('\n').filter((l) => l.includes('FAIL') || l.includes('rigc:'))));
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4562
|
+
const activeWorldRows: MotionSeamWorldRow[] = [];
|
|
4563
|
+
motionSeam = motionSeamLine(pairs, animationNames, fps, readMotionSeams(activeDest, animationNames, fps, read, {}, stripped !== null && env === null ? activeWorldRows : undefined));
|
|
4564
|
+
if (stripped !== null) {
|
|
4565
|
+
const response = environmentResponse(readFileSync(join(buildDir, 'skeleton.json'), 'utf8'));
|
|
4566
|
+
motionSeam.worlds = motionSeamWorlds(true, response.wind.length > 0, world => {
|
|
4567
|
+
if (world === 'default' && env === null) { renderedWorlds.add(world); return activeWorldRows; }
|
|
4568
|
+
const dest = join(seamMotionDir, world);
|
|
4569
|
+
const args = ['render', '--candidate', buildDir, '--seam', list, '--fps', String(fps), '--max', String(FOLD_RENDER_MAX), '--out', dest];
|
|
4570
|
+
if (world === 'still') {
|
|
4571
|
+
const schedule = join(seamMotionDir, 'still.json');
|
|
4572
|
+
writeFileSync(schedule, JSON.stringify({ spec: ENVIRONMENT_SPEC, steps: [{ t: 0, wind: [0, 0] }] }));
|
|
4573
|
+
args.push('--environment', schedule);
|
|
4574
|
+
}
|
|
4575
|
+
// These reference worlds are independent of the caller's --environment.
|
|
4576
|
+
const rendered = rigc(args);
|
|
4577
|
+
if (rendered.status !== 0) refuseIfAny(rigcFailed('render --seam (' + world + ' reference world)', rendered, rendered.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
4578
|
+
const rows = readMotionSeamWorldRows(dest, animationNames, fps, read);
|
|
4579
|
+
renderedWorlds.add(world);
|
|
4580
|
+
return rows;
|
|
4581
|
+
});
|
|
4582
|
+
for (const world of renderedWorlds) {
|
|
4583
|
+
const reading = motionSeam.worlds?.[world];
|
|
4584
|
+
if (reading !== undefined) reading.dir = MOTION_SEAM_DIR + '/' + world;
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4441
4587
|
}
|
|
4442
4588
|
}
|
|
4443
4589
|
}
|
|
@@ -4692,7 +4838,9 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
4692
4838
|
problems.unshift(...barProblems);
|
|
4693
4839
|
problems.push(...foldProblems, ...levelProblems, ...stressProblems, ...limbProblems, ...sweepProblems, ...reqProblems);
|
|
4694
4840
|
figures.PASS = problems.length === 0;
|
|
4695
|
-
write('check.json', `${JSON.stringify(figures, null, 1)}\n`);
|
|
4841
|
+
const publishCheck = (): void => write('check.json', `${JSON.stringify(figures, null, 1)}\n`);
|
|
4842
|
+
if (motionSeam.worlds === undefined) publishCheck();
|
|
4843
|
+
else publishMotionSeamWorlds(out, seamMotionDir, motionSeam.worlds, publishCheck);
|
|
4696
4844
|
const bars: CheckReport['bars'] = { measured: ['gate'], skipped: [] };
|
|
4697
4845
|
const tally = (bar: string, reason: string | null): void => {
|
|
4698
4846
|
if (reason === null) bars.measured.push(bar);
|
|
@@ -4731,6 +4879,9 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
4731
4879
|
cloth,
|
|
4732
4880
|
...(sweepSteps.size === 0 ? {} : { sweepSteps }),
|
|
4733
4881
|
};
|
|
4882
|
+
} finally {
|
|
4883
|
+
rmSync(seamMotionDir, { recursive: true, force: true });
|
|
4884
|
+
}
|
|
4734
4885
|
}
|
|
4735
4886
|
|
|
4736
4887
|
// ---------------------------------------------------------------------------
|
package/src/comfy/painting.ts
CHANGED
|
@@ -31,7 +31,7 @@ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
|
31
31
|
import { join } from 'node:path';
|
|
32
32
|
import type { ControlPose, PaintConfig } from '../config.ts';
|
|
33
33
|
import { type Problem, refuseIfAny } from '../errors.ts';
|
|
34
|
-
import { buildPrompts, checkGraph, paintingGraph, resolvedControl, resolvedLoras, resolvedSampler } from '../graphs.ts';
|
|
34
|
+
import { buildPrompts, checkGraph, paintingGraph, resolvedControl, resolvedLoras, resolvedSampler, UPSCALE_MODEL, UPSCALE_THEN } from '../graphs.ts';
|
|
35
35
|
import { decodePngBytes, encodePngBytes } from '../raster/png.ts';
|
|
36
36
|
import { isSkeletonName, renderSkeleton } from '../skeleton.ts';
|
|
37
37
|
import { ComfyClient, historyImages, refuse } from './client.ts';
|
|
@@ -112,6 +112,7 @@ export async function runPainting(client: ComfyClient, run: PaintRun, say: (line
|
|
|
112
112
|
checkpoint: g.checkpoint,
|
|
113
113
|
loras: resolvedLoras(g.loras),
|
|
114
114
|
sampler: resolvedSampler(g.sampler),
|
|
115
|
+
upscale: { model: UPSCALE_MODEL, then: UPSCALE_THEN },
|
|
115
116
|
control,
|
|
116
117
|
pose_from: prompts.poseFrom,
|
|
117
118
|
dropped: prompts.dropped,
|