rig-parts 1.58.0 → 1.59.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 +61 -2
- package/docs/STABILITY.md +3 -2
- package/package.json +1 -1
- package/src/build.ts +40 -5
- package/src/check.ts +51 -24
- package/src/config.ts +97 -3
- package/src/parts.ts +27 -0
- package/src/rig.ts +91 -11
- package/src/scene.ts +3 -2
package/docs/AUTHORING.md
CHANGED
|
@@ -118,9 +118,9 @@ 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?, 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 |
|
|
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?, 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>]`. `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 |
|
|
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
|
-
| `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 |
|
|
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?}, …], 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 |
|
|
125
125
|
| `meshes.<part>` | rig | **proposed**, then corrected. Exactly one of `grid` (the lattice: cell size, px — what `propose` writes: by default one spacing for the figure, round(H / 37) rig px with H the height of every part's box together, a part whose tenth of its short side is already coarser keeping that, and under `propose --grid-rule part` the reference's tenth of the part's short side clamped to 5..36, issue #265), `contour` (the outline mode, authored; the next row and "A contour mesh" below) or `auto` (the automatic mode, authored; "An automatic mesh" below) — two, or none, is `CONFIG_MESH_MODE`. In every mode: `r` (added to every distance before weighting: `w = 1/(d + r)²`), `segments` (a chain name, a bone name with a `tip`, or `[bone, [x0,y0], [x1,y1]]`), and, **authored**, optional, `exponent` (issue #161): a number above 0 that replaces the 2 in that rule, `w = 1/(d + r)^exponent` — a larger one hands each vertex more fully to its nearest bone; absent is 2 and changes no byte, a value that is not a number above 0 is `CONFIG_FIELD_TYPE` at `meshes.<part>.exponent`, and a declared one is echoed as `exponent` in the mesh's `mesh_report.json` row; the exponent is the distance rule's, so declared beside `rule: "heat"` it is refused (`CONFIG_FIELD_TYPE` at `meshes.<part>.exponent`). The segment list is the one authored decision about a layer: which bones may pull it. The slot's bone is the first segment's. Optional `rule` (issue #161): `"distance"` — the rule above, and what an absent `rule` means (every byte is the same) — or `"heat"`, bone heat over the part's own silhouette, in every mode: the lattice's art (alpha above 8, less any island a declared `stray` left out) with holes filled, or for `contour` and `auto` the silhouette their outline is traced from (that mode's art — alpha above 8 for `contour`, alpha 1 and above for `auto` — less any island a declared `stray` left out, holes filled, grown by its `margin`); each bound bone's sources are the silhouette pixels whose centre lies within 0.75 px of its segment (a pixel two bones reach goes to the nearer, a tie to the first listed), held at 1 for that bone and 0 for the others; the field is solved by row-major Gauss–Seidel over-relaxation to a sweep change under 1e-7 within 20000 sweeps; a vertex reads the nearest silhouette pixel and takes the same cap and floor (and `regions`) as the distance rule; `r` is not read. The mesh's `mesh_report.json` row gains `heat` (the constants, each bone's sources and sweeps, the residual). Any other value is `CONFIG_FIELD_TYPE`; a bound bone with no source pixel is `RIG_HEAT_BONE_SOURCE`, an island no bone has a source in `RIG_HEAT_ISLAND_SOURCE`, a solve past its sweep bound `RIG_HEAT_CONVERGED` — none is weighted 0. The rule is chosen per mesh, so `RIG_HEAT_BONE_SOURCE` names three remedies: move the segment onto the art, take the bone out of `segments`, or keep this part on the distance rule — the one to take when the bone anchors the part from outside its art (a torso bone under a neck), since the first moves a bone another part placed and the second drops the anchor (issue #303). On a lattice, `RIG_HEAT_ISLAND_SOURCE` on an island that is dust — at most 4 px and at most 0.1 % of the part's art px, `mesh-draft`'s line — names `meshes.<part>.stray` and the figure that leaves it out, with the value declared; an island above that line keeps the segment remedy, a real piece being a real authoring question. In every mode the mesh's `mesh_report.json` row's `bones` names the bones the emitted model binds for the attachment — the sorted set its weights in the written `rig.json` name, so a `turn` twin (`turn_<part>_<bone>`) or a stopped link's `<link>_d` where those rebind it, never the segment bone it stands for — the same list in every mode, `remesh --delta`'s included (issue #536) |
|
|
126
126
|
| `meshes.<part>.influence` | rig | **authored**, optional (issue #378), a mode beside `grid`, `contour` and `auto`: `{cell, radius, across, max, shape, hold_tip?}`, every field but `hold_tip` required, none defaulted. rig-c's `segments` lattice over the part at `cell` px, each vertex pulled by every link of the mesh's `segments` within `radius` px of it — a pull that falls to exactly 0 at `radius` (`shape` `"linear"` or `"smooth"`), across the `segments` entries or only within the nearest one (`across`), the strongest `max` kept. The lattice and the shares are computed by rig-c's own promised functions (`buildSegmentsLattice`, `segmentDistance`, `influenceShares`), so the rule is rig-c's (its AUTHORING §3.4.7), and the mesh is written with explicit weights like every other mode. `radius` is a length on this part: the rig stage measures the farthest lattice vertex's distance to its nearest link and refuses a radius at or under it (`RIG_INFLUENCE_REACH`), naming the distance. `propose --cloth` drafts it when a recipe declares `influence` and no `radius` (issue #518): the farthest vertex's distance plus 3 of the part's lattice cells, printed on a `LINT` line with both figures. Measured on the cloth fixture and the public `wind` example (#513: 8 covered parts, `render --folds` with the physics on under wind and a hip sway of 8° and 30°): a radius just above the floor folds **more** than the lattice (one skirt went from 0 to 55 folded frames), and a larger one is **not** safer (one fringe folded again at about 3–4× its farthest distance); +2 to +6 cells read 0 on every part, +2 at the edge. That reading counted folds only; read against `check` as well (the rig as built, under the wind schedule +1 → −1 → calm, `build --environment`, the three covered `wind` parts at the same number of cells), the window that holds is **+2 to +3 cells**, and +4 is the ceiling: `wind` `bottomwear`'s `CHECK_TIP_OVER_ROOT` ratio is 1.898 on the lattice, 1.801 at +2 cells, 1.590 at +3 and **1.471 at +4**, under the floor 1.4725, so the build fails there, and 1.351 at +6 (#513, rig-parts 1.52.0, rigc 2.60.0; the lattice, +3 and +4 read again on rig-parts 1.54.0, rigc 2.60.0, the same figures, #599). The drafted +3 sits in that window, one cell under the ceiling (no radius between +3 and +4 was read), and the window is a hypothesis until a third subject — each edge rests on one part — so state `radius` in the recipe to keep your own. `r`, `exponent`, `rule`, `influences`, `stray` and `ribs` belong to the distance rule or another mode and are refused beside it (`CONFIG_INFLUENCE_MODE`). `hold_tip` (issue #615) — `true` only, or absent: the pulled shares are smoothed by the lattice's held-fork passes (the cloth recipe's `split.hold_tip` sentence below: four passes of 1-ring mesh-edge averaging, self weight 0.5, floor 0.005) capped at the declared `max`, so no vertex binds more than `max` bones; absent, the shares are rig-c's as pulled and every byte is the one written before the field existed (`false`, a second spelling of absent, is `CONFIG_FIELD_TYPE`). The mesh's `mesh_report.json` row echoes it in `influence`. `propose --cloth` writes it, with `max` raised to at least 8 (the lattice's smoothing cap), on the parts a recipe with `influence` and `split.hold_tip: true` meshes; the rig stage reads it off the mesh and never the recipe. Measured on `wind` `bottomwear` and the cloth fixture's skirt under a 60° hip sway (#615, `render --folds`, physics on): `wind` `bottomwear` folds 41 frames as drafted before the field (max 6) and **0** with `hold_tip` and max 8, against its lattice's 5; with `hold_tip` at max 6 it reads 23, and at max 8 without `hold_tip` 3; the fixture skirt (recipe given `split.hold_tip`) reads 20 before and 0 with it, against its lattice's 0, and 0 at max 8 without it. So the raised `max` carries most of the gap and the smoothing the rest on `wind` (rig-parts 1.54.0, rigc 2.60.0; a split skirt without `hold_tip` is not smoothed and reads its 44 as before). For cloth and hair that should bend as one surface across its chains |
|
|
@@ -877,6 +877,59 @@ The first character built this way (the exam-01 test rig, issue #349) read, per
|
|
|
877
877
|
missing cap pixels at the elbows and knees and 468 and 562 at the ankles, where the shoe starts
|
|
878
878
|
below the ankle line.
|
|
879
879
|
|
|
880
|
+
### Front slots (issue #664)
|
|
881
|
+
|
|
882
|
+
A gesture set (`assemble.alternates`, issue #476) replaces a limb's attachments
|
|
883
|
+
but cannot change where they are drawn: a set maps slot to attachment and never
|
|
884
|
+
reorders slots. A forearm brought across the chest is drawn where the base arm
|
|
885
|
+
is, behind the topwear and the face. A **front slot** is a second slot for one
|
|
886
|
+
segment, declared on its limb:
|
|
887
|
+
|
|
888
|
+
```json
|
|
889
|
+
"limbs": { "arm_r": { "segments": [ … ], "front": { "parts": ["forearm_r"], "after": "face" } } }
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
and drawn on by a set that names the part in its own `front`:
|
|
893
|
+
|
|
894
|
+
```json
|
|
895
|
+
{ "name": "chest", "parts": ["upperarm_r", "forearm_r"], "drawn": { "sleeve_r1": 0 }, "front": ["forearm_r"] }
|
|
896
|
+
```
|
|
897
|
+
|
|
898
|
+
- `front.parts` is a nonempty list of this limb's own segment parts, each once
|
|
899
|
+
(`CONFIG_FRONT_SCOPE`). `front.after` names one produced part — the same
|
|
900
|
+
notion a layout's `part` target uses, so a consumed source layer is not one —
|
|
901
|
+
and not a segment of this same limb (`CONFIG_FRONT_NAME`).
|
|
902
|
+
- The rig stage adds `<part>_front` on the bone the part's base slot binds, with
|
|
903
|
+
**no setup attachment** (`"attachment": null`), and places it immediately
|
|
904
|
+
after `after`'s whole slot family (its slot and its `<part>_still`) in the
|
|
905
|
+
final setup order; several front slots after one family keep the config's
|
|
906
|
+
order. The slot rides stops and the turn control with the rest, and stays out
|
|
907
|
+
of the limb closure (#646). An empty front slot renders nothing: with no set
|
|
908
|
+
using it, the setup render is pixel-identical, and a config with no `front`
|
|
909
|
+
anywhere writes the same bytes as before.
|
|
910
|
+
- A set's `front` part is drawn from `slots["<part>_front"]` and its base slot
|
|
911
|
+
`<part>` is hidden while the set is active (`sets.json` `hides`, with
|
|
912
|
+
`<part>_still` when there is one); its attachment is filed under the front
|
|
913
|
+
slot's skin key, with the same bones and weights. A part in a set's `front`
|
|
914
|
+
must be covered by that set and declared on its limb (`CONFIG_SET_FRONT`); a
|
|
915
|
+
`parts.json` set record mapping both `<part>` and `<part>_front` is refused
|
|
916
|
+
(`RIG_SET_FRONT_BOTH`).
|
|
917
|
+
- `assemble` places the front part after its target when it clears the
|
|
918
|
+
set's part of what base parts cover (#587) and when it measures the set's
|
|
919
|
+
recomposite; `check --set` stacks the set's flat composite the same way, at
|
|
920
|
+
the front slot's place in the rig's final slot order, so the seam reads the
|
|
921
|
+
forearm against the parts now behind it.
|
|
922
|
+
- Version 1 does not compose with an explicit limb layout (#647): a config that
|
|
923
|
+
declares `front` on one limb and `layout` on any limb is refused
|
|
924
|
+
(`CONFIG_FRONT_LAYOUT`). Keyed draw-order changes are out of scope: a `{"t", "set"}`
|
|
925
|
+
key that switches a set drawing the track's part on its front slot is refused
|
|
926
|
+
(`CONFIG_SET_FRONT_KEYED`) — show such a set with `setSet`.
|
|
927
|
+
- `assemble` reads the front part's place off `parts.json`'s order (after
|
|
928
|
+
`after`), while the rig and `check --set` read it off the final setup slot
|
|
929
|
+
order. The two agree unless the limb closure (#646) moves the target's
|
|
930
|
+
family; then only the set's #587 exclusion and recomposite figures read the
|
|
931
|
+
parts order, and the render and its seam bar follow the rig.
|
|
932
|
+
|
|
880
933
|
### The weight cut (`meshes.<part>.influences`, issue #284)
|
|
881
934
|
|
|
882
935
|
This section and the mesh sections after it are for parts with no joints; a limb is cut at
|
|
@@ -3557,6 +3610,12 @@ says why each requirement exists and what breaks without it.
|
|
|
3557
3610
|
| <a id="CONFIG_LAYOUT_TARGET"></a>`CONFIG_LAYOUT_TARGET` | `config.limbs.<name>.layout` declares both or neither `before`/`after`, or a target declares both or neither `limb`/`part` | write one immediate placement side and one typed named target |
|
|
3558
3611
|
| <a id="CONFIG_LAYOUT_NAME"></a>`CONFIG_LAYOUT_NAME` | a layout names no declared target limb or produced part; a consumed source layer is not an emitted part | use the declared limb or produced segment/part names printed in the detail |
|
|
3559
3612
|
| <a id="CONFIG_LAYOUT_SCOPE"></a>`CONFIG_LAYOUT_SCOPE` | layout `parts` is empty, duplicated, nonconsecutive, foreign, or names a rider instead of an own source-bound segment part | select distinct consecutive own segment-part references; inherited riders are proven separately |
|
|
3613
|
+
| <a id="CONFIG_FRONT_SCOPE"></a>`CONFIG_FRONT_SCOPE` | `config.limbs.<name>.front.parts` (issue #664) is empty, repeats a part, or names a part that is not one of this limb's own segment parts | list this limb's own segment parts, each once |
|
|
3614
|
+
| <a id="CONFIG_FRONT_NAME"></a>`CONFIG_FRONT_NAME` | `config.limbs.<name>.front.after` (issue #664) names no produced part (a consumed source layer is not one), or names a segment part of this same limb; or a part `front.parts` names would take the slot name `<part>_front` of a part the config already makes | name a produced part the limb is drawn behind, from the list in the detail; or rename the part holding that name |
|
|
3615
|
+
| <a id="CONFIG_FRONT_LAYOUT"></a>`CONFIG_FRONT_LAYOUT` | a config declares `config.limbs.<name>.front` (issue #664) while some limb declares `layout` (issue #647); version 1 does not compose the two | drop one of them on this rig |
|
|
3616
|
+
| <a id="CONFIG_SET_FRONT"></a>`CONFIG_SET_FRONT` | `assemble.alternates[i].front` (issue #664) is empty, repeats a part, or names a part the set does not cover (in its `parts`, not its `hides`) or that no `config.limbs.<limb>.front.parts` lists; the detail names the part and which held | cover the part in the set's `parts`, and declare its front slot on its limb |
|
|
3617
|
+
| <a id="CONFIG_SET_FRONT_KEYED"></a>`CONFIG_SET_FRONT_KEYED` | `motion.animations_from` (issue #664): a `{"t", "set"}` key on a slot attachment track names a set that draws the track's part on its front slot; that would change the draw order mid-clip, which is out of scope | show the set with `setSet`, or key a part the set draws on its base slot |
|
|
3618
|
+
| <a id="RIG_SET_FRONT_BOTH"></a>`RIG_SET_FRONT_BOTH` | a `parts.json` alternate record (issue #664) maps both a part's slot and its front slot `<part>_front`; the detail names the set and the part | re-run `assemble`, which maps one or the other |
|
|
3560
3619
|
| <a id="RIG_LAYOUT_NONEXCLUSIVE"></a>`RIG_LAYOUT_NONEXCLUSIVE` | a requested segment family/target, or an accepted replay's bindings, span owners or leave the selected segment scope across base/alternate attachments | correct the named bindings or scope; mixed ownership is never forced and no stale proof is emitted |
|
|
3561
3620
|
| <a id="RIG_LAYOUT_UNREPRESENTABLE"></a>`RIG_LAYOUT_UNREPRESENTABLE` | the named slot family is absent, a target is not contiguous, the accepted slot population/adjacency changed, or final rig text is stale | use an emitted contiguous target and the exact final accepted source; unrelated slots are not absorbed |
|
|
3562
3621
|
| <a id="RIG_LAYOUT_CONFLICT"></a>`RIG_LAYOUT_CONFLICT` | layout declarations share a slot, target themselves, or form a reciprocal/chained pair; both field paths are printed | declare one disjoint pair, with each participating slot in only that placement |
|
package/docs/STABILITY.md
CHANGED
|
@@ -127,13 +127,14 @@ 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`, `drawn`, `tips` (issues #454, #465, #652)
|
|
130
|
+
- **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `drawn`, `tips`, `front` (issues #454, #465, #652, #664)
|
|
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`
|
|
134
134
|
- **assemble.cuts[i]** — required: `from`, `into`, `polygon`, `draw`, `overlap`; optional: `under`, `under_fill`
|
|
135
135
|
- **assemble.cuts[i].draw**, when an object — required: `before`
|
|
136
|
-
- **limbs.<limb>** — required: `segments`; optional: `split`, `layout` (issues #349, #446, #647)
|
|
136
|
+
- **limbs.<limb>** — required: `segments`; optional: `split`, `layout`, `front` (issues #349, #446, #647, #664)
|
|
137
|
+
- **limbs.<limb>.front** — required: `parts` (own segment parts, issue #664), `after` (a produced part)
|
|
137
138
|
- **limbs.<limb>.layout** — exactly one of `before`, `after`; optional: `parts` (own consecutive segment-part references, issue #647)
|
|
138
139
|
- **limbs.<limb>.layout.before**, **limbs.<limb>.layout.after** — exactly one typed target: `limb` or `part`
|
|
139
140
|
- **limbs.<limb>.segments[i]** — required: `part`, `from`, `bone`; required below a joint (i > 0): `joint`; optional below a joint: `range`, `cap`, `edge`, `cap_shape`, `cut_band`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rig-parts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.59.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/build.ts
CHANGED
|
@@ -80,7 +80,7 @@ import { CONTROL_SUFFIX, withAnimations } from './motion.ts';
|
|
|
80
80
|
import type { PaletteError } from './palette.ts';
|
|
81
81
|
import { type LayerSet, readLayers } from './layers.ts';
|
|
82
82
|
import { placeBoneEntriesForSkeleton, poseBoneEntriesForDrawn, REGISTER_OFFSET_BAR, REGISTER_SCALE_BAR, registeredWithinBar, registerSkeleton, SKELETON_LIMB_BONES, skeletonDrawnLength, skeletonLimbJoints } from './limbs.ts';
|
|
83
|
-
import { type AlternatePartsRecord, type PartRecord, readParts, type RecompositeRecord, type SingleRunPad, tagOf, writeParts } from './parts.ts';
|
|
83
|
+
import { type AlternatePartsRecord, FRONT_SUFFIX, type PartRecord, readParts, type RecompositeRecord, type SingleRunPad, tagOf, writeParts } from './parts.ts';
|
|
84
84
|
import { encodePngBytes, readPng, writePng } from './raster/png.ts';
|
|
85
85
|
import type { Raster } from './raster/types.ts';
|
|
86
86
|
import { type Mask, newMask } from './raster/types.ts';
|
|
@@ -287,6 +287,28 @@ export function readCaps(configPath: string, limbs: Readonly<Record<string, Limb
|
|
|
287
287
|
return out;
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Issue #664: `items` (in parts.json's order) with each part named in `front`
|
|
292
|
+
* moved to just after the part `after` maps it to — where its front slot draws
|
|
293
|
+
* it. Several front parts after one target keep `items`' order. A part whose
|
|
294
|
+
* target is not among `items` stays where it is. With `front` empty, `items`.
|
|
295
|
+
*/
|
|
296
|
+
export function frontOrdered<T extends { record: { name: string } }>(items: readonly T[], front: ReadonlySet<string>, after: ReadonlyMap<string, string>): T[] {
|
|
297
|
+
if (front.size === 0) return [...items];
|
|
298
|
+
const names = new Set(items.map((x) => x.record.name));
|
|
299
|
+
const moving = items.filter((x) => front.has(x.record.name) && names.has(after.get(x.record.name) ?? '') && after.get(x.record.name) !== x.record.name);
|
|
300
|
+
const out: T[] = [];
|
|
301
|
+
const place = (x: T): void => {
|
|
302
|
+
if (out.includes(x)) return;
|
|
303
|
+
out.push(x);
|
|
304
|
+
for (const m of moving) if (after.get(m.record.name) === x.record.name) place(m);
|
|
305
|
+
};
|
|
306
|
+
for (const x of items) if (!moving.includes(x)) place(x);
|
|
307
|
+
// Front parts whose targets form a cycle have no anchor: they are appended at the end, in items' order.
|
|
308
|
+
for (const x of items) place(x);
|
|
309
|
+
return out;
|
|
310
|
+
}
|
|
311
|
+
|
|
290
312
|
/** Read, assemble, and write only after every refusal has had its chance. Throws a PartsError on a refusal, having written nothing. */
|
|
291
313
|
export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs, log: Log): AssembleResult {
|
|
292
314
|
// The early door: assemble runs before propose has drafted bones, meshes,
|
|
@@ -318,6 +340,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
318
340
|
skeleton?: string;
|
|
319
341
|
drawn?: Record<string, number>;
|
|
320
342
|
tips?: Record<string, [number, number]>;
|
|
343
|
+
front?: string[];
|
|
321
344
|
}> = cfgAlts.map((a, i) => {
|
|
322
345
|
const cli = cliByName.get(a.name);
|
|
323
346
|
if (cli !== undefined) cliByName.delete(a.name);
|
|
@@ -334,6 +357,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
334
357
|
skeleton: a.skeleton === undefined ? undefined : resolve(configDir, a.skeleton),
|
|
335
358
|
drawn: a.drawn,
|
|
336
359
|
tips: a.tips,
|
|
360
|
+
front: a.front,
|
|
337
361
|
};
|
|
338
362
|
});
|
|
339
363
|
for (const cli of cliByName.values()) {
|
|
@@ -349,6 +373,9 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
349
373
|
const altProblems: Problem[] = [];
|
|
350
374
|
const altBuilt: Array<{ record: AlternatePartsRecord; images: Array<{ name: string; image: Raster }>; excluded: ExcludedCount[]; islands: IslandCount[]; splits: SplitCount[]; capSplits: SplitCount[] }> = [];
|
|
351
375
|
const baseSlots = result.parts.parts.map((p) => p.name);
|
|
376
|
+
// Issue #664: each limb segment part with a declared front slot -> the part its front slot follows.
|
|
377
|
+
const frontAfter = new Map<string, string>();
|
|
378
|
+
for (const limb of Object.values(fields.limbs ?? {})) for (const p of limb.front?.parts ?? []) frontAfter.set(p, (limb.front as { after: string }).after);
|
|
352
379
|
for (const alt of mergedAlts) {
|
|
353
380
|
if (alt.source === undefined || alt.full === undefined) {
|
|
354
381
|
altProblems.push({
|
|
@@ -566,10 +593,17 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
566
593
|
if (altOthers !== undefined && input.setSplit === 'whole-limb') altOthers.line = 'whole-limb';
|
|
567
594
|
// Issue #587: a subset set's limb part takes nothing a base part it does not replace covers at setup.
|
|
568
595
|
const [exW, exH] = result.parts.rig_size;
|
|
596
|
+
// Issue #664: a part the set draws on its front slot is drawn after its front slot's target, so only base parts
|
|
597
|
+
// drawn after that target cover it; every other segment part keeps the base order.
|
|
598
|
+
const altFront = new Set(alt.front ?? []);
|
|
599
|
+
const altSegParts = Object.values(altLimbs).flatMap((l) => l.segments.map((sg) => sg.part));
|
|
600
|
+
const replacedSet = new Set([...coveredSet, ...hidesSet]);
|
|
569
601
|
const altExclude =
|
|
570
602
|
alt.parts === undefined || input.setExclusion === 'none'
|
|
571
603
|
? []
|
|
572
|
-
:
|
|
604
|
+
: altFront.size === 0
|
|
605
|
+
? setExclusions(result.images, exW, exH, altSegParts, replacedSet)
|
|
606
|
+
: altSegParts.flatMap((sp) => setExclusions(altFront.has(sp) ? frontOrdered(result.images, new Set([sp]), frontAfter) : result.images, exW, exH, [sp], replacedSet));
|
|
573
607
|
let altRes: ReturnType<typeof assemble>;
|
|
574
608
|
try {
|
|
575
609
|
altRes = assemble({
|
|
@@ -614,12 +648,12 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
614
648
|
.map(({ record, image }) => ({ name: `${alt.name}_${record.name}`, image }));
|
|
615
649
|
const keptRecords = altRes.parts.parts.filter((p) => coveredSet.has(p.name));
|
|
616
650
|
const slots: Record<string, string> = {};
|
|
617
|
-
for (const r of keptRecords) slots[r.name] = `${alt.name}_${r.name}`;
|
|
651
|
+
for (const r of keptRecords) slots[altFront.has(r.name) ? `${r.name}${FRONT_SUFFIX}` : r.name] = `${alt.name}_${r.name}`;
|
|
618
652
|
let altRecomposite = altRes.parts.recomposite as RecompositeRecord;
|
|
619
653
|
if (alt.parts !== undefined) {
|
|
620
654
|
const [rW, rH] = result.parts.rig_size;
|
|
621
655
|
const altByName = new Map(altRes.images.map((x) => [x.record.name, x]));
|
|
622
|
-
const fullSetPlaced = result.images
|
|
656
|
+
const fullSetPlaced = frontOrdered(result.images, altFront, frontAfter)
|
|
623
657
|
.filter(({ record }) => !hidesSet.has(record.name))
|
|
624
658
|
.map((baseItem) => altByName.get(baseItem.record.name) ?? baseItem);
|
|
625
659
|
const altSrcRig = sourceInRig(altSrc, rW, rH);
|
|
@@ -630,7 +664,8 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
630
664
|
record: {
|
|
631
665
|
name: alt.name,
|
|
632
666
|
...(alt.parts === undefined ? {} : { parts: [...alt.parts] }),
|
|
633
|
-
...(alt.hides === undefined || alt.hides.length === 0 ? {} : { hides: [...alt.hides] }),
|
|
667
|
+
...(alt.hides === undefined || alt.hides.length === 0 ? (altFront.size === 0 ? {} : { hides: [...altFront] }) : { hides: [...alt.hides, ...[...altFront].filter((p) => !(alt.hides as string[]).includes(p))] }),
|
|
668
|
+
...(altFront.size === 0 ? {} : { front: [...altFront] }),
|
|
634
669
|
slots,
|
|
635
670
|
records: keptRecords,
|
|
636
671
|
ghost_px: altRes.parts.ghost_px,
|
package/src/check.ts
CHANGED
|
@@ -127,7 +127,7 @@ import {
|
|
|
127
127
|
type ChainEdge,
|
|
128
128
|
type WorldBox,
|
|
129
129
|
} from './instruments.ts';
|
|
130
|
-
import { type AlternatePartsRecord, type LimbRecord, type PartRecord, type PartsFile, readParts } from './parts.ts';
|
|
130
|
+
import { type AlternatePartsRecord, FRONT_SUFFIX, type LimbRecord, type PartRecord, type PartsFile, readParts } from './parts.ts';
|
|
131
131
|
import { poseRigBonesForDrawn, type RigBone, SETS_FILE } from './rig.ts';
|
|
132
132
|
import { turnTwin } from './turn.ts';
|
|
133
133
|
import {
|
|
@@ -1238,23 +1238,58 @@ export function flatComposite(parts: PartsFile, partsDir: string, background: re
|
|
|
1238
1238
|
}
|
|
1239
1239
|
|
|
1240
1240
|
/**
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1241
|
+
* What an alternate set draws, in draw order (issues #454, #664): `parts.parts`
|
|
1242
|
+
* order, hidden slots skipped, covered slots drawn from `alt.records` at their
|
|
1243
|
+
* box, uncovered base slots at their base box. A part the set draws on its front
|
|
1244
|
+
* slot (`alt.front`) is drawn from its record although `alt.hides` names it (the
|
|
1245
|
+
* hide is its base slot's) — with `slotOrder`, the rig's final setup slot names,
|
|
1246
|
+
* right after the nearest part slot before `<part>_front` there; without it (or
|
|
1247
|
+
* with no such slot), in its own place, as the base slot would draw it.
|
|
1244
1248
|
*/
|
|
1245
|
-
export function
|
|
1246
|
-
const [W, H] = parts.rig_size;
|
|
1247
|
-
let canvas = newRaster(W, H);
|
|
1248
|
-
for (let i = 0; i < W * H; i++) canvas.data.set(background, i * 4);
|
|
1249
|
+
export function setPlacements(parts: PartsFile, alt: AlternatePartsRecord, slotOrder?: readonly string[]): Array<{ name: string; png: string; box: PartRecord }> {
|
|
1249
1250
|
const hides = new Set(alt.hides ?? []);
|
|
1251
|
+
const front = new Set(alt.front ?? []);
|
|
1250
1252
|
const byName = new Map(alt.records.map((r) => [r.name, r]));
|
|
1253
|
+
const partNames = new Set(parts.parts.map((p) => p.name));
|
|
1254
|
+
// Each front part the slot order places -> the part it is drawn after.
|
|
1255
|
+
const after = new Map<string, string>();
|
|
1256
|
+
if (slotOrder !== undefined) {
|
|
1257
|
+
for (const p of front) {
|
|
1258
|
+
const at = slotOrder.indexOf(`${p}${FRONT_SUFFIX}`);
|
|
1259
|
+
for (let j = at - 1; j >= 0; j--) {
|
|
1260
|
+
if (partNames.has(slotOrder[j]) && !front.has(slotOrder[j])) {
|
|
1261
|
+
after.set(p, slotOrder[j]);
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
const moved = [...after.keys()].sort((a, b) => (slotOrder as readonly string[]).indexOf(`${a}${FRONT_SUFFIX}`) - (slotOrder as readonly string[]).indexOf(`${b}${FRONT_SUFFIX}`));
|
|
1268
|
+
const out: Array<{ name: string; png: string; box: PartRecord }> = [];
|
|
1269
|
+
const draw = (name: string, base: PartRecord): void => {
|
|
1270
|
+
if (hides.has(name) && !front.has(name)) return;
|
|
1271
|
+
const rec = byName.get(name);
|
|
1272
|
+
out.push({ name, png: rec === undefined ? name : `${alt.name}_${rec.name}`, box: rec ?? base });
|
|
1273
|
+
};
|
|
1274
|
+
const baseOf = new Map(parts.parts.map((p) => [p.name, p]));
|
|
1251
1275
|
for (const p of parts.parts) {
|
|
1252
|
-
if (
|
|
1253
|
-
|
|
1254
|
-
const
|
|
1255
|
-
const box = rec ?? p;
|
|
1256
|
-
canvas = alphaComposite(canvas, readPng(join(partsDir, `${pngName}.png`)), box.x, box.y);
|
|
1276
|
+
if (after.has(p.name)) continue;
|
|
1277
|
+
draw(p.name, p);
|
|
1278
|
+
for (const m of moved) if (after.get(m) === p.name) draw(m, baseOf.get(m) as PartRecord);
|
|
1257
1279
|
}
|
|
1280
|
+
return out;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* The flat stack of parts for an alternate set (issue #454), in the order
|
|
1285
|
+
* {@link setPlacements} gives: with `slotOrder`, a front part (issue #664) is
|
|
1286
|
+
* stacked where its front slot draws it.
|
|
1287
|
+
*/
|
|
1288
|
+
export function flatCompositeForSet(parts: PartsFile, alt: AlternatePartsRecord, partsDir: string, background: readonly [number, number, number, number], slotOrder?: readonly string[]): Raster {
|
|
1289
|
+
const [W, H] = parts.rig_size;
|
|
1290
|
+
let canvas = newRaster(W, H);
|
|
1291
|
+
for (let i = 0; i < W * H; i++) canvas.data.set(background, i * 4);
|
|
1292
|
+
for (const { png, box } of setPlacements(parts, alt, slotOrder)) canvas = alphaComposite(canvas, readPng(join(partsDir, `${png}.png`)), box.x, box.y);
|
|
1258
1293
|
return canvas;
|
|
1259
1294
|
}
|
|
1260
1295
|
|
|
@@ -4477,23 +4512,15 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
4477
4512
|
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'))));
|
|
4478
4513
|
const altStillSet = readFrameSet(join(setDir, 'render'));
|
|
4479
4514
|
if (keepStills) cpSync(join(setDir, 'render'), join(keptDir, alt.name), { recursive: true });
|
|
4480
|
-
const
|
|
4515
|
+
const rigSlotOrder = (Array.isArray(inp.rig.slots) ? inp.rig.slots : []).filter(isRecord).map((sl) => String(sl.name));
|
|
4516
|
+
const altComposite = flatCompositeForSet(inp.parts, alt, inp.partsDir, altStillSet.background, rigSlotOrder);
|
|
4481
4517
|
const altSeam = seamFigures(altComposite, altStillSet.frames[0].image, inp.stage, altStillSet.viewport, altStillSet.background, undefined, alt.scene !== undefined);
|
|
4482
4518
|
const altMean = round3(altSeam.mean);
|
|
4483
4519
|
const altScale = round6(altStillSet.viewport.scale);
|
|
4484
4520
|
const altFailed = seamFails(altMean, altSeam.over40, altScale);
|
|
4485
4521
|
let altPairs: SeamPairRow[] | null = null;
|
|
4486
4522
|
if (seamPairsAsked || altFailed) {
|
|
4487
|
-
const
|
|
4488
|
-
const byName = new Map(alt.records.map((r) => [r.name, r]));
|
|
4489
|
-
const placed = inp.parts.parts
|
|
4490
|
-
.filter((p) => !hides.has(p.name))
|
|
4491
|
-
.map((p) => {
|
|
4492
|
-
const rec = byName.get(p.name);
|
|
4493
|
-
const pngName = rec === undefined ? p.name : `${alt.name}_${rec.name}`;
|
|
4494
|
-
const box = rec ?? p;
|
|
4495
|
-
return { name: p.name, from: box.from, x: box.x, y: box.y, image: readPng(join(inp.partsDir, `${pngName}.png`)) };
|
|
4496
|
-
});
|
|
4523
|
+
const placed = setPlacements(inp.parts, alt, rigSlotOrder).map(({ name, png, box }) => ({ name, from: box.from, x: box.x, y: box.y, image: readPng(join(inp.partsDir, `${png}.png`)) }));
|
|
4497
4524
|
const split = seamPairRows(altSeam, placed, inp.parts.rig_size, altStillSet.viewport);
|
|
4498
4525
|
const altSeamDir = join(seamDir, alt.name);
|
|
4499
4526
|
mkdirSync(altSeamDir, { recursive: true });
|
package/src/config.ts
CHANGED
|
@@ -262,6 +262,13 @@ export interface AlternateSetConfig {
|
|
|
262
262
|
drawn?: Record<string, number>;
|
|
263
263
|
/** Explicit bone endpoints on this alternate painting, full source-crop pixels, x right/y down. */
|
|
264
264
|
tips?: Record<string, Point>;
|
|
265
|
+
/**
|
|
266
|
+
* Issue #664: covered limb segment parts this set draws on their front slot
|
|
267
|
+
* (`<part>_front`, declared by `config.limbs.<limb>.front`) instead of the
|
|
268
|
+
* base slot, which the set hides. Absent, the set draws every covered part
|
|
269
|
+
* in its base slot.
|
|
270
|
+
*/
|
|
271
|
+
front?: string[];
|
|
265
272
|
}
|
|
266
273
|
|
|
267
274
|
export interface Assemble {
|
|
@@ -935,6 +942,18 @@ export interface Limb {
|
|
|
935
942
|
split?: LimbSplit;
|
|
936
943
|
/** Explicit rig-stage adjacency; absent, the existing limb closure is unchanged. */
|
|
937
944
|
layout?: LimbLayout;
|
|
945
|
+
/** Issue #664: a second, empty-at-setup slot per named segment part; absent, no slot is added and no byte moves. */
|
|
946
|
+
front?: LimbFront;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Issue #664: `parts` are this limb's own segment parts; each gets a slot
|
|
951
|
+
* `<part>_front` on its base slot's bone with no setup attachment, placed in the
|
|
952
|
+
* final setup slot order immediately after `after`'s whole slot family.
|
|
953
|
+
*/
|
|
954
|
+
export interface LimbFront {
|
|
955
|
+
parts: string[];
|
|
956
|
+
after: string;
|
|
938
957
|
}
|
|
939
958
|
|
|
940
959
|
export type LimbLayoutTarget = { limb: string; part?: never } | { part: string; limb?: never };
|
|
@@ -2137,7 +2156,7 @@ function checkAlternates(
|
|
|
2137
2156
|
const seenNames = new Map<string, number>();
|
|
2138
2157
|
(v as Json[]).forEach((entry, i) => {
|
|
2139
2158
|
const at = `${p}[${i}]`;
|
|
2140
|
-
const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'drawn', 'tips']);
|
|
2159
|
+
const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'drawn', 'tips', 'front']);
|
|
2141
2160
|
if (e === null) return;
|
|
2142
2161
|
if ('name' in e && c.string(`${at}.name`, e.name)) {
|
|
2143
2162
|
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`);
|
|
@@ -2228,6 +2247,27 @@ function checkAlternates(
|
|
|
2228
2247
|
} else seenHides.add(hn);
|
|
2229
2248
|
});
|
|
2230
2249
|
}
|
|
2250
|
+
// Issue #664: a part the set draws on its front slot is one the set covers and a limb declares a front slot for.
|
|
2251
|
+
if ('front' in e) {
|
|
2252
|
+
if (!Array.isArray(e.front) || e.front.length === 0) {
|
|
2253
|
+
c.fail('CONFIG_SET_FRONT', `${at}.front`, `is ${show(e.front)}; a nonempty list of covered limb segment parts with a declared front slot is required`);
|
|
2254
|
+
} else {
|
|
2255
|
+
const seenFront = new Set<string>();
|
|
2256
|
+
(e.front as Json[]).forEach((fn, k) => {
|
|
2257
|
+
if (!c.string(`${at}.front[${k}]`, fn)) return;
|
|
2258
|
+
const declaredBy = limbs?.front.get(fn);
|
|
2259
|
+
const covered = 'parts' in e && seenParts.has(fn) && !seenHides.has(fn);
|
|
2260
|
+
if (seenFront.has(fn)) c.fail('CONFIG_SET_FRONT', `${at}.front[${k}]`, `repeats "${fn}"; each front part is named once`);
|
|
2261
|
+
else if (!covered) {
|
|
2262
|
+
c.fail('CONFIG_SET_FRONT', `${at}.front[${k}]`, `names "${fn}", which this set does not cover${'parts' in e ? ` (its parts less its hides: ${[...seenParts].filter((q) => !seenHides.has(q)).map((q) => `"${q}"`).join(', ') || 'none'})` : ' (a set without parts is a full set; front slots are for a subset set over a limb)'}; a set draws on a front slot only the parts it covers`);
|
|
2263
|
+
} else if (declaredBy === undefined) {
|
|
2264
|
+
const declared = [...(limbs?.front.keys() ?? [])].map((q) => `"${q}"`).join(', ') || 'none';
|
|
2265
|
+
c.fail('CONFIG_SET_FRONT', `${at}.front[${k}]`, `names "${fn}", which no config.limbs.<limb>.front.parts lists (front slots declared: ${declared}); declare the front slot on its limb first`);
|
|
2266
|
+
}
|
|
2267
|
+
seenFront.add(fn);
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2231
2271
|
if ('parts' in e && limbs !== null) {
|
|
2232
2272
|
for (const [limbName, chain] of limbs.chains) {
|
|
2233
2273
|
const coveredSegs = chain.parts.filter((sp) => seenParts.has(sp) && !seenHides.has(sp));
|
|
@@ -2968,6 +3008,8 @@ interface LimbNames {
|
|
|
2968
3008
|
parts: Map<string, { bone: string; at: string }>;
|
|
2969
3009
|
consumed: Map<string, string>;
|
|
2970
3010
|
chains: Map<string, { parts: string[]; bones: string[]; froms: string[] }>;
|
|
3011
|
+
/** Issue #664: each segment part a limb's `front.parts` names -> that limb. */
|
|
3012
|
+
front: Map<string, string>;
|
|
2971
3013
|
}
|
|
2972
3014
|
|
|
2973
3015
|
/**
|
|
@@ -2993,7 +3035,7 @@ interface LimbNames {
|
|
|
2993
3035
|
* resolved. Returns the limb parts and the parts the limbs take.
|
|
2994
3036
|
*/
|
|
2995
3037
|
function checkLimbs(c: Check, v: Json, made: { parts: string[]; patches: string[]; cuts: string[] }, names: { bones: Set<string>; parents: Map<string, string> } | null, resolveLayoutParts = true): LimbNames {
|
|
2996
|
-
const out: LimbNames = { parts: new Map(), consumed: new Map(), chains: new Map() };
|
|
3038
|
+
const out: LimbNames = { parts: new Map(), consumed: new Map(), chains: new Map(), front: new Map() };
|
|
2997
3039
|
if (!isPlainObject(v)) {
|
|
2998
3040
|
c.fail('CONFIG_FIELD_TYPE', 'config.limbs', `is ${show(v)}; an object of limb name -> {"segments": [...]} is required`);
|
|
2999
3041
|
return out;
|
|
@@ -3004,7 +3046,7 @@ function checkLimbs(c: Check, v: Json, made: { parts: string[]; patches: string[
|
|
|
3004
3046
|
const splitLimbs: string[] = [];
|
|
3005
3047
|
for (const [limb, spec] of Object.entries(v)) {
|
|
3006
3048
|
const at = `config.limbs.${limb}`;
|
|
3007
|
-
const o = c.object(at, spec, ['segments'], ['split', 'layout']);
|
|
3049
|
+
const o = c.object(at, spec, ['segments'], ['split', 'layout', 'front']);
|
|
3008
3050
|
if (o === null) continue;
|
|
3009
3051
|
if ('split' in o) {
|
|
3010
3052
|
const sp = c.object(`${at}.split`, o.split, [], ['line', 'edge']);
|
|
@@ -3143,9 +3185,61 @@ function checkLimbs(c: Check, v: Json, made: { parts: string[]; patches: string[
|
|
|
3143
3185
|
}
|
|
3144
3186
|
}
|
|
3145
3187
|
checkLimbLayouts(c, v, made, out, resolveLayoutParts);
|
|
3188
|
+
checkLimbFronts(c, v, made, out, resolveLayoutParts);
|
|
3146
3189
|
return out;
|
|
3147
3190
|
}
|
|
3148
3191
|
|
|
3192
|
+
/**
|
|
3193
|
+
* Issue #664: `config.limbs.<limb>.front` — `parts` a nonempty list of this
|
|
3194
|
+
* limb's own segment parts, each once (`CONFIG_FRONT_SCOPE`); `after` one
|
|
3195
|
+
* produced part, the same notion {@link checkLimbLayouts} holds a part target
|
|
3196
|
+
* to, and not a part of this limb (`CONFIG_FRONT_NAME`). A front slot and an
|
|
3197
|
+
* explicit layout are not composed: a config declaring both, on one limb or on
|
|
3198
|
+
* two, is refused (`CONFIG_FRONT_LAYOUT`).
|
|
3199
|
+
*/
|
|
3200
|
+
function checkLimbFronts(c: Check, limbs: Record<string, Json>, made: { parts: string[]; patches: string[]; cuts: string[] }, names: LimbNames, resolveParts: boolean): void {
|
|
3201
|
+
const produced = new Set([...made.parts, ...made.patches, ...made.cuts].filter((n) => !names.consumed.has(n)));
|
|
3202
|
+
for (const n of names.parts.keys()) produced.add(n);
|
|
3203
|
+
const layouts = Object.entries(limbs).filter(([, raw]) => isPlainObject(raw) && 'layout' in raw).map(([l]) => l);
|
|
3204
|
+
for (const [limb, raw] of Object.entries(limbs)) {
|
|
3205
|
+
if (!isPlainObject(raw) || !('front' in raw)) continue;
|
|
3206
|
+
const at = `config.limbs.${limb}.front`;
|
|
3207
|
+
if (layouts.length > 0) {
|
|
3208
|
+
c.fail(
|
|
3209
|
+
'CONFIG_FRONT_LAYOUT',
|
|
3210
|
+
at,
|
|
3211
|
+
`is declared while ${layouts.map((l) => `config.limbs.${l}.layout`).join(', ')} ${layouts.length === 1 ? 'is' : 'are'} declared; version 1 of front slots does not compose with an explicit limb layout (issue #647) — the layout's adjacency proof would have to move the front slots too — so declare one or the other on a rig`,
|
|
3212
|
+
);
|
|
3213
|
+
}
|
|
3214
|
+
const f = c.object(at, raw.front, ['parts', 'after'], []);
|
|
3215
|
+
if (f === null) continue;
|
|
3216
|
+
const own = names.chains.get(limb)?.parts ?? [];
|
|
3217
|
+
if ('parts' in f) {
|
|
3218
|
+
const ps = f.parts;
|
|
3219
|
+
if (!Array.isArray(ps) || ps.length === 0 || !ps.every((p) => typeof p === 'string' && own.includes(p))) {
|
|
3220
|
+
c.fail('CONFIG_FRONT_SCOPE', `${at}.parts`, `is ${show(ps)}; a nonempty list of this limb's own segment parts (${own.join(', ')}) is required — a front slot is a second slot for one of its segments`);
|
|
3221
|
+
} else if (new Set(ps).size !== ps.length) {
|
|
3222
|
+
c.fail('CONFIG_FRONT_SCOPE', `${at}.parts`, `is ${show(ps)}; each segment part is named once`);
|
|
3223
|
+
} else {
|
|
3224
|
+
for (const p of ps as string[]) {
|
|
3225
|
+
names.front.set(p, limb);
|
|
3226
|
+
// The front slot is named <part>_front; a part already made under that name would take the same slot name.
|
|
3227
|
+
if (produced.has(`${p}_front`)) c.fail('CONFIG_FRONT_NAME', `${at}.parts`, `names "${p}", whose front slot "${p}_front" is the name of a part this config already makes; rename that part, since a slot name is held once`);
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
if ('after' in f && c.string(`${at}.after`, f.after)) {
|
|
3232
|
+
const n = f.after;
|
|
3233
|
+
if (own.includes(n)) {
|
|
3234
|
+
c.fail('CONFIG_FRONT_NAME', `${at}.after`, `names "${n}", a segment part of this same limb; a front slot is placed after a part the limb is drawn behind, never after its own segment`);
|
|
3235
|
+
} else if (resolveParts && !produced.has(n)) {
|
|
3236
|
+
const consumed = names.consumed.get(n);
|
|
3237
|
+
c.fail('CONFIG_FRONT_NAME', `${at}.after`, `names "${n}"; a produced part (${[...produced].join(', ')}) is required${consumed === undefined ? '' : `; "${n}" is consumed by limb "${consumed}" into ${names.chains.get(consumed)?.parts.join(', ')}`}`);
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3149
3243
|
/** Validate after every limb is known; a declaration may refer forward by name. */
|
|
3150
3244
|
function checkLimbLayouts(c: Check, limbs: Record<string, Json>, made: { parts: string[]; patches: string[]; cuts: string[] }, names: LimbNames, resolveParts: boolean): void {
|
|
3151
3245
|
const produced = new Set([...made.parts, ...made.patches, ...made.cuts].filter((n) => !names.consumed.has(n)));
|
package/src/parts.ts
CHANGED
|
@@ -293,10 +293,22 @@ export interface AlternateSetMap {
|
|
|
293
293
|
threshold?: { yaw: number; pitch: number };
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Issue #664: the suffix of a limb segment part's front slot — a second slot on
|
|
298
|
+
* the segment's bone, empty at setup, that a gesture set draws the part on.
|
|
299
|
+
*/
|
|
300
|
+
export const FRONT_SUFFIX = '_front';
|
|
301
|
+
|
|
296
302
|
export interface AlternatePartsRecord {
|
|
297
303
|
name: string;
|
|
298
304
|
parts?: string[];
|
|
299
305
|
hides?: string[];
|
|
306
|
+
/**
|
|
307
|
+
* Issue #664: the covered parts this set draws on their front slot: each `p`
|
|
308
|
+
* is mapped as `slots["<p>_front"]` (never `slots[p]`) and listed in `hides`.
|
|
309
|
+
* Written only when the set declares `front`.
|
|
310
|
+
*/
|
|
311
|
+
front?: string[];
|
|
300
312
|
slots: Record<string, string>;
|
|
301
313
|
records: PartRecord[];
|
|
302
314
|
ghost_px: Record<string, number>;
|
|
@@ -451,6 +463,7 @@ export function serializeParts(file: PartsFile): string {
|
|
|
451
463
|
name: a.name,
|
|
452
464
|
...(a.parts === undefined ? {} : { parts: a.parts }),
|
|
453
465
|
...(a.hides === undefined ? {} : { hides: a.hides }),
|
|
466
|
+
...(a.front === undefined ? {} : { front: a.front }),
|
|
454
467
|
slots: a.slots,
|
|
455
468
|
records: serializePartList(a.records),
|
|
456
469
|
ghost_px: Object.fromEntries(Object.keys(a.ghost_px).sort().map((k) => [k, a.ghost_px[k]])),
|
|
@@ -697,6 +710,20 @@ function checkParts(raw: unknown, path: string): PartsFile {
|
|
|
697
710
|
}
|
|
698
711
|
}
|
|
699
712
|
}
|
|
713
|
+
// Issue #664: each front part is drawn on its front slot and hidden on its base slot, never both.
|
|
714
|
+
if ('front' in set) {
|
|
715
|
+
const slots = typeof set.slots === 'object' && set.slots !== null && !Array.isArray(set.slots) ? (set.slots as Record<string, unknown>) : {};
|
|
716
|
+
const hides = Array.isArray(set.hides) ? set.hides : [];
|
|
717
|
+
if (!Array.isArray(set.front) || set.front.length === 0 || !set.front.every((p) => typeof p === 'string')) {
|
|
718
|
+
fail('PARTS_FIELD_TYPE', `${at} front`, `is ${show(set.front)}; a nonempty array of part names is required`);
|
|
719
|
+
} else {
|
|
720
|
+
for (const p of set.front as string[]) {
|
|
721
|
+
if (!Object.hasOwn(slots, `${p}${FRONT_SUFFIX}`) || !hides.includes(p)) {
|
|
722
|
+
fail('PARTS_FIELD_TYPE', `${at} front "${p}"`, `requires slots."${p}${FRONT_SUFFIX}" and "${p}" in hides; re-run assemble`);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
700
727
|
if (!Array.isArray(set.records)) return;
|
|
701
728
|
set.records.forEach((p, j) => {
|
|
702
729
|
if (typeof p !== 'object' || p === null || Array.isArray(p)) return;
|
package/src/rig.ts
CHANGED
|
@@ -172,7 +172,7 @@ import { coalesceLimbSlots } from './limbslots.ts';
|
|
|
172
172
|
import { layoutAlias, placeLimbLayouts, type LayoutPlan } from './limblayout.ts';
|
|
173
173
|
import { artCoverage, ART_ALPHA, latticeCells, latticeMesh, latticeStray, ONE_LOOP_PASSES } from './mesh.ts';
|
|
174
174
|
import { bindFaceSurfaceDeform, BLINK, blinkHoldMisses, blinkSpan, CONTROL_SUFFIX, controlledBones, IDLE_FPS, idleMotion, type MotionSpec, moveKeysToControls } from './motion.ts';
|
|
175
|
-
import { type AlternateSetMap, PAINTING_RUN, type PartsFile, readFrom, tagOf } from './parts.ts';
|
|
175
|
+
import { type AlternateSetMap, FRONT_SUFFIX, PAINTING_RUN, type PartsFile, readFrom, tagOf } from './parts.ts';
|
|
176
176
|
import { readTag } from './tags.ts';
|
|
177
177
|
import { EYE_GROUP_TAGS } from './propose.ts';
|
|
178
178
|
import { alphaAbove, crop, pad, type Raster } from './raster/index.ts';
|
|
@@ -507,7 +507,8 @@ export interface RigSpec {
|
|
|
507
507
|
images: 'images';
|
|
508
508
|
skeleton: { x: number; y: number; width: number; height: number };
|
|
509
509
|
bones: RigBone[];
|
|
510
|
-
|
|
510
|
+
/** `attachment` null only on a limb segment's front slot (issue #664), which shows nothing at setup. */
|
|
511
|
+
slots: Array<{ name: string; bone: string; attachment: string | null }>;
|
|
511
512
|
skins: { default: Record<string, Record<string, MeshAttachment | RegionAttachment>> };
|
|
512
513
|
/**
|
|
513
514
|
* `config.constraints`, in the order written, each as the config wrote it
|
|
@@ -669,6 +670,7 @@ function applyTurn(
|
|
|
669
670
|
slots: RigSpec['slots'],
|
|
670
671
|
skin: RigSpec['skins']['default'],
|
|
671
672
|
constraints: readonly ConfigConstraint[],
|
|
673
|
+
frontSlots: ReadonlySet<string> = new Set(),
|
|
672
674
|
): { constraints: Array<Record<string, unknown>>; detached: DetachedRule[]; rows: TurnRow[] } {
|
|
673
675
|
const problems: Problem[] = [];
|
|
674
676
|
const taken = new Set(bones.map((b) => b.name));
|
|
@@ -679,7 +681,8 @@ function applyTurn(
|
|
|
679
681
|
const row: TurnRow = { ...f, twins: [] };
|
|
680
682
|
rows.push(row);
|
|
681
683
|
if (f.fraction === 0) continue;
|
|
682
|
-
|
|
684
|
+
// A declared front slot (issue #664) rides its part; a part merely named `<part>_front` is a part of its own.
|
|
685
|
+
const mine = slots.filter((sl) => sl.name === f.part || sl.name === `${f.part}${STILL_SUFFIX}` || (sl.name === `${f.part}${FRONT_SUFFIX}` && frontSlots.has(sl.name)));
|
|
683
686
|
const bound: string[] = [];
|
|
684
687
|
const bind = (b: string): void => {
|
|
685
688
|
if (!bound.includes(b)) bound.push(b);
|
|
@@ -706,7 +709,7 @@ function applyTurn(
|
|
|
706
709
|
const twinOf = new Map(row.twins.map((t) => [t.bone, t.twin]));
|
|
707
710
|
for (const t of row.twins) bones.push({ name: t.twin, parent: t.bone, x: 0, y: 0 });
|
|
708
711
|
for (const sl of slots) {
|
|
709
|
-
if (sl.name !== row.part && sl.name !== `${row.part}${STILL_SUFFIX}`) continue;
|
|
712
|
+
if (sl.name !== row.part && sl.name !== `${row.part}${STILL_SUFFIX}` && !(sl.name === `${row.part}${FRONT_SUFFIX}` && frontSlots.has(sl.name))) continue;
|
|
710
713
|
sl.bone = twinOf.get(sl.bone) as string;
|
|
711
714
|
const atts = skin[sl.name] ?? {};
|
|
712
715
|
for (const [k, att] of Object.entries(atts)) {
|
|
@@ -2394,6 +2397,28 @@ export function buildRig(
|
|
|
2394
2397
|
});
|
|
2395
2398
|
}
|
|
2396
2399
|
refuseIfAny(problems);
|
|
2400
|
+
// ---- front slots (issue #664) ------------------------------------------
|
|
2401
|
+
// Only when a limb declares `front`: each named segment part gets `<part>_front` on its base slot's bone, showing
|
|
2402
|
+
// nothing at setup. They ride with every slot through stops and turn, but stay out of the limb closure (#646) and
|
|
2403
|
+
// are placed after their target's family once the setup order is final.
|
|
2404
|
+
const frontSlots: RigSpec['slots'] = [];
|
|
2405
|
+
const frontTargets: Array<{ slot: string; after: string; at: string }> = [];
|
|
2406
|
+
for (const [limbName, limb] of Object.entries(cfg.limbs ?? {})) {
|
|
2407
|
+
if (limb.front === undefined) continue;
|
|
2408
|
+
for (const part of limb.front.parts) {
|
|
2409
|
+
const at = `config.limbs.${limbName}.front`;
|
|
2410
|
+
const base = slots.find((sl) => sl.name === part);
|
|
2411
|
+
if (base === undefined) {
|
|
2412
|
+
fail('RIG_NAME_RESOLVES', `${at}.parts`, `names "${part}", which has no slot in the base rig; a front slot rides its segment's base slot bone`);
|
|
2413
|
+
continue;
|
|
2414
|
+
}
|
|
2415
|
+
frontSlots.push({ name: `${part}${FRONT_SUFFIX}`, bone: base.bone, attachment: null });
|
|
2416
|
+
frontTargets.push({ slot: `${part}${FRONT_SUFFIX}`, after: limb.front.after, at });
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
refuseIfAny(problems);
|
|
2420
|
+
// Only declared front slots are front slots: a part authored as `<part>_front` is an ordinary part (review of #667).
|
|
2421
|
+
const declaredFront = new Set(frontSlots.map((sl) => sl.name));
|
|
2397
2422
|
// ---- alternate painting sets (issues #454, #465) ------------------------
|
|
2398
2423
|
// Only when `parts.alternates` is present: each alternate set's `<set>_<part>`
|
|
2399
2424
|
// attachments are added to `skins.default[<part>]` on the existing bones and
|
|
@@ -2413,13 +2438,21 @@ export function buildRig(
|
|
|
2413
2438
|
fail('RIG_ALT_TIP_POINT', `parts.json alternates[${altIdx}].tips.${bone}`, 'requires a finite [x, y] endpoint in rig-crop pixels');
|
|
2414
2439
|
}
|
|
2415
2440
|
}
|
|
2441
|
+
// Issue #664: one segment is drawn by one slot of a set, its base slot or its front slot, never both.
|
|
2442
|
+
for (const slotName of Object.keys(alt.slots)) {
|
|
2443
|
+
if (declaredFront.has(`${slotName}${FRONT_SUFFIX}`) && Object.hasOwn(alt.slots, `${slotName}${FRONT_SUFFIX}`)) {
|
|
2444
|
+
fail('RIG_SET_FRONT_BOTH', `parts.json alternates[${altIdx}] (set "${alt.name}") part "${slotName}"`, `maps both slot "${slotName}" and its front slot "${slotName}${FRONT_SUFFIX}"; a set draws a segment on its base slot or on its front slot, not both — re-run assemble`);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
const altFront = new Set(alt.front ?? []);
|
|
2416
2448
|
refuseIfAny(problems);
|
|
2417
2449
|
const explicitDrawn = alt.drawn ?? cfgAlt?.drawn;
|
|
2418
2450
|
const isSubsetSet = alt.parts !== undefined || cfgAlt?.parts !== undefined;
|
|
2419
2451
|
let coveredBones: Set<string> | null = null;
|
|
2420
2452
|
if (isSubsetSet) {
|
|
2421
2453
|
coveredBones = new Set<string>();
|
|
2422
|
-
for (const
|
|
2454
|
+
for (const slotName of Object.keys(alt.slots)) {
|
|
2455
|
+
const pName = declaredFront.has(slotName) && altFront.has(slotName.slice(0, -FRONT_SUFFIX.length)) ? slotName.slice(0, -FRONT_SUFFIX.length) : slotName;
|
|
2423
2456
|
if (pName in cfg.regions) coveredBones.add(cfg.regions[pName]);
|
|
2424
2457
|
for (const s of meshSegments.get(pName) ?? []) coveredBones.add(s.bone);
|
|
2425
2458
|
const m = cfg.meshes[pName];
|
|
@@ -2477,13 +2510,16 @@ export function buildRig(
|
|
|
2477
2510
|
const attName = `${alt.name}_${p.name}`;
|
|
2478
2511
|
const rawImg = images.get(attName);
|
|
2479
2512
|
if (rawImg === undefined) continue;
|
|
2513
|
+
// Issue #664: a part the set draws on its front slot files its attachment under that slot; bones are shared.
|
|
2514
|
+
const skinSlot = altFront.has(p.name) ? `${p.name}${FRONT_SUFFIX}` : p.name;
|
|
2515
|
+
skin[skinSlot] ??= {};
|
|
2480
2516
|
const img = pad(rawImg, PAD, PAD, PAD, PAD, [0, 0, 0, 0]);
|
|
2481
2517
|
const file = `${attName}.png`;
|
|
2482
2518
|
outImages.push([file, img]);
|
|
2483
2519
|
const mesh = cfg.meshes[p.name];
|
|
2484
2520
|
if (mesh === undefined) {
|
|
2485
2521
|
const bone = B.get(cfg.regions[p.name]) as Bone;
|
|
2486
|
-
skin[
|
|
2522
|
+
skin[skinSlot][attName] = altRegion(file, bone.name, p.x + p.w / 2, p.y + p.h / 2);
|
|
2487
2523
|
continue;
|
|
2488
2524
|
}
|
|
2489
2525
|
const fullSegs = meshSegments.get(p.name) as Segment[];
|
|
@@ -2535,7 +2571,7 @@ export function buildRig(
|
|
|
2535
2571
|
const r = 'r' in mesh ? mesh.r : 80;
|
|
2536
2572
|
const lm = latticeMesh(attName, art, grid, maxLoopPasses);
|
|
2537
2573
|
if ('code' in lm) {
|
|
2538
|
-
skin[
|
|
2574
|
+
skin[skinSlot][attName] = altRegion(file, segs[0].bone, p.x + p.w / 2, p.y + p.h / 2);
|
|
2539
2575
|
continue;
|
|
2540
2576
|
}
|
|
2541
2577
|
const ox = p.x - PAD;
|
|
@@ -2598,7 +2634,7 @@ export function buildRig(
|
|
|
2598
2634
|
}
|
|
2599
2635
|
const uvs: number[] = [];
|
|
2600
2636
|
for (const [x, y] of lm.vertices) uvs.push(pyRound(x / w, 6), pyRound(y / h, 6));
|
|
2601
|
-
skin[
|
|
2637
|
+
skin[skinSlot][attName] = { type: 'mesh', image: file, width: w, height: h, uvs, triangles: lm.triangles, hull: lm.hull, weights };
|
|
2602
2638
|
}
|
|
2603
2639
|
const slotMap: Record<string, string> = {};
|
|
2604
2640
|
for (const [slotName, att] of Object.entries(alt.slots)) slotMap[slotName] = att;
|
|
@@ -2635,11 +2671,12 @@ export function buildRig(
|
|
|
2635
2671
|
// ---- leg stops (issue #404) --------------------------------------------
|
|
2636
2672
|
// Only when the config has `stops`: each link after the first (and any bone hanging from a stopped link) hangs
|
|
2637
2673
|
// from the drawn link `<link>_d` above it, and slots and weights on a stopped link bind `<link>_d`.
|
|
2638
|
-
const
|
|
2674
|
+
const rebound = frontSlots.length === 0 ? slots : [...slots, ...frontSlots];
|
|
2675
|
+
const stops = cfg.stops === undefined ? null : applyStops(cfg.stops, chains, bones, rebound, skin, (original, emitted) => layoutAlias(explicitLayout.plan, original, emitted));
|
|
2639
2676
|
// ---- the turn control (issue #251) -------------------------------------
|
|
2640
2677
|
// Only when the config has `turn`: every other build adds nothing here, so no byte moves.
|
|
2641
2678
|
if (cfg.turn !== undefined) refuseIfAny(turnRiderProblems(cfg.turn, cfg, parts.parts));
|
|
2642
|
-
const turned = cfg.turn === undefined ? null : applyTurn(cfg.turn, parts.parts.map((p) => p.name), bones,
|
|
2679
|
+
const turned = cfg.turn === undefined ? null : applyTurn(cfg.turn, parts.parts.map((p) => p.name), bones, rebound, skin, cfg.constraints ?? [], declaredFront);
|
|
2643
2680
|
for (const row of turned?.rows ?? []) for (const t of row.twins) layoutAlias(explicitLayout.plan, t.bone, t.twin);
|
|
2644
2681
|
// issue #536: every row names the bones the emitted attachment binds, read once the turn and the stops have
|
|
2645
2682
|
// rebound the weights; a rig with neither rebinds nothing, so this reads back the names each row already holds.
|
|
@@ -2655,7 +2692,7 @@ export function buildRig(
|
|
|
2655
2692
|
images: 'images',
|
|
2656
2693
|
skeleton: { x: -CX, y: 0, width: W, height: H },
|
|
2657
2694
|
bones,
|
|
2658
|
-
slots: explicitLayout.slots,
|
|
2695
|
+
slots: frontSlots.length === 0 ? explicitLayout.slots : spliceFrontSlots(explicitLayout.slots, frontSlots, frontTargets, slotFamilies),
|
|
2659
2696
|
skins: { default: skin },
|
|
2660
2697
|
};
|
|
2661
2698
|
if (cfg.constraints !== undefined) rig.constraints = cfg.constraints.map(constraintForRig);
|
|
@@ -2712,6 +2749,32 @@ export function buildRig(
|
|
|
2712
2749
|
};
|
|
2713
2750
|
}
|
|
2714
2751
|
|
|
2752
|
+
/**
|
|
2753
|
+
* Issue #664: the final setup slot order with each front slot placed
|
|
2754
|
+
* immediately after its target part's whole slot family (the part's slot and
|
|
2755
|
+
* its `<part>_still`), wherever the closure (#646) left that family's last
|
|
2756
|
+
* member; several front slots after one family keep the order the config
|
|
2757
|
+
* declares them in. A target with no slot in the order is refused by name.
|
|
2758
|
+
*/
|
|
2759
|
+
function spliceFrontSlots(order: RigSpec['slots'], fronts: RigSpec['slots'], targets: ReadonlyArray<{ slot: string; after: string; at: string }>, families: ReadonlyMap<string, readonly string[]>): RigSpec['slots'] {
|
|
2760
|
+
const problems: Problem[] = [];
|
|
2761
|
+
const out = [...order];
|
|
2762
|
+
for (const [i, f] of fronts.entries()) {
|
|
2763
|
+
const t = targets[i];
|
|
2764
|
+
const family = families.get(t.after) ?? [];
|
|
2765
|
+
const last = Math.max(-1, ...family.map((n) => out.findIndex((s) => s.name === n)));
|
|
2766
|
+
if (last < 0) {
|
|
2767
|
+
problems.push({ code: 'RIG_NAME_RESOLVES', object: `${t.at}.after`, detail: `names "${t.after}", which has no slot in the rig's setup order; a front slot is placed after a part's slot family` });
|
|
2768
|
+
continue;
|
|
2769
|
+
}
|
|
2770
|
+
let at = last + 1;
|
|
2771
|
+
while (at < out.length && fronts.slice(0, i).includes(out[at])) at++;
|
|
2772
|
+
out.splice(at, 0, f);
|
|
2773
|
+
}
|
|
2774
|
+
refuseIfAny(problems);
|
|
2775
|
+
return out;
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2715
2778
|
/**
|
|
2716
2779
|
* Issue #473: expand `{"t": …, "set": "<name>" | null}` keys on slot attachment
|
|
2717
2780
|
* tracks in `merged.animations` into `{"t": …, "v": "<attachment>" | null}`
|
|
@@ -2844,6 +2907,23 @@ export function expandSetAttachmentKeys(rig: RigSpec, sets: AttachmentSetsFile |
|
|
|
2844
2907
|
});
|
|
2845
2908
|
return;
|
|
2846
2909
|
}
|
|
2910
|
+
// Issue #664: a set that draws this track's part on its front slot moves the part in the draw order, which a
|
|
2911
|
+
// keyed attachment swap cannot do; keyed draw-order changes are out of scope.
|
|
2912
|
+
// A declared front slot is the one slot the rig writes with no setup attachment.
|
|
2913
|
+
const isFront = (name: string): boolean => rig.slots.some((sl) => sl.name === name && sl.attachment === null);
|
|
2914
|
+
const frontBase = slot.endsWith(FRONT_SUFFIX) && isFront(slot) ? slot.slice(0, -FRONT_SUFFIX.length) : null;
|
|
2915
|
+
const drawsFront =
|
|
2916
|
+
(isFront(`${slot}${FRONT_SUFFIX}`) && Object.hasOwn(entry.slots, `${slot}${FRONT_SUFFIX}`) && entry.hides?.includes(slot) === true) ||
|
|
2917
|
+
(frontBase !== null && Object.hasOwn(entry.slots, slot) && entry.hides?.includes(frontBase) === true);
|
|
2918
|
+
if (drawsFront) {
|
|
2919
|
+
const part = frontBase ?? slot;
|
|
2920
|
+
problems.push({
|
|
2921
|
+
code: 'CONFIG_SET_FRONT_KEYED',
|
|
2922
|
+
object: keyAt,
|
|
2923
|
+
detail: `names alternate set "${setVal}" on slot "${slot}", and set "${setVal}" draws "${part}" on its front slot "${part}${FRONT_SUFFIX}" (hiding "${part}"); a keyed set switch on a front part would change the draw order mid-clip, which is out of scope — show the set with setSet, or key a part the set draws on its base slot`,
|
|
2924
|
+
});
|
|
2925
|
+
return;
|
|
2926
|
+
}
|
|
2847
2927
|
if (Object.hasOwn(entry.slots, slot)) {
|
|
2848
2928
|
resolvedV = entry.slots[slot];
|
|
2849
2929
|
} else if (entry.hides?.includes(slot) === true) {
|
package/src/scene.ts
CHANGED
|
@@ -1115,7 +1115,7 @@ export function composeScene(
|
|
|
1115
1115
|
const sized = s === 1 ? {} : { x: scaledBy(bone.x, s), y: scaledBy(bone.y, s), ...(bone.length === undefined ? {} : { length: scaledBy(bone.length, s) }) };
|
|
1116
1116
|
bones.push({ ...bone, name: P(id, bone.name), ...(bone.parent === undefined ? {} : { parent: P(id, bone.parent) }), ...sized, ...(first ? { x: placed(bone.x, dx, s), y: placed(bone.y, dy, s) } : {}) });
|
|
1117
1117
|
}
|
|
1118
|
-
for (const s of b.rig.slots) slotDefs.set(prefixed(id, s.name), { ...s, name: prefixed(id, s.name), bone: P(id, s.bone), attachment: prefixed(id, s.attachment) });
|
|
1118
|
+
for (const s of b.rig.slots) slotDefs.set(prefixed(id, s.name), { ...s, name: prefixed(id, s.name), bone: P(id, s.bone), attachment: s.attachment === null ? null : prefixed(id, s.attachment) });
|
|
1119
1119
|
// Everything the character places in root's own frame moves with it: a region on a slot root carries, and a
|
|
1120
1120
|
// weight bound to root. Every other offset is local to a bone the shift already moved.
|
|
1121
1121
|
const slotBone = new Map(b.rig.slots.map((s) => [s.name, s.bone]));
|
|
@@ -1305,7 +1305,8 @@ export function unprefixedNames(rig: RigSpec, motion: MotionSpec, ids: readonly
|
|
|
1305
1305
|
for (const s of rig.slots) {
|
|
1306
1306
|
name('slot', s.name);
|
|
1307
1307
|
name(`slot ${s.name} bone`, s.bone);
|
|
1308
|
-
|
|
1308
|
+
// Issue #664: a front slot shows nothing at setup; null names nothing.
|
|
1309
|
+
if (s.attachment !== null) name(`slot ${s.name} attachment`, s.attachment);
|
|
1309
1310
|
}
|
|
1310
1311
|
for (const [slot, atts] of Object.entries(rig.skins.default)) {
|
|
1311
1312
|
name('skin slot', slot);
|