@rig-c/parts 1.60.2 → 1.62.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/docs/STABILITY.md CHANGED
@@ -92,9 +92,9 @@ rules that make the contract:
92
92
  after it holds any JSON value in the same places. They are not open in `meshes`,
93
93
  `regions` or `motion.blink.still`, whose keys are part names.
94
94
  - **Coordinates** in `bones`, `meshes` and `motion` are rig pixels, y down, origin
95
- top-left.
96
- - **A mesh is one of three modes**: `grid` (the lattice, what `propose` writes),
97
- `contour` (the traced outline with declared interior points) or `auto` (the
95
+ top-left. Explicit mesh UVs are normalized padded-image coordinates, and its weights are bone-local Spine pixels, already y up.
96
+ - **A mesh has exactly one mode**: `grid` (the lattice, what `propose` writes),
97
+ `contour` (the traced outline with declared interior points), `influence` (core's lattice and pull), `explicit` (a hash-bound accepted payload) or `auto` (the
98
98
  automatic mode: the contour mesh at alpha 1 and above reduced by rig-c's
99
99
  `reduceMesh` under declared bounds, written only when its motion against the
100
100
  unreduced source passes the author's bounds). Two, or none, is
@@ -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`, `anchor`, `drawn`, `tips`, `front` (issues #454, #465, #543, #652, #664)
130
+ - **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `anchor`, `drawn`, `tips`, `front`, `layers`, `focus` (issues #454, #465, #543, #652, #664, #666, #719). `focus` is an authored finite `[x, y]` in painting pixels, within its canvas (edges included), refused as CONFIG_SET_FOCUS before assemble output when invalid; only when present, `parts.json` records it with focus_source_size and `sets.json` emits it in setup-world coordinates through the actual rig resize and `src/coords.ts`. Absent focus emits no field or inferred value; changing/removing it requires reassembly
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,8 @@ 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`, `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)
145
+ - **meshes.<part>** — exactly one of `grid`, `contour`, `auto`, `influence`, `explicit`; required in every mode: `segments`, and `r` in generated modes other than `influence`; `explicit` refuses generation fields and uses direct bone names in `segments`, the first the slot bone; 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
+ - **meshes.&lt;part&gt;.explicit** — required: `image_sha256`, `region_sha256`, `uvs`, `triangles`, `hull`, `weights` (issue #658); direct payload numbers are transferred without normalization; weights require `bone`, `x`, `y`, `weight`. Image SHA-256 is over decoded unpadded RGBA bytes; region SHA-256 is over JSON.stringify([rig width, rig height, part x, part y, part w, part h]). Both must match before output. All weighted bones must occur in segments; declared stopped links may use their emitted `<link>_d` names. Other unknown names remain refused. Alternate artwork for this part is refused; use a generated mesh for it.
146
147
  - **meshes.&lt;part&gt;.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
148
  - **meshes.&lt;part&gt;.influences** — optional, at least one: `maxInfluences` (a whole number, 1 or more, or null for no cap), `floor` ("cut" or "continuous")
148
149
  - **meshes.&lt;part&gt;.ribs.&lt;chain&gt;** — required: `stations`
@@ -199,21 +200,59 @@ every number) are AUTHORING §3's tables, and the loader refuses any other by na
199
200
  | --- | --- | --- |
200
201
  | `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
202
  | `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
- | `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`; 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 |
203
+ | `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); or `mode` "explicit" with `image_sha256` and `region_sha256` (the verified guards; counts and coverage are measured from the supplied mesh, no legacy generator report is adopted); `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) |
204
+ | `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 retains existing pair warnings; issue #686 gates GAP on proven body-root pairs only (gap-only; mixed ghost remains INFO until rig-c/core#1555 supplies owners): `status` — `WARN`, `CLEAR`, `SKIP` or `FAIL` — `reason` on a SKIP only, `fps`, `floor`, `pairs` — each `pair`, `a`, `b`, `declared`, optional `root` (`limb`, `bone`, `parent`) on a proven body-root pair, and `unread` on a pair not read — `animations`, `warnings`, `rows` — each `pair`, `animation`, `status`, `drawn`, `banded`, `opens`, `px`, `max_px`, `under_floor`, and only on new-root rows stock `gapOpen` plus UNDER-owned `ghostA`/`ghostB` cells selected by resolved per-frame draw order gate their summed count against the unchanged strict one-cell floor on the original raw kind boxes (their union when both kinds contribute), never narrowed partition boxes, while `gapCovered` and OVER-owned ghost cells are excluded (issue #711); `cells` retains partition counts, UNDER owner and counted total, `worst` retains frame/count/cell/box, and `roots` retains status, mode `gap-open+under-ghost`, ghost_owner `resolved-draw-order`, pairs, failed, reason and optional unmeasured bindings; eligible candidates whose valid setup bands are all zero retain a named unmeasured root and SKIP bar, including when no pair is selected; measured root FAIL wins over SKIP, while measured PASS plus an unmeasured root remains SKIP; every eligible body drawing with stock setup `banded > 0` is selected, including both when a parent is shared; issue #708 resolves a body slot on its exact generated turn child to the same named carrier only after unique identity-bone/control/per-part-transform proof, without changing pair identity, setup selection or the direct-carrier path; setup-only observation preserves the authored motion and default drawing, root-free inputs add no setup compile/render, and no animation remains SKIP rather than a measured zero; existing internal pair warnings and their exits are unchanged; 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. Missing stock partitions or resolved owner are named refusals, never zero. No whole-box exemption or consumer compositor remains; internal warnings and reference raw readings are unchanged. |
204
205
  | `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
206
  | 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
207
  | `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` |
207
208
  | `basis.json` | `propose` | spec `spine-parts-basis/1` |
208
209
  | an existing config named by `--write-config` | `propose --head-box`, `assemble --propose-plan`, ordinary `propose` | issue #356, additive: `assemble --propose-plan` must update `--config` itself; only the selected proposed fields are replaced by whole-value text splices, preserving untouched bytes; absent optional proposal sections and other fields remain; the stage loader validates before atomic replacement, relative paths keep their base, an unchanged update preserves bytes and mtime, and stderr lists changes; no multi-artifact transaction is promised; with `--only-missing` (issue #671) only a `meshes.<part>` or `regions.<part>` entry for a proposed part the config attaches by neither is added, and an `assemble.plan` row for such a part the 1.37.0 arm split makes that the plan does not name, every existing row and entry and every other byte as read |
209
210
  | a new `--write-config` file | `propose --cloth … --write-config` | complete checked splice text published without overwrite; an intervening creator is refused, while cleanup failure after publication may leave the complete new file present; intentional partial configs retain their existing contract; the `--cloth` config read, byte for byte, but for the entries the recipe drafts (issue #537), measured against the same parts drafted without it: `meshes.<part>` and `regions.<part>` for each part the recipe moves, and `bones`, `constraints` and `motion.tracks` entry by entry by name (issue #552) — an entry the recipe drafts replaced or inserted, one it replaces removed, every other entry kept with its bytes and its place, and a hand edit to an entry the recipe owns refused by name (`PROPOSE_WRITE_CONFIG_CONFLICT`) rather than dropped; a section the input lacks is inserted; with `--from <previous config>` (issue #571) an entry equal to the previous recipe's draft is the recipe's as well |
210
- | `config.json`, `mesh_draft.json` | `mesh-draft` | `config.json` is the config read, byte for byte, but for each drafted part's `meshes` entry; `mesh_draft.json` is spec `rig-parts-mesh-draft/1`: `rules`, `lattice_check`, `draft_check`, `figure_overdraw`, and per lattice part `part`, `mode`, `lattice`, `candidate` (with `bridges` — `units`, `joins` of `span` and `area_px2`, `area_px2`, `overdraw`, and `faint` only when an island was left out as faint — only when the candidate is a bridged one, issue #326), `delta` (under `--more-triangles` only), `readings`, `gate` (each line's `reading`, `pass`, `text`, `margin`), `note`; and `not_compared` (issue #307), only when the config holds an `auto` or `contour` entry: per such entry, in config order, `part`, `mode` and `note` — the part was neither drafted nor compared, and a config of lattices alone writes no such key |
211
+ | `config.json`, `mesh_draft.json` | `mesh-draft` | `config.json` is the config read, byte for byte, but for each drafted part's `meshes` entry; `mesh_draft.json` is spec `rig-parts-mesh-draft/1`: `rules`, `lattice_check`, `draft_check`, `figure_overdraw`, and per lattice part `part`, `mode`, `lattice`, `candidate` (with `bridges` — `units`, `joins` of `span` and `area_px2`, `area_px2`, `overdraw`, and `faint` only when an island was left out as faint — only when the candidate is a bridged one, issue #326), `delta` (under `--more-triangles` only), `readings`, `gate` (each line's `reading`, `pass`, `text`, `margin`), `note`; and `not_compared` (issue #307), only when the config holds an `auto`, `contour`, `influence` or `explicit` entry: per such entry, in config order, `part`, `mode` and `note` — the part was neither drafted nor compared, and a config of lattices alone writes no such key |
211
212
  | `rig.json`, `motion.json`, `mesh_report.json`, `images/`, `remesh.json` | `remesh` | the input revision's files, `rig.json` and `mesh_report.json` with the part's attachment and row replaced (under `--delta` the row is the input's with its counts, `bones` and influences recomputed and `mode` "delta"), every other file byte for byte; `remesh.json` is spec `rig-parts-remesh/1`: `request` (`part`, `mesh`, `mesh_sha256`, `idle_keys`, `page_edges`, `pack_shape`; under `--delta`, issue #526: `part`, `delta` — the mesh edit as read — `delta_sha256`, `ops`, `applied` — `moved`, `added`, `removed`, `constrained` — `idle_keys`, `page_edges`, `pack_shape`), `versions` (`parts`, `rigc`), `input` (`rig` — `path`, `bytes`, `sha256` per file — `config_sha256`, `parts_json_sha256`), `baseline` (`reproduced`, `not_compared`; under `--delta` `reproduced` holds one sentence: no config is built, the input is the baseline), `target` (`before`, `after`: `vertices`, `triangles`, `hull`), `preserved` (`identical`, `spliced`), `revision` (per file as `input.rig`), `check` (`input`, `revision`: `pass`, `measured`, `not_met`, `skipped`, `physics`, then `line` and `status` — issue #541, additive, the spec stays `rig-parts-remesh/1`: `line` is the last line `check` prints on that tree, byte for byte, and `status` every block's status as that tree's `check.json` records it, by name in the file's order — `gate`, `loop` and `seam` read from their figures, every other block its own `status`, a block the file does not write absent; `scope`) |
212
213
  | `rig.json`, `motion.json`, `mesh_report.json`, `images/`, `retune.json` | `retune` | the input revision's files, `rig.json` with `constraints` and `invariants.detached` replaced and `motion.json` with `animations.idle` replaced by the config's build, every other file byte for byte; `retune.json` is spec `rig-parts-retune/1`: `request` (`idle_keys`, `page_edges`, `pack_shape`), `versions` (`parts`, `rigc`), `input` (`rig` — `path`, `bytes`, `sha256` per file — `config_sha256`, `parts_json_sha256`), `held` (`compared`, `not_compared`), `changed` (`constraints` — each `name`, `type`, `fields` — `added`, `removed`, `idle`: `tracks_changed`, `duration` as before and after), `preserved` (`identical`, `spliced`), `revision` (per file as `input.rig`), `check` (`input`, `revision`: `pass`, `measured`, `not_met`, `skipped`, `physics`, then `line` and `status` — issue #541, additive, the spec stays `rig-parts-retune/1`: `line` is the last line `check` prints on that tree, byte for byte, and `status` every block's status as that tree's `check.json` records it, by name in the file's order — `gate`, `loop` and `seam` read from their figures, every other block its own `status`, a block the file does not write absent; `scope`) |
213
214
  | `input-check.json` | `remesh --record-input-check`, `retune --record-input-check` | spec `rig-parts-input-check/1` (issue #617, additive): `versions` (`parts`, `rigc` — `rigc --version`'s whole output), `options` (`page_edges`, `pack_shape`, `requirements` — null, or `path` as resolved and `sha256`), `rig` and `parts` (`dir` as resolved, `files` — `path`, `bytes`, `sha256` per file: every file under `--rig`; `parts.json` and every file under `parts/`), `check` (the input's check side as `remesh.json` carries it); `--input-check` reads it back, and either command's serves the other |
214
215
  | the scene report | `compose` | spec `spine-parts-scene-report/1` |
215
216
  | `idle.png`, `idle-indexed.png`, `idle.gif` | `loop`, `build --loop` | APNG and GIF encodings of the rendered idle |
216
217
 
218
+ Issue #705 pins setup-seam acceptance to one source-relative scale1 union U of the authored stage and all actual drawn base/checked-set still vertices. U is snapped relative to the source origin, including odd-width half phase.
219
+ The existing seam fields and pair pictures use that grid; source/blink and
220
+ motion-root frames are unchanged. `sets.<name>` gates its affected numerator
221
+ on the same fixed base source-cell denominator A. Non-scenes count the whole U numerator; scenes retain original border and outside-authored exclusions. Padding never enlarges A. Base failure OR any affected-set
222
+ failure remains overall failure, with mean 1.0, levels 40/80 and aggregate 50
223
+ unchanged. Added `seam_scope` identifies `source-grid/base` or
224
+ `source-grid/affected-set`, `denominator_px`, canonical `whole`, diagnostic
225
+ `auto_frame_raw` (unrounded mean, display mean, support, counts, scale, viewport),
226
+ effect/inheritance reasons, semantic drawing changes and named unavailability,
227
+ `domain.states` state/frame/piece/bounds/pose identity, and each raw pair's
228
+ whole/affected/inherited counts and reasons. `whole_pairs`
229
+ keeps complete canonical raw pair data (boxes/cut metadata included), omitting
230
+ `picture` unless its image exists. Semantic signatures preserve original source
231
+ attachment UVs/topology/weights, own image content and world vertices/colour,
232
+ not atlas pages/UVs or global piece ordinals. Unknown/no-art support stays conservative.
233
+ Renderer metadata and exact raster reads use the promised `rig-c/render-shared` entry (rig-c >=2.69.0 <3.0.0). It registers no Spine runtime; where that runtime resolves from rig-c's own package root, the existing `rig-c/render` entry registers the official Spine side explicitly. An install without Spine keeps rig-c's own candidate chooser and gate; candidate or loader failures never select a guessed fallback.
234
+
235
+ An unavailable, nonfinite, unrepresentable or oversized union, or nonempty official pinned.outside, refuses `CHECK_SEAM_DOMAIN`. Geometry margins outside the authored canvas are included in U, not treated as opaque-clip evidence. State-by-state geometry reads retain bounds/identities rather than all decoded pages or poses. `--keep-stills` keeps
236
+ canonical frames in `setup_still/` and fitted diagnostics in `setup_still_auto/`.
237
+ There is one extra seam render per checked state and no extra compile/gate.
238
+
239
+ Issue #716 adds `seam_scope.population` on a measured base or checked set,
240
+ without changing that metric or its consumers. Before RGB error is read, each
241
+ included comparison sample is attributed by the existing alpha-above0,
242
+ top-two-of-2x2 reference rule. `basis` names that rule; `pair_count` and `pairs`
243
+ name only genuine observed two-part footprints in source draw order.
244
+ `single_art` and `no_reference_art` remain separate buckets. Each row's
245
+ `whole_sample_px` equals `scope_sample_px + inherited_sample_px`; base scope
246
+ equals whole, and a set uses the unchanged semantic effect mask. The sum of
247
+ whole buckets equals `measured_sample_px`, not the mean denominator A. Scenes
248
+ retain their existing exclusions. A zero-error comparison can have named pair
249
+ support; no genuine pair is explicit, while an unmeasured seam retains SKIP
250
+ and no population. This is reference support, not joint or physical-gap
251
+ measurement. Existing sparse error rows, boxes, pictures, flags, thresholds,
252
+ verdicts, gates and CLI consumer counts are unchanged; no zero-error picture is
253
+ created and no new bar or refusal is added.
254
+
255
+
217
256
  Skeleton alternate registration accepts an optional `anchor` mapping of one or
218
257
  two body-18 keypoints to declared base-bone origins (issue #543). One pair holds
219
258
  scale at 1; two determine scale and offset. The registration bars and painting
@@ -250,7 +289,7 @@ in the package.
250
289
 
251
290
  ## rig-c
252
291
 
253
- `dependencies` takes `rig-c` `^2.33.0`: 2.33.0 or any later 2.x. Bun 1.2 or later
292
+ `dependencies` takes `rig-c` `^2.69.0`: 2.69.0 or any later 2.x. Bun 1.2 or later
254
293
  runs the package (`engines`). What this package relies on in rig-c, every import
255
294
  read off `src/` and `cli.ts`:
256
295
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/parts",
3
- "version": "1.60.2",
3
+ "version": "1.62.0",
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": {
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "ag-psd": "^31.0.2",
67
- "rig-c": "^2.60.0"
67
+ "rig-c": "^2.69.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@esotericsoftware/spine-core": "4.3.13",
@@ -0,0 +1,115 @@
1
+ /** Per-covered-part alternate sources; all coordinates and pixels stay in their original run. */
2
+ import type { Cut, Limb, PlanEntry } from './config.ts';
3
+ import type { OtherLimbs } from './assemble.ts';
4
+ import { refuseIfAny, type Problem } from './errors.ts';
5
+ import { readLayerTag } from './tags.ts';
6
+
7
+ export interface AlternateLayerSources {
8
+ plan: PlanEntry[];
9
+ cuts: Cut[];
10
+ limbs: Record<string, Limb>;
11
+ /** Cut output -> independently selected piece layer; its from still names the parent's own source. */
12
+ cutLayers: ReadonlyMap<string, string>;
13
+ /** Effective source name -> original logical source, only for sources split across layers. */
14
+ groups: ReadonlyMap<string, string>;
15
+ }
16
+
17
+ /** Resolve output names before the stage checks required layers. Never mutate the base plan or limb declarations. */
18
+ export function alternateLayerSources(
19
+ plan: PlanEntry[], cuts: Cut[], limbs: Record<string, Limb>, covered: ReadonlySet<string>, layers?: Readonly<Record<string, string>>,
20
+ ): AlternateLayerSources {
21
+ if (layers === undefined || Object.keys(layers).length === 0) return { plan, cuts, limbs, cutLayers: new Map(), groups: new Map() };
22
+ const problems: Problem[] = [];
23
+ const planByName = new Map(plan.map(p => [p[0], p]));
24
+ const cutByName = new Map(cuts.map(c => [c.into, c]));
25
+ const segments = Object.values(limbs).flatMap(l => l.segments);
26
+ const sourceOf = (part: string): string => segments.find(s => s.part === part)?.from ?? part;
27
+ const rowOf = (source: string): PlanEntry | undefined => planByName.get(cutByName.get(source)?.from ?? source);
28
+ for (const [part, layer] of Object.entries(layers)) {
29
+ const at = `alternate layers.${part}`;
30
+ if (!covered.has(part)) problems.push({ code: 'CONFIG_SET_LAYERS', object: at, detail: `names "${part}", which the set does not cover; name a covered, nonhidden part` });
31
+ if (rowOf(sourceOf(part)) === undefined) problems.push({ code: 'ASSEMBLE_ALT_LAYER_SOURCE', object: at, detail: `"${part}" has no planned layer source; a painting patch cannot take a run layer — declare a layer-backed plan part instead` });
32
+ if (typeof layer !== 'string' || readLayerTag(layer) === null) problems.push({ code: 'CONFIG_TAG_KNOWN', object: at, detail: `is ${JSON.stringify(layer)}; a See-through tag or author:<label> layer name is required` });
33
+ }
34
+ refuseIfAny(problems);
35
+ const occupied = new Set([...planByName.keys(), ...cutByName.keys(), ...segments.map(s => s.part)]);
36
+ const variants = new Map<string, Map<string, string>>();
37
+ const madePlans = new Map<string, PlanEntry[]>();
38
+ const madeCuts = new Map<string, Cut[]>();
39
+ const cutLayers = new Map<string, string>();
40
+ const originalTag = (source: string): string => (rowOf(source) as PlanEntry)[2];
41
+ const chosen = (part: string, source: string): string => Object.hasOwn(layers, part) ? layers[part] : originalTag(source);
42
+ const variant = (source: string, layer: string): string => {
43
+ let choices = variants.get(source);
44
+ if (choices === undefined) { choices = new Map(); variants.set(source, choices); }
45
+ const existing = choices.get(layer);
46
+ if (existing !== undefined) return existing;
47
+ let name = source;
48
+ if (choices.size > 0) {
49
+ let n = 1;
50
+ do { name = `${source}_layer_${n++}`; } while (occupied.has(name));
51
+ occupied.add(name);
52
+ }
53
+ choices.set(layer, name);
54
+ const cut = cutByName.get(source);
55
+ if (cut !== undefined) {
56
+ const parentLayer = chosen(cut.from, cut.from);
57
+ const next = { ...cut, into: name, from: variant(cut.from, parentLayer) };
58
+ if (layer !== parentLayer) cutLayers.set(name, layer);
59
+ madeCuts.set(source, [...(madeCuts.get(source) ?? []), next]);
60
+ } else {
61
+ const row = planByName.get(source) as PlanEntry;
62
+ madePlans.set(source, [...(madePlans.get(source) ?? []), [name, row[1], layer]]);
63
+ }
64
+ return name;
65
+ };
66
+ // Direct output names keep their identity; limb-only sources follow declaration order.
67
+ for (const [name] of plan) if (covered.has(name)) variant(name, chosen(name, name));
68
+ for (const cut of cuts) if (covered.has(cut.into)) variant(cut.into, chosen(cut.into, cut.into));
69
+ const selected = Object.fromEntries(Object.entries(limbs).map(([name, limb]) => [name, {
70
+ ...limb, segments: limb.segments.map(s => ({ ...s, from: variant(s.from, chosen(s.part, s.from)) })),
71
+ }]));
72
+ // Uncovered cuts can still remove art from a covered source. Keep their declared route.
73
+ for (const c of cuts) if (!variants.has(c.into)) variant(c.into, originalTag(c.into));
74
+ const consumed = new Set(segments.map(s => s.from));
75
+ for (const [name] of plan) if (!variants.has(name) && !consumed.has(name)) variant(name, originalTag(name));
76
+ const groups = new Map<string, string>();
77
+ for (const [source, choices] of variants) if (choices.size > 1) for (const name of choices.values()) groups.set(name, source);
78
+ return {
79
+ plan: plan.flatMap(([name]) => madePlans.get(name) ?? []),
80
+ cuts: cuts.flatMap(c => madeCuts.get(c.into) ?? []),
81
+ limbs: selected,
82
+ cutLayers,
83
+ groups,
84
+ };
85
+ }
86
+
87
+ /** Shared-source island rules follow every selected layer of that logical source. */
88
+ export function alternateLayerIslands(sources: readonly string[], groups: ReadonlyMap<string, string>): string[] {
89
+ return sources.flatMap(source => {
90
+ const choices = [...groups].filter(([, original]) => original === source).map(([name]) => name);
91
+ return choices.length === 0 ? [source] : choices;
92
+ });
93
+ }
94
+
95
+ /** Preserve the other limb's pose/evidence while giving each selected source its own ownership reading. */
96
+ export function alternateLayerOthers(other: OtherLimbs, groups: ReadonlyMap<string, string>): OtherLimbs {
97
+ if (groups.size === 0) return other;
98
+ const limbs: Record<string, Limb> = {}, unposed: Record<string, readonly string[]> = {}, baseArt: Record<string, OtherLimbs['baseArt'][string]> = {};
99
+ const occupied = new Set(Object.keys(other.limbs));
100
+ for (const [name, limb] of Object.entries(other.limbs)) {
101
+ let copies = [limb];
102
+ for (const source of new Set(limb.segments.map(s => s.from))) {
103
+ const choices = [...groups].filter(([, original]) => original === source).map(([effective]) => effective);
104
+ if (choices.length > 0) copies = copies.flatMap(copy => choices.map(choice => ({ ...copy, segments: copy.segments.map(s => s.from === source ? { ...s, from: choice } : s) })));
105
+ }
106
+ copies.forEach((copy, i) => {
107
+ let key = name;
108
+ if (i > 0) { let n = i; do { key = `${name}_layer_${n++}`; } while (occupied.has(key)); occupied.add(key); }
109
+ limbs[key] = copy;
110
+ unposed[key] = other.unposed[name];
111
+ baseArt[key] = other.baseArt[name];
112
+ });
113
+ }
114
+ return { ...other, limbs, unposed, baseArt };
115
+ }
package/src/assemble.ts CHANGED
@@ -322,6 +322,8 @@ export interface AssembleInput {
322
322
  patches: Patch[];
323
323
  /** `assemble.cuts`: plan parts' pixels taken into new parts by polygon (`cutPart`), placed per their `draw`. */
324
324
  cuts: Cut[];
325
+ /** Internal alternate selection: piece layer by cut output; polygon subtraction and under stay on from. */
326
+ cutLayers?: ReadonlyMap<string, string>;
325
327
  /**
326
328
  * `cuts[i].under`'s image, decoded by the caller (the stage reads no file),
327
329
  * at the cut's index: null for a cut without `under`. Absent = every cut
@@ -335,6 +337,8 @@ export interface AssembleInput {
335
337
  scene?: boolean;
336
338
  /** `config.limbs` (issue #349): the parts cut at their joints ({@link LimbCount}). Absent or empty: nothing changes. */
337
339
  limbs?: Record<string, Limb>;
340
+ /** Alternate sources with different layers retain the original joint cut bounds. */
341
+ limbSourceGroups?: ReadonlyMap<string, string>;
338
342
  /** `config.bones`, read for the limbs' joints; required with `limbs`. */
339
343
  bones?: BoneEntry[];
340
344
  /** Already normalized alternate endpoints; applied after bones have been posed. */
@@ -623,6 +627,13 @@ function squaredDistanceTo(cc: Components, W: number, label: number, at: readonl
623
627
  * set whose layer holds its one leg writes what it wrote before. A pixel the limbs wrote where the source is
624
628
  * transparent (a `cap_shape: "ball"` lower half from the cap image) is on no island and kept.
625
629
  */
630
+ /** Layer variants share the original source's segment line for ownership, without changing its pixel source. */
631
+ function logicalSourceLimb(limb: Limb, source: string, groups: ReadonlyMap<string, string>): Limb {
632
+ if (!groups.has(source)) return limb;
633
+ const original = groups.get(source);
634
+ return { ...limb, segments: limb.segments.map(s => (groups.get(s.from) ?? s.from) === original ? { ...s, from: source } : s) };
635
+ }
636
+
626
637
  function keepJointIslands(
627
638
  sources: readonly string[],
628
639
  limbs: Readonly<Record<string, Limb>>,
@@ -635,6 +646,7 @@ function keepJointIslands(
635
646
  floorShare: number,
636
647
  others?: OtherLimbs,
637
648
  tips?: Record<string, [number, number]>,
649
+ sourceGroups: ReadonlyMap<string, string> = new Map(),
638
650
  ): { counts: IslandCount[]; splits: SplitCount[]; problems: Problem[] } {
639
651
  const counts: IslandCount[] = [];
640
652
  const splits: SplitCount[] = [];
@@ -650,7 +662,7 @@ function keepJointIslands(
650
662
  const n = reading.candidates.length;
651
663
  if (n < 2) {
652
664
  // Issue #609: one island may hold both limbs, overlapping; the island rule cannot part them, the segment lines can.
653
- if (n === 1 && others !== undefined) splitOneIsland(src, b, limbs, places, parts, pieces, others, W, H, splits, problems);
665
+ if (n === 1 && others !== undefined) splitOneIsland(src, b, limbs, places, parts, pieces, others, W, H, splits, problems, sourceGroups);
654
666
  continue;
655
667
  }
656
668
  const numberOf = new Map(reading.candidates.map((l, i) => [l, i + 1]));
@@ -864,6 +876,7 @@ function splitOneIsland(
864
876
  H: number,
865
877
  splits: SplitCount[],
866
878
  problems: Problem[],
879
+ sourceGroups: ReadonlyMap<string, string> = new Map(),
867
880
  ): void {
868
881
  const mine = parts.map((q, i) => ({ q, i })).filter(({ q }) => q.of === src);
869
882
  if (mine.length === 0) return;
@@ -903,9 +916,9 @@ function splitOneIsland(
903
916
  // The same source selection applies to every segment, without reading a part name or a layer tag.
904
917
  const taking = (l: string, all: Readonly<Record<string, Limb>>): Limb => others.line === 'whole-limb'
905
918
  ? all[l]
906
- : { ...all[l], segments: all[l].segments.filter((sg) => sg.from === src) };
919
+ : { ...all[l], segments: logicalSourceLimb(all[l], src, sourceGroups).segments.filter((sg) => sg.from === src) };
907
920
  const polyOf = (l: string, all: Readonly<Record<string, Limb>>): Array<[number, number]> =>
908
- others.line === 'whole-limb' ? limbPolyline(all[l], places) : sourceLimbTarget(all[l], src, places).line;
921
+ others.line === 'whole-limb' ? limbPolyline(all[l], places) : sourceLimbTarget(logicalSourceLimb(all[l], src, sourceGroups), src, places).line;
909
922
  for (const [l, all] of [...ownNames.map((l) => [l, limbs] as const), ...posed.map((l) => [l, others.limbs] as const)]) {
910
923
  const selected = taking(l, all);
911
924
  const line = polyOf(l, all);
@@ -1011,6 +1024,7 @@ function assignCapOwnership(
1011
1024
  sources: readonly string[], limbs: Readonly<Record<string, Limb>>, bones: readonly BoneEntry[],
1012
1025
  parts: readonly LimbPart[], pieces: readonly Built[], sourceOf: (name: string) => Built | null,
1013
1026
  capFrom: ReadonlyArray<CapFrom | null>, W: number, H: number, others?: OtherLimbs, tips?: Record<string, [number, number]>,
1027
+ sourceGroups: ReadonlyMap<string, string> = new Map(),
1014
1028
  ): { counts: SplitCount[]; problems: Problem[] } {
1015
1029
  const counts: SplitCount[] = [], problems: Problem[] = [];
1016
1030
  if (others === undefined) return { counts, problems };
@@ -1041,8 +1055,8 @@ function assignCapOwnership(
1041
1055
  detail: `holds ${on} cap pixels where the base draws ${l}, but the set does not pose ${unposed.map((b) => `"${b}"`).join(', ')}; a supplied pose for the other limb is required to assign the cap by its target source segments, never its base place` });
1042
1056
  }
1043
1057
  if (problems.length > before || posed.length === 0) return;
1044
- const own = sourceLimbTarget(limbs[q.limb], q.of, places);
1045
- const other = posed.map((l) => ({ l, target: sourceLimbTarget(others.limbs[l], q.of, places) }));
1058
+ const own = sourceLimbTarget(logicalSourceLimb(limbs[q.limb], q.of, sourceGroups), q.of, places);
1059
+ const other = posed.map((l) => ({ l, target: sourceLimbTarget(logicalSourceLimb(others.limbs[l], q.of, sourceGroups), q.of, places) }));
1046
1060
  for (const { l, target } of [{ l: q.limb, target: own }, ...other]) {
1047
1061
  if (target.missingEndBone !== null) problems.push({ code: 'ASSEMBLE_ALT_LIMB_POSE', object: `config.limbs.${l} (part "${q.part}", source-transparent cap, bone "${target.missingEndBone}")`,
1048
1062
  detail: `takes "${q.of}" on a segment with no supplied end; an explicit bone tip or the following segment's joint in the set's pose is required to assign its cap, never an invented endpoint` });
@@ -3800,7 +3814,9 @@ function cutLimbs(
3800
3814
  hiddenOf: (part: string) => HiddenArt | null = () => null,
3801
3815
  readHidden: (layer: string, by: string) => void = () => undefined,
3802
3816
  tips?: Record<string, [number, number]>,
3817
+ sourceGroups: ReadonlyMap<string, string> = new Map(),
3803
3818
  ): { parts: LimbPart[]; pieces: Built[]; counts: LimbCount[]; capFrom: Array<CapFrom | null> } {
3819
+ const logical = (source: string): string => sourceGroups.get(source) ?? source;
3804
3820
  const names = Object.keys(limbs);
3805
3821
  if (names.length === 0) return { parts: [], pieces: [], counts: [], capFrom: [] };
3806
3822
  const problems: Problem[] = [];
@@ -3809,7 +3825,7 @@ function cutLimbs(
3809
3825
  for (const l of names) {
3810
3826
  const covering = limbs[l].split !== undefined;
3811
3827
  limbs[l].segments.forEach((sg, k) =>
3812
- parts.push({ limb: l, segment: k, part: sg.part, of: sg.from, ...(covering ? { covering: true } : {}), record: { name: l, segment: k, of: sg.from, bone: sg.bone, ...(k === 0 ? {} : { joint: sg.joint as string, ...(sg.range === undefined ? {} : { range: [sg.range[0], sg.range[1]] as [number, number] }) }) } }),
3828
+ parts.push({ limb: l, segment: k, part: sg.part, of: sg.from, ...(covering ? { covering: true } : {}), record: { name: l, segment: k, of: logical(sg.from), bone: sg.bone, ...(k === 0 ? {} : { joint: sg.joint as string, ...(sg.range === undefined ? {} : { range: [sg.range[0], sg.range[1]] as [number, number] }) }) } }),
3813
3829
  );
3814
3830
  }
3815
3831
  const polylines = new Map(names.map((l) => [l, limbPolyline(limbs[l], places)]));
@@ -3850,10 +3866,11 @@ function cutLimbs(
3850
3866
  const counts: LimbCount[] = [];
3851
3867
  // Issue #603: which count of its cap each pixel of a lower segment's cap box was counted in, for the set exclusion.
3852
3868
  const capFrom: Array<CapFrom | null> = parts.map(() => null);
3869
+ const jobs: Array<{ src: string; b: Built; on: string[]; own: Int32Array; before: number }> = [];
3853
3870
  for (const src of sources) {
3854
3871
  const b = builtOf(src);
3855
3872
  if (b === null) continue;
3856
- const on = names.filter((l) => limbs[l].segments.some((sg) => sg.from === src));
3873
+ const on = names.filter((l) => limbs[l].segments.some((sg) => logical(sg.from) === logical(src)));
3857
3874
  const own = new Int32Array(W * H).fill(-1);
3858
3875
  const before = opaqueOf(b.r);
3859
3876
  if (before === 0) {
@@ -3878,11 +3895,17 @@ function cutLimbs(
3878
3895
  const underPolys = underNames.map((l) => polylines.get(l) as Array<[number, number]>);
3879
3896
  assignCrossedLimbs(coverIdx, polylines.get(coverLimb) as Array<[number, number]>, limbs[coverLimb].split as NonNullable<Limb['split']>, underIndices, underPolys, b.r, OPAQUE_ALPHA_ABOVE, own);
3880
3897
  }
3898
+ owners.set(src, own);
3899
+ jobs.push({ src, b, on, own, before });
3900
+ }
3901
+ // Place every cut on the selected lower source before any source is split.
3902
+ // A per-part layer change does not turn a logical elbow into two uncut layers.
3903
+ for (const { src, b, on, own } of jobs) {
3881
3904
  // Issue #360 (item 14): each joint of this part that declares cut_band has its cut placed, on the limb's own art.
3882
3905
  for (const l of on) {
3883
3906
  const li = names.indexOf(l);
3884
3907
  limbs[l].segments.forEach((sg, k) => {
3885
- if (k === 0 || sg.cut_band === undefined || sg.from !== src || limbs[l].segments[k - 1].from !== src) return;
3908
+ if (k === 0 || sg.cut_band === undefined || sg.from !== src || logical(limbs[l].segments[k - 1].from) !== logical(src)) return;
3886
3909
  const line = (lines.get(l) as Array<JointLine | null>)[k] as JointLine;
3887
3910
  const art = (x: number, y: number): boolean => x >= 0 && y >= 0 && x < W && y < H && own[y * W + x] === li && b.r.data[(y * W + x) * 4 + 3] > OPAQUE_ALPHA_ABOVE;
3888
3911
  const luma = (x: number, y: number): number => luma601(b.r.data[(y * W + x) * 4], b.r.data[(y * W + x) * 4 + 1], b.r.data[(y * W + x) * 4 + 2]);
@@ -3901,12 +3924,15 @@ function cutLimbs(
3901
3924
  placements.set(`${l}/${k}`, placed);
3902
3925
  });
3903
3926
  }
3927
+ }
3928
+ for (const { src, b, on, own, before: wholeBefore } of jobs) {
3929
+ let selectedBefore = 0;
3904
3930
  const segOverride = new Int32Array(W * H).fill(-1);
3905
3931
  const segAt = (l: string, x: number, y: number): number => {
3906
3932
  const segs = limbs[l].segments;
3907
- const first = segs.findIndex((sg) => sg.from === src);
3933
+ const first = segs.findIndex((sg) => logical(sg.from) === logical(src));
3908
3934
  let last = first;
3909
- while (last + 1 < segs.length && segs[last + 1].from === src) last++;
3935
+ while (last + 1 < segs.length && logical(segs[last + 1].from) === logical(src)) last++;
3910
3936
  return segmentOf(cutLines.get(l) as Array<JointLine | null>, first, last, x, y);
3911
3937
  };
3912
3938
  // Issue #400: when two forearm segments share `src` and their hand regions overlap, the overlap goes to the front
@@ -3914,7 +3940,7 @@ function cutLimbs(
3914
3940
  const forearms = on.flatMap((l) => {
3915
3941
  const li = names.indexOf(l);
3916
3942
  return limbs[l].segments.flatMap((sg, k) => {
3917
- if (k === 0 || sg.joint !== 'elbow' || sg.from !== src) return [];
3943
+ if (k === 0 || sg.joint !== 'elbow' || logical(sg.from) !== logical(src)) return [];
3918
3944
  const me = places.get(sg.bone) as BonePlace;
3919
3945
  return me.end === null ? [] : [{ limb: li, seg: k, elbow: me.at, wrist: me.end, isSeg: (x: number, y: number): boolean => segAt(l, x, y) === k }];
3920
3946
  });
@@ -3931,6 +3957,8 @@ function cutLimbs(
3931
3957
  const l = names[own[p]];
3932
3958
  const k = segOverride[p] >= 0 ? segOverride[p] : segAt(l, x, y);
3933
3959
  const at = parts.findIndex((q) => q.limb === l && q.segment === k);
3960
+ if (parts[at].of !== src) continue;
3961
+ if (b.r.data[p * 4 + 3] > OPAQUE_ALPHA_ABOVE) selectedBefore++;
3934
3962
  rasters[at].data.set(b.r.data.subarray(p * 4, p * 4 + 4), p * 4);
3935
3963
  if (b.region === null || b.region.data[p] === 1) regions[at].data[p] = 1;
3936
3964
  }
@@ -3938,6 +3966,7 @@ function cutLimbs(
3938
3966
  owners.set(src, own);
3939
3967
  const shares = parts.map((q, i) => ({ q, i })).filter(({ q }) => q.of === src);
3940
3968
  const counted = shares.map(({ q, i }) => ({ part: q.part, px: opaqueOf(rasters[i]) }));
3969
+ const before = sourceGroups.has(src) ? selectedBefore : wholeBefore;
3941
3970
  const sum = counted.reduce((a, c) => a + c.px, 0);
3942
3971
  if (sum !== before) {
3943
3972
  problems.push({ code: 'ASSEMBLE_COUNTS_ADD_UP', object: `part "${src}" (config.limbs)`, detail: `opaque px: ${before} before the limbs, ${sum} over their parts; equal is required (a bug in the assembler, not in the inputs)` });
@@ -4379,6 +4408,12 @@ export function assemble(input: AssembleInput): AssembleResult {
4379
4408
  // Issue #490: when generation.control.skeleton is present, split merged arm layers (or refuse when sleeve and drape share one colour).
4380
4409
  const full = input.keySkeleton === undefined ? fullArmSplit : splitMergedArmRuns(fullArmSplit, input.resolution, frame, source.width, source.height, input.keySkeleton);
4381
4410
  const plan = mergedArmSplitPlan(armSplitPlan(input.plan, input.armSplit), full);
4411
+ const cutLayerPlan: PlanEntry[] = input.cuts.flatMap(c => {
4412
+ const tag = input.cutLayers?.get(c.into);
4413
+ const parent = plan.find(([name]) => name === c.from);
4414
+ return tag === undefined || parent === undefined ? [] : [[c.into, parent[1], tag]];
4415
+ });
4416
+ const sourcePlan = plan.flatMap(row => [row, ...cutLayerPlan.filter(([name]) => input.cuts.some(c => c.into === name && c.from === row[0]))]);
4382
4417
  // Issue #492: in two-run mode, check that head:face covers >= 75% of full:face's silhouette on the head canvas
4383
4418
  // (after applying head_face_underfill when declared). Skip only on a single-run subset (a mouth-only or clothes-only alternate).
4384
4419
  const checkHeadFace =
@@ -4390,7 +4425,7 @@ export function assemble(input: AssembleInput): AssembleResult {
4390
4425
  const head = headFacePrep.head;
4391
4426
  const padRecord = singleRunPadRecord(single, source.width, source.height, input.resolution, frame);
4392
4427
  if (single) checkSingleRun(full, plan, extend);
4393
- checkPlanAgainstRuns(plan, extend, full, head);
4428
+ checkPlanAgainstRuns(sourcePlan, extend, full, head);
4394
4429
  const { W, H } = frame;
4395
4430
  const srcr = sourceInRig(source, W, H);
4396
4431
  // Issue #359: a part's hidden-art layer is the under of a cut that names none — and, with one named, a refusal, since
@@ -4433,9 +4468,9 @@ export function assemble(input: AssembleInput): AssembleResult {
4433
4468
  const layers = runLayers(set, input.resolution);
4434
4469
  if (run === 'full') fullTags.push(...layers.filter((l) => l.opaqueRunPx > 0).map((l) => l.tag));
4435
4470
  const rigLayers = layers.map((l) => layerToRig(l.canvas, frame, run));
4436
- const rank = planRanks(layers.map((l) => l.tag), run, plan);
4471
+ const rank = planRanks(layers.map((l) => l.tag), run, sourcePlan);
4437
4472
  const keep = layers.map((l, i): Mask | null => {
4438
- if (input.limbUnderCover !== true || !plan.some(([name, ru, tag]) => limbPlans.has(name) && ru === run && tag === l.tag)) return null;
4473
+ if (input.limbUnderCover !== true || ![...plan, ...cutLayerPlan].some(([name, ru, tag]) => (limbPlans.has(name) || limbSources.has(name)) && ru === run && tag === l.tag)) return null;
4439
4474
  const mask = newMask(W, H);
4440
4475
  const cover = newMask(W, H);
4441
4476
  for (let p = 0; p < W * H; p++) {
@@ -4569,7 +4604,7 @@ export function assemble(input: AssembleInput): AssembleResult {
4569
4604
  }
4570
4605
  return { x0, y0, x1, y1, opaque };
4571
4606
  };
4572
- plan.forEach(([name, run, tag], pi) => {
4607
+ const buildSource = (name: string, run: Run, tag: string, pi: number): Built | null => {
4573
4608
  const key = `${run}:${tag}`;
4574
4609
  const src = rig.get(key) as Raster;
4575
4610
  const r: Raster = { width: W, height: H, data: new Uint8ClampedArray(src.data) };
@@ -4593,9 +4628,16 @@ export function assemble(input: AssembleInput): AssembleResult {
4593
4628
  object: `part "${name}" (${key}, config.assemble.plan[${pi}])`,
4594
4629
  detail: `has 0 pixels with alpha above ${OPAQUE_ALPHA_ABOVE} in the rig (${x1 < 0 ? 'no pixel at all' : 'only fringe below it'}; ${ghost[key]} ghost px removed in the run); a part with at least one opaque pixel is required — drop it from the plan or take the tag from the other run`,
4595
4630
  });
4596
- return;
4631
+ return null;
4597
4632
  }
4598
- built[pi] = { key, r, st, extendKeys, trace, merged, region: null };
4633
+ return { key, r, st, extendKeys, trace, merged, region: null };
4634
+ };
4635
+ plan.forEach(([name, run, tag], pi) => { built[pi] = buildSource(name, run, tag, pi); });
4636
+ // Snapshot independent piece pixels before any parent's subtraction or under fill.
4637
+ const cutSources = cuts.map(c => {
4638
+ const pi = plan.findIndex(([name]) => name === c.from);
4639
+ const row = plan[pi], tag = input.cutLayers?.get(c.into);
4640
+ return tag === undefined ? null : buildSource(c.from, row[1], tag, pi);
4599
4641
  });
4600
4642
  const silhouette = seamRule === 'silhouette' || patches.some((q) => q.alpha === 'silhouette') ? figureSilhouette(srcr) : null;
4601
4643
  const cut = patches.map((q, i) => {
@@ -4729,6 +4771,15 @@ export function assemble(input: AssembleInput): AssembleResult {
4729
4771
  cutCounts.push(c);
4730
4772
  });
4731
4773
  });
4774
+ // Parent partition counts and under use the removed parent art above. Only
4775
+ // the emitted piece (and any limb cut from it) reads this independent source.
4776
+ cutSources.forEach((source, i) => {
4777
+ if (source === null) return;
4778
+ const m = cutMasks[i], r = newRaster(W, H);
4779
+ for (let p = 0; p < W * H; p++) if (m.data[p] === 1) r.data.set(source.r.data.subarray(p * 4, p * 4 + 4), p * 4);
4780
+ if (opaqueOf(r) === 0) empty.push({ code: 'ASSEMBLE_CUT_PIXELS', object: `config.assemble.cuts[${i}] (part "${cuts[i].into}")`, detail: `takes 0 opaque pixels from selected ${source.key}; draw its polygon over that layer's art` });
4781
+ pieces[i] = { ...source, r, region: m, merged: mergedIn(source, m) };
4782
+ });
4732
4783
  refuseIfAny(empty);
4733
4784
  // In cut order, as the config lists them.
4734
4785
  cutCounts.sort((a, b) => cuts.findIndex((q) => q.into === a.into) - cuts.findIndex((q) => q.into === b.into));
@@ -4749,7 +4800,7 @@ export function assemble(input: AssembleInput): AssembleResult {
4749
4800
  const ci = cuts.findIndex((q) => q.into === name);
4750
4801
  return ci >= 0 ? pieces[ci] : null;
4751
4802
  };
4752
- const lim = cutLimbs(input.limbs ?? {}, input.bones ?? [], input.caps ?? new Map(), W, H, limbSource, opaqueOf, mergedIn, count, (name) => hiddenArt.get(name) ?? null, (layer, by) => hiddenUses.get(layer)?.push(by), input.boneTips);
4803
+ const lim = cutLimbs(input.limbs ?? {}, input.bones ?? [], input.caps ?? new Map(), W, H, limbSource, opaqueOf, mergedIn, count, (name) => hiddenArt.get(name) ?? null, (layer, by) => hiddenUses.get(layer)?.push(by), input.boneTips, input.limbSourceGroups);
4753
4804
  // Issue #564: and the cap a run's own layer fills above its upper joint, read once the limbs are cut.
4754
4805
  if (bands !== null) refuseIfAny(limbBands(cuts, pieces, input.limbs ?? {}, input.bones ?? [], W, H, (l, k) => lim.parts.find((q) => q.limb === l && q.segment === k)?.record.cap, input.boneTips).problems);
4755
4806
  const limbPieces = lim.pieces;
@@ -4762,10 +4813,10 @@ export function assemble(input: AssembleInput): AssembleResult {
4762
4813
  const islandKept =
4763
4814
  (input.limbIslands ?? []).length === 0
4764
4815
  ? { counts: [], splits: [], problems: [] }
4765
- : keepJointIslands(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, W, H, input.islandFloor ?? ISLAND_FLOOR_SHARE, input.otherLimbs, input.boneTips);
4816
+ : keepJointIslands(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, W, H, input.islandFloor ?? ISLAND_FLOOR_SHARE, input.otherLimbs, input.boneTips, input.limbSourceGroups);
4766
4817
  refuseIfAny(islandKept.problems);
4767
4818
  const capAssigned = input.capOwnership === 'source' ? { counts: [], problems: [] }
4768
- : assignCapOwnership(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, lim.capFrom, W, H, input.otherLimbs, input.boneTips);
4819
+ : assignCapOwnership(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, lim.capFrom, W, H, input.otherLimbs, input.boneTips, input.limbSourceGroups);
4769
4820
  refuseIfAny(capAssigned.problems);
4770
4821
 
4771
4822