rig-parts 1.55.2 → 1.57.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/AUTHORING.md CHANGED
@@ -106,9 +106,9 @@ read by no CPU stage).
106
106
  | `assemble.rig_scale` | assemble — the rig is `trunc(w × rig_scale)` x `trunc(h × rig_scale)`, and every rig-px value after it (`bones`, `meshes`, `motion`, `patches`, `cuts`) is in that rig's pixels; `check --source` (`CHECK_SOURCE_SIZE`) and `compose` (`SCENE_RIG_SCALE_AGREES`) read it back off `parts.json` | authored; rig pixels per source pixel. 0.5 in both examples (a 1664x2432 painting makes an 832x1216 rig). **Keep the figure about 1,100 to 1,200 rig px tall** — the `H` of `propose`'s `mesh spacing:` note, the height of the parts' boxes together — so for another painting, about 1,150 over the figure's height in painting px: that is the size the proposer's spacing divisor was calibrated at (H 1106–1185, the `mesh spacing` note says so) and the size of the two examples `check`'s bars are derived from, and the proposer and `check` also hold fixed rig-px values that do not scale with it (the fringe's 10 px step, the trunk segments' 18, 20, 30 and 100 px, the 15 px wrist tolerance, the 10-row pendant floor, the seam bar's 50 rig px over 40). What else it trades, measured on `demo` with the README loop from a fresh config at 0.25, 0.5 and 1 (issue #345, rig-c 2.47.1): the same plan and the same ten chains; every bar but the one the uncorrected `demo` always fails (`bottomwear` `TIP_OVER_ROOT`, the README loop's `RL01`) passing at all three; the atlas page 418x606, 832x1205 and 1825x2047; the figure's mesh spacing 16, 32 and 64, so 830, 868 and 932 triangles; the breath 2.5 % of a torso that scales with it; and the proposed bones, scaled to 0.5, off the 0.5 proposal's by up to 38 px at 0.25 and 22.5 px at 1 (the hairpin's origin; the skirt roots 20 and 10.5) — the fixed-px values above. `propose` records it on the proposal as `proposed_rig_scale` (issue #354), and changing `assemble.rig_scale` after the rig sections are written is refused (`CONFIG_PROPOSED_RIG_SCALE`): without that refusal `demo`'s tracked config built at 0.25 gated green and `check` failed only `TIP_OVER_ROOT` on both sleeves (`propose --from-config` named 54 `LINT` lines, links off the art) — re-run `assemble` and `propose` at the new scale. Absent: `CONFIG_FIELD_PRESENT`; 0, negative or not a number: `CONFIG_FIELD_TYPE`; a rig under 1x1: `ASSEMBLE_RIG_SIZE` |
107
107
  | `assemble.plan` | assemble; also the list every `meshes`/`regions` key must come from | **proposed** by `assemble --propose-plan`. `[part name, "full" \| "head", See-through tag]`, in draw order back to front. Names are free; roles come from the tag. A layer the author made and added to a run takes `author:<label>` in the tag's place, and has no role (§5, *A layer the author made*). When `generation.control.skeleton` is present and a full-run `handwear-r` or `handwear-l` layer merges sleeve, bare hand and overgarment drape into one layer — a skin-coloured hand cluster (`>= 40` run px, `GHOST_MIN_AREA`, measured `516..4,787` run px across the 9-standee corpus) lies within `0.35` forearm lengths of `<s>_wrist` and non-skin pixels reach more than `1.0x` the forearm length (`<s>_elbow -> <s>_wrist`) below `<s>_wrist` (issue #490; measured `-0.15x..0.45x` on the 6 clean standees vs `1.25x..2.02x` on the 3 merged standees, placing `1.0x` inside the `0.45x..1.25x` gap) — the layer is split into `drape-<s>`, `handwear-<s>` and `hand-<s>` (back to front) when the Euclidean RGB distance between the sleeve median colour above `<s>_wrist` and the drape median colour below `<s>_wrist` is at least `80` (`ARM_DRAPE_COLOR_DISTANCE`, measured `103.6..236.0` on the two distinct-colour merged standees vs `20.8..28.2` on the same-colour merged standee, placing `80` between `28.2` and `103.6`), or refused with `SEETHROUGH_ARM_RUN_MERGED` when the distance is under `80` |
108
108
  | `assemble.extend_below_crop` | assemble | **proposed** with the plan: `{part, run, tag}` — a head-run part that reaches the bottom of the head crop is continued from a full-run layer, whole connected components |
109
- | `assemble.patches` | assemble; `meshes`/`regions` keys may name them too | **authored**, optional: `[{name, box, alpha, draw}]` — an extra part cut from the **painting** itself, for figure no See-through layer holds (a hem both runs dropped). `box` is `[x0, y0, x1, y1]` in **rig** pixels, `x1`/`y1` exclusive — the space of `parts.json` and `recomposite_rig.png`, where the hole is found; `alpha` is `"silhouette"` (the painting's figure silhouette inside the box, the one `--seam silhouette` uses) or `"box"` (the whole box); `draw` is `"back"`, `"front"` or `{"before": "<plan part>"}`. A patch is always a region: its bone is `regions.<name>`, in the one place every region's bone lives, and a `meshes` entry for it is refused. See §5 for how to place one |
109
+ | `assemble.patches` | assemble; `meshes`/`regions` keys may name them too | **authored**, optional: `[{name, box, alpha, draw}]` — an extra part cut from the **painting** itself, for figure no See-through layer holds (a hem both runs dropped). `box` is `[x0, y0, x1, y1]` in **rig** pixels, `x1`/`y1` exclusive — the space of `parts.json` and `recomposite_rig.png`, where the hole is found; `alpha` is `"silhouette"` (the painting's figure silhouette inside the box, the one `--seam silhouette` uses) or `"box"` (the whole box); `draw` is `"back"`, `"front"` or `{"before": "<plan part>"}`. A patch is always a region: its bone is `regions.<name>`, in the one place every region's bone lives, and a `meshes` entry for it is refused. `draw` sets assembled part order; an exclusively bound limb rider's final rig slot joins that limb's block (see the limbs subsection). See §5 for how to place one |
110
110
  | `assemble.cuts` | assemble; `meshes`/`regions` keys may name the new parts too, and must (each is a part like any other) | **authored**, optional (issue #170): `[{from, into, polygon, draw, overlap, under, under_fill}]`, `under` and `under_fill` optional — a plan part's layer cut by a polygon the author draws: the pixels of plan part `from` whose **centre** lies inside `polygon` (even-odd; a centre exactly on an edge is outside) leave `from` and make the new part `into`, colour and alpha, so every pixel of the layer ends in exactly one of the two. `polygon` is `[[x, y], …]`, at least three points, non-negative integer **rig** pixels — the space of `parts.json` and of the patches' boxes. The file that shows the layer in those coordinates is `assemble`'s own `rig/parts/<from>.png`, placed at its `parts.json` `x`, `y` (the PNG's pixel `(i, j)` is rig pixel `(x + i, y + j)`), or `render/recomposite_rig.png`, the whole rig 1:1; the contact sheets (`sheet`) are scaled and carry no coordinates. `draw` is `"back"`, `"front"` or `{"before": "<plan part>"}`, as for a patch (to keep the setup pose, draw the piece immediately in front of `from` — `{"before": "<the plan part after from>"}`, or `"front"` when `from` is the last plan part; `{"before": "<from>"}` draws it behind `from`, which `under` refuses as `ASSEMBLE_UNDER_DRAW` because the fill would hide it). `from` must be a plan part (`CONFIG_NAME_RESOLVES`; a patch or another cut's piece is refused; a part a limb takes may be cut where no segment of the limb holds it, issue #564, §5 *Limbs*), `into` a new name (`CONFIG_PART_UNIQUE`), the polygon three or more integer points (`CONFIG_FIELD_TYPE`). The piece's `parts.json` record carries `from`'s `<run>:<tag>` and its own counts, each split from the layer's by where the pixel lies; it is a mesh or a region under its own name, and the coverage rule holds it like a plan part. What the config cannot know the stage refuses: a polygon point past the rig (`ASSEMBLE_CUT_INSIDE`), two cuts of one part sharing a pixel (`ASSEMBLE_CUT_OVERLAP`), a cut that takes none of the layer's opaque pixels or leaves `from` none (`ASSEMBLE_CUT_PIXELS`), a cut of a part a limb takes that takes a pixel a segment of the limb holds (`ASSEMBLE_CUT_CROSSES_LIMB`). `overlap` is required, a non-negative integer of rig pixels with no default (`CONFIG_FIELD_TYPE`): the **band** — the polygon's pixels within `overlap` px of its edge by Chebyshev distance (the polygon's mask less its erosion by a `2 * overlap + 1` square) — stays in `from` as well as going to the piece, so the piece's resampled edge has art under it; the counts stay a strict partition and the band is the base's extra copy, printed on the `cut:` line. At `0` the two abut and `check`'s seam bar judges the edge between them (`CHECK_SEAM_WITHIN_BAR`, §5). A band only covers the edge at rest: a piece that swings well clear of where it was painted shows the hole it leaves, and a thin piece's band shows a ghost of the piece. `under` (issue #193), optional, is the author's image of what lies under the piece: a PNG path relative to the config's directory (`CONFIG_FIELD_TYPE` unless a non-empty string), in rig pixels over the polygon's **bounding box** — the least and greatest polygon x and y, so the image is `max x − min x` by `max y − min y` and its pixel `(i, j)` is rig pixel `(min x + i, min y + j)`. Where the cut removed pixels from `from` — the piece's pixels (alpha above 0) less the band — `from` takes the image's pixel, colour and alpha wherever the image's alpha is at least the alpha the cut removed there (**filled**); elsewhere `from` stays empty there (**left empty**): a transparent pixel is the author's statement that nothing lies under it (the background, or a part drawn behind), and a less opaque one is not half-filled. The image is read nowhere else, so its pixels over the band, over the box outside the polygon or where the layer had no art never change `from`. The `cut:` line then ends `; under <n> px filled, <m> px left empty` (`n + m` is every removed pixel), so an unintended hole is a number in the log, not a guess; the filled pixels count in `from`'s `opaque_px` and `occluded_px` (the piece is drawn over them), never as visible or projected. The stage refuses: a file that is not there (`ASSEMBLE_UNDER_PRESENT`) or not a PNG (`ASSEMBLE_UNDER_DECODES`), an image not exactly the box's size (`ASSEMBLE_UNDER_SIZE`, both sizes given), an image that fills none of the removed pixels — all transparent there, or another file (`ASSEMBLE_UNDER_EMPTY`; to leave the whole hole, drop `under`), and a piece drawn behind `from` (`ASSEMBLE_UNDER_DRAW`: the fill would hide it; draw it `"front"` or `{"before": "<the plan part after from>"}`). Producing the image is the author's, by whatever means; absent, `from` keeps only its band. `under_fill` (issue #360), optional, is the one value `"colour"` (`CONFIG_FIELD_TYPE` on any other): the same pixels are filled and left empty, and a filled pixel takes the image's **colour** at the alpha the cut removed there instead of the image's alpha, so `from`'s alpha is the uncut layer's wherever the image fills and its silhouette does not grow — an opaque image over a soft edge leaves the edge soft. It applies to the part's hidden-art layer as well as to a file; a cut with neither is refused (`ASSEMBLE_UNDER_FILL_SOURCE`). The `cut:` line's filled count then says how many took the colour only: `; under 190 px filled (190 colour only, at the alpha the cut removed), 0 px left empty`. Absent, a filled pixel takes the image's colour and alpha, as above |
111
- | `assemble.alternates` | assemble, rig, check (`--set`, `--all-sets`) | **authored**, optional (issues #454, #465, #472, #473, #476): `[{name, source?, full?, head?, head_box?, parts?, hides?, cuts?, skeleton?, drawn?}]` — alternate painting sets assembled into `<out>/rig/parts/<set>_<part>.png` (`parts.json` `alternates`), attached on each covered slot in `rig.json` as `<set>_<part>` beside the base attachment, and indexed in `<out>/rig/sets.json` (`rig-parts-sets/1`: `sets.<set>.slots`, `.hides`, `.drawn` when present, and `.threshold: {yaw: 15, pitch: 12}` when the set replaces `face` on a rig with `turn` or `turn`/`tilt` slider animations). `source`, `full` and `head` may instead be given on the CLI with `--alt <name>=<source>:<full>[:<head>]`. `parts` lists the subset of parts the set replaces (default: every part not in `hides`); a **subset set** (issue #473, e.g. mouth visemes `a`, `i`, `u` with `"parts": ["mouth"]`) cuts only its covered parts from the alternate runs (refusing with `ASSEMBLE_ALT_INPUT_PRESENT` if a covered part's layer is missing or empty), writes only `{slot: "<set>_<slot>"}` in `sets.json` so `@rig-c/play`'s `setSet(name)` switches those slots while leaving every other slot on its base attachment (and `setSet(null)` restores the base pose), may be keyed on a slot attachment track in `motion.animations_from` as `{"t": …, "set": "<name>" \| null}` (`CONFIG_SET_COVERS_SLOT` if `"set"` is undeclared or does not cover the track's slot), and under `check --set <name>` counts `ANIMATIONS_DO_NOT_FOLD` only on its own covered slots; `hides` lists slots the set hides (`null` in `sets.json`). A **gesture subset set** (issue #476) covers a limb chain declared in `config.limbs.<limb>` (all of its segment `part`s; with `drawn` alone, cut at the base's joints posed to the set's own `drawn` angles by `poseBoneEntriesForDrawn`, each segment keeping the base's length; with `skeleton` (issue #539), cut at the skeleton's own joint positions by `placeBoneEntriesForSkeleton` — each covered bone the body-18 table names (`sleeve_*`, `arm_*0`/`arm_*1`, `leg_*0`/`leg_*1`) at its skeleton origin with the skeleton segment's own length and direction (`drawn` overriding the direction of a bone it names), and a covered bone the table does not name (a hand link `arm_r2`, a single `foot_r`) placed from its parent's new place — its base offset from the parent, stretched along the parent by the parent's length change and turned by its turn, so a link or a foot at the parent's end lands on the skeleton's end — with its base length and the drawn or base direction, so a foreshortened shin or forearm is cut where it is painted; naming the unsplit `from` layer, covering only some segments of the limb, or declaring polygon `cuts` on a limb set is refused with `CONFIG_LIMB_SET_JOINTS`) and carries `drawn` (or `skeleton`) for the covered bones only (giving `drawn` for an uncovered bone is refused with `CONFIG_SET_COVERS_BONE` / `RIG_SET_COVERS_BONE`; uncovered bones keep the base's `drawn`). A subset set's limb part takes no pixel that a base part drawn after it, which the set neither covers nor hides, covers at setup (issue #587): the set's attachment is drawn in the base slot's place, so that base part is drawn over it and what the set's painting shows there is that base part (shorts over a leg set's thigh top, which See-through synthesised in the set's leg layer); `assemble` clears those pixels — the base part's PNG at alpha above 8, at its `parts.json` x, y, on the shared canvas — from the set's part once its limbs are cut, before any count — its `merged_px` and its cap's record too (issue #603): a cap pixel it clears leaves the count it was in (`layer_px`, `image_px`, `upper_px`, `lower_px`, `lower_kept_px`) for the cap's `excluded_px`, written only when above 0, so every count is the written PNG's — and prints `LINT set "<set>" <part>: <n> px under <base part> excluded` per part and base part that took a pixel (n counts alpha above 8); a set that carries that base part itself (`"parts": ["thigh_l", "shin_l", "bottomwear"]`) excludes nothing and writes what it wrote before. A subset set that names one limb side of a layer more limbs take (issue #588: `"parts": ["thigh_r", "shin_r"]` where `leg_r` and `leg_l` both take the one `legs` layer) would put every pixel of that layer on its one limb, so each of its parts would hold a piece of both legs; when the set's layer holds more than one island (8-connected pixels with alpha above 8) of at least 1 % of its largest (issue #608: the ghost clean-up's own share; a smaller island is a speck, which goes with the island nearest it — the one holding the pixel centre nearest one of the speck's, none when two are equally near — and is never an island of its own), each segment part keeps the island its joints fall on — its bone's origin and the next segment's bone's origin, at the set's own bones, a joint on the island of a pixel whose square holds the point, and a joint on no island on the one island whose nearest pixel centre lies within the radius of the cap cut at that joint (`cap.radius`: an ankle just past the legwear's edge, on the shoe) — and drops the rest, once its limbs are cut and before the exclusion above, and `assemble` prints `LINT set "<set>" <part>: <layer part> holds <n> islands (8-connected, alpha above 8)[, and <s> speck(s) under 1 % of the largest (<f> px), each with the island nearest it], kept the one under <bone> [x, y] and <bone> [x, y][ (<e> px off it, within its cap's radius <r>)] (<k> px), dropped <m> (<d> px)` per part (k and d count the part's pixels above alpha 8, m the islands it lost one from, and `dropped none` when it lost none); a joint on no island with none or two within that radius, or with no cap cut at it (a limb's first joint), and a segment whose joints fall on two, are refused with `ASSEMBLE_ALT_LIMB_ISLAND` rather than guessed. A layer of one island — specks aside — may hold both legs over each other (a folded shin across the standing leg; issue #609): each of the set's segment parts then keeps the pixels nearer its own limb's segment line — the polyline of only its segments taking that source, their bone origins and the last segment's supplied tip or following segment's joint (issue #638) — than the other limb's, both in the set's pose, and gives the rest away, once its limbs are cut and before the exclusion above; a pixel whose two distances differ by 0.5 px or less (the overlap band: half a pixel, the reach by which a pixel centre is read as on a line) goes to the limb whose part there is drawn later in the base's draw order, and the `LINT set` line above counts what each part kept, gave and held in the band. The other limb stands where the set's `skeleton` places it — its keypoints place every limb bone of the body-18 table, the other leg's as well as the set's own (its `drawn` and `drawnLength` stay the covered bones') — and never at the base's place: a set that does not place it (a `drawn` set, which may not name a bone it does not cover, or a set with neither) is refused with `ASSEMBLE_ALT_LIMB_POSE` when its layer has art where the base draws that limb, and when it has none nothing says the layer holds it and the layer is cut as before; two limbs whose segment lines run closer than the limb's half-width over most of where their art can meet are refused with `ASSEMBLE_ALT_LIMB_OVERLAP`. A set that carries every limb of the layer is cut as before. For a subset set, where a limb's own source layer holds art (`alpha > 8`) under another layer of that run drawn in front (`alpha > 8`, by the projection's plan/depth order), the limb keeps its own layer pixels through projection, limb cutting, island/nearest-line assignment, base-footprint exclusion, fringe clearing and seam correction (issue #637). Those pixels are occluded, never counted as painting projection; no base footprint or painting colour replaces them. After source-art island/nearest-line assignment, a source-transparent cap pixel is assigned before protection, in both doors: its centre is compared against only the segments taking the recipient's source, at the set's supplied bones (ankle-to-toe for a separate foot source), with the existing 0.5 px overlap band and base draw order. A missing last endpoint is refused with `ASSEMBLE_ALT_LIMB_POSE`; an actual following joint may supply that endpoint, never a guessed point. An unposed other limb with base art beneath these cap pixels is likewise refused; without such overlap the existing compatible path retains the cap without inventing the other limb's pose. A pixel cleared by this assignment is never restored. `CAP_FROM_UPPER` records a copy made before assignment and alone proves no ownership: only a retained copy is protected beneath the upper segment, which is drawn over it. The source-art island selection itself is unchanged. Other retained cap pixels (from the layer or a supplied cap image) are protected under an actual front layer even where the lower source is transparent. Protection follows each assigned piece through exclusion, fringe clearing and seam correction; it never restores a pixel ownership removed. Cap pixels removed during ownership leave their original counts for `excluded_px`, just as excluded pixels do, so the cap ledger describes the written PNG. Target assignment reconciles this ledger even when there are no source-transparent cap candidates and when a direct caller does not request cover protection. Unprotected source pixels still obey the base-footprint exclusion. Missing limb/cap art is never extended or guessed. Base builds and uncovered, unexcluded sets keep their existing bytes. `skeleton` (a pose file path relative to the config's directory, `{"width": W, "height": H, "points": {…}}` with all 18 body-18 keypoints on the canvas, validated by the same rules as `generation.control.skeleton`: `CONFIG_FILE_PRESENT`, `CONFIG_IS_JSON`, `CONFIG_FIELD_TYPE`, `CONFIG_KEY_KNOWN`, `CONFIG_KEY_UNIQUE`, `CONFIG_POSE_CANVAS`, `CONFIG_POSE_KEYPOINTS`, `CONFIG_POSE_IN_CANVAS`) or `drawn` (`{<bone>: <worldDegrees>}`, each bone resolved against `bones`, `CONFIG_NAME_RESOLVES`) declares the posed angles the alternate was painted at (issue #465); when `skeleton` is given, `assemble` derives `drawn` from its 18 keypoints (filtered to covered bones on a subset set, with `drawn` overriding any bone named in both), records both `skeleton` (scaled by `assemble.rig_scale` to rig px) and `drawn` in `parts.json` `alternates` — and, when the skeleton placed the set's limb bones (issue #539), `drawnLength` (`{<bone>: <ratio>}`, each covered table bone's skeleton segment length over its base length, 6 places) and `registration` (`{offset: [dx, dy], scale}`: the similarity without rotation, about the canvas origin, that maps the skeleton's torso — the mean of its shoulders `r_shoulder`/`l_shoulder` to the mean of its hips `r_hip`/`l_hip`, read where the base declares the bone rooted there, `sleeve_*0`/`arm_*0` and `leg_*0` — onto those base bones' origins, 6 places), both also written to `sets.json`; the set's painting must be registered, its torso within 1 rig px and 1 % in scale of the base's, or the set is refused by name before any joint is cut (`ASSEMBLE_ALT_SKELETON_REGISTERED`, with the offset and scale the painting would need) — and the `rig` stage writes `<set>_*` region and mesh attachments in the bone-local frame of `poseRigBonesForDrawn(bones, drawn)` (weighting limb segments directly from `skeleton`'s joint endpoints when `skeleton` is present) and emits `drawn` in `sets.json` so `rig-pose` and `check --set <name>` / `--all-sets` pose the bones at `drawn` without rotating the already-posed art a second time |
111
+ | `assemble.alternates` | assemble, rig, check (`--set`, `--all-sets`) | **authored**, optional (issues #454, #465, #472, #473, #476): `[{name, source?, full?, head?, head_box?, parts?, hides?, cuts?, skeleton?, drawn?, tips?}]` — alternate painting sets assembled into `<out>/rig/parts/<set>_<part>.png` (`parts.json` `alternates`), attached on each covered slot in `rig.json` as `<set>_<part>` beside the base attachment, and indexed in `<out>/rig/sets.json` (`rig-parts-sets/1`: `sets.<set>.slots`, `.hides`, `.drawn` when present, and `.threshold: {yaw: 15, pitch: 12}` when the set replaces `face` on a rig with `turn` or `turn`/`tilt` slider animations). `source`, `full` and `head` may instead be given on the CLI with `--alt <name>=<source>:<full>[:<head>]`. `parts` lists the subset of parts the set replaces (default: every part not in `hides`); a **subset set** (issue #473, e.g. mouth visemes `a`, `i`, `u` with `"parts": ["mouth"]`) cuts only its covered parts from the alternate runs (refusing with `ASSEMBLE_ALT_INPUT_PRESENT` if a covered part's layer is missing or empty), writes only `{slot: "<set>_<slot>"}` in `sets.json` so `@rig-c/play`'s `setSet(name)` switches those slots while leaving every other slot on its base attachment (and `setSet(null)` restores the base pose), may be keyed on a slot attachment track in `motion.animations_from` as `{"t": …, "set": "<name>" \| null}` (`CONFIG_SET_COVERS_SLOT` if `"set"` is undeclared or does not cover the track's slot), and under `check --set <name>` counts `ANIMATIONS_DO_NOT_FOLD` only on its own covered slots; `hides` lists slots the set hides (`null` in `sets.json`). A **gesture subset set** (issue #476) covers a limb chain declared in `config.limbs.<limb>` (all of its segment `part`s; with `drawn` alone, cut at the base's joints posed to the set's own `drawn` angles by `poseBoneEntriesForDrawn`, each segment keeping the base's length; with `skeleton` (issue #539), cut at the skeleton's own joint positions by `placeBoneEntriesForSkeleton` — each covered bone the body-18 table names (`sleeve_*`, `arm_*0`/`arm_*1`, `leg_*0`/`leg_*1`) at its skeleton origin with the skeleton segment's own length and direction (`drawn` overriding the direction of a bone it names), and a covered bone the table does not name (a hand link `arm_r2`, a single `foot_r`) placed from its parent's new place — its base offset from the parent, stretched along the parent by the parent's length change and turned by its turn, so a link or a foot at the parent's end lands on the skeleton's end — with its base length and the drawn or base direction, so a foreshortened shin or forearm is cut where it is painted; naming the unsplit `from` layer, covering only some segments of the limb, or declaring polygon `cuts` on a limb set is refused with `CONFIG_LIMB_SET_JOINTS`) and carries `drawn` (or `skeleton`) for the covered bones only (giving `drawn` for an uncovered bone is refused with `CONFIG_SET_COVERS_BONE` / `RIG_SET_COVERS_BONE`; uncovered bones keep the base's `drawn`). A subset set's limb part takes no pixel that a base part drawn after it, which the set neither covers nor hides, covers at setup (issue #587): the set's attachment is drawn in the base slot's place, so that base part is drawn over it and what the set's painting shows there is that base part (shorts over a leg set's thigh top, which See-through synthesised in the set's leg layer); `assemble` clears those pixels — the base part's PNG at alpha above 8, at its `parts.json` x, y, on the shared canvas — from the set's part once its limbs are cut, before any count — its `merged_px` and its cap's record too (issue #603): a cap pixel it clears leaves the count it was in (`layer_px`, `image_px`, `upper_px`, `lower_px`, `lower_kept_px`) for the cap's `excluded_px`, written only when above 0, so every count is the written PNG's — and prints `LINT set "<set>" <part>: <n> px under <base part> excluded` per part and base part that took a pixel (n counts alpha above 8); a set that carries that base part itself (`"parts": ["thigh_l", "shin_l", "bottomwear"]`) excludes nothing and writes what it wrote before. A subset set that names one limb side of a layer more limbs take (issue #588: `"parts": ["thigh_r", "shin_r"]` where `leg_r` and `leg_l` both take the one `legs` layer) would put every pixel of that layer on its one limb, so each of its parts would hold a piece of both legs; when the set's layer holds more than one island (8-connected pixels with alpha above 8) of at least 1 % of its largest (issue #608: the ghost clean-up's own share; a smaller island is a speck, which goes with the island nearest it — the one holding the pixel centre nearest one of the speck's, none when two are equally near — and is never an island of its own), each segment part keeps the island its joints fall on — its bone's origin and the next segment's bone's origin, at the set's own bones, a joint on the island of a pixel whose square holds the point, and a joint on no island on the one island whose nearest pixel centre lies within the radius of the cap cut at that joint (`cap.radius`: an ankle just past the legwear's edge, on the shoe) — and drops the rest, once its limbs are cut and before the exclusion above, and `assemble` prints `LINT set "<set>" <part>: <layer part> holds <n> islands (8-connected, alpha above 8)[, and <s> speck(s) under 1 % of the largest (<f> px), each with the island nearest it], kept the one under <bone> [x, y] and <bone> [x, y][ (<e> px off it, within its cap's radius <r>)] (<k> px), dropped <m> (<d> px)` per part (k and d count the part's pixels above alpha 8, m the islands it lost one from, and `dropped none` when it lost none); a joint on no island with none or two within that radius, or with no cap cut at it (a limb's first joint), and a segment whose joints fall on two, are refused with `ASSEMBLE_ALT_LIMB_ISLAND` rather than guessed. A layer of one island — specks aside — may hold both legs over each other (a folded shin across the standing leg; issue #609): each of the set's segment parts then keeps the pixels nearer its own limb's segment line — the polyline of only its segments taking that source, their bone origins and the last segment's supplied tip or following segment's joint (issue #638) — than the other limb's, both in the set's pose, and gives the rest away, once its limbs are cut and before the exclusion above; a pixel whose two distances differ by 0.5 px or less (the overlap band: half a pixel, the reach by which a pixel centre is read as on a line) goes to the limb whose part there is drawn later in the base's draw order, and the `LINT set` line above counts what each part kept, gave and held in the band. The other limb stands where the set's `skeleton` places it — its keypoints place every limb bone of the body-18 table, the other leg's as well as the set's own (its `drawn` and `drawnLength` stay the covered bones') — and never at the base's place: a set that does not place it (a `drawn` set, which may not name a bone it does not cover, or a set with neither) is refused with `ASSEMBLE_ALT_LIMB_POSE` when its layer has art where the base draws that limb, and when it has none nothing says the layer holds it and the layer is cut as before; two limbs whose segment lines run closer than the limb's half-width over most of where their art can meet are refused with `ASSEMBLE_ALT_LIMB_OVERLAP`. A set that carries every limb of the layer is cut as before. For a subset set, where a limb's own source layer holds art (`alpha > 8`) under another layer of that run drawn in front (`alpha > 8`, by the projection's plan/depth order), the limb keeps its own layer pixels through projection, limb cutting, island/nearest-line assignment, base-footprint exclusion, fringe clearing and seam correction (issue #637). Those pixels are occluded, never counted as painting projection; no base footprint or painting colour replaces them. After source-art island/nearest-line assignment, a source-transparent cap pixel is assigned before protection, in both doors: its centre is compared against only the segments taking the recipient's source, at the set's supplied bones (ankle-to-toe for a separate foot source), with the existing 0.5 px overlap band and base draw order. A missing last endpoint is refused with `ASSEMBLE_ALT_LIMB_POSE`; an actual following joint may supply that endpoint, never a guessed point. An unposed other limb with base art beneath these cap pixels is likewise refused; without such overlap the existing compatible path retains the cap without inventing the other limb's pose. A pixel cleared by this assignment is never restored. `CAP_FROM_UPPER` records a copy made before assignment and alone proves no ownership: only a retained copy is protected beneath the upper segment, which is drawn over it. The source-art island selection itself is unchanged. Other retained cap pixels (from the layer or a supplied cap image) are protected under an actual front layer even where the lower source is transparent. Protection follows each assigned piece through exclusion, fringe clearing and seam correction; it never restores a pixel ownership removed. Cap pixels removed during ownership leave their original counts for `excluded_px`, just as excluded pixels do, so the cap ledger describes the written PNG. Target assignment reconciles this ledger even when there are no source-transparent cap candidates and when a direct caller does not request cover protection. Unprotected source pixels still obey the base-footprint exclusion. Missing limb/cap art is never extended or guessed. Base builds and uncovered, unexcluded sets keep their existing bytes. `skeleton` (a pose file path relative to the config's directory, `{"width": W, "height": H, "points": {…}}` with all 18 body-18 keypoints on the canvas, validated by the same rules as `generation.control.skeleton`: `CONFIG_FILE_PRESENT`, `CONFIG_IS_JSON`, `CONFIG_FIELD_TYPE`, `CONFIG_KEY_KNOWN`, `CONFIG_KEY_UNIQUE`, `CONFIG_POSE_CANVAS`, `CONFIG_POSE_KEYPOINTS`, `CONFIG_POSE_IN_CANVAS`) or `drawn` (`{<bone>: <worldDegrees>}`, each bone resolved against `bones`, `CONFIG_NAME_RESOLVES`) declares the posed angles the alternate was painted at (issue #465); when `skeleton` is given, `assemble` derives `drawn` from its 18 keypoints (filtered to covered bones on a subset set, with `drawn` overriding any bone named in both), records both `skeleton` (scaled by `assemble.rig_scale` to rig px) and `drawn` in `parts.json` `alternates` — and, when the skeleton placed the set's limb bones (issue #539), `drawnLength` (`{<bone>: <ratio>}`, each covered table bone's skeleton segment length over its base length, 6 places) and `registration` (`{offset: [dx, dy], scale}`: the similarity without rotation, about the canvas origin, that maps the skeleton's torso — the mean of its shoulders `r_shoulder`/`l_shoulder` to the mean of its hips `r_hip`/`l_hip`, read where the base declares the bone rooted there, `sleeve_*0`/`arm_*0` and `leg_*0` — onto those base bones' origins, 6 places), both also written to `sets.json`; the set's painting must be registered, its torso within 1 rig px and 1 % in scale of the base's, or the set is refused by name before any joint is cut (`ASSEMBLE_ALT_SKELETON_REGISTERED`, with the offset and scale the painting would need) — and the `rig` stage writes `<set>_*` region and mesh attachments in the bone-local frame of `poseRigBonesForDrawn(bones, drawn)` (weighting limb segments directly from `skeleton`'s joint endpoints when `skeleton` is present) and emits `drawn` in `sets.json` so `rig-pose` and `check --set <name>` / `--all-sets` pose the bones at `drawn` without rotating the already-posed art a second time |
112
112
  | `assemble.head_face_underfill` | assemble, `assemble --propose-plan` | **authored**, optional (issue #492): `boolean` (`CONFIG_FIELD_TYPE` on any other). When both runs exist and `full:face` has at least `200` opaque run px (`PROPOSE_MIN_PX`), the stage maps `full:face` into the head canvas via `fullLayerToHead` and measures how much of its hole-filled silhouette (`alpha > 8`) is covered by `head:face` (`alpha > 8`). A head-run `face` covering less than `75 %` (`HEAD_FACE_COVERAGE_FLOOR`, measured `0.0 %..48.6 %` on hollow/omitted head runs vs `84.8 %..99.6 %` on clean head runs across the 4 public examples and 9-standee corpus) is refused with `SEETHROUGH_HEAD_RUN_HOLLOW` unless `head_face_underfill: true` is declared. When `head_face_underfill: true` is declared and `head:face` exists (`opaqueRunPx >= 200`), `fullLayerToHead(full:face)` is composited under `head:face` on the head canvas (`alpha = max(headAlpha, fullAlpha)`, RGB blended by `headAlpha / 255`) before `head:face` is placed in rig space (`underfill=<N>px(full:face)` on the `face` part log line and a `face: head_face_underfill composited …` note in `assemble --propose-plan`). The fill restores transparent pixels only and leaves the cut's own edge where it is — a hollow whose edge is not under hair stays visible, and that is the author's to fix at the cut. When `head:face` has fewer than `200` opaque pixels, `SEETHROUGH_HEAD_RUN_HOLLOW` still fires even under `head_face_underfill: true` because the head run omitted the face layer and cannot supply a jawline |
113
113
  | `limbs` | assemble (the cut and the caps), rig (through `regions`), check (`LIMB_ONE_BONE`) | **proposed** by `propose --keypoints` (issue #349), then checked: `{<limb>: {segments: [{part, from, bone}, {part, from, bone, joint, range?, cap?, edge?, cap_shape?, cut_band?}, …]}}`, the upper segment first. The rule is *Limbs: cut at their joints* below the table. `part` is a new part (`CONFIG_PART_NAME`, `CONFIG_PART_UNIQUE` against the plan, patches, cuts and every other limb part); `from` a plan part or a cut's piece (`CONFIG_NAME_RESOLVES`) — the layer the segment's pixels come from, which is cut into the limb parts and is not itself made: a `meshes` or `regions` entry for it is `CONFIG_NAME_RESOLVES`, and the segments of one limb that take one part are consecutive (`CONFIG_LIMB_FROM_RUN`); `bone` a declared bone, each segment's the child of the one before (`CONFIG_LIMB_BONES_CHAIN`); the upper segment names no `joint`, `range`, `cap`, `edge`, `cap_shape` or `cut_band` (`CONFIG_KEY_KNOWN`), every other names its `joint` (`CONFIG_FIELD_PRESENT`) — the joint is its bone's origin; `range` is `[min, max]` degrees from rest with `min <= 0 <= max` (`CONFIG_LIMB_RANGE`), which `assemble` writes into the lower part's `parts.json` record and `check` poses the joint at — its two ends and its middle — reading the seam there (`SEAM_OVER_RANGE`, issue #360; rig-c needs no rotation limit); `cap` a PNG path relative to the config's directory (`CONFIG_FIELD_TYPE`); `edge` `"feather"` (issue #360), the one value it takes, and `cap_shape` `"disc"` (issue #360) or `"ball"` (issue #579) (`CONFIG_FIELD_TYPE` on any other) — the cut's geometry at that joint, *Limbs: cut at their joints* below; absent, the cut is hard and the cap the layer's half-disc of half the limb's width; `cut_band` a whole number of px, 1 or more (`CONFIG_FIELD_TYPE`), on a segment that takes the segment above's part — between two layers nothing is cut, so a band there is `CONFIG_KEY_KNOWN` — places the cut within that many px of the joint line (issue #360, *Limbs: cut at their joints*); absent, the cut is the joint line. Each limb part is attached like any part — `regions.<part>`, which must be the segment's `bone` (`CONFIG_LIMB_BONE`), or a mesh, which `check` holds to that bone alone (`LIMB_ONE_BONE`). With `limbs`, `assemble` reads `bones` too (`CONFIG_FIELD_PRESENT` without it). Absent, nothing is cut at a joint and no byte of any output moves |
114
114
  | `bones` | rig; `propose --from-config` | **proposed** by `propose`, then corrected. A single bone `{name, parent, at, tip?}` or a chain `{chain, parent, points, tip, link_inherit?}` whose links are named `<chain>0 … <chain>n`. Parents come before children. In `rig.json` each link is **turned along its chain** — `rotation` is the direction from its origin to the next link's (the last link's to `tip`) and `length` that distance (issue #73), so a physics constraint added downstream finds a lever; under `--idle-keys ctl` the link's `<link>_ctl` carries the turn and the length and the link sits at local rotation 0 beneath it. A single bone with a `tip` is turned the same way, towards its tip, with that distance as its length (issue #239); a tip on the bone's own origin is refused (`RIG_TIP_DISTINCT`). The five face bones `eye_r`, `eye_l`, `brow_r`, `brow_l` and `mouth` (by name, when one has no tip of its own) are turned to the eye line — the line through the origins of `eye_r` and `eye_l` as `bones` writes them, read image-left to image-right, drawn when parts.json holds both an `eyewhite-r` and an `eyewhite-l` part — so the blink's `scaley` squashes across the eye line on a tilted head; move an eye bone and the line moves with it. With one eyewhite or none, or an eye bone missing, the rig stage's `face axis:` line says so and they keep the page's axes. A bone under a face bone keeps the face's axis. With the line, `rig.json` also declares `invariants.axes` — one entry, `"face"`, through `eye_r` and `eye_l`, holding the turned face bones (and their controls) — so rig-c's gate holds the build to the line; the line is the one rigc draws through the same two bones, so the tolerance is only the float floor — the largest gap the emitted (float32) bones have to it, rounded up to 6 places plus one 6-place unit — and the `face axis:` line prints it. With the line the rig stage also adds `head_up` (issue #250): a slotless bone under `head`, at head's origin, turned to the eye line + 90 degrees and as long as the eye midpoint lies from head's origin along that axis — the head's frame, which a rule that needs it reads; `head` keeps its own frame, so no key on it or under it changes meaning, and a config bone of that name is refused (`RIG_HEAD_UP_NAME_FREE`). A face bone with its own `tip` is held too (issue #258), in a second entry, `"face_tips"`, when its tip lies along the line within whole-pixel rounding — a tip written in whole pixels sits at most sqrt(2)/2 px off the point of the line it stands for, so its direction may sit up to asin((sqrt(2)/2) / length) degrees off — with its tolerance measured the same way; a tip further off is the bone's own axis, and the `face axis:` line names it with its gap and that bound. A failure is rig-c's `A51_BONES_LIE_ALONG_THEIR_DECLARED_AXIS` line, which names the bone and the fix (rig-c's `docs/AUTHORING.md` §3.7 and §5.2); with no line no entry is written and A51 reports SKIP. Every region on a turned bone is turned back, so the setup pose does not move. Any other single bone keeps world rotation 0; one whose parent is a link is turned back upright. A single bone may declare `inherit` (issue #348): what it takes from its parent's transform, one of rig-c's own mode names exactly as rig-c's table spells them — `normal`, `onlyTranslation`, `noRotationOrReflection`, `noScale`, `noScaleOrReflection` (rig-c's `RigBone.inherit`) — written to that bone in `rig.json` as declared; any other spelling, `"NoScale"` included (the runtime would fold its first letter; nothing here folds or maps), is refused (`CONFIG_BONE_INHERIT`), and a chain takes no `inherit` (`CONFIG_KEY_KNOWN`). A chain may instead declare `link_inherit` (issue #369), an object mapping its own expanded link names to those same modes, for example `"link_inherit": {"leg_r1": "noScale"}`. Only the named link changes; omitted links inherit normally. A key outside this chain is `CONFIG_NAME_RESOLVES`, with this chain's valid link names in the detail; a non-object or non-string mode is `CONFIG_FIELD_TYPE`, and another mode spelling is `CONFIG_BONE_INHERIT`. The mode is forwarded to the expanded link, or to its control under `--idle-keys ctl`, by the same rule as a single bone. This is an authored opt-in: `propose` does not add it. Its setup rotation is the turn from where rig-c's own poser puts the bone with no rotation of its own under that mode, so it still stands upright (or along its tip) at the setup pose. Where the idle gives the bone a `<bone>_ctl`, the mode goes on the control: the control is the bone the parent's rotation reaches, and the bone under it inherits normally, so the idle's keys moved onto the control still turn it. A foot that does not take its shin's rotation (`noRotationOrReflection` or `onlyTranslation`) keeps its shoe level while the leg is posed (`FEET_STAY_LEVEL`, §7); which mode is the author's. `noScale` keeps a shin or shoe's shape under a scaled parent but still takes the parent's rotation: a shoe that must also stay level needs a separate rotation constraint, for example a transform constraint from an unrotated bone. This does not change the proposed feet's existing inheritance or `FEET_STAY_LEVEL` default. An automatic mesh weighted through a bone with a mode other than `normal` gets no derived amplitude (its row names the bone) and no residual envelope (rig-c's `SKINNING_RANGE_UNSUPPORTED`). Absent, `rig.json` carries no `inherit` and no byte moves |
@@ -526,6 +526,69 @@ top edge instead would close the eye upward onto the upper lid and still move wh
526
526
  above it by (1 − squash) × its height above the pivot, so the cut, not the pivot, is what
527
527
  holds the crease.
528
528
 
529
+ ### Explicit alternate endpoints (`assemble.alternates[i].tips`, issue #652)
530
+
531
+ An alternate may declare a non-empty map of bone names to `[x, y]` endpoints:
532
+
533
+ ```json
534
+ {"name": "step", "tips": {"foot_r": [108, 60], "foot_l": [92, 100]}}
535
+ ```
536
+
537
+ These are **full source-crop pixels on that alternate painting**, origin at the
538
+ top left, x right and y down. They are not the See-through resolution square,
539
+ head crop, bone-local coordinates or Spine coordinates. Unlike global
540
+ `config.bones` coordinates, which are already rig pixels, each supplied point is
541
+ converted once by `[x * rig_width / source_width, y * rig_height / source_height]`.
542
+ The accepted integer `parts.rig_size` supplies the destination dimensions; the
543
+ nominal `rig_scale` alone need not equal either actual resize ratio.
544
+
545
+ Names must be declared single bones or expanded chain links. A chain shorthand
546
+ or the implicit root is not an endpoint-bearing declared bone. Points have
547
+ exactly two finite numbers. A finite point outside the painting is allowed;
548
+ this field adds no clipping or anatomical inference. Both the full loader and
549
+ the early assemble loader validate names, including when there are no limbs.
550
+
551
+ The existing skeleton/drawn placement runs first. These endpoints then replace
552
+ only that alternate's effective bone endpoints, including a missing global tip.
553
+ Other endpoints retain the existing posed-global result. Origins, subsequent
554
+ chain-link joints, drawn rotations and body-18 remain unchanged. Supplying a tip
555
+ does not prove that its origin or an ancestor was posed. A subset may supply an
556
+ uncovered opposite-side endpoint as ownership evidence for a shared source;
557
+ it does not gain that side's attachment. Missing other-side origin evidence and
558
+ missing terminal endpoints still produce named refusals. No ankle normal,
559
+ rotation, bone name or skeleton extension invents a toe or heel.
560
+
561
+ Joint cuts, source-segment ownership and source-transparent caps read the same
562
+ normalized endpoint view. Their existing overlap band and draw-order rules do
563
+ not change. `parts.json` records optional `alternates[i].tips` in **rig-crop
564
+ pixels**, sorted by bone name, for standalone rig and one-process build to read.
565
+ Only with tips, `tips_source_size: [width, height]` records the actual positive
566
+ integer painting dimensions used in that normalization. The reader checks their
567
+ relationship to `rig_size` and `scale_rig_per_source`; rig checks configured
568
+ keys and the points normalized with those source dimensions against the record.
569
+ Rig consumes the matching record, never raw source coordinates as rig points.
570
+ If config declares tips but an older parts file has not recorded them, re-run
571
+ assemble: rig refuses instead of guessing a conversion. For a matching declared
572
+ config set, tip presence, keys and normalized values must match the record:
573
+ removing its entire `tips` field also requires reassembly, rather than keeping a
574
+ stale override. If the config set itself is entirely absent, rig accepts the
575
+ record-only path, including sets supplied by CLI extras; recorded tips still
576
+ require finite pairs, valid source-size provenance and actual configured bone
577
+ names. CLI extras themselves declare source/full/head, not tips. Missing/invalid
578
+ normalization provenance also requires reassembly. A mismatch is refused before
579
+ the rig gate or owned rig outputs. These are structural consistency checks,
580
+ not cryptographic authentication of an original painting unavailable to a
581
+ standalone rig invocation. Coherently rewritten provenance is outside that
582
+ claim. The rig's named mesh segments
583
+ read these endpoints after existing pose placement; explicit mesh coordinate
584
+ tuples retain their authored endpoint priority. No tip-derived rotation or
585
+ second y conversion is added. No `sets.json.tips` or unknown core rig field is
586
+ emitted: endpoint geometry is baked into the attachments, while the existing
587
+ `drawn` metadata keeps its existing consumer meaning.
588
+
589
+ With `tips` absent the existing path emits no new field or log line. This is an
590
+ explicit endpoint mechanism, not an ownership claim based on anatomical names.
591
+
529
592
  ### Limbs: cut at their joints (`limbs`, issue #349)
530
593
 
531
594
  **A limb is separate parts, cut at its joints, each rigid on its own bone.** The upper arm,
@@ -538,6 +601,79 @@ section about fitting a mesh to motion — the weight cut, the contour and autom
538
601
  the physics recipe — is for the parts that have no joints: the skirt, the clothing, the hair,
539
602
  the torso.
540
603
 
604
+ **Assembled order and final rig slot order are distinct** (issue #646). Assembly keeps
605
+ `parts.json` and its recomposite in the authored part order, including each patch's
606
+ `draw`. At rig time, each declared limb gathers its exclusively bound rider slots
607
+ locally into its existing segment block. The block's anchor is its first segment
608
+ slot in the original setup draw order; block-anchor order and each limb's owned
609
+ slots' internal relative order are stable. This applies to every declared limb,
610
+ without inferring an anatomical pair or a torso target. A front painting patch
611
+ bound exclusively to a foot therefore stays in front of that limb's own earlier
612
+ slots, but need not remain globally in front of every unrelated slot in the rig.
613
+
614
+ Ownership reads explicit region bindings and every weight of every base/alternate
615
+ attachment, following the bone graph to a declared segment boundary. A still slot
616
+ is read from its own binding. Mixed bindings spanning limbs, a limb and outside
617
+ bones, or attachments with different owners are nonexclusive and are not forced
618
+ into one block; complete closure is not promised across them. With no declared
619
+ limbs, rig output is unchanged. Gathering riders can cross an intervening part
620
+ whose pixels overlap them, so setup RGBA equality must be measured on the authored
621
+ input. Public generated setup comparisons are evidence for those inputs, not a
622
+ universal promise that all art keeps its compositing order.
623
+
624
+ **Explicit adjacency** (issue #647) is optional and takes effect at **rig time**,
625
+ after every base and alternate attachment has been built. For example, on an
626
+ existing limb named `unit_a`:
627
+
628
+ ```json
629
+ "layout": { "before": { "limb": "unit_b" } }
630
+ ```
631
+
632
+ Exactly one of `before` and `after` is required, and its target names exactly one
633
+ `limb` or produced `part`. It means immediately adjacent in setup slot order, with
634
+ the subject block before or after the stationary target block. It does not name
635
+ an anatomical role or request a pose depth policy. A consumed source layer is not
636
+ a produced part: name the emitted segment part instead.
637
+
638
+ Without `parts`, the subject is its whole exclusive limb block, including its
639
+ inherited riders. To move only a source-bound segment scope, write, for example:
640
+
641
+ ```json
642
+ "layout": { "parts": ["piece_a_lower"], "after": { "part": "panel" } }
643
+ ```
644
+
645
+ `parts` is a nonempty list of this limb's own **consecutive segment-part names**,
646
+ not numeric indices or rider names. List order does not reorder the art. Inherited
647
+ riders move only when every base/alternate binding belongs entirely to the selected
648
+ segment boundaries. A rider spanning selected and unselected boundaries stays
649
+ unforced, as does mixed ownership across limbs. Partial layout explicitly overrides
650
+ whole-limb closure for that scope: it never drags an unselected upper segment along
651
+ with the selected lower one. A target limb is its whole exclusive block; a target
652
+ part uses its actual generated slot family, including a still piece, without
653
+ suffix matching. A requested segment or target with mixed bindings is refused.
654
+
655
+ Only disjoint placements are supported. Self, reciprocal, chained/shared-slot,
656
+ and pair/part conflicts name both declaration paths and the shared slot; no
657
+ constraint solver chooses a winner. Internal block order and all unselected
658
+ slots' mutual order are stable. Declaring placement may change visible occlusion;
659
+ assembly's part/PNG/recomposite order and every setup seam bar remain unchanged,
660
+ so check can still refuse a setup whose occlusion differs from its authored stack.
661
+
662
+ A declared layout writes **`layout.json`**, `spec: "rig-parts-layout/1"`, beside
663
+ `rig.json` and optional `sets.json`. The companion records the SHA-256 of those
664
+ **exact final accepted bytes**, final `setup_slots`, and deterministic `placements`
665
+ with `limb`, selected segment `parts`, authored `before`/`after`, resolved `slots`
666
+ and `target_slots`. It is never a new core RigSpec field or a fictitious alternate
667
+ set. Replayed candidates re-resolve closure before their gate. All metadata checks
668
+ precede output; only a successful green undeclared `rig` removes its stale owned
669
+ companion. With no layout declaration, output and log bytes retain the preceding
670
+ limb-closure path and no companion is emitted.
671
+
672
+ Producer adjacency is **not consumer motion acceptance**. Pose 0.42 does not read
673
+ this companion. Pose issue #346 owns its actual reader and explicit depth-source
674
+ mapping, including a refusal when a part/scope has no supported depth source. Do
675
+ not infer it from names, parents, weights, an ordinal or a zero-depth fallback.
676
+
541
677
  `propose --keypoints` drafts the block from the body-18 joints (§3, *A posed figure*): an arm
542
678
  whose shoulder, elbow and wrist are given is `arm_<s>`, `upperarm_<s>` on `sleeve_<s>0` and
543
679
  `forearm_<s>` on `sleeve_<s>1`, cut at `elbow`; a leg whose hip, knee and ankle are given is
@@ -2984,10 +3120,13 @@ Do not borrow an unused See-through tag for it instead (`tail`, `wings`): `layer
2984
3120
  prints it as a body layer, `parts.json` records it as See-through's `tail`, and
2985
3121
  `propose` reads it as a tail — a role the part does not have (selftest `AS229`).
2986
3122
 
2987
- `parts.json` holds one record per part, in draw order: the plan's, with each patch
3123
+ `parts.json` holds one record per part, in **assembled** draw order: the plan's, with each patch
2988
3124
  and each cut's piece where its `draw` puts it (`"back"` patches first in their own
2989
3125
  order, then `"back"` pieces; each `{"before": X}` patch, then each such piece,
2990
- immediately behind `X`; `"front"` patches last, then `"front"` pieces). Its counts:
3126
+ immediately behind `X`; `"front"` patches last, then `"front"` pieces). This is also the
3127
+ recomposite order. The final rig locally gathers exclusively bound limb riders into
3128
+ their existing segment blocks as described above; assembled `front` does not mean
3129
+ global final-slot front when that closure moves a rider. Its counts:
2991
3130
 
2992
3131
  | field | counts |
2993
3132
  | --- | --- |
@@ -3086,6 +3225,14 @@ row in this page's `rule` and `line` tables; the selftest holds that (`TY16`).
3086
3225
 
3087
3226
  | rule | means | change |
3088
3227
  | --- | --- | --- |
3228
+ | <a id="ASSEMBLE_ALT_TIP_NAME"></a>`ASSEMBLE_ALT_TIP_NAME` | an explicit endpoint names no supplied bone | declare the single bone or expanded link |
3229
+ | <a id="ASSEMBLE_ALT_TIP_POINT"></a>`ASSEMBLE_ALT_TIP_POINT` | an explicit endpoint is not finite after normalization onto the accepted rig canvas | correct the source-crop pair and scale |
3230
+ | <a id="PARTS_ALT_TIPS"></a>`PARTS_ALT_TIPS` | alternate endpoints are not a non-empty bone-name map of finite rig-crop pairs | re-run assemble with valid source-crop tips |
3231
+ | <a id="PARTS_ALT_TIPS_SOURCE"></a>`PARTS_ALT_TIPS_SOURCE` | normalized tips lack positive integer source dimensions, or the dimensions do not produce rig_size at the recorded scale | re-run assemble to record actual normalization provenance |
3232
+ | <a id="RIG_ALT_TIPS_RECORDED"></a>`RIG_ALT_TIPS_RECORDED` | config declares tips but the parts alternate lacks their normalized record | re-run assemble before rig |
3233
+ | <a id="RIG_ALT_TIPS_SOURCE"></a>`RIG_ALT_TIPS_SOURCE` | a direct rig caller supplies endpoints without valid source-size normalization provenance | re-run assemble; do not guess dimensions from nominal scale |
3234
+ | <a id="RIG_ALT_TIPS_MATCH_CONFIG"></a>`RIG_ALT_TIPS_MATCH_CONFIG` | tip presence for a matching declared config set, or keys or values normalized using recorded source dimensions, differs from the parts record | re-run assemble after the config change; source points are never treated as rig points |
3235
+ | <a id="RIG_ALT_TIP_POINT"></a>`RIG_ALT_TIP_POINT` | a direct rig caller supplies an invalid normalized pair | re-run assemble with a finite source-crop pair |
3089
3236
  | <a id="LAYERS_INPUT_KIND"></a>`LAYERS_INPUT_KIND` | the path is neither a directory with `layers.json`, a `layers.json`, nor a `.psd` | the `--full`/`--head` path |
3090
3237
  | <a id="LAYERS_MANIFEST_PRESENT"></a><a id="LAYERS_MANIFEST_IS_JSON"></a><a id="LAYERS_FIELD_PRESENT"></a><a id="LAYERS_KEY_KNOWN"></a>`LAYERS_MANIFEST_PRESENT`, `LAYERS_MANIFEST_IS_JSON`, `LAYERS_FIELD_PRESENT`, `LAYERS_KEY_KNOWN` | the wrapper's `layers.json` is missing, unparsable, or not the wrapper's shape | the run's output directory; re-export it |
3091
3238
  | <a id="LAYERS_PNG_PRESENT"></a><a id="LAYERS_PNG_UNAMBIGUOUS"></a><a id="LAYERS_PNG_DECODES"></a><a id="LAYERS_PNG_MATCHES_BBOX"></a>`LAYERS_PNG_PRESENT`, `LAYERS_PNG_UNAMBIGUOUS`, `LAYERS_PNG_DECODES`, `LAYERS_PNG_MATCHES_BBOX` | a layer's PNG is missing, found in two places, not a PNG, or not its box's size | the run's files |
@@ -3336,6 +3483,12 @@ says why each requirement exists and what breaks without it.
3336
3483
  | <a id="RIG_KEY_FRAME_UNTURNED"></a>`RIG_KEY_FRAME_UNTURNED` | a `translate` key on a bone whose parent is a chain link turned along its chain, or a `scale`/`shear` key (a track, or the blink's `eyes`/`brows` group) on a turned link: the key would act along the link's axis, not the picture's; the detail names the track, the bone and the turn | key the chain's own parent, or key `rotate`; a link whose turn is 0 (a level chain) keeps every key |
3337
3484
  | <a id="RIG_BLINK_INSIDE_IDLE"></a>`RIG_BLINK_INSIDE_IDLE` | the blink runs outside the idle | `motion.blink.t` |
3338
3485
  | <a id="RIG_BLINK_HOLD_SPANS_A_FRAME"></a>`RIG_BLINK_HOLD_SPANS_A_FRAME` | the tree's `BLINK.hold` is shorter than one frame at `IDLE_FPS`, so for some `motion.blink.t` no idle frame — and no frame of the loop — shows the closed eye; the detail counts the phases that miss and names the first | nothing in the config: `BLINK.hold` in `src/motion.ts`, at least `1/IDLE_FPS` s (§3) |
3486
+ | <a id="CONFIG_LAYOUT_TARGET"></a>`CONFIG_LAYOUT_TARGET` | `config.limbs.<name>.layout` declares both or neither `before`/`after`, or a target declares both or neither `limb`/`part` | write one immediate placement side and one typed named target |
3487
+ | <a id="CONFIG_LAYOUT_NAME"></a>`CONFIG_LAYOUT_NAME` | a layout names no declared target limb or produced part; a consumed source layer is not an emitted part | use the declared limb or produced segment/part names printed in the detail |
3488
+ | <a id="CONFIG_LAYOUT_SCOPE"></a>`CONFIG_LAYOUT_SCOPE` | layout `parts` is empty, duplicated, nonconsecutive, foreign, or names a rider instead of an own source-bound segment part | select distinct consecutive own segment-part references; inherited riders are proven separately |
3489
+ | <a id="RIG_LAYOUT_NONEXCLUSIVE"></a>`RIG_LAYOUT_NONEXCLUSIVE` | a requested segment family/target, or an accepted replay's bindings, span owners or leave the selected segment scope across base/alternate attachments | correct the named bindings or scope; mixed ownership is never forced and no stale proof is emitted |
3490
+ | <a id="RIG_LAYOUT_UNREPRESENTABLE"></a>`RIG_LAYOUT_UNREPRESENTABLE` | the named slot family is absent, a target is not contiguous, the accepted slot population/adjacency changed, or final rig text is stale | use an emitted contiguous target and the exact final accepted source; unrelated slots are not absorbed |
3491
+ | <a id="RIG_LAYOUT_CONFLICT"></a>`RIG_LAYOUT_CONFLICT` | layout declarations share a slot, target themselves, or form a reciprocal/chained pair; both field paths are printed | declare one disjoint pair, with each participating slot in only that placement |
3339
3492
  | <a id="RIG_STILL_ROW_INSIDE_PART"></a><a id="RIG_STILL_ROW_CLEAR"></a><a id="RIG_STILL_PIECES_HAVE_ART"></a><a id="RIG_STILL_NAME_FREE"></a>`RIG_STILL_ROW_INSIDE_PART`, `RIG_STILL_ROW_CLEAR`, `RIG_STILL_PIECES_HAVE_ART`, `RIG_STILL_NAME_FREE` | a `motion.blink.still` row that is not strictly inside the part, that crosses art (a cut through art changes the render even at rest), that leaves one piece with no art, or whose `<part>_still` slot name another part already has | that entry's `row` — a row with no art between the crease and the lash line — or rename the other part |
3340
3493
  | <a id="RIG_SET_COVERS_BONE"></a>`RIG_SET_COVERS_BONE` | `assemble.alternates[i].drawn.<bone>` (issue #476): a subset set in `parts.json` `alternates` (`parts` present) states a `drawn` world angle for a bone none of its covered slots ride; the detail names the bone, the set, and the covered bones | remove the uncovered bone from that set's `drawn`, or add the part that rides it to `parts` |
3341
3494
  | <a id="RIG_INFLUENCE_REACH"></a>`RIG_INFLUENCE_REACH` | an influence mesh's `radius` is at or under the distance from its farthest lattice vertex to that vertex's nearest link (issue #378): a link pulls only when it is nearer than `radius`, so that vertex would be pulled by none. The vertex, where it is and the distance are named | a `radius` above the distance named, or a segment nearer that part of the art |
package/docs/STABILITY.md CHANGED
@@ -124,13 +124,15 @@ part name, `[i]` an entry of a list):
124
124
  - **seethrough** — required: `resolution`, `steps`, `seed`, `offload`; optional: `head_box`, `arm_split`
125
125
  - **seethrough.arm_split** — required: `order`, and one of `x` or `line` (issue #439)
126
126
  - **assemble** — required: `rig_scale`, `plan` (from plain `assemble` on); optional: `extend_below_crop`, `patches`, `cuts`, `alternates`, `head_face_underfill`
127
- - **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `drawn` (issues #454, #465)
127
+ - **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `drawn`, `tips` (issues #454, #465, #652)
128
128
  - **assemble.extend_below_crop[i]** — required: `part`, `run`, `tag`
129
129
  - **assemble.patches[i]** — required: `name`, `box`, `alpha`, `draw`
130
130
  - **assemble.patches[i].draw**, when an object — required: `before`
131
131
  - **assemble.cuts[i]** — required: `from`, `into`, `polygon`, `draw`, `overlap`; optional: `under`, `under_fill`
132
132
  - **assemble.cuts[i].draw**, when an object — required: `before`
133
- - **limbs.&lt;limb&gt;** — required: `segments` (issue #349)
133
+ - **limbs.&lt;limb&gt;** — required: `segments`; optional: `split`, `layout` (issues #349, #446, #647)
134
+ - **limbs.&lt;limb&gt;.layout** — exactly one of `before`, `after`; optional: `parts` (own consecutive segment-part references, issue #647)
135
+ - **limbs.&lt;limb&gt;.layout.before**, **limbs.&lt;limb&gt;.layout.after** — exactly one typed target: `limb` or `part`
134
136
  - **limbs.&lt;limb&gt;.segments[i]** — required: `part`, `from`, `bone`; required below a joint (i > 0): `joint`; optional below a joint: `range`, `cap`, `edge`, `cap_shape`, `cut_band`
135
137
  - **bones[i]**, a single bone — required: `name`, `parent`, `at`; optional: `tip`, `inherit`
136
138
  - **bones[i]**, a chain — required: `chain`, `parent`, `points`, `tip`; optional: `link_inherit`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-parts",
3
- "version": "1.55.2",
3
+ "version": "1.57.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": {
package/src/assemble.ts CHANGED
@@ -337,6 +337,8 @@ export interface AssembleInput {
337
337
  limbs?: Record<string, Limb>;
338
338
  /** `config.bones`, read for the limbs' joints; required with `limbs`. */
339
339
  bones?: BoneEntry[];
340
+ /** Already normalized alternate endpoints; applied after bones have been posed. */
341
+ boneTips?: Record<string, [number, number]>;
340
342
  /** Each segment's `cap` image, decoded by the caller, keyed `<limb>/<segment index>`; a segment naming a cap with none here is refused (`ASSEMBLE_LIMB_CAP_PRESENT`). */
341
343
  caps?: ReadonlyMap<string, Raster>;
342
344
  /** One run (issue #359): `head` is `full`, `headBox` {@link singleRunHeadBox}, and {@link checkSingleRun} holds the plan to it. Absent: two runs. */
@@ -632,11 +634,12 @@ function keepJointIslands(
632
634
  H: number,
633
635
  floorShare: number,
634
636
  others?: OtherLimbs,
637
+ tips?: Record<string, [number, number]>,
635
638
  ): { counts: IslandCount[]; splits: SplitCount[]; problems: Problem[] } {
636
639
  const counts: IslandCount[] = [];
637
640
  const splits: SplitCount[] = [];
638
641
  const problems: Problem[] = [];
639
- const places = bonePlaces(bones);
642
+ const places = bonePlaces(bones, tips);
640
643
  for (const src of sources) {
641
644
  const b = sourceOf(src);
642
645
  if (b === null) continue;
@@ -1007,11 +1010,11 @@ function splitOneIsland(
1007
1010
  function assignCapOwnership(
1008
1011
  sources: readonly string[], limbs: Readonly<Record<string, Limb>>, bones: readonly BoneEntry[],
1009
1012
  parts: readonly LimbPart[], pieces: readonly Built[], sourceOf: (name: string) => Built | null,
1010
- capFrom: ReadonlyArray<CapFrom | null>, W: number, H: number, others?: OtherLimbs,
1013
+ capFrom: ReadonlyArray<CapFrom | null>, W: number, H: number, others?: OtherLimbs, tips?: Record<string, [number, number]>,
1011
1014
  ): { counts: SplitCount[]; problems: Problem[] } {
1012
1015
  const counts: SplitCount[] = [], problems: Problem[] = [];
1013
1016
  if (others === undefined) return { counts, problems };
1014
- const places = bonePlaces(bones);
1017
+ const places = bonePlaces(bones, tips);
1015
1018
  const drawAt = new Map(others.drawOrder.map((name, i) => [name, i]));
1016
1019
  parts.forEach((q, i) => {
1017
1020
  const from = capFrom[i], source = sourceOf(q.of), piece = pieces[i];
@@ -3695,10 +3698,11 @@ function limbBands(
3695
3698
  W: number,
3696
3699
  H: number,
3697
3700
  caps: ((limb: string, segment: number) => CapRecord | undefined) | null,
3701
+ tips?: Record<string, [number, number]>,
3698
3702
  ): { problems: Problem[]; past: Map<number, { limb: string; joint: string; part: string; bone: string }> } {
3699
3703
  const problems: Problem[] = [];
3700
3704
  const past = new Map<number, { limb: string; joint: string; part: string; bone: string }>();
3701
- const places = bonePlaces(bones);
3705
+ const places = bonePlaces(bones, tips);
3702
3706
  const lineAbove = (l: string, k: number): JointLine | null => {
3703
3707
  const segs = limbs[l].segments;
3704
3708
  const up = places.get(segs[k - 1].bone);
@@ -3795,11 +3799,12 @@ function cutLimbs(
3795
3799
  count: (m: Mask | null, region: Mask) => number,
3796
3800
  hiddenOf: (part: string) => HiddenArt | null = () => null,
3797
3801
  readHidden: (layer: string, by: string) => void = () => undefined,
3802
+ tips?: Record<string, [number, number]>,
3798
3803
  ): { parts: LimbPart[]; pieces: Built[]; counts: LimbCount[]; capFrom: Array<CapFrom | null> } {
3799
3804
  const names = Object.keys(limbs);
3800
3805
  if (names.length === 0) return { parts: [], pieces: [], counts: [], capFrom: [] };
3801
3806
  const problems: Problem[] = [];
3802
- const places = bonePlaces(bones);
3807
+ const places = bonePlaces(bones, tips);
3803
3808
  const parts: LimbPart[] = [];
3804
3809
  for (const l of names) {
3805
3810
  const covering = limbs[l].split !== undefined;
@@ -4729,7 +4734,7 @@ export function assemble(input: AssembleInput): AssembleResult {
4729
4734
  cutCounts.sort((a, b) => cuts.findIndex((q) => q.into === a.into) - cuts.findIndex((q) => q.into === b.into));
4730
4735
 
4731
4736
  // Issue #564: a cut from a part a limb takes lies outside the limb's segments, read before the limbs are cut.
4732
- const bands = input.limbs === undefined || cuts.length === 0 ? null : limbBands(cuts, pieces, input.limbs, input.bones ?? [], W, H, null);
4737
+ const bands = input.limbs === undefined || cuts.length === 0 ? null : limbBands(cuts, pieces, input.limbs, input.bones ?? [], W, H, null, input.boneTips);
4733
4738
  if (bands !== null) {
4734
4739
  refuseIfAny(bands.problems);
4735
4740
  for (const [i, at] of bands.past) {
@@ -4744,9 +4749,9 @@ export function assemble(input: AssembleInput): AssembleResult {
4744
4749
  const ci = cuts.findIndex((q) => q.into === name);
4745
4750
  return ci >= 0 ? pieces[ci] : null;
4746
4751
  };
4747
- 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));
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);
4748
4753
  // Issue #564: and the cap a run's own layer fills above its upper joint, read once the limbs are cut.
4749
- 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).problems);
4754
+ 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);
4750
4755
  const limbPieces = lim.pieces;
4751
4756
  const order = limbOrder(order0, plan, cuts, lim.parts);
4752
4757
  const pieceAt = (d: { plan: number } | { cut: number } | { limb: number }): { name: string; b: Built } =>
@@ -4757,10 +4762,10 @@ export function assemble(input: AssembleInput): AssembleResult {
4757
4762
  const islandKept =
4758
4763
  (input.limbIslands ?? []).length === 0
4759
4764
  ? { counts: [], splits: [], problems: [] }
4760
- : keepJointIslands(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, W, H, input.islandFloor ?? ISLAND_FLOOR_SHARE, input.otherLimbs);
4765
+ : keepJointIslands(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, W, H, input.islandFloor ?? ISLAND_FLOOR_SHARE, input.otherLimbs, input.boneTips);
4761
4766
  refuseIfAny(islandKept.problems);
4762
4767
  const capAssigned = input.capOwnership === 'source' ? { counts: [], problems: [] }
4763
- : assignCapOwnership(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, lim.capFrom, W, H, input.otherLimbs);
4768
+ : assignCapOwnership(input.limbIslands ?? [], input.limbs ?? {}, input.bones ?? [], lim.parts, limbPieces, limbSource, lim.capFrom, W, H, input.otherLimbs, input.boneTips);
4764
4769
  refuseIfAny(capAssigned.problems);
4765
4770
 
4766
4771
 
package/src/build.ts CHANGED
@@ -93,6 +93,7 @@ import { KEYPOINT_NAMES, type KeypointName, type PosePoints } from './skeleton.t
93
93
  import { AUTHOR_NO_ROLE, isAuthorTag } from './tags.ts';
94
94
  import { TURN_BONE } from './turn.ts';
95
95
  import { pyRound } from './round.ts';
96
+ import { LAYOUT_FILE, layoutCompanion, refreshLimbLayout } from './limblayout.ts';
96
97
 
97
98
  /** Where a stage's lines go. The commands hand it `console.log`; `build` hands it a prefixing wrapper. */
98
99
  export type Log = (line: string) => void;
@@ -316,6 +317,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
316
317
  cuts?: Cut[];
317
318
  skeleton?: string;
318
319
  drawn?: Record<string, number>;
320
+ tips?: Record<string, [number, number]>;
319
321
  }> = cfgAlts.map((a, i) => {
320
322
  const cli = cliByName.get(a.name);
321
323
  if (cli !== undefined) cliByName.delete(a.name);
@@ -331,6 +333,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
331
333
  cuts: a.cuts,
332
334
  skeleton: a.skeleton === undefined ? undefined : resolve(configDir, a.skeleton),
333
335
  drawn: a.drawn,
336
+ tips: a.tips,
334
337
  };
335
338
  });
336
339
  for (const cli of cliByName.values()) {
@@ -547,6 +550,18 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
547
550
  }
548
551
  for (const b of Object.keys(limbDrawn)) setPlaced.add(b);
549
552
  }
553
+ // Source-crop endpoints are final evidence, not angles or origin placement.
554
+ // Resize exactly onto the accepted raster, after skeleton/drawn placement.
555
+ const altTips: Record<string, [number, number]> | undefined = alt.tips === undefined ? undefined
556
+ : Object.fromEntries(Object.keys(alt.tips).sort().map((bone) => [bone, [
557
+ (alt.tips as Record<string, [number, number]>)[bone][0] * (result.parts.rig_size[0] / altSrc.width),
558
+ (alt.tips as Record<string, [number, number]>)[bone][1] * (result.parts.rig_size[1] / altSrc.height),
559
+ ] as [number, number]]));
560
+ const invalidTip = Object.entries(altTips ?? {}).find(([, tip]) => !tip.every(Number.isFinite));
561
+ if (invalidTip !== undefined) {
562
+ altProblems.push({ code: 'ASSEMBLE_ALT_TIP_POINT', object: `${alt.at}.tips.${invalidTip[0]}`, detail: 'does not normalize to a finite [x, y] endpoint on the accepted rig canvas' });
563
+ continue;
564
+ }
550
565
  const altOthers = Object.keys(otherLimbs).length === 0 ? undefined : otherLimbsOf(otherLimbs, setPlaced, fields.bones ?? [], result.images, result.parts.rig_size, altSkeleton !== undefined ? 'skeleton' : alt.drawn !== undefined ? 'drawn' : 'none');
551
566
  if (altOthers !== undefined && input.setSplit === 'whole-limb') altOthers.line = 'whole-limb';
552
567
  // Issue #587: a subset set's limb part takes nothing a base part it does not replace covers at setup.
@@ -560,6 +575,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
560
575
  altRes = assemble({
561
576
  source: altSrc,
562
577
  limbUnderCover: alt.parts !== undefined && input.setCover !== 'painting',
578
+ ...(altTips === undefined ? {} : { boneTips: altTips }),
563
579
  capOwnership: input.setCapOwnership ?? 'target',
564
580
  full: altRuns.full,
565
581
  head: altRuns.head,
@@ -623,6 +639,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
623
639
  ...(altRes.parts.single_run_pad === undefined ? {} : { single_run_pad: altRes.parts.single_run_pad }),
624
640
  ...(altSkeleton === undefined ? {} : { skeleton: altSkeleton }),
625
641
  ...(alt.drawn === undefined ? {} : { drawn: { ...alt.drawn } }),
642
+ ...(altTips === undefined ? {} : { tips_source_size: [altSrc.width, altSrc.height], tips: altTips }),
626
643
  ...(altDrawnLength === undefined ? {} : { drawnLength: altDrawnLength }),
627
644
  ...(altRegistration === undefined ? {} : { registration: altRegistration }),
628
645
  },
@@ -1289,18 +1306,22 @@ export function readRigInputs(config: string, partsDir: string): RigInputs {
1289
1306
  return { cfg, from, parts, images };
1290
1307
  }
1291
1308
 
1292
- export function rigStage(input: RigStageInput, rigc: RigcRunner, scratch: string, log: Log): RigOutput {
1293
- const { cfg, from, parts, images } = readRigInputs(input.config, input.parts);
1294
- const first = buildRig(cfg, parts, images, undefined, input.idleKeys ?? DEFAULT_IDLE_KEYS, input.reduce);
1295
- const textsOf = (r: RigOutput): Array<[string, string]> => {
1296
- const mergedMotion = withAnimations(r.motion, from === null ? null : from.table);
1309
+ /** Final candidate serialization shared by initial and settled motion replay. */
1310
+ export function rigOutputTexts(r: RigOutput, animations: Parameters<typeof withAnimations>[1]): Array<[string, string]> {
1311
+ const mergedMotion = withAnimations(r.motion, animations);
1312
+ if (r.layout !== undefined) r.layout = refreshLimbLayout(r.layout, r.rig);
1297
1313
  return [
1298
1314
  ['rig.json', rigJsonText(r.rig)],
1299
1315
  ['motion.json', rigJsonText(mergedMotion)],
1300
1316
  ['mesh_report.json', rigJsonText(r.meshReport)],
1301
1317
  ...(r.sets === undefined ? [] : [[SETS_FILE, rigJsonText(r.sets)] as [string, string]]),
1302
1318
  ];
1303
- };
1319
+ }
1320
+
1321
+ export function rigStage(input: RigStageInput, rigc: RigcRunner, scratch: string, log: Log): RigOutput {
1322
+ const { cfg, from, parts, images } = readRigInputs(input.config, input.parts);
1323
+ const first = buildRig(cfg, parts, images, undefined, input.idleKeys ?? DEFAULT_IDLE_KEYS, input.reduce);
1324
+ const textsOf = (r: RigOutput): Array<[string, string]> => rigOutputTexts(r, from === null ? null : from.table);
1304
1325
  const firstTexts = textsOf(first);
1305
1326
  // The gate runs before the lines are printed, and its lines print where they always did: an automatic part's motion
1306
1327
  // gate compares the model document of this very build, the one written (issue #126 item 3). mesh_report.json is staged
@@ -1449,9 +1470,13 @@ export function rigStage(input: RigStageInput, rigc: RigcRunner, scratch: string
1449
1470
  rig.meshReport.splice(0, rig.meshReport.length, ...rows);
1450
1471
  texts[2] = ['mesh_report.json', rigJsonText(rig.meshReport)];
1451
1472
  }
1473
+ const layout = rig.layout === undefined ? undefined : layoutCompanion(rig.layout, rig.rig, texts[0][1], texts.find(([n]) => n === SETS_FILE)?.[1]);
1474
+ // This stage owns the companion. A red run reaches neither cleanup nor emit.
1475
+ if (layout === undefined) rmSync(join(input.out, LAYOUT_FILE), { force: true });
1452
1476
  mkdirSync(join(input.out, 'images'), { recursive: true });
1453
1477
  for (const [file, img] of rig.images) writePng(join(input.out, 'images', file), img);
1454
1478
  for (const [file, text] of texts) writeFileSync(join(input.out, file), text);
1479
+ if (layout !== undefined) writeFileSync(join(input.out, LAYOUT_FILE), rigJsonText(layout));
1455
1480
  log(`rig-parts rig: wrote ${join(input.out, 'rig.json')}, motion.json, mesh_report.json and ${rig.images.length} image(s) under ${join(input.out, 'images')}`);
1456
1481
  return rig;
1457
1482
  }