rig-parts 1.68.0 → 1.69.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 +50 -1
- package/docs/STABILITY.md +1 -1
- package/package.json +1 -1
- package/src/baseanchor.ts +59 -0
- package/src/build.ts +4 -0
- package/src/check.ts +47 -4
- package/src/config.ts +5 -1
- package/src/parts.ts +9 -0
- package/src/rig.ts +34 -0
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
|
|
@@ -3779,6 +3824,10 @@ See-through with another seed.
|
|
|
3779
3824
|
| <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
3825
|
| <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
3826
|
| <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 |
|
|
3827
|
+
| <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 |
|
|
3828
|
+
| <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 |
|
|
3829
|
+
| <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 |
|
|
3830
|
+
| <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
3831
|
| <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
3832
|
| <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
3833
|
| <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 |
|
package/docs/STABILITY.md
CHANGED
|
@@ -127,7 +127,7 @@ part name, `[i]` an entry of a list):
|
|
|
127
127
|
- **seethrough** — required: `resolution`, `steps`, `seed`, `offload`; optional: `head_box`, `arm_split`
|
|
128
128
|
- **seethrough.arm_split** — required: `order`, and one of `x` or `line` (issue #439)
|
|
129
129
|
- **assemble** — required: `rig_scale`, `plan` (from plain `assemble` on); optional: `extend_below_crop`, `patches`, `cuts`, `alternates`, `head_face_underfill`
|
|
130
|
-
- **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `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`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rig-parts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.69.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] }),
|
package/src/check.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { baseAnchorMoves, type AnchorRegion } from './baseanchor.ts';
|
|
1
2
|
/**
|
|
2
3
|
* The check stage: build a rig through rig-c, gate it under both
|
|
3
4
|
* profiles, render its idle, and measure the two things the gate cannot see —
|
|
@@ -1379,6 +1380,25 @@ export function resolvePlacedAlpha(placements: readonly ReferencePlacement[], pa
|
|
|
1379
1380
|
return { name: pl.name, from: pl.box.from, x: pl.box.x, y: pl.box.y, image: islands[pl.islandIndex] ?? raw };
|
|
1380
1381
|
}
|
|
1381
1382
|
return { name: pl.name, from: pl.box.from, x: pl.box.x, y: pl.box.y, image: raw };
|
|
1383
|
+
}).map(placed => {
|
|
1384
|
+
if (Number.isInteger(placed.x) && Number.isInteger(placed.y)) return placed;
|
|
1385
|
+
// Explicit anchored placement can be subpixel. Preserve premultiplied edge
|
|
1386
|
+
// colour while moving it onto the integer reference grid, never the PNG.
|
|
1387
|
+
const { image } = placed, premult = newFloatImage(image.width, image.height, 4);
|
|
1388
|
+
for (let i = 0; i < image.width * image.height; i++) {
|
|
1389
|
+
const alpha = image.data[i * 4 + 3];
|
|
1390
|
+
for (let c = 0; c < 3; c++) premult.data[i * 4 + c] = image.data[i * 4 + c] * alpha / 255;
|
|
1391
|
+
premult.data[i * 4 + 3] = alpha;
|
|
1392
|
+
}
|
|
1393
|
+
const x = Math.floor(placed.x) - 1, y = Math.floor(placed.y) - 1;
|
|
1394
|
+
const warped = warpAffine(premult, { sx: 1, sy: 1, tx: placed.x - x, ty: placed.y - y }, image.width + 2, image.height + 2, 'bilinear');
|
|
1395
|
+
const shifted = newRaster(warped.width, warped.height);
|
|
1396
|
+
for (let i = 0; i < shifted.width * shifted.height; i++) {
|
|
1397
|
+
const alpha = warped.data[i * 4 + 3];
|
|
1398
|
+
for (let c = 0; c < 3; c++) shifted.data[i * 4 + c] = alpha > 0 ? warped.data[i * 4 + c] * 255 / alpha : 0;
|
|
1399
|
+
shifted.data[i * 4 + 3] = alpha;
|
|
1400
|
+
}
|
|
1401
|
+
return { ...placed, x, y, image: shifted };
|
|
1382
1402
|
});
|
|
1383
1403
|
}
|
|
1384
1404
|
|
|
@@ -1545,6 +1565,29 @@ export function armSplitSetHint(parts: PartsFile, alt: AlternatePartsRecord): st
|
|
|
1545
1565
|
return ` — the set covers a sleeve whose merged arm layer 1.37.0 split (issue #490), and it neither covers nor hides ${open.map((n) => `"${n}"`).join(', ')}, so the base draws ${open.length === 1 ? 'that part' : 'those parts'} beside the set's own art; a set made before 1.37.0 hides it: add ${open.map((n) => `"${n}"`).join(', ')} to the set's hides (see ${ARM_SPLIT_MIGRATION})`;
|
|
1546
1566
|
}
|
|
1547
1567
|
|
|
1568
|
+
/** Expected placement from the authored rule and base, never the candidate alternate's offset. */
|
|
1569
|
+
export function baseAnchoredReference(parts: PartsFile, alt: AlternatePartsRecord, rig: Record<string, unknown>, drawn?: Record<string, number>): AlternatePartsRecord {
|
|
1570
|
+
if (alt.base_anchor === undefined) return alt;
|
|
1571
|
+
const posed = setupWorld(stillRigForSet(rig, alt, drawn ?? alt.drawn));
|
|
1572
|
+
const slots = new Map((Array.isArray(rig.slots) ? rig.slots : []).filter(isRecord).map(s => [String(s.name), String(s.bone)]));
|
|
1573
|
+
const skins = isRecord(rig.skins) && isRecord(rig.skins.default) ? rig.skins.default : {};
|
|
1574
|
+
const source = new Map<string, AnchorRegion>(), base = new Map<string, AnchorRegion>();
|
|
1575
|
+
for (const record of alt.records) {
|
|
1576
|
+
const slot = (alt.front ?? []).includes(record.name) ? `${record.name}${FRONT_SUFFIX}` : record.name;
|
|
1577
|
+
const bone = slots.get(slot), frame = bone === undefined ? undefined : posed.get(bone);
|
|
1578
|
+
const list = skins[record.name], original = isRecord(list) ? list[record.name] : null;
|
|
1579
|
+
if (bone === undefined || frame === undefined) continue;
|
|
1580
|
+
const local = toBoneLocal(frame, record.x + record.w / 2 - parts.rig_size[0] / 2, cropToSpineY(record.y + record.h / 2, parts.rig_size[1]));
|
|
1581
|
+
source.set(record.name, { bone, x: local[0], y: local[1] });
|
|
1582
|
+
if (isRecord(original) && typeof original.x === 'number' && typeof original.y === 'number' && (original.type === undefined || original.type === 'region')) base.set(record.name, { bone, x: original.x, y: original.y });
|
|
1583
|
+
}
|
|
1584
|
+
const moves = baseAnchorMoves(alt.base_anchor, base, source, posed);
|
|
1585
|
+
return { ...alt, records: alt.records.map(record => {
|
|
1586
|
+
const move = moves.get(record.name);
|
|
1587
|
+
return move === undefined ? record : { ...record, x: record.x + move.world[0], y: record.y - move.world[1] };
|
|
1588
|
+
}) };
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1548
1591
|
/**
|
|
1549
1592
|
* The flat stack of parts for an alternate set (issue #454), in the order
|
|
1550
1593
|
* {@link setPlacements} gives: with `slotOrder`, a front part (issue #664) is
|
|
@@ -6349,7 +6392,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6349
6392
|
writeFileSync(join(dir, 'motion.json'), JSON.stringify({ ...inp.motion, animations: setStillAnimations }));
|
|
6350
6393
|
const built = rigc(['build', '--rig', join(dir, 'rig.json'), '--motion', join(dir, 'motion.json'), '--out', join(dir, 'build'), '--profile', 'spine']);
|
|
6351
6394
|
if (built.status !== 0) refuseIfAny(rigcFailed(`build (the setup-pose still of set "${alt.name}")`, built, buildGateLines(built.out)));
|
|
6352
|
-
return { alt, dir };
|
|
6395
|
+
return { alt, reference: baseAnchoredReference(inp.parts!, alt, inp.rig, drawn), dir };
|
|
6353
6396
|
});
|
|
6354
6397
|
const states: SeamStateBounds[] = [seamStateBounds(join(stillDir, 'build'), 'base')];
|
|
6355
6398
|
for (const { alt, dir } of staged) states.push(seamStateBounds(join(dir, 'build'), alt.name));
|
|
@@ -6382,15 +6425,15 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6382
6425
|
}
|
|
6383
6426
|
if (set !== undefined || allSets) {
|
|
6384
6427
|
const baseSupport = seamSupport(join(stillDir, 'build'), join(stillDir, 'rig.json'), canonicalSet, placed, seamStacks, inp.stage);
|
|
6385
|
-
for (const { alt, dir: setDir } of staged) {
|
|
6428
|
+
for (const { alt, reference, dir: setDir } of staged) {
|
|
6386
6429
|
const asr = rigc(['render', '--candidate', join(setDir, 'build'), '--animation', 'still', '--fps', String(STILL_FPS), '--max', String(maxSide), '--out', join(setDir, 'render')]);
|
|
6387
6430
|
if (asr.status !== 0) refuseIfAny(rigcFailed(`render (the setup-pose still of set "${alt.name}")`, asr, asr.out.split('\n').filter((l) => l.includes('FAIL'))));
|
|
6388
6431
|
const altStillSet = readFrameSet(join(setDir, 'render'));
|
|
6389
6432
|
if (keepStills) cpSync(join(setDir, 'render'), join(out, 'setup_still_auto', alt.name), { recursive: true });
|
|
6390
|
-
const altComposite = flatCompositeForSet(inp.parts,
|
|
6433
|
+
const altComposite = flatCompositeForSet(inp.parts, reference, inp.partsDir, altStillSet.background, rigSlotOrder);
|
|
6391
6434
|
const altCanonical = canonical(join(setDir, 'build'), join(setDir, 'seam'));
|
|
6392
6435
|
if (keepStills) cpSync(join(setDir, 'seam'), join(keptDir, alt.name), { recursive: true });
|
|
6393
|
-
const altPlaced = resolvePlacedAlpha(setPlacements(inp.parts,
|
|
6436
|
+
const altPlaced = resolvePlacedAlpha(setPlacements(inp.parts, reference, rigSlotOrder), inp.partsDir);
|
|
6394
6437
|
const altSupport = seamSupport(join(setDir, 'build'), join(setDir, 'rig.json'), altCanonical, altPlaced, seamStacks, inp.stage);
|
|
6395
6438
|
const effects = seamEffectSelection(baseSupport, altSupport);
|
|
6396
6439
|
const autoAltSeam = seamFigures(altComposite, altStillSet.frames[0].image, inp.stage, altStillSet.viewport, altStillSet.background, undefined, alt.scene !== undefined);
|
package/src/config.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { baseAnchorProblems, type BaseAnchor } from './baseanchor.ts';
|
|
1
2
|
import type { DepthConfig } from './depthsheets.ts';
|
|
2
3
|
/**
|
|
3
4
|
* The character config: everything character-specific the CPU stages read,
|
|
@@ -267,6 +268,8 @@ export interface Cut {
|
|
|
267
268
|
|
|
268
269
|
export interface AlternateSetConfig {
|
|
269
270
|
name: string;
|
|
271
|
+
/** Opt-in base region offsets on explicitly selected local axes, with paired painting patches. */
|
|
272
|
+
base_anchor?: BaseAnchor;
|
|
270
273
|
/** Authored point on this painting, x right/y down; omitted means no focus. */
|
|
271
274
|
focus?: Point;
|
|
272
275
|
source?: string;
|
|
@@ -2267,7 +2270,7 @@ function checkAlternates(
|
|
|
2267
2270
|
const seenNames = new Map<string, number>();
|
|
2268
2271
|
(v as Json[]).forEach((entry, i) => {
|
|
2269
2272
|
const at = `${p}[${i}]`;
|
|
2270
|
-
const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'anchor', 'drawn', 'tips', 'front', 'layers', 'focus']);
|
|
2273
|
+
const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'anchor', 'drawn', 'tips', 'front', 'layers', 'focus', 'base_anchor']);
|
|
2271
2274
|
if (e === null) return;
|
|
2272
2275
|
if ('name' in e && c.string(`${at}.name`, e.name)) {
|
|
2273
2276
|
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`);
|
|
@@ -2380,6 +2383,7 @@ function checkAlternates(
|
|
|
2380
2383
|
if (typeof layer !== 'string' || readLayerTag(layer) === null) c.fail('CONFIG_TAG_KNOWN', path, `is ${show(layer)}; a See-through v3 tag or "${AUTHOR_PREFIX}<label>" is required; ${AUTHOR_LABEL_RULE}`);
|
|
2381
2384
|
}
|
|
2382
2385
|
}
|
|
2386
|
+
if ('base_anchor' in e) c.problems.push(...baseAnchorProblems(e.base_anchor, `${at}.base_anchor`, new Set([...('parts' in e ? seenParts : baseSlots)].filter(n => !seenHides.has(n))), new Set(made.patches), isPlainObject(regions) ? new Set(Object.keys(regions).filter(n => !isPlainObject(meshes) || !Object.hasOwn(meshes, n))) : undefined));
|
|
2383
2387
|
// Issue #664: a part the set draws on its front slot is one the set covers and a limb declares a front slot for.
|
|
2384
2388
|
if ('front' in e) {
|
|
2385
2389
|
if (!Array.isArray(e.front) || e.front.length === 0) {
|
package/src/parts.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { baseAnchorProblems, orderedBaseAnchor, type BaseAnchor } from './baseanchor.ts';
|
|
1
2
|
import { partDepthProblems, type PartDepthReference } from './depthsheets.ts';
|
|
2
3
|
/**
|
|
3
4
|
* The output contract of the assemble stage: `parts.json`, one record per
|
|
@@ -305,6 +306,7 @@ export interface RecompositeRecord {
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
export interface AlternateSetMap {
|
|
309
|
+
base_anchor?: BaseAnchor;
|
|
308
310
|
/** Authored point in setup-world coordinates, only when supplied (issue #719). */
|
|
309
311
|
focus?: [number, number];
|
|
310
312
|
slots: Record<string, string>;
|
|
@@ -325,6 +327,7 @@ export const FRONT_SUFFIX = '_front';
|
|
|
325
327
|
|
|
326
328
|
export interface AlternatePartsRecord {
|
|
327
329
|
name: string;
|
|
330
|
+
base_anchor?: BaseAnchor;
|
|
328
331
|
/** Original authored painting point and its source size, only when supplied. */
|
|
329
332
|
focus?: [number, number];
|
|
330
333
|
focus_source_size?: [number, number];
|
|
@@ -492,6 +495,7 @@ export function serializeParts(file: PartsFile): string {
|
|
|
492
495
|
: {
|
|
493
496
|
alternates: file.alternates.map((a) => ({
|
|
494
497
|
name: a.name,
|
|
498
|
+
...(a.base_anchor === undefined ? {} : { base_anchor: orderedBaseAnchor(a.base_anchor) }),
|
|
495
499
|
...(a.parts === undefined ? {} : { parts: a.parts }),
|
|
496
500
|
...(a.hides === undefined ? {} : { hides: a.hides }),
|
|
497
501
|
...(a.front === undefined ? {} : { front: a.front }),
|
|
@@ -702,6 +706,11 @@ function checkParts(raw: unknown, path: string): PartsFile {
|
|
|
702
706
|
if (typeof a !== 'object' || a === null || Array.isArray(a)) return;
|
|
703
707
|
const set = a as Record<string, unknown>;
|
|
704
708
|
const at = `${path} alternates[${i}]${typeof set.name === 'string' ? ` (set "${set.name}")` : ''}`;
|
|
709
|
+
if ('base_anchor' in set) {
|
|
710
|
+
const names = new Set(Array.isArray(set.records) ? set.records.flatMap(v => typeof v === 'object' && v !== null && typeof v.name === 'string' ? [v.name] : []) : []);
|
|
711
|
+
const patches = new Set(Array.isArray(set.records) ? set.records.flatMap(v => typeof v === 'object' && v !== null && typeof v.name === 'string' && typeof v.from === 'string' && v.from.startsWith('painting:') ? [v.name] : []) : []);
|
|
712
|
+
problems.push(...baseAnchorProblems(set.base_anchor, `${at}.base_anchor`, names, patches, undefined, 'PARTS_ALT_BASE_ANCHOR'));
|
|
713
|
+
}
|
|
705
714
|
if (sizeOk && typeof scale === 'number') problems.push(...recordedFocusProblems(set, `${at}.focus`, size as number[], scale));
|
|
706
715
|
if ('tips' in set || 'tips_source_size' in set) {
|
|
707
716
|
const sourceSize = set.tips_source_size;
|
package/src/rig.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { baseAnchorProblems, orderedBaseAnchor, baseAnchorMoves, type AnchorRegion } from './baseanchor.ts';
|
|
1
2
|
import { padDepthSheet, padTurnDepthSheet, depthSheetProblems, type PartDepthReference } from './depthsheets.ts';
|
|
2
3
|
import { explicitBoneNames, explicitSlotBones, explicitWeightRows, regionBone } from './config.ts';
|
|
3
4
|
import { explicitAttachment, type ExplicitMeshReport } from './explicitmesh.ts';
|
|
@@ -1321,11 +1322,27 @@ export function buildRig(
|
|
|
1321
1322
|
const CX = W / 2;
|
|
1322
1323
|
const byPart = new Map(parts.parts.map((p) => [p.name, p]));
|
|
1323
1324
|
|
|
1325
|
+
const configuredAlts = cfg.assemble.alternates ?? cfg.alternates ?? [];
|
|
1326
|
+
const anchorRegions = new Set(Object.keys(cfg.regions).filter(n => !(n in cfg.meshes)));
|
|
1327
|
+
for (const a of configuredAlts) {
|
|
1328
|
+
if (a.base_anchor === undefined) continue;
|
|
1329
|
+
const covered = new Set((a.parts ?? parts.parts.map(p => p.name)).filter(n => !(a.hides ?? []).includes(n)));
|
|
1330
|
+
problems.push(...baseAnchorProblems(a.base_anchor, `config alternate set "${a.name}".base_anchor`, covered, new Set((cfg.assemble.patches ?? []).map(p => p.name)), anchorRegions, 'RIG_ALT_BASE_ANCHOR'));
|
|
1331
|
+
}
|
|
1332
|
+
for (const a of parts.alternates ?? []) {
|
|
1333
|
+
if (a.base_anchor !== undefined) problems.push(...baseAnchorProblems(a.base_anchor, `parts.json alternate set "${a.name}".base_anchor`, new Set(a.records.map(p => p.name)), new Set(a.records.filter(p => p.from.startsWith('painting:')).map(p => p.name)), anchorRegions, 'RIG_ALT_BASE_ANCHOR'));
|
|
1334
|
+
}
|
|
1335
|
+
// Direct callers need the same shape checks as serialized readers. Collect
|
|
1336
|
+
// both sides before any canonical ordering can inspect their axes or pairs.
|
|
1337
|
+
refuseIfAny(problems);
|
|
1324
1338
|
for (const a of parts.alternates ?? []) {
|
|
1339
|
+
const configured = configuredAlts.find(c => c.name === a.name)?.base_anchor;
|
|
1340
|
+
if (JSON.stringify(configured === undefined ? null : orderedBaseAnchor(configured)) !== JSON.stringify(a.base_anchor === undefined ? null : orderedBaseAnchor(a.base_anchor))) fail('RIG_ALT_BASE_ANCHOR_MATCH_CONFIG', `alternate set "${a.name}" base_anchor`, 'config and parts.json declare different base anchors; re-run assemble before rig');
|
|
1325
1341
|
problems.push(...recordedFocusProblems(a, `parts.json alternate set "${a.name}".focus`, parts.rig_size, parts.scale_rig_per_source));
|
|
1326
1342
|
}
|
|
1327
1343
|
for (const a of cfg.assemble.alternates ?? cfg.alternates ?? []) {
|
|
1328
1344
|
const record = parts.alternates?.find((p) => p.name === a.name);
|
|
1345
|
+
if (a.base_anchor !== undefined && record === undefined) fail('RIG_ALT_BASE_ANCHOR_MATCH_CONFIG', `alternate set "${a.name}" base_anchor`, 'has no assembled set; re-run assemble before rig');
|
|
1329
1346
|
if ((a.focus !== undefined || record?.focus !== undefined)
|
|
1330
1347
|
&& JSON.stringify(a.focus) !== JSON.stringify(record?.focus)) {
|
|
1331
1348
|
fail('CONFIG_SET_FOCUS', `config.assemble alternate set "${a.name}".focus`, 'does not match the assembled painting point; re-run assemble after changing or removing focus');
|
|
@@ -2867,6 +2884,22 @@ export function buildRig(
|
|
|
2867
2884
|
for (const [x, y] of lm.vertices) uvs.push(pyRound(x / w, 6), pyRound(y / h, 6));
|
|
2868
2885
|
skin[skinSlot][attName] = { type: 'mesh', image: file, width: w, height: h, uvs, triangles: lm.triangles, hull: lm.hull, weights };
|
|
2869
2886
|
}
|
|
2887
|
+
if (alt.base_anchor !== undefined) {
|
|
2888
|
+
const baseRegions = new Map<string, AnchorRegion>(), altRegions = new Map<string, AnchorRegion>();
|
|
2889
|
+
for (const p of alt.records) {
|
|
2890
|
+
if (cfg.meshes[p.name] !== undefined || cfg.regions[p.name] === undefined) continue;
|
|
2891
|
+
const bone = regionBone(cfg.regions[p.name]), slot = altFront.has(p.name) ? `${p.name}${FRONT_SUFFIX}` : p.name;
|
|
2892
|
+
const original = skin[p.name]?.[p.name], art = skin[slot]?.[`${alt.name}_${p.name}`];
|
|
2893
|
+
if (original !== undefined && !('type' in original)) baseRegions.set(p.name, { bone, x: original.x, y: original.y });
|
|
2894
|
+
if (art !== undefined && !('type' in art)) altRegions.set(p.name, { bone, x: art.x, y: art.y });
|
|
2895
|
+
}
|
|
2896
|
+
const moves = baseAnchorMoves(alt.base_anchor, baseRegions, altRegions, altWorld);
|
|
2897
|
+
for (const [name, move] of moves) {
|
|
2898
|
+
const slot = altFront.has(name) ? `${name}${FRONT_SUFFIX}` : name;
|
|
2899
|
+
const attachment = skin[slot][`${alt.name}_${name}`] as RegionAttachment;
|
|
2900
|
+
skin[slot][`${alt.name}_${name}`] = { ...attachment, x: places(attachment.x + move.local[0]), y: places(attachment.y + move.local[1]) };
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2870
2903
|
const slotMap: Record<string, string> = {};
|
|
2871
2904
|
for (const [slotName, att] of Object.entries(alt.slots)) slotMap[slotName] = att;
|
|
2872
2905
|
const hideList: string[] = [];
|
|
@@ -2882,6 +2915,7 @@ export function buildRig(
|
|
|
2882
2915
|
const coversFace = Object.hasOwn(slotMap, 'face');
|
|
2883
2916
|
setEntries[alt.name] = {
|
|
2884
2917
|
slots: slotMap,
|
|
2918
|
+
...(alt.base_anchor === undefined ? {} : { base_anchor: orderedBaseAnchor(alt.base_anchor) }),
|
|
2885
2919
|
...(alt.focus === undefined ? {} : { focus: paintingToSetupPoint(alt.focus, alt.focus_source_size as [number, number], parts.rig_size) }),
|
|
2886
2920
|
...(hideList.length > 0 ? { hides: hideList } : {}),
|
|
2887
2921
|
...(drawn === undefined ? {} : { drawn }),
|