rig-parts 1.56.0 → 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
@@ -108,7 +108,7 @@ read by no CPU stage).
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
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,
@@ -3162,6 +3225,14 @@ row in this page's `rule` and `line` tables; the selftest holds that (`TY16`).
3162
3225
 
3163
3226
  | rule | means | change |
3164
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 |
3165
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 |
3166
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 |
3167
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 |
package/docs/STABILITY.md CHANGED
@@ -124,7 +124,7 @@ 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`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-parts",
3
- "version": "1.56.0",
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
@@ -317,6 +317,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
317
317
  cuts?: Cut[];
318
318
  skeleton?: string;
319
319
  drawn?: Record<string, number>;
320
+ tips?: Record<string, [number, number]>;
320
321
  }> = cfgAlts.map((a, i) => {
321
322
  const cli = cliByName.get(a.name);
322
323
  if (cli !== undefined) cliByName.delete(a.name);
@@ -332,6 +333,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
332
333
  cuts: a.cuts,
333
334
  skeleton: a.skeleton === undefined ? undefined : resolve(configDir, a.skeleton),
334
335
  drawn: a.drawn,
336
+ tips: a.tips,
335
337
  };
336
338
  });
337
339
  for (const cli of cliByName.values()) {
@@ -548,6 +550,18 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
548
550
  }
549
551
  for (const b of Object.keys(limbDrawn)) setPlaced.add(b);
550
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
+ }
551
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');
552
566
  if (altOthers !== undefined && input.setSplit === 'whole-limb') altOthers.line = 'whole-limb';
553
567
  // Issue #587: a subset set's limb part takes nothing a base part it does not replace covers at setup.
@@ -561,6 +575,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
561
575
  altRes = assemble({
562
576
  source: altSrc,
563
577
  limbUnderCover: alt.parts !== undefined && input.setCover !== 'painting',
578
+ ...(altTips === undefined ? {} : { boneTips: altTips }),
564
579
  capOwnership: input.setCapOwnership ?? 'target',
565
580
  full: altRuns.full,
566
581
  head: altRuns.head,
@@ -624,6 +639,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
624
639
  ...(altRes.parts.single_run_pad === undefined ? {} : { single_run_pad: altRes.parts.single_run_pad }),
625
640
  ...(altSkeleton === undefined ? {} : { skeleton: altSkeleton }),
626
641
  ...(alt.drawn === undefined ? {} : { drawn: { ...alt.drawn } }),
642
+ ...(altTips === undefined ? {} : { tips_source_size: [altSrc.width, altSrc.height], tips: altTips }),
627
643
  ...(altDrawnLength === undefined ? {} : { drawnLength: altDrawnLength }),
628
644
  ...(altRegistration === undefined ? {} : { registration: altRegistration }),
629
645
  },
package/src/config.ts CHANGED
@@ -260,6 +260,8 @@ export interface AlternateSetConfig {
260
260
  cuts?: Cut[];
261
261
  skeleton?: string;
262
262
  drawn?: Record<string, number>;
263
+ /** Explicit bone endpoints on this alternate painting, full source-crop pixels, x right/y down. */
264
+ tips?: Record<string, Point>;
263
265
  }
264
266
 
265
267
  export interface Assemble {
@@ -1356,6 +1358,9 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null):
1356
1358
  // Issue #349: the limbs' joints are their bones' origins, so the bones are read with them, and only then.
1357
1359
  let limbs: LimbNames | null = null;
1358
1360
  let names: { bones: Set<string>; chains: Map<string, number>; parents: Map<string, string> } | null = null;
1361
+ const hasTips = isPlainObject(t.assemble) && Array.isArray(t.assemble.alternates) && t.assemble.alternates.some((a) => isPlainObject(a) && 'tips' in a);
1362
+ if (hasTips && !('bones' in t)) c.fail('CONFIG_FIELD_PRESENT', 'config.bones', 'is absent; alternate tips name declared bones, so assemble reads bones when tips are supplied');
1363
+ if (hasTips && 'bones' in t && !('limbs' in t)) names = checkBones(c, t.bones);
1359
1364
  if ('limbs' in t) {
1360
1365
  if (!('bones' in t)) c.fail('CONFIG_FIELD_PRESENT', 'config.bones', 'is absent; config.limbs names bones, and each joint is its bone\'s origin, so assemble reads the bones with the limbs');
1361
1366
  names = 'bones' in t ? checkBones(c, t.bones) : null;
@@ -2132,7 +2137,7 @@ function checkAlternates(
2132
2137
  const seenNames = new Map<string, number>();
2133
2138
  (v as Json[]).forEach((entry, i) => {
2134
2139
  const at = `${p}[${i}]`;
2135
- const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'drawn']);
2140
+ const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'drawn', 'tips']);
2136
2141
  if (e === null) return;
2137
2142
  if ('name' in e && c.string(`${at}.name`, e.name)) {
2138
2143
  if (!partNameOk(e.name)) c.fail('CONFIG_PART_NAME', `${at}.name`, `names the set ${show(e.name)}; a set name is a file prefix, so it may not be empty, start with "." or hold a slash`);
@@ -2155,6 +2160,17 @@ function checkAlternates(
2155
2160
  }
2156
2161
  }
2157
2162
  }
2163
+ if ('tips' in e) {
2164
+ if (!isPlainObject(e.tips) || Object.keys(e.tips).length === 0) {
2165
+ c.fail('CONFIG_FIELD_TYPE', `${at}.tips`, `is ${show(e.tips)}; a non-empty object of declared bone name -> [x, y] in full source-crop pixels is required`);
2166
+ } else for (const [bone, point] of Object.entries(e.tips)) {
2167
+ const path = `${at}.tips.${bone}`;
2168
+ if (bones !== null && (bone === ROOT_BONE || !bones.has(bone))) c.fail('CONFIG_NAME_RESOLVES', path, `names "${bone}", which config.bones does not declare as a single bone or expanded chain link`);
2169
+ if (!Array.isArray(point) || point.length !== 2 || !point.every((n) => typeof n === 'number' && Number.isFinite(n))) {
2170
+ c.fail('CONFIG_FIELD_TYPE', path, `is ${show(point)}; a finite point [x, y] in full source-crop pixels is required`);
2171
+ }
2172
+ }
2173
+ }
2158
2174
  if ('head_box' in e) checkHeadBox(c, `${at}.head_box`, e.head_box);
2159
2175
  const altCuts = 'cuts' in e ? checkCuts(c, e.cuts, made.parts, [], `${at}.cuts`) : [];
2160
2176
  let cutsConsumedLimb = false;
package/src/limbs.ts CHANGED
@@ -115,6 +115,7 @@
115
115
  * crossing.
116
116
  */
117
117
  import type { BoneEntry, Limb, LimbSplit } from './config.ts';
118
+ import { refuseIfAny, type Problem } from './errors.ts';
118
119
  import { edgeLength } from './length.ts';
119
120
  import { pyRound } from './round.ts';
120
121
  import type { KeypointName, PosePoints } from './skeleton.ts';
@@ -128,13 +129,24 @@ export interface BonePlace {
128
129
  }
129
130
 
130
131
  /** Where every bone `bones` declares sits and ends (module comment). */
131
- export function bonePlaces(bones: readonly BoneEntry[]): Map<string, BonePlace> {
132
+ export function bonePlaces(bones: readonly BoneEntry[], tips?: Readonly<Record<string, readonly [number, number]>>): Map<string, BonePlace> {
132
133
  const out = new Map<string, BonePlace>();
133
134
  for (const b of bones) {
134
135
  if ('chain' in b) {
135
136
  b.points.forEach((p, k) => out.set(`${b.chain}${k}`, { at: [p[0], p[1]], end: k + 1 < b.points.length ? [b.points[k + 1][0], b.points[k + 1][1]] : [b.tip[0], b.tip[1]] }));
136
137
  } else out.set(b.name, { at: [b.at[0], b.at[1]], end: b.tip === undefined ? null : [b.tip[0], b.tip[1]] });
137
138
  }
139
+ // Explicit alternate endpoints overlay the already placed bones. Origins and
140
+ // following chain-link joints stay where the existing pose put them.
141
+ const problems: Problem[] = [];
142
+ for (const [bone, tip] of Object.entries(tips ?? {})) {
143
+ const place = out.get(bone);
144
+ const validPoint = Array.isArray(tip) && tip.length === 2 && tip.every((n) => typeof n === 'number' && Number.isFinite(n));
145
+ if (place === undefined) problems.push({ code: 'ASSEMBLE_ALT_TIP_NAME', object: `alternate tips.${bone}`, detail: `names "${bone}", which the supplied bones do not declare` });
146
+ if (!validPoint) problems.push({ code: 'ASSEMBLE_ALT_TIP_POINT', object: `alternate tips.${bone}`, detail: 'requires a finite [x, y] endpoint in rig-crop pixels' });
147
+ if (place !== undefined && validPoint) out.set(bone, { at: place.at, end: [tip[0], tip[1]] });
148
+ }
149
+ refuseIfAny(problems);
138
150
  return out;
139
151
  }
140
152
 
package/src/parts.ts CHANGED
@@ -304,6 +304,10 @@ export interface AlternatePartsRecord {
304
304
  scene?: SceneRecord;
305
305
  single_run_pad?: SingleRunPad;
306
306
  skeleton?: PosePoints;
307
+ /** Explicit endpoints normalized once into this parts file's rig-crop frame. */
308
+ tips?: Record<string, [number, number]>;
309
+ /** Source dimensions used to normalize tips onto rig_size; required with tips. */
310
+ tips_source_size?: [number, number];
307
311
  drawn?: Record<string, number>;
308
312
  /** Issue #539: as `sets.json`'s; written only when `skeleton` placed the set's limb bones. */
309
313
  drawnLength?: Record<string, number>;
@@ -455,6 +459,8 @@ export function serializeParts(file: PartsFile): string {
455
459
  ...(a.single_run_pad === undefined ? {} : { single_run_pad: Object.fromEntries(SINGLE_RUN_PAD_KEYS.map((k) => [k, (a.single_run_pad as SingleRunPad)[k]])) }),
456
460
  ...(a.skeleton === undefined ? {} : { skeleton: Object.fromEntries(KEYPOINT_NAMES.map((k) => [k, (a.skeleton as PosePoints)[k]])) }),
457
461
  ...(a.drawn === undefined ? {} : { drawn: a.drawn }),
462
+ ...(a.tips_source_size === undefined ? {} : { tips_source_size: a.tips_source_size }),
463
+ ...(a.tips === undefined ? {} : { tips: Object.fromEntries(Object.keys(a.tips).sort().map((bone) => [bone, (a.tips as Record<string, [number, number]>)[bone]])) }),
458
464
  ...(a.drawnLength === undefined ? {} : { drawnLength: a.drawnLength }),
459
465
  ...(a.registration === undefined ? {} : { registration: { offset: a.registration.offset, scale: a.registration.scale } }),
460
466
  })),
@@ -672,8 +678,26 @@ function checkParts(raw: unknown, path: string): PartsFile {
672
678
  o.alternates.forEach((a, i) => {
673
679
  if (typeof a !== 'object' || a === null || Array.isArray(a)) return;
674
680
  const set = a as Record<string, unknown>;
675
- if (!Array.isArray(set.records)) return;
676
681
  const at = `${path} alternates[${i}]${typeof set.name === 'string' ? ` (set "${set.name}")` : ''}`;
682
+ if ('tips' in set || 'tips_source_size' in set) {
683
+ const sourceSize = set.tips_source_size;
684
+ if (!('tips' in set) || !Array.isArray(sourceSize) || sourceSize.length !== 2 || !sourceSize.every((n) => typeof n === 'number' && Number.isInteger(n) && n > 0)) {
685
+ fail('PARTS_ALT_TIPS_SOURCE', `${at} tips_source_size`, 'requires the positive integer [source_width, source_height] used to normalize the tips; re-run assemble');
686
+ } else if (sizeOk && typeof scale === 'number' && (Math.trunc(sourceSize[0] * scale) !== (size as number[])[0] || Math.trunc(sourceSize[1] * scale) !== (size as number[])[1])) {
687
+ fail('PARTS_ALT_TIPS_SOURCE', `${at} tips_source_size`, 'does not produce rig_size at scale_rig_per_source; re-run assemble rather than guessing the normalization ratio');
688
+ }
689
+ }
690
+ if ('tips' in set) {
691
+ const t = set.tips;
692
+ if (typeof t !== 'object' || t === null || Array.isArray(t) || Object.keys(t).length === 0) {
693
+ fail('PARTS_ALT_TIPS', `${at} tips`, 'requires a non-empty bone-name map of finite [x, y] endpoints in rig-crop pixels');
694
+ } else for (const [bone, point] of Object.entries(t)) {
695
+ if (!Array.isArray(point) || point.length !== 2 || !point.every((n) => typeof n === 'number' && Number.isFinite(n))) {
696
+ fail('PARTS_ALT_TIPS', `${at} tips.${bone}`, 'requires a finite [x, y] endpoint in rig-crop pixels');
697
+ }
698
+ }
699
+ }
700
+ if (!Array.isArray(set.records)) return;
677
701
  set.records.forEach((p, j) => {
678
702
  if (typeof p !== 'object' || p === null || Array.isArray(p)) return;
679
703
  const r = p as Record<string, unknown>;
package/src/rig.ts CHANGED
@@ -1244,6 +1244,43 @@ export function buildRig(
1244
1244
  const CX = W / 2;
1245
1245
  const byPart = new Map(parts.parts.map((p) => [p.name, p]));
1246
1246
 
1247
+ // Standalone rig checks source-bound normalization, never reconstructing
1248
+ // original dimensions from nominal scale or treating source points as rig points.
1249
+ for (const a of parts.alternates ?? []) {
1250
+ if (a.tips === undefined && a.tips_source_size === undefined) continue;
1251
+ const size = a.tips_source_size;
1252
+ if (a.tips === undefined || !Array.isArray(size) || size.length !== 2 || !size.every((n) => typeof n === 'number' && Number.isInteger(n) && n > 0)
1253
+ || Math.trunc(size[0] * parts.scale_rig_per_source) !== W || Math.trunc(size[1] * parts.scale_rig_per_source) !== H) {
1254
+ fail('RIG_ALT_TIPS_SOURCE', `parts.json alternate set "${a.name}" tips_source_size`, 'requires the original source dimensions that produce rig_size at scale_rig_per_source; re-run assemble to record normalization provenance');
1255
+ }
1256
+ }
1257
+ refuseIfAny(problems);
1258
+ for (const a of cfg.assemble.alternates ?? cfg.alternates ?? []) {
1259
+ const record = parts.alternates?.find((p) => p.name === a.name);
1260
+ if (a.tips === undefined) {
1261
+ if (record?.tips !== undefined) {
1262
+ fail('RIG_ALT_TIPS_MATCH_CONFIG', `parts.json alternate set "${a.name}" tips`, 'records endpoints while the matching config set has no tips; re-run assemble after removing source-crop tips');
1263
+ }
1264
+ continue;
1265
+ }
1266
+ if (record?.tips === undefined) {
1267
+ fail('RIG_ALT_TIPS_RECORDED', `parts.json alternate set "${a.name}" tips`, 'is absent while config declares source-crop tips; re-run assemble to record normalized endpoints before rig');
1268
+ continue;
1269
+ }
1270
+ const [sw, sh] = record.tips_source_size as [number, number];
1271
+ const configured = Object.keys(a.tips).sort(), recorded = Object.keys(record.tips).sort();
1272
+ if (configured.length !== recorded.length || configured.some((bone, i) => bone !== recorded[i])) {
1273
+ fail('RIG_ALT_TIPS_MATCH_CONFIG', `parts.json alternate set "${a.name}" tips`, `records bones [${recorded.join(', ')}] while config declares [${configured.join(', ')}]; re-run assemble after changing source-crop tips`);
1274
+ } else for (const bone of configured) {
1275
+ const raw = a.tips[bone], found = record.tips[bone];
1276
+ const expected: Point = [raw[0] * (W / sw), raw[1] * (H / sh)];
1277
+ if (!Array.isArray(found) || found.length !== 2 || found[0] !== expected[0] || found[1] !== expected[1]) {
1278
+ fail('RIG_ALT_TIPS_MATCH_CONFIG', `parts.json alternate set "${a.name}" tips.${bone}`, `is ${JSON.stringify(found)}; config source-crop tip ${JSON.stringify(raw)} on ${sw}x${sh} requires rig-crop ${JSON.stringify(expected)}; re-run assemble, never reinterpret or silently replace recorded endpoints`);
1279
+ }
1280
+ }
1281
+ }
1282
+ refuseIfAny(problems);
1283
+
1247
1284
  // ---- bones -------------------------------------------------------------
1248
1285
  const B = new Map<string, Bone>();
1249
1286
  B.set(ROOT_BONE, { name: ROOT_BONE, parent: null, x: CX, y: H });
@@ -2370,6 +2407,13 @@ export function buildRig(
2370
2407
  const setEntries: Record<string, AlternateSetMap> = {};
2371
2408
  for (const [altIdx, alt] of parts.alternates.entries()) {
2372
2409
  const cfgAlt = cfg.alternates?.find((a) => a.name === alt.name);
2410
+ for (const [bone, tip] of Object.entries(alt.tips ?? {})) {
2411
+ if (bone === ROOT_BONE || !B.has(bone)) fail('RIG_NAME_RESOLVES', `parts.json alternates[${altIdx}].tips.${bone}`, `names "${bone}", which config.bones does not declare; re-run assemble with declared bone names`);
2412
+ if (!Array.isArray(tip) || tip.length !== 2 || !tip.every((n) => typeof n === 'number' && Number.isFinite(n))) {
2413
+ fail('RIG_ALT_TIP_POINT', `parts.json alternates[${altIdx}].tips.${bone}`, 'requires a finite [x, y] endpoint in rig-crop pixels');
2414
+ }
2415
+ }
2416
+ refuseIfAny(problems);
2373
2417
  const explicitDrawn = alt.drawn ?? cfgAlt?.drawn;
2374
2418
  const isSubsetSet = alt.parts !== undefined || cfgAlt?.parts !== undefined;
2375
2419
  let coveredBones: Set<string> | null = null;
@@ -2443,6 +2487,7 @@ export function buildRig(
2443
2487
  continue;
2444
2488
  }
2445
2489
  const fullSegs = meshSegments.get(p.name) as Segment[];
2490
+ const explicitSegments = new Map(fullSegs.map((s, k) => [s, typeof mesh.segments[(meshSegmentEntries.get(p.name) as number[])[k]] !== 'string']));
2446
2491
  const baseAtt = skin[p.name]?.[p.name];
2447
2492
  const baseBones = baseAtt !== undefined && 'type' in baseAtt ? new Set(baseAtt.weights.flatMap((v) => v.map((e) => e.bone))) : null;
2448
2493
  const filteredSegs = baseBones !== null && baseBones.size > 0 ? fullSegs.filter((s) => baseBones.has(s.bone)) : fullSegs;
@@ -2460,8 +2505,23 @@ export function buildRig(
2460
2505
  alt.skeleton === undefined ? null : new Map(skeletonLimbJoints(alt.skeleton).map(([bone, a, b]) => [bone, [pt(a), pt(b)] as const]));
2461
2506
  segs = segs.map((s) => {
2462
2507
  const skPair = skSegs?.get(s.bone);
2463
- return skPair !== undefined ? { bone: s.bone, a: skPair[0], b: skPair[1] } : { bone: s.bone, a: movePt(s.bone, s.a), b: movePt(s.bone, s.b) };
2508
+ const moved = skPair !== undefined ? { bone: s.bone, a: skPair[0], b: skPair[1] } : { bone: s.bone, a: movePt(s.bone, s.a), b: movePt(s.bone, s.b) };
2509
+ explicitSegments.set(moved, explicitSegments.get(s) === true);
2510
+ return moved;
2464
2511
  });
2512
+ }
2513
+ if (alt.tips !== undefined) {
2514
+ segs = segs.map((s) => {
2515
+ // Coordinate tuples are independent authored geometry. Only a named
2516
+ // bone/chain endpoint takes the explicit alternate tip.
2517
+ const explicit = explicitSegments.get(s) === true;
2518
+ const end = alt.tips?.[s.bone];
2519
+ return explicit || end === undefined ? s : { ...s, b: [end[0], end[1]] };
2520
+ });
2521
+ }
2522
+ // Select against final endpoints, retaining each original entry's
2523
+ // tuple/named provenance through the preceding pose and base filters.
2524
+ if (drawn !== undefined) {
2465
2525
  const nonSkirt = segs.filter((s) => !hipChainLinks.has(s.bone));
2466
2526
  if (nonSkirt.length > 0) segs = nonSkirt;
2467
2527
  const yOverlapping = segs.filter((s) => Math.max(s.a[1], s.b[1]) >= p.y && Math.min(s.a[1], s.b[1]) <= p.y + p.h);