rig-parts 1.68.0 → 1.70.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
@@ -118,7 +118,7 @@ read by no CPU stage).
118
118
  | `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 |
119
119
  | `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 |
120
120
  | `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 |
121
- | `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?, anchor?, drawn?, tips?, front?}]` — 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>]`. Windows absolute drive paths such as `C:\paint\painting.png` are accepted as written; each segment's leading drive colon belongs to that path, while other colons still separate `source`, `full` and `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. `front` (issue #664) lists covered limb segment parts the set draws on their **front slot** instead of the base slot: each must be in the set's `parts` and not its `hides`, and listed in some `config.limbs.<limb>.front.parts` (`CONFIG_SET_FRONT`); the set then maps `<part>_front` (never `<part>`) to `<set>_<part>` in `parts.json` and `sets.json` and hides `<part>` (and `<part>_still`), its #587 exclusion counts only base parts drawn after the front slot's target, and keying that part's set on a slot track is refused (`CONFIG_SET_FRONT_KEYED`) — *Front slots (issue #664)* below `layers` optionally maps covered, nonhidden output part names to layer names in their existing source run (issue #666); for example `"layers": {"upperarm_r": "author:raised", "forearm_r": "author:raised"}`. Limb cuts, caps, islands and base exclusions read the selected layer; the base plan stays unchanged. |
121
+ | `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?, anchor?, base_anchor?, drawn?, tips?, front?}]` — 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>]`. Windows absolute drive paths such as `C:\paint\painting.png` are accepted as written; each segment's leading drive colon belongs to that path, while other colons still separate `source`, `full` and `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. `front` (issue #664) lists covered limb segment parts the set draws on their **front slot** instead of the base slot: each must be in the set's `parts` and not its `hides`, and listed in some `config.limbs.<limb>.front.parts` (`CONFIG_SET_FRONT`); the set then maps `<part>_front` (never `<part>`) to `<set>_<part>` in `parts.json` and `sets.json` and hides `<part>` (and `<part>_still`), its #587 exclusion counts only base parts drawn after the front slot's target, and keying that part's set on a slot track is refused (`CONFIG_SET_FRONT_KEYED`) — *Front slots (issue #664)* below `layers` optionally maps covered, nonhidden output part names to layer names in their existing source run (issue #666); for example `"layers": {"upperarm_r": "author:raised", "forearm_r": "author:raised"}`. Limb cuts, caps, islands and base exclusions read the selected layer; the base plan stays unchanged. |
122
122
  | `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 |
123
123
  | `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?, hybrid?}, …], split?, layout?, front?}}`, 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. Optional `front` (issue #664), `{parts: [<own segment part>, …], after: "<produced part>"}`, gives each named segment a second slot `<part>_front`, empty at setup, placed after `after`'s slot family, for a gesture set to draw on (`CONFIG_FRONT_SCOPE`, `CONFIG_FRONT_NAME`, `CONFIG_FRONT_LAYOUT`; *Front slots (issue #664)* below) |
124
124
  | `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 |
@@ -556,6 +556,51 @@ top edge instead would close the eye upward onto the upper lid and still move wh
556
556
  above it by (1 − squash) × its height above the pivot, so the cut, not the pivot, is what
557
557
  holds the crease.
558
558
 
559
+ ### Base-anchored alternate regions (`base_anchor`, issue #780)
560
+
561
+ `--alt <name>=<source>:<full>[:<head>]` supplies painting/run paths for the
562
+ config set of that name; its placement declaration stays in
563
+ `assemble.alternates[i]`. With no `base_anchor`, placement is art-measured,
564
+ exactly as before: the alternate's image centre is measured in its keyframe's
565
+ posed bone frame. Use that default when the keyframe art is trusted for placement.
566
+
567
+ When the art inherited convergence from its source and should contribute only its
568
+ appearance, explicitly inherit selected **bone-local** offsets from the base region:
569
+
570
+ ```json
571
+ {
572
+ "name": "step",
573
+ "parts": ["shoe", "shoe_patch"],
574
+ "base_anchor": {
575
+ "shoe": { "axes": ["x"], "paired": ["shoe_patch"] }
576
+ }
577
+ }
578
+ ```
579
+
580
+ Here `shoe` is a region, and `shoe_patch` is a region declared in
581
+ `assemble.patches`. The alternate shoe's `x` becomes the base attachment's `x`
582
+ in the alternate's posed frame; `y` stays art-measured. Use `axes: ["x", "y"]`
583
+ for the complete base local offset, or `["y"]` for vertical anchoring alone.
584
+ The image stays centred on the resulting attachment placement, with its pixels,
585
+ size and orientation unchanged. Each explicit paired patch receives the same
586
+ **world displacement**, converted into its own bone's local frame. Nothing is
587
+ paired by its spelling, inferred from proximity, or moved twice.
588
+
589
+ Every owner must be a covered, nonhidden region with its own base attachment;
590
+ every pair must be a covered, nonhidden painting-patch region owned by exactly
591
+ one anchor. Meshes, overlapping declarations, unknown axes and unknown fields
592
+ are refused by name. This is separate from `anchor`, which registers a skeleton
593
+ on torso keypoints. `parts.json` and `sets.json` record `base_anchor` only when
594
+ supplied; changing or removing it requires assemble again. `check --set` derives
595
+ the translated reference from the declaration and base attachment, independently
596
+ of the candidate alternate's offset; the original source boxes and PNGs remain
597
+ provenance. Source-comparison figures still describe the original painting.
598
+
599
+ Anchoring does not un-shear a neighbouring mesh or change a depth scale. Those
600
+ remain separate authoring decisions; a shifted shoe can still require work on
601
+ its neighbouring shin. A walk built from eight generated keyframes motivated
602
+ the opt-in placement; it does not change the default for existing inputs.
603
+
559
604
  ### Alternate part layers (`assemble.alternates[i].layers`, issue #666)
560
605
 
561
606
  A gesture run may hold a raised arm only in a layer the author added, while
@@ -1139,6 +1184,80 @@ lattice and contour modes a mesh may declare it:
1139
1184
  "bottomwear": { "grid": 25, "r": 10, "segments": [["hip", [232, 425], [601, 425]], "skirt_r", "skirt_c", "skirt_l"], "influences": { "maxInfluences": 6, "floor": "continuous" } }
1140
1185
  ```
1141
1186
 
1187
+ **A topwear hem over a rigid bottomwear (issue #650).** Only an explicit `waist`
1188
+ declaration enables this construction. Without it, even an eligible pair keeps
1189
+ the original bindings, rigid region, graph, motion, reports and images. A distance lattice whose
1190
+ `topwear` provenance declares exactly two distinct segment bones receives a waist
1191
+ driver only when one is the explicit region binding of a `bottomwear` part and the
1192
+ other is its descendant in the declared bone graph. Part and bone spellings do not
1193
+ select this rule. More than one eligible bottomwear partner, or multiple topwear
1194
+ drivers of one bottomwear region, is `RIG_WAIST_PAIR`;
1195
+ an explicit declaration without that qualifying pair is refused by name.
1196
+ The declaration selects one pair; no other pair is changed.
1197
+
1198
+ Call the region bone H and the descendant C. The existing lattice art criterion is
1199
+ strictly alpha above 8, after any declared stray removal. The last such pixel row
1200
+ is the painted hem, rather than the padded image boundary. The lattice splits its
1201
+ original triangles at C's image-space origin, the H-only plateau and the hem row, retaining the
1202
+ original diagonal partition and rebuilding
1203
+ the outline, triangles, UVs and bindings together. At and above C's row, distance
1204
+ weights stay unchanged. Below it, the H-only plateau starts one source texel before the painted hem,
1205
+ with `t = min(1, (y - C.y) / (plateau - C.y))`. The
1206
+ uncut distance share `h` becomes `h + (1 - h) * t` for H and its complement for C;
1207
+ the declared cap and floor are then applied once. The whole last art pixel and the
1208
+ padding below it bind fully to H. `RIG_WAIST_HEIGHT` names a missing hem or a C
1209
+ origin not strictly above the plateau; `RIG_WAIST_BINDING` names a missing member of the
1210
+ declared pair. Alternate drawings use their own art and posed C origin. Heat,
1211
+ contour, automatic, influence and meshes with other binding sets keep their rules.
1212
+ The original triangle's native setup position and UV field are interpolated at
1213
+ each new point. Bind coordinates are inverted through the runtime frame, written
1214
+ with the existing six decimal places, then stored by the runtime as float32;
1215
+ UVs retain the interpolated value and the runtime's existing page-float32 step.
1216
+ This is the nearest representable field under those storage rules, not a promise
1217
+ of exact mathematical setup coordinates or universally identical raster pixels.
1218
+ Setup RGBA differences must be measured on the actual input, reporting differing
1219
+ pixels and the maximum absolute difference per channel. The waist acceptance
1220
+ allows at most one per channel. Literal whole-hem support is checked separately
1221
+ in the actual stored UV field; nominal source rows are not that proof.
1222
+ The stored-space check reads native page UVs through the promised renderer entry,
1223
+ requires integral unscaled page/source metadata at most 2048 on each edge, and
1224
+ intersects every complete last-row alpha>8 pixel cell with the UV triangles.
1225
+ Exact coverage and absence of positive non-H support are required; duplicate
1226
+ coverage cannot compensate for a hole, and an empty or missing read is refused.
1227
+ A source-coordinate rounding envelope alone is not an acceptance result.
1228
+ Paired alternate drawings retain their selected base or front slots, including
1229
+ hidden-base-slot semantics and deform target identities.
1230
+
1231
+
1232
+ Only the paired bottomwear region becomes a mesh. Its whole existing padded
1233
+ image is partitioned by the top's actual triangle arrangement. Inside that domain
1234
+ each bone receives the barycentric stored moments `w`, `w*x`, `w*y`, divided by
1235
+ the resulting positive weight to recover local coordinates; cap/floor is not
1236
+ applied again. Common vertices copy complete bindings. Outside the top domain,
1237
+ the supplied region rectangle's nodes retain H, and the arrangement connects the
1238
+ fields. The bottom's mesh report names the top driver's grid and measures the
1239
+ resulting geometry and art coverage. Alternate sets select their own paired
1240
+ field; a subset without a new bottom drawing receives a derived attachment on
1241
+ the existing bottom slot/image. A set hiding the top retains the rigid bottom.
1242
+ Explicit still pieces remain separate and retain their own binding.
1243
+
1244
+ External numeric deforms on the changed top topology are expanded in the **old
1245
+ per-influence** index space, including sparse runs, odd `offset`, odd lengths,
1246
+ `fromVertex` and null setup keys. Per-bone delta moments are transferred by the
1247
+ same old-to-new barycentric correspondence. `RIG_WAIST_DEFORM_RUN` names an old
1248
+ run outside its array; `RIG_WAIST_DEFORM_SUPPORT` refuses a nonzero moment whose
1249
+ bone the new field no longer contains. Such a moment cannot be carried by another
1250
+ bone under arbitrary motion. `RIG_WAIST_DEFORM_REBIND` refuses nonzero numeric
1251
+ offsets after stops/turn changed those local binding frames without a proven
1252
+ correspondence. A whole-attachment transform is `RIG_WAIST_DEFORM_MODEL`: evaluating
1253
+ a nonlinear model at new nodes is not proven equivalent to its old piecewise
1254
+ field. `RIG_WAIST_DEFORM_REGION` refuses an authored timeline on the original
1255
+ bottom region, which had no mesh deform array. Refusals occur when external
1256
+ animations are merged, before the build gate or output. Other attachments,
1257
+ including unrelated face deforms, retain their existing path and are not refused.
1258
+ This changes the rig's response to motion; the consumer's motion and an owner's
1259
+ viewing of the result remain separate checks.
1260
+
1142
1261
  **When to reach for it:** a part that folds where two chains meet, or at the end of a curl.
1143
1262
  The default does not move; a fold is today found by looking at a build that passes every
1144
1263
  bar, and this field is what there is to turn once one is seen.
@@ -3779,6 +3898,10 @@ See-through with another seed.
3779
3898
  | <a id="CONFIG_HEAD_BOX_SQUARE"></a>`CONFIG_HEAD_BOX_SQUARE` | `seethrough.head_box` is not a non-empty square | `head_box` — take `propose --head-box`'s |
3780
3899
  | <a id="CONFIG_TAG_KNOWN"></a><a id="CONFIG_PART_NAME"></a><a id="CONFIG_PART_UNIQUE"></a>`CONFIG_TAG_KNOWN`, `CONFIG_PART_NAME`, `CONFIG_PART_UNIQUE` | a plan or extend entry names neither a v3 tag nor `author:<label>` (an `author:` tag with a malformed label says what the label must be), a part name that is not a file name, or a part or layer twice — a patch named like a plan part or another patch, and a cut's `into` named like a plan part, a patch or another cut's, included | `assemble.plan`, `assemble.patches`, `assemble.cuts` |
3781
3900
  | <a id="CONFIG_SET_FOCUS"></a>`CONFIG_SET_FOCUS` | optional `assemble.alternates[i].focus` (issue #719) must be exactly two finite painting-pixel coordinates `[x, y]`, x right/y down, inside that alternate painting (edges included); the loader checks the tuple and `assemble` checks the actual canvas before writing. Only with focus, `parts.json` carries the original point and `focus_source_size`; `sets.json` carries the point in setup-world coordinates through the accepted rig-canvas resize and `src/coords.ts`. Absent means no focus field or inferred hand position | author a point inside the painting or omit `focus`; after changing or removing it, re-run `assemble` and `rig`. Scene placement belongs to the consumer |
3901
+ | <a id="CONFIG_SET_BASE_ANCHOR"></a>`CONFIG_SET_BASE_ANCHOR` | `assemble.alternates[i].base_anchor` is malformed or names an unknown, hidden, nonregion owner, a nonpatch pair, duplicate ownership, or an axis other than distinct `x`/`y` | declare covered region owners with explicit axes and unique covered painting-patch pairs, or omit the opt-in mode |
3902
+ | <a id="PARTS_ALT_BASE_ANCHOR"></a>`PARTS_ALT_BASE_ANCHOR` | serialized alternate placement metadata is malformed or names missing/nonpatch records | re-run assemble with the current declaration |
3903
+ | <a id="RIG_ALT_BASE_ANCHOR"></a>`RIG_ALT_BASE_ANCHOR` | an owner has no matching base/alternate region on the same bone, a pair has no region/frame, or direct input metadata is invalid | correct the named region/patch bindings; mesh placement is not supported by this mode |
3904
+ | <a id="RIG_ALT_BASE_ANCHOR_MATCH_CONFIG"></a>`RIG_ALT_BASE_ANCHOR_MATCH_CONFIG` | config and assembled parts declare different base anchors, including a removed declaration or absent set | re-run assemble after changing or removing the declaration |
3782
3905
  | <a id="CONFIG_SET_LAYERS"></a>`CONFIG_SET_LAYERS` | `assemble.alternates[i].layers` names an unknown, uncovered or hidden part, or a painting patch with no run-layer source | name a covered layer-backed output part (a limb segment name, not its consumed source); use `author:<label>` for author art |
3783
3906
  | <a id="CONFIG_MOTION_SEAM"></a>`CONFIG_MOTION_SEAM` | motion_seams has a malformed entry, an unknown output part, a self-pair, duplicate/reversed pair or unknown entry field | declare each unordered pair once with two resolved output part names |
3784
3907
  | <a id="PARTS_MOTION_SEAM"></a>`PARTS_MOTION_SEAM` | parts.json motion_seams violates the same declaration shape/name/uniqueness contract | reassemble with the declared output part names |
@@ -3948,6 +4071,29 @@ says why each requirement exists and what breaks without it.
3948
4071
  | <a id="RIG_PNG_PRESENT"></a><a id="RIG_PNG_MATCHES_BOX"></a><a id="RIG_PART_HAS_ART"></a>`RIG_PNG_PRESENT`, `RIG_PNG_MATCHES_BOX`, `RIG_PART_HAS_ART` | a part's PNG is missing, the wrong size, or has no art pixel | re-run assemble |
3949
4072
  | <a id="RIG_NAME_RESOLVES"></a><a id="RIG_SEGMENT_DEFINED"></a><a id="RIG_CHAIN_POINTS"></a>`RIG_NAME_RESOLVES`, `RIG_SEGMENT_DEFINED`, `RIG_CHAIN_POINTS` | a segment names an undeclared bone, a bone with no `tip` and no next link, or a chain too short to make a link | that bone's `tip`, or write the segment out as `[bone, [x0,y0], [x1,y1]]` |
3950
4073
  | <a id="RIG_INFLUENCES_KEPT"></a>`RIG_INFLUENCES_KEPT` | a mesh's declared `influences` leaves a vertex with no bone: every capped share is under 0.03 (at or under it, for the continuous floor). The largest of k shares is at least 1/k, so this needs 34 or more kept bones; the default cap of 4 never reaches it (issue #284). The detail names the first vertex, how many more, and its largest share | declare `maxInfluences` 33 or less, or name fewer bones in `segments` |
4074
+ | <a id="RIG_LATTICE_STATION"></a>`RIG_LATTICE_STATION` | a requested lattice subdivision row is not finite | supply finite source-image row coordinates |
4075
+ | <a id="RIG_WAIST_PIVOT_SOURCE"></a>`RIG_WAIST_PIVOT_SOURCE` | paired original mesh layout/masks are absent, contact is empty/disjoint, or no bilateral lower station precedes the painted hem | retain the source layout and nonempty contiguous alpha support; do not guess a band height |
4076
+ | <a id="RIG_WAIST_PIVOT_NAME"></a>`RIG_WAIST_PIVOT_NAME` | the appended bone name exists, or the constraint name is empty | choose a new explicit bone and nonempty constraint name; do not replace a graph node |
4077
+ | <a id="RIG_WAIST_PIVOT_FRAME"></a>`RIG_WAIST_PIVOT_FRAME` | exact authored upper/lower rest frames are not unturned unit frames, or the source graph has constraints, turn or stops | retain the unconstrained original graph; authored eligibility uses exact frames, while inverse binding uses runtime frames; no epsilon or graph rewrite |
4078
+ | <a id="RIG_WAIST_COPY_SOURCE"></a>`RIG_WAIST_COPY_SOURCE` | supplied paired meshes/images or an existing upper source row are missing, a triangle crosses that row, or original upper support is lost | retain the stored source topology and an existing row above the annotated copy boundary; no replacement lattice or upper refinement |
4079
+ | <a id="RIG_WAIST_COPY_FRAME"></a>`RIG_WAIST_COPY_FRAME` | the supplied waist frame is absent, already drives the original top, has an incompatible graph/property contract or authored non-unit rest frame | supply the existing upper-parented world rotate-only frame; do not rewrite graph or motion |
4080
+ | <a id="RIG_WAIST_COPY_DEFORM"></a>`RIG_WAIST_COPY_DEFORM` | a targeted original top deform carries a nonzero numeric run or attachment transform whose per-bone moment cannot be transferred to the new waist frame | retain the original field or provide a proved composition; no silent deformation reinterpretation |
4081
+ | <a id="RIG_WAIST_COPY_COVERAGE"></a>`RIG_WAIST_COPY_COVERAGE` | a mixed-support triangle has positive source area below the copy boundary, or actual native UV/support correspondence is unavailable | retain the constrained source arrangement and native whole-area proof; inserted points alone are insufficient |
4082
+ | <a id="RIG_WAIST_PAIR"></a>`RIG_WAIST_PAIR` | a topwear has multiple eligible bottomwear partners, or a bottomwear has multiple topwear drivers | declare one unambiguous binding pair; no first-match selection |
4083
+ | <a id="RIG_WAIST_HEIGHT"></a>`RIG_WAIST_HEIGHT` | the painted hem is missing, or the upper origin does not precede its one-texel plateau | retain nonempty art and an upper origin strictly above the plateau |
4084
+ | <a id="RIG_WAIST_BINDING"></a>`RIG_WAIST_BINDING` | the uncut distance field does not retain both declared waist bones | declare both members of the eligible binding pair |
4085
+ | <a id="RIG_WAIST_GEOMETRY"></a>`RIG_WAIST_GEOMETRY` | a waist arrangement coordinate is not finite | supply finite source geometry |
4086
+ | <a id="RIG_WAIST_TOPOLOGY"></a>`RIG_WAIST_TOPOLOGY` | the arrangement has an invalid edge incidence, a pinched boundary or multiple boundary loops | supply one coherent closed mesh domain |
4087
+ | <a id="RIG_WAIST_CORRESPONDENCE"></a>`RIG_WAIST_CORRESPONDENCE` | a subdivision point lies outside the original supplied triangle domain | preserve the source triangle domain and its correspondence |
4088
+ | <a id="RIG_WAIST_SET_BINDING"></a>`RIG_WAIST_SET_BINDING` | a selected set no longer resolves the paired source meshes on their declared slots | preserve the selected top and bottom attachment identities |
4089
+ | <a id="RIG_WAIST_STORED_METADATA"></a>`RIG_WAIST_STORED_METADATA` | native atlas metadata is not integral, unscaled, size-bounded and consistent with the original drawing | read back the actual page and region metadata; require matching original dimensions and page edges at most2048 |
4090
+ | <a id="RIG_WAIST_STORED_UV"></a>`RIG_WAIST_STORED_UV` | native UVs, support or triangles are missing, nonfinite, not float32 or inconsistent | supply complete native float32 UVs with parallel support and valid triangles |
4091
+ | <a id="RIG_WAIST_STORED_EMPTY"></a>`RIG_WAIST_STORED_EMPTY` | the stored-hem drawing has no painted row | supply nonempty original art; an empty read cannot pass |
4092
+ | <a id="RIG_WAIST_DEFORM_REGION"></a>`RIG_WAIST_DEFORM_REGION` | an authored deform targets the original rigid bottomwear region | remove the invalid region deform; conversion cannot reinterpret it as a mesh timeline |
4093
+ | <a id="RIG_WAIST_DEFORM_MODEL"></a>`RIG_WAIST_DEFORM_MODEL` | an unproved whole-attachment transform targets a subdivided waist mesh | supply a representable numeric old-topology run |
4094
+ | <a id="RIG_WAIST_DEFORM_RUN"></a>`RIG_WAIST_DEFORM_RUN` | an old-topology deform run has invalid values, offsets or array bounds | supply a finite numeric run within the original per-influence array |
4095
+ | <a id="RIG_WAIST_DEFORM_REBIND"></a>`RIG_WAIST_DEFORM_REBIND` | a nonzero old local deform follows a stop or turn that changed the waist binding frames | retain an established correspondence for the rebound field before supplying nonzero local deltas |
4096
+ | <a id="RIG_WAIST_DEFORM_SUPPORT"></a>`RIG_WAIST_DEFORM_SUPPORT` | a nonzero old bone moment has no corresponding influence on the new vertex | preserve that bone support; another bone cannot carry its moment under arbitrary motion |
3951
4097
  | <a id="RIG_LATTICE_ONE_LOOP"></a>`RIG_LATTICE_ONE_LOOP` | the lattice over a part does not close into one outline even after the repair passes | that mesh's `grid` |
3952
4098
  | <a id="RIG_CONTROL_NAME_FREE"></a>`RIG_CONTROL_NAME_FREE` | a keyed, mesh-weighted bone needs `<bone>_ctl` and that name is taken | rename the declared bone |
3953
4099
  | <a id="RIG_HEAD_UP_NAME_FREE"></a>`RIG_HEAD_UP_NAME_FREE` | `config.bones` declares `head_up`, the bone the rig stage adds under `head` to carry the face's up axis (issue #250) | rename that bone |
@@ -5421,3 +5567,122 @@ art. An authored `parts.json` depth reference remains an active standalone
5421
5567
  `rig` declaration even without config opt-in: its file/size/color/opacity
5422
5568
  guards still apply. With binding inactive there is no added reference, file or
5423
5569
  legacy-byte change. #773 adds no image generation, geometry or motion model.
5570
+ ### Explicit source-derived waist pivot stage
5571
+
5572
+ `withWaistPivot` is a pure, explicit candidate-stage operation over an already
5573
+ built paired waist. It leaves the ordinary builder unchanged. The complete top
5574
+ attachment, original bones, limb attachments, images and motion object remain
5575
+ unchanged; one bone is appended under the declared upper chain. Its translation
5576
+ is the parent-upper frame evaluated at the source band TOP centre. This is an
5577
+ explicit definition, not a claim that a spatially blended top field equals that
5578
+ single parent frame. The candidate's native readings must report their difference.
5579
+
5580
+ The source profile uses the existing alpha-above-eight masks: one contiguous
5581
+ shared column run, its central bottom upper cell edge, then the first later row
5582
+ whose bottom silhouette expands beyond both original side supports. That is the
5583
+ lower station, a conservative source boundary rather than an inferred semantic
5584
+ colour seam. The last painted bottom row is the end of a fixed linear waist-to-
5585
+ lower blend. Original triangles are split at those two rows, original UVs are
5586
+ interpolated through their original correspondence, and old stored setup points
5587
+ are inverse-bound through the fixed rest frames. The whole upper band uses the
5588
+ waist bone; the last painted hem has only lower-frame support. No coefficient,
5589
+ colour classifier, image edit or animation fitting is involved.
5590
+
5591
+ The generated core transform explicitly declares `rotate` to `rotate`,
5592
+ `mixRotate: 1`, and every translation, scale and shear mix zero. A mix without
5593
+ its matching property is dead data in the native 4.3 contract. With no declared
5594
+ destination property, the native gate rejects the constraint as
5595
+ `A48_TRANSFORM_CONSTRAINT_NOT_MUTED_THROUGHOUT`: it drives no property. The
5596
+ planted missing-property control requires that exact refusal for its named
5597
+ constraint as the only failed assertion; an arbitrary exit 1 or a skipped check
5598
+ does not pass. It does not build successfully and then reach a no-op angle
5599
+ probe. The positive control still reads native rotation and translation. Both
5600
+ controls carry their commands, full stdout/stderr and SHA-256 hashes in their
5601
+ case details or errors before temporary cleanup. Native gating is mandatory
5602
+ before this stage can be called a compiled candidate; it does not
5603
+ establish visual or motion acceptance. Nonzero bottom deformation remains subject
5604
+ to the original region/deform refusal; the operation adds no motion adapter.
5605
+
5606
+ The refusal rows are in the waist registry in section6. Eligibility measures
5607
+ authored unit frames with the core exact-frame evaluator; inverse binding keeps
5608
+ the core runtime-frame evaluator. No tolerance is applied to authored rotations.
5609
+ An existing constrained, turned or stopped graph remains ineligible.
5610
+
5611
+ `withWaistSharedCopy` is a separate explicit operation on a supplied pivot
5612
+ output. It preserves that output's bottom attachment, bones, constraints, limb
5613
+ attachments, art and motion. Its copy boundary is an operational annotation:
5614
+ the existing shared source columns' first bottom alpha cells, connected at
5615
+ column centres and continued at each end across the top hull. It is not a
5616
+ semantic cloth detector. The upper anchor is the last existing stored UV row
5617
+ strictly above that boundary, including its stored rounding rather than a
5618
+ nominal regenerated row. The fixed smoothstep between those source boundaries
5619
+ transfers original per-bone weights and first moments into the existing waist
5620
+ frame. Each new waist moment inverse-binds the original corresponding rest
5621
+ point; no geometry is snapped to the band's edge.
5622
+
5623
+ The lower original triangles are constrained along the boundary segments and
5624
+ existing edges. Boundary-interface points are propagated only below the upper
5625
+ anchor; original upper vertex UV/binding records and triangle fields are exact
5626
+ under the hull's required index permutation. Every triangle with positive area
5627
+ below the copy boundary must have only waist support, including side
5628
+ extensions. The native control repeats this test with actual runtime source
5629
+ UVs using exact binary arithmetic. A planted crossing triangle demonstrates why
5630
+ checking just inserted vertices is insufficient. Nonzero targeted top deforms
5631
+ and attachment transforms are refused by name until a composition into the new
5632
+ per-bone support is proved; original motion is never silently rewritten. A
5633
+ passing gate still does not establish picture, seam or motion acceptance.
5634
+
5635
+ The rigid copy support starts conservatively above that annotated boundary by
5636
+ `(source height + max absolute boundary slope * source width) * 2^-23` source
5637
+ pixels. This is a storage guard, not an authored height or fit coefficient:
5638
+ rig-c's `f32` writes the shortest decimal naming the same float32 as its input,
5639
+ and Spine retains that decimal. A complete float32 rounding cell on normalized
5640
+ UVs `[0,1]` is bounded by `2^-23`. Each actual new UV is checked with exact
5641
+ arithmetic against that source-coordinate bound, including arithmetic before
5642
+ the conversion. The boundary's slope bound then keeps the represented mixed
5643
+ triangles above the **original** boundary. Native whole-area coverage still
5644
+ tests the original boundary without tolerance; its failure remains a failure.
5645
+
5646
+ ### Opting into the accepted shared waist
5647
+
5648
+ ```json
5649
+ "waist": {
5650
+ "top": "shirt", "bottom": "skirt",
5651
+ "upper": "chest", "lower": "hip",
5652
+ "bone": "skirt_waist", "constraint": "skirt_waist_rotation"
5653
+ }
5654
+ ```
5655
+
5656
+ All six nonempty names are required. `top` names a two-bone distance lattice
5657
+ with topwear provenance; `bottom` names a rigid region with bottomwear
5658
+ provenance bound to `lower`. `upper` is the other segment bone and a descendant
5659
+ of `lower`. `bone` is a new generated name; `constraint` names its rotate-only
5660
+ constraint. Origins and the canvas come from the actual parts, including their
5661
+ existing padding. There are no authored offsets, gains or search parameters.
5662
+ `buildRig` and the `rig`/`build` commands compose the preserved pair, pivot and
5663
+ shared-copy stages. The pure `buildWaistPairSource` intermediate is for stage
5664
+ composition and controls; `buildRig` is the complete declared construction.
5665
+
5666
+ This bounded construction requires one base pair without alternate or limb-owned
5667
+ replacements, unit rest frames and an unconstrained, unturned, unstopped graph.
5668
+ Unsupported input is refused, never silently changed to a different construction.
5669
+ Imported original keys remain unchanged; nonzero targeted top deforms or tracks
5670
+ driving the generated waist frame are refused before gated emission.
5671
+
5672
+ The accepted integrated-walk artifact in
5673
+ [the final issue disposition](https://github.com/rig-c/parts/issues/650#issuecomment-6408838090)
5674
+ reported native seam ghost 0 and gap 0 over 380 samples. Its maximum raster jut
5675
+ was **7 metric pixels at frame 1 against the previous limit of 6**: the raw bar
5676
+ failed and acceptance explicitly retained that exception. The separate fixed
5677
+ emission audit at frame 57 counted 375 all-bracketed background pixels, including
5678
+ 26 in the dropping half. Native seam gap 0 is not a whole-picture no-background
5679
+ claim. These figures belong to the preserved artifact and its recorded toolchain;
5680
+ they do not certify a new toolchain, input or packaging build. No tuning to meet
5681
+ 6 pixels is part of this declaration.
5682
+
5683
+ | rule | means | change |
5684
+ | --- | --- | --- |
5685
+ | <a id="CONFIG_WAIST_BINDING"></a>`CONFIG_WAIST_BINDING` | A declaration names an absent mesh/region/bone or repeats a pair member; supply the actual distinct bound objects | supply the actual distinct bound objects |
5686
+ | <a id="CONFIG_WAIST_NAME_FREE"></a>`CONFIG_WAIST_NAME_FREE` | The generated bone name already exists; declare an unused name | declare an unused name |
5687
+ | <a id="RIG_WAIST_DECLARATION"></a>`RIG_WAIST_DECLARATION` | Actual provenance, pair bindings or drawing ownership do not match the bounded declaration; supply the declared base two-bone mesh/rigid-region pair | supply the declared base pair |
5688
+ | <a id="RIG_WAIST_MOTION"></a>`RIG_WAIST_MOTION` | Imported tracks drive the generated waist frame; retain their original authored targets | retain the original authored targets |
package/docs/STABILITY.md CHANGED
@@ -118,7 +118,7 @@ The fields, object by object (a bold path is where the object sits; `<part>` is
118
118
  part name, `[i]` an entry of a list):
119
119
 
120
120
  <!-- stable:config -->
121
- - **config** — required by the full loader, in front of rig and build: `key`, `assemble`, `bones`, `meshes`, `regions`, `motion`; optional: `generation`, `seethrough`, `limbs`, `constraints`, `stops`, `turn`, `scene`, `cloth`, `proposed_rig_scale`, `requirements` (issue #556, additive: a path beside the config that build reads in place of its requirements flag, whose behaviour is unchanged), `motion_seams`, `depth`
121
+ - **config** — required by the full loader, in front of rig and build: `key`, `assemble`, `bones`, `meshes`, `regions`, `motion`; optional: `generation`, `seethrough`, `limbs`, `constraints`, `stops`, `turn`, `scene`, `cloth`, `proposed_rig_scale`, `requirements` (issue #556, additive: a path beside the config that build reads in place of its requirements flag, whose behaviour is unchanged), `motion_seams`, `depth`, `waist`
122
122
  - **generation** — required: `checkpoint`, `loras`, `trigger`, `identity`, `sampler`, `costume`, `negative_extra`, `style`, `negative_pose`, `latent`, `seed`; optional: `pose`, `control`
123
123
  - **generation.loras[i]** — required: `name`, `strength`; optional: `strength_clip`
124
124
  - **generation.sampler** — required: `steps`, `cfg`, `sampler`, `scheduler`
@@ -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`, `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
130
+ - **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `anchor`, `base_anchor`, `drawn`, `tips`, `front`, `layers`, `focus` (issues #454, #465, #543, #652, #664, #666, #719, #780). `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`
@@ -189,6 +189,7 @@ part name, `[i]` an entry of a list):
189
189
  - **depth** — optional: `zScale`, `full`, `head` (#773)
190
190
  - **depth.full**, **depth.head** — optional: `layers`, `atlas` (one fallback route)
191
191
  - **depth.full.layers.&lt;layer&gt;**, **depth.head.layers.&lt;layer&gt;**, **depth.full.atlas**, **depth.head.atlas** — required: `image`, `near`, `zScale`
192
+ - **waist** — required: `top`, `bottom`, `upper`, `lower`, `bone`, `constraint` (#650; absent keeps the ordinary bindings and graph)
192
193
  <!-- /stable:config -->
193
194
 
194
195
  `TY14` holds the set of field names in backticks above to the set of names the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-parts",
3
- "version": "1.68.0",
3
+ "version": "1.70.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": {
@@ -0,0 +1,59 @@
1
+ /** Explicit alternate region placement; source pixels and crop provenance never change. */
2
+ import { toBoneLocalVector, toWorld, type BoneTransform } from './coords.ts';
3
+ import { refuseIfAny, type Problem } from './errors.ts';
4
+
5
+ export type BaseAnchor = Record<string, { axes: Array<'x' | 'y'>; paired?: string[] }>;
6
+ const object = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
7
+
8
+ /** Both config doors, serialized parts, and direct builders validate the same explicit rule. */
9
+ export function baseAnchorProblems(value: unknown, at: string, covered: ReadonlySet<string>, patches?: ReadonlySet<string>, regions?: ReadonlySet<string>, code = 'CONFIG_SET_BASE_ANCHOR'): Problem[] {
10
+ const problems: Problem[] = [];
11
+ const fail = (where: string, detail: string): void => { problems.push({ code, object: where, detail }); };
12
+ if (!object(value) || Object.keys(value).length === 0) return [{ code, object: at, detail: 'requires a nonempty region-name map of {axes: ["x" and/or "y"], paired?: [patch names]}; omit base_anchor for art-measured placement' }];
13
+ const paired = new Set<string>();
14
+ for (const [name, rule] of Object.entries(value)) {
15
+ const path = `${at}.${name}`;
16
+ if (!covered.has(name) || (regions !== undefined && !regions.has(name))) fail(path, `names "${name}"; a covered, nonhidden region with a base attachment is required, never a mesh`);
17
+ if (!object(rule)) { fail(path, 'requires {axes: ["x" and/or "y"], paired?: [patch names]}'); continue; }
18
+ for (const key of Object.keys(rule)) if (key !== 'axes' && key !== 'paired') fail(`${path}.${key}`, 'is unknown; only axes and paired are accepted');
19
+ if (!Array.isArray(rule.axes) || rule.axes.length === 0 || rule.axes.some(a => a !== 'x' && a !== 'y') || new Set(rule.axes).size !== rule.axes.length) fail(`${path}.axes`, `is ${JSON.stringify(rule.axes)}; one or both distinct local axes "x", "y" are required`);
20
+ if (rule.paired !== undefined) {
21
+ if (!Array.isArray(rule.paired) || rule.paired.length === 0) { fail(`${path}.paired`, 'requires a nonempty list of covered painting patches'); continue; }
22
+ for (const patch of rule.paired) {
23
+ if (typeof patch !== 'string' || !covered.has(patch) || (patches !== undefined && !patches.has(patch)) || (regions !== undefined && !regions.has(patch))) fail(`${path}.paired`, `names ${JSON.stringify(patch)}; a covered, nonhidden painting-patch region is required`);
24
+ else if (patch === name || Object.hasOwn(value, patch) || paired.has(patch)) fail(`${path}.paired`, `names "${patch}" more than once or also as an anchor; one anchor owns each paired patch`);
25
+ else paired.add(patch);
26
+ }
27
+ }
28
+ }
29
+ return problems;
30
+ }
31
+
32
+ export function orderedBaseAnchor(value: BaseAnchor): BaseAnchor {
33
+ return Object.fromEntries(Object.keys(value).sort().map(name => [name, { axes: (['x', 'y'] as const).filter(a => value[name].axes.includes(a)), ...(value[name].paired === undefined ? {} : { paired: [...value[name].paired!].sort() }) }]));
34
+ }
35
+
36
+ export interface AnchorRegion { bone: string; x: number; y: number }
37
+ /** Local displacement for every owner and explicitly paired region; pairs share a world displacement. */
38
+ export function baseAnchorMoves(rules: BaseAnchor, base: ReadonlyMap<string, AnchorRegion>, source: ReadonlyMap<string, AnchorRegion>, world: ReadonlyMap<string, BoneTransform>): Map<string, { local: [number, number]; world: [number, number] }> {
39
+ const problems: Problem[] = [];
40
+ const out = new Map<string, { local: [number, number]; world: [number, number] }>();
41
+ for (const name of Object.keys(rules).sort()) {
42
+ const original = base.get(name), art = source.get(name), rule = rules[name];
43
+ if (original === undefined || art === undefined || !world.has(art.bone) || original.bone !== art.bone) {
44
+ problems.push({ code: 'RIG_ALT_BASE_ANCHOR', object: `base_anchor.${name}`, detail: `requires matching base and alternate region attachments on the same declared bone; base ${original?.bone ?? 'absent'}, alternate ${art?.bone ?? 'absent'}` }); continue;
45
+ }
46
+ const frame = world.get(art.bone)!;
47
+ const dx = rule.axes.includes('x') ? original.x - art.x : 0, dy = rule.axes.includes('y') ? original.y - art.y : 0;
48
+ const origin = toWorld(frame, 0, 0), target = toWorld(frame, dx, dy);
49
+ const delta: [number, number] = [target[0] - origin[0], target[1] - origin[1]];
50
+ out.set(name, { local: [dx, dy], world: delta });
51
+ for (const pair of rule.paired ?? []) {
52
+ const region = source.get(pair), pairFrame = region === undefined ? undefined : world.get(region.bone);
53
+ if (pairFrame === undefined) problems.push({ code: 'RIG_ALT_BASE_ANCHOR', object: `base_anchor.${name}.paired`, detail: `paired patch "${pair}" has no alternate region or bone frame; re-run assemble with the patch covered` });
54
+ else out.set(pair, { local: toBoneLocalVector(pairFrame, ...delta), world: delta });
55
+ }
56
+ }
57
+ refuseIfAny(problems);
58
+ return out;
59
+ }
package/src/build.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { readSourceDepth } from './depthsheets.ts';
2
+ import { orderedBaseAnchor } from './baseanchor.ts';
2
3
  import { alternateLayerSources, alternateLayerIslands, alternateLayerOthers } from './alternatelayers.ts';
3
4
  import { setFocusProblems } from './setfocus.ts';
4
5
  /**
@@ -332,6 +333,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
332
333
  for (const a of cliAlts) cliByName.set(a.name, a);
333
334
  const mergedAlts: Array<{
334
335
  name: string;
336
+ base_anchor?: NonNullable<typeof cfg.assemble.alternates>[number]['base_anchor'];
335
337
  at: string;
336
338
  source?: string;
337
339
  full?: string;
@@ -352,6 +354,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
352
354
  if (cli !== undefined) cliByName.delete(a.name);
353
355
  return {
354
356
  name: a.name,
357
+ base_anchor: a.base_anchor,
355
358
  at: `config.assemble.alternates[${i}] (set "${a.name}")`,
356
359
  source: cli?.source ?? (a.source === undefined ? undefined : resolve(configDir, a.source)),
357
360
  full: cli?.full ?? (a.full === undefined ? undefined : resolve(configDir, a.full)),
@@ -694,6 +697,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
694
697
  altBuilt.push({
695
698
  record: {
696
699
  name: alt.name,
700
+ ...(alt.base_anchor === undefined ? {} : { base_anchor: orderedBaseAnchor(alt.base_anchor) }),
697
701
  ...(alt.parts === undefined ? {} : { parts: [...alt.parts, ...generatedBands.filter((n) => !(alt.parts as string[]).includes(n))] }),
698
702
  ...(alt.hides === undefined || alt.hides.length === 0 ? (altFront.size === 0 ? {} : { hides: [...altFront] }) : { hides: [...alt.hides, ...[...altFront].filter((p) => !(alt.hides as string[]).includes(p))] }),
699
703
  ...(altFront.size === 0 ? {} : { front: [...altFront] }),