@rig-c/parts 1.21.0 → 1.23.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/README.md CHANGED
@@ -107,7 +107,7 @@ page** (issue #2):
107
107
 
108
108
  | path under `--out` | what |
109
109
  | --- | --- |
110
- | `check/build/skeleton.json`, `skeleton.atlas`, `skeleton.png` | **the artifact** — Spine 4.3 skeleton data and one packed page, written by `rigc build --pack --page-edges free --pack-shape polygon` and gated under `spine-html`, which holds every rule `spine` measures (on reference-demo, rigc 2.1.3 and 2.10.1: the 14 rules `validate --profile spine` measures are among the build's 24; 16 are not in `spine`) |
110
+ | `check/build/skeleton.json`, `skeleton.atlas`, `skeleton.png` | **the artifact** — Spine 4.3 skeleton data and one packed page, written by `rigc build --pack --page-edges free --pack-shape polygon` and gated under `rig-play` (named `spine-html` before rig-c 2.50.0), which holds every rule `spine` measures (on reference-demo, rigc 2.1.3 and 2.10.1: the 14 rules `validate --profile spine` measures are among the build's 24; 16 are not in `spine`) |
111
111
  | `parts/*.png`, `parts.json`, `recomposite_rig.png`, `recomposite_error_rig.png` | the loose parts, each cropped to its alpha box; the record of where every part came from, how many of its pixels were re-taken from the painting, and the recomposite's uncovered holes with their boxes; the flat stack of parts; its error map — red where no part covers a pixel the painting has, blue where a part covers it in the wrong colour |
112
112
  | `rig/` | `rig.json` and `motion.json` in rig-c's spec, `mesh_report.json`, the padded `images/` |
113
113
  | `check/` | both gate files verbatim, the idle's frames and their `geometry.json` (skinned vertices per frame), `contact.png`, `motion_heat.png`, `check.json` (with `pack_mode`, the `--page-edges` and `--pack-shape` the page was packed under) |
@@ -155,7 +155,7 @@ atlas written by anything else would have no oracle behind it.
155
155
  | --- | --- | --- |
156
156
  | painting + See-through layers → parts and specs | **rig-parts** (npm `@rig-c/parts`) | the merge of two runs, the measurements, the rig spec and motion spec |
157
157
  | specs → Spine skeleton data | **[rig-c](https://github.com/rig-c/core)** (npm `rig-c`) | compile, the gate (rigc's own validator in an install; the round trip through `spine-core` where the runtime is beside it, as in this repository's CI), the named assertions, the packer, the renderer |
158
- | skeleton data → a page | **[rig-play](https://github.com/rig-c/play)** (npm `@rig-c/play`; formerly spine-html), a sibling project | a DOM renderer; rigc's `spine-html` profile is its policy, and every build here is gated under that profile as well as under `spine` |
158
+ | skeleton data → a page | **[rig-play](https://github.com/rig-c/play)** (npm `@rig-c/play`; formerly spine-html), a sibling project | a DOM renderer; rigc's `rig-play` profile is its policy, and every build here is gated under that profile as well as under `spine` |
159
159
 
160
160
  rig-parts never writes Spine data itself. Everything on disk under `check/build/`
161
161
  was written by rig-c after its own gate passed.
@@ -305,7 +305,7 @@ agent skill.
305
305
  | `propose … --from-config <config>` | draw and LINT the config's current bones (by the joints too, given `--keypoints`) |
306
306
  | `compare --left <file> --right <file> [--map <bonemap.json>]` | compare two skeletons — a config, a proposal or a `rig.json` — bone by bone: origin, parent, tip, length and direction per pair, the bones neither side pairs, the required ones missing, and each side's roles read off the spec; no frame is guessed, and nothing pairs by resemblance (`propose --compare` reads origins only) |
307
307
  | `rig --config --parts --out [--idle-keys ctl\|direct]` | author `rig.json` + `motion.json`, written only after rig-c's gate is green; each mesh is in the mode its config entry names — `grid` (the lattice, what `propose` writes), `contour` (the traced outline with declared interior points) or `auto` (the contour mesh at alpha 1 and above, reduced and locally refined by rig-c's `reduceMesh` under the author's declared bounds, written only when its motion against the unreduced source on the idle passes the author's `motion` bounds through rig-c's `compareMeshesInMotion`; [AUTHORING §3](docs/AUTHORING.md)); every chain link is turned along its chain and carries its `length`, so a physics constraint added later has a lever, with every offset under it in the turned frame so nothing moves; `--idle-keys` says whether the idle's keys on mesh-driving bones go through `<bone>_ctl` parents (default) or stay on the bones with `invariants.idleDrivesMeshes` declared; the config's `constraints` go to rigc as written, and a two-bone ik over keyed links needs `--idle-keys direct` (on `rig` or `build`) |
308
- | `check --rig --out [--parts] [--source] [--requirements]` | build packed, gated under `spine-html`, render the idle, measure seam, loop and the six judgement lines (mesh texture stretch among them, from the idle's `render --geometry`), and report the recomposite's holes from `parts.json`; on a rig spec with no `parts.json` or no `idle` (a merged rig, issue #77) the gate still runs and every line that needs the missing input says SKIP by name; `--source <painting.png>` adds `SETUP_POSE_VS_SOURCE`, the setup pose against the painting by assemble's recomposite figures; `--requirements <scene.json>` measures what a scene declares of the motion — a contact, a follow fraction, an aim, a joint range, a mesh's stretch, the seam between two parts over the motion — each against the author's own bar, from rig-c's posed frames, one line each, PASS, FAIL or NOT MEASURABLE (AUTHORING §7, *Declared requirements*) |
308
+ | `check --rig --out [--parts] [--source] [--requirements]` | build packed, gated under `rig-play`, render the idle, measure seam, loop and the six judgement lines (mesh texture stretch among them, from the idle's `render --geometry`), and report the recomposite's holes from `parts.json`; on a rig spec with no `parts.json` or no `idle` (a merged rig, issue #77) the gate still runs and every line that needs the missing input says SKIP by name; `--source <painting.png>` adds `SETUP_POSE_VS_SOURCE`, the setup pose against the painting by assemble's recomposite figures; `--requirements <scene.json>` measures what a scene declares of the motion — a contact, a follow fraction, an aim, a joint range, a mesh's stretch, the seam between two parts over the motion — each against the author's own bar, from rig-c's posed frames, one line each, PASS, FAIL or NOT MEASURABLE (AUTHORING §7, *Declared requirements*) |
309
309
  | `loop --frames <dir> --out <file.gif \| file.png> [--palette]` | encode a rendered idle as a looping GIF, lossless APNG, or indexed APNG (`--palette`) |
310
310
  | `build --config --source --full --head --out [--seam] [--project] [--loop] [--lead-in <periods>] [--requirements] [--seam-pairs] [--keep-stills] [--idle-keys ctl\|direct]` | assemble, rig and check in one process, stopping at the first refusal; `--requirements`, `--seam-pairs` and `--keep-stills` are forwarded to check, `--idle-keys` to rig; `--lead-in` (with `--loop`) encodes the loop from the last of n + 1 idle periods played back to back, for a rig whose physics does not end where the render starts it |
311
311
  | `compose --scene <scene.json> --out [--requirements] [--accept]` | bind several characters' green builds into one rig (or, under `--accept`, builds failing only the bars named — for looking, not shipping): every name prefixed `<id>:` under one shared root, each character's offset added at its first-level bones, an optional background plate (its provenance recorded, judged by nothing) drawn first, and the draw order between the characters' slots as the scene file declares it — nothing inferred, nothing scaled; gated through rig-c as `rig` is, then checked ([AUTHORING §7](docs/AUTHORING.md), *Composing several characters*) |
package/cli.ts CHANGED
@@ -209,7 +209,10 @@ usage:
209
209
  of the consumer's environment — no direction is drafted), and drafts no
210
210
  idle key on them. A bottomwear recipe's "swing" drives each tree's
211
211
  first link from one shared pendulum. A recipe that drafts nothing is
212
- refused (PROPOSE_CLOTH_DRAFTED). Without --cloth nothing changes.
212
+ refused (PROPOSE_CLOTH_DRAFTED). A topwear part shaped like a skirt (a
213
+ dress) is named in a note, never drafted on its shape; a bottomwear
214
+ recipe's "part" declares it, and its trees hang from the hip over the
215
+ part's art below it (PROPOSE_CLOTH_PART). Without --cloth nothing changes.
213
216
 
214
217
  rig-parts propose --parts <dir> --source <painting.png> --out <dir> --from-config <config.json>
215
218
  Draw the config's CURRENT bones instead (<out>/render/landmarks_config.png
package/docs/AUTHORING.md CHANGED
@@ -29,6 +29,12 @@ kept as fixtures because their `expected/` is that implementation's own output;
29
29
  figure this guide quotes for them was measured on them. `demo` is the painting the
30
30
  README shows since issue #227 and `scarf` the hanging-element example; both have
31
31
  `expected/` from this port's own build, and a figure quoted for them says so.
32
+ In every example, `expected/rig.json` is the flat form: every bone unturned, which is
33
+ `flattenRig` (`src/rig.ts`) of the built rig. A build's `rig/rig.json` carries
34
+ `rotation` and `length` on its chain links, and the offsets under them in the turned
35
+ frame (§5, the `rig` row), where that file holds unturned offsets only, so the two
36
+ differ as text and not as a rig: the chain suite (`CH03`) compares `expected/rig.json`
37
+ with `flattenRig(built)`, not with the built file.
32
38
 
33
39
  ## 1. Prerequisites
34
40
 
@@ -101,7 +107,7 @@ read by no CPU stage).
101
107
  | `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 |
102
108
  | `assemble.patches` | assemble; `meshes`/`regions` keys may name them too | **authored**, optional: `[{name, box, alpha, draw}]` — an extra part cut from the **painting** itself, for figure no See-through layer holds (a hem both runs dropped). `box` is `[x0, y0, x1, y1]` in **rig** pixels, `x1`/`y1` exclusive — the space of `parts.json` and `recomposite_rig.png`, where the hole is found; `alpha` is `"silhouette"` (the painting's figure silhouette inside the box, the one `--seam silhouette` uses) or `"box"` (the whole box); `draw` is `"back"`, `"front"` or `{"before": "<plan part>"}`. A patch is always a region: its bone is `regions.<name>`, in the one place every region's bone lives, and a `meshes` entry for it is refused. See §5 for how to place one |
103
109
  | `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), `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`). `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 |
104
- | `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?}, …]}}`, 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` or `cap_shape` (`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"` and `cap_shape` `"disc"` (issue #360), each the one value its field takes (`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. 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 |
110
+ | `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"` and `cap_shape` `"disc"` (issue #360), each the one value its field takes (`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 |
105
111
  | `bones` | rig; `propose --from-config` | **proposed** by `propose`, then corrected. A single bone `{name, parent, at, tip?}` or a chain `{chain, parent, points, tip}` 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`). 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. 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 |
106
112
  | `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 |
107
113
  | `meshes.<part>.contour` | rig | **authored**, optional (issue #84): `{tolerance, margin, spacing, maxEdge?, budget?, stray?, bridges?, regions?}`. `tolerance` — rig-c's Douglas–Peucker tolerance on the traced outline, px, 0 or more; `margin` — how far the silhouette grows before it is traced, px: 0, or 1 or more (a pixel joins when its centre lies within `margin` of an art pixel's centre; a value above 0 and below 1 adds nothing and is refused, `CONFIG_FIELD_TYPE`); `spacing` — the background interior spacing, px, above 0; `maxEdge` (issue #265) — the longest outline edge, px, above 0: every simplified edge longer than it is cut into `ceil(length / maxEdge)` equal pieces, each cut point on the 1/256 px grid, before any region or rib touches the outline (absent: nothing is cut, and no byte moves; under 2/256 px the rig stage refuses it, `CONTOUR_PARAMETER`, because two cut points could snap together); the row echoes it in `params` and counts the points it added in `contour.outlineCut`, both only when declared; `budget` — the most vertices the mesh may have (refused above it, nothing thinned); `stray` — the largest island, in art pixels, that may be left out of the mesh (absent: none is); `bridges` (issue #326) — `true`, its one value: islands are read in this order — **dust first** (those `stray` leaves out), **then faint islands** (every pixel's alpha under 64, a quarter of full opacity: left out the same way, their pixels kept in the image but not meshed, so not drawn, and named in the row's `contour.bridges.faint` with their px, brightest alpha and box), **then every visible island is meshed and bridged, whatever the bridge costs** — overdraw is reported, never a reason to drop art; the largest island, or a tie for it, is never left out, faint or not: dropping it would draft the part without its art, and a part whose main body is faint is a question about the layer, which the plan and the author own, not one for the mesh — and the pieces are joined into the one outline rig-c takes by bridges — the kept islands, holes filled, grow together by `margin`, so islands closer than about twice the margin are one grown silhouette, traced as one; each silhouette is traced, simplified, capped, refined and triangulated as a one-island mesh is; then, starting from the silhouette with the most art, the nearest pair of a vertex on the joined outline and one on a silhouette still apart whose quad holds (wound as the mesh, crossing no outline, holding no other vertex, one closed outline after) is joined by that quad, two triangles over no art, until none is apart. Coverage and overshoot read the silhouettes' triangles; a bridge's area is in `meshArea` and in the row's `contour.bridges` (`islands`, `units`, and per join `unit`, `span` — its two crossing edges, px — `area`, `vertices`, `pair`; and `faint`, only when an island was left out as faint), and the row's `params` echoes `bridges`, both only when declared; `art_coverage` counts a faint island's pixels as art not covered. Absent, a second island is refused as below and no byte moves; on one island it writes the mesh the undeclared entry writes. Any other value is `CONFIG_FIELD_TYPE`; beside `ribs` it is `CONTOUR_PARAMETER` (a rib runs across one outline); a join no pair makes is `CONTOUR_BRIDGE`. A bridge stretches with whatever pulls its two ends apart, so it belongs on a part whose pieces ride one bone — the only case `mesh-draft` drafts; `regions` — local deformation regions, each `{name, shape, bone, spacing, band}` with `shape` `"circle"` (`cx, cy, r`) or `"polygon"` (`points`, 3 or more): `bone` is the region's control bone (any bone `bones` declares), `spacing` the interior spacing inside the region and its band, `band` the width the bone's weight falls across. Every length and position is **rig px**, like every other in the config; the part image is the rig less `(x − 4, y − 4)` (its box less the pad), a translation, so a length is the same number in both. A region's `cx`, `cy`, `r`, `band` and `points` are multiples of 1/256 px (`CONFIG_FIELD_TYPE` otherwise); region names are unique per mesh (`CONFIG_REGION_NAME_UNIQUE`). The alpha threshold is not a field: art is alpha above 8, the lattice's and `check`'s |
@@ -117,7 +123,7 @@ read by no CPU stage).
117
123
  | `constraints` | rig (handed to rig-c as `rig.json`'s `constraints`); `compare` and the coverage lines (roles) | **authored**, optional; `propose` writes none, but with `--cloth` (issue #364), where it writes the recipe's physics and swing transforms (*Recipe: cloth and hair that answer the world*, below). A list of constraints in **rig-c's own rig-spec shape** (`RigConstraint`: `ik`, `transform`, `path`, `physics`, `slider` — rig-c's `src/rig.ts` documents every field), in the order rigc applies them. The loader checks only what this package owns: each entry is an object with a `type` rigc names (`CONFIG_CONSTRAINT_TYPE_KNOWN`) and a non-empty `name`, unique within its kind as rigc finds constraints (`CONFIG_CONSTRAINT_NAME_UNIQUE`; an ik and a transform may share one); every bone it names — `bones`, an ik's `target`, a transform's `source`, a physics or slider constraint's `bone` — is a bone `bones` declares, a chain link as `<chain><i>` (`CONFIG_NAME_RESOLVES`); the bone a constraint follows does not sit under a bone it drives (`CONFIG_CONSTRAINT_TARGET_DETACHED`). Every other field (`mix`, `softness`, `properties`, a path's `slot`, a slider's `animation`) and every value is rigc's to accept or refuse at the rig stage's gate, in rigc's words (`RIG_RIGC_GREEN`) — an ik's `bones` as a shape too: from rig-c 2.15.0 rigc refuses an ik over more than two bones, or over a pair whose second bone is not the first's child (issue #103; this loader refused both itself until then). A note and an `x-` record may ride on an entry; the rig stage leaves them out of what it hands rigc. Under the default `--idle-keys ctl` a two-bone ik whose child link the idle keys is split by that link's control, and rigc refuses the pair: run `rig --idle-keys direct` or `build --idle-keys direct` (the rig stage adds that sentence, naming the flag on the command that ran, to rigc's line; `build` forwards it to its rig stage, issue #95). Each bone a constraint follows is declared to rigc as `invariants.detached` from every bone it drives, which rigc's gate rule `A25` checks |
118
124
  | `turn` | rig (adds the turn control) | **proposed** only with `propose --full`/`--head` (issue #251), then corrected: `{pivot, depths}`. `depths` holds, per part, the See-through layer's `depth_median` the part came from (larger = further back), read from the run the part was assembled from; a `painting:` patch has none and is not carried. A rider (issue #271) — a part from an `eyewhite`, `irides`, `eyelash`, `eyebrow`, `nose` or `mouth` layer — is drafted at the `face` part's depth, 0.001 nearer when parts.json draws it after the face and 0.001 further when before: See-through makes no depth of its own for the eye group (it cuts them from one depth map of the combined eyes) and clamps nose and mouth to the face's median − 0.001, and the two runs' own medians for these layers disagreed by up to 0.47 and swapped their order against the face. Every other layer — ears, headwear and earwear included — keeps its own median. With no `face` part, or more than one, the riders keep their own and a note says so. One note lists each part's depth and where it came from; a carrier the other run places more than 10 % of `pivot − nearest` away gets a note naming both values and the run read — the two runs are not reconciled. `pivot` is the depth that stays put; `propose` drafts the mean of the parts' depths weighted by `opaque_px`, the one depth at which the painted pixels' centroid does not slide under the dial. The rig stage adds a bone `turn` under `root` at its origin that nothing keys — its local x is the dial, in rig px — and carries each part by `(pivot − depth) / (pivot − nearest depth)` of it: the nearest part all of it, a part behind the pivot the other way, a part at the pivot not at all. Each part rides leaf twins (`turn_<part>_<bone>`, an identity child of every bone its slot and weights bind) moved by one `transform` constraint (`turn_<part>`, after the config's own); the idle's keys, the `<bone>_ctl` controls and a physics constraint stay on the bones, and the dial moves none of them. At rest: with `turn` declared, no pixel differs by more than 1 level at dial 0 (not byte-identical; the cause is float noise in the identity child bones, and the constraints add nothing); without `turn`, byte-identical. Neither field has a default (`CONFIG_FIELD_PRESENT`); the pivot must lie behind the nearest part (`CONFIG_TURN_PIVOT_BEHIND_NEAREST`). Absent, no control is added and no byte of any output moves |
119
125
  | `scene` | assemble (the recomposite, its holes and the figure's mask); check, through `parts.json`'s `scene` block (`RECOMPOSITE_HOLES`, the seam) | **authored**, optional; `propose` writes none (issue #242). `{}` declares the painting a scene: the figure and its surroundings in one image, See-through's full run holding only the figure. With it, `assemble` reads the recomposite figures, the hole list and the `uncovered:` lines inside the figure — the rig pixels where any full-run layer's alpha is above 8 (`OPAQUE_ALPHA_ABOVE`, the cut every layer's painted pixels are read by) — each line starting `inside the figure (config.scene: …, <n> of <m> rig px)`; writes that figure as `figure_rig.png` (white on black) beside the recomposite, and a `scene` block in `parts.json`; flags error pixels on the error map inside it only (outside, the painting grey); and `check` leaves out of the seam every frame pixel whose composite sample reaches the painting's outermost row or column, saying how many (`seam_border` in `check.json`, and on the seam line). It takes no field: the figure and its threshold are derived. A key in it other than a record or an annotation is `CONFIG_KEY_KNOWN`. Absent, no byte of any output moves |
120
- | `cloth` | `propose --cloth` only; no other stage reads it, so it moves no byte of any build | **authored**, optional (issue #364): one recipe per tag, `{"bottomwear": {…}, "back hair": {…}, "front hair": {…}}`, each `{chains, links, wind, gravity, split?, length_ratio?, strength?, damping?, alternate_damping?, translate?, swing?}`. `chains` — trees across the piece (for `back hair`, per side of the eye axis), a whole number, 1 or more; `links` — links from root to tip on every path, 1 or more; `split` — `{at, into}`: the first `at` links are the trunk, which forks into `into` (2 or more) branches; `at` below `links` (`CONFIG_CLOTH_SPLIT_BEFORE_TIP`); `length_ratio` — a path's last link over its first, above 0, default 0.5; `strength` — `{trunk, branch, edge}`, each above 0 and below the spring's stability bound (`CONFIG_CLOTH_SPRING_STABLE`), default 100 / 100 / 50; `damping` — in [0, 1], absent: rig-c's default; `alternate_damping` — the odd trees' damping, in [0, 1], beside `damping` and different from it (`CONFIG_CLOTH_ALTERNATE_DIFFERS`); `wind`, `gravity` — `[root, tip]`, each 0 or more, tip at or above root (`CONFIG_CLOTH_RESPONSE_GROWS_TO_TIP`); `translate` — the x and y mix of a dangling end's flutter, above 0 and at most 1; `swing` — `bottomwear` only, `{scales}`, one positive scale per tree (`CONFIG_CLOTH_SWING_SCALE_PER_TREE`). The two defaults are the recipe's own, measured on its synthetic fixture (the recipe below). The recipe below says what each field drafts |
126
+ | `cloth` | `propose --cloth` only; no other stage reads it, so it moves no byte of any build | **authored**, optional (issue #364): one recipe per tag, `{"bottomwear": {…}, "back hair": {…}, "front hair": {…}}`, each `{chains, links, wind, gravity, split?, length_ratio?, strength?, damping?, alternate_damping?, translate?, swing?, part?}`. `chains` — trees across the piece (for `back hair`, per side of the eye axis), a whole number, 1 or more; `links` — links from root to tip on every path, 1 or more; `split` — `{at, into}`: the first `at` links are the trunk, which forks into `into` (2 or more) branches; `at` below `links` (`CONFIG_CLOTH_SPLIT_BEFORE_TIP`); `length_ratio` — a path's last link over its first, above 0, default 0.5; `strength` — `{trunk, branch, edge}`, each above 0 and below the spring's stability bound (`CONFIG_CLOTH_SPRING_STABLE`), default 100 / 100 / 50; `damping` — in [0, 1], absent: rig-c's default; `alternate_damping` — the odd trees' damping, in [0, 1], beside `damping` and different from it (`CONFIG_CLOTH_ALTERNATE_DIFFERS`); `wind`, `gravity` — `[root, tip]`, each 0 or more, tip at or above root (`CONFIG_CLOTH_RESPONSE_GROWS_TO_TIP`); `translate` — the x and y mix of a dangling end's flutter, above 0 and at most 1; `swing` — `bottomwear` only, `{scales}`, one positive scale per tree (`CONFIG_CLOTH_SWING_SCALE_PER_TREE`); `part` — `bottomwear` only (`CONFIG_CLOTH_PART_ON_BOTTOMWEAR`), a non-empty part name: the `topwear` part that holds a skirt See-through returned inside it (a dress), which takes the skirt's trees as well (issue #402, *A skirt inside topwear* below; the part is checked by `propose`, `PROPOSE_CLOTH_PART`). The two defaults are the recipe's own, measured on its synthetic fixture (the recipe below). The recipe below says what each field drafts |
121
127
 
122
128
  **A scene target is an ordinary bone.** A target the scene places — a point a hand
123
129
  reaches for, a face something turns toward — is a single bone parented to `root`,
@@ -506,6 +512,26 @@ layers, as follows; every step is arithmetic on the declared bones and the layer
506
512
  angle, the rest pose composites to the hard cut's bytes and no bend shows through the fade what
507
513
  lies behind the limb. The `limb cap:` line adds `edge "feather": N px of "<upper>" faded …`, and
508
514
  the record `edge`, `feather_radius` and `feathered_px`.
515
+ - **`cut_band: N`** (issue #360, opt-in on the segment below a joint whose two segments take one
516
+ part). The cut is placed rather than typed: of the lines parallel to the joint line at whole-pixel
517
+ offsets `-N .. N` along the axis, the one that crosses the fewest **stroke pixels**. A line crosses
518
+ the pixels a joint line runs through (the limb's art whose centre lies within half a pixel of it,
519
+ across the run of art through its point — the reading the limb's width uses); a stroke pixel is one
520
+ of those, over the whole band, whose integer BT.601 luma is at or below the **Otsu split** of their
521
+ luma histogram (the dark class of the two that maximise the between-class variance). The split is
522
+ derived from the band's own art and no threshold is typed: art of one luma has no split and so no
523
+ stroke. Ties go to the line nearer the joint, then to the upper side, so with nothing to avoid the
524
+ joint line itself is chosen. The bone does not move — the joint, the cap's disc and the limb's width
525
+ stay at its origin; only the line that splits the pixels between the two pieces moves, and the cap
526
+ takes the disc's pixels on the upper side of that line (under `edge: "feather"` the fade runs from
527
+ that line to the band's arc). The art read is the layer as the cut splits it, before the seam pass
528
+ recolours what the painting shows. A cut off the joint line leaves a sliver of one piece on the other
529
+ side of the pivot; `SEAM_OVER_RANGE` reads what that costs at a bend. A band with a line off the
530
+ limb's art is `ASSEMBLE_LIMB_CUT_BAND`. The `limb cap:` line adds `cut_band N: the cut
531
+ <k> px before|past the joint line (toward "<part>"), through [x, y], crosses <n> stroke px; the joint
532
+ line crosses <m> (stroke: luma <T> or below, the Otsu split of the <px> px …)`, and the record
533
+ `cut_band`, `cut_offset`, `cut_at`, `cut_crossed`, `joint_crossed`, `band_px` and, when the band has
534
+ a split, `stroke_luma_max`.
509
535
  - **Draw order.** A limb stands where its upper segment's part stood in the plan, its parts
510
536
  lowest first, so the upper is drawn over the lower at every joint: upper arm over forearm,
511
537
  thigh over shin, shin over foot. The parts it took leave the order.
@@ -1563,6 +1589,7 @@ What each rule drafts (`src/cloth.ts` holds them):
1563
1589
  | response | link j of an n-link path takes `wind` and `gravity` at j/(n − 1) of the way from the root value to the tip value; a single-link path takes the tip value. Each is a scalar **multiplier** of the environment the consumer sets (spine-core's skeleton `windX, windY`, `gravityX, gravityY`; rig-c 2.52.0's live track `setEnvironment`, rig-play 1.10.0's `environment()`): no direction is drafted | `wind`, `gravity` |
1564
1590
  | out of phase | the odd trees take `alternate_damping`, the even ones `damping` | `damping`, `alternate_damping` |
1565
1591
  | flutter | the last link of every path gets a second physics constraint, `<bone>_translate`, moving x and y by `translate`, with the link's stiffness and damping and **no** wind or gravity response. spine-core scales a translate spring's response by the skeleton's reference scale (100) and a rotation's by the link's length over it, so one response on both pushes an end about 100/length times further than it turns it (the table below) | `translate` |
1592
+ | part | `bottomwear` only (issue #402): the named `topwear` part takes the skirt's rule as the `bottomwear` parts do — trees from `hip` over its art below the hip, its waist line, and, as its art reaches above the chest, the chest segment the long-robe `bottomwear` keeps — in place of the two robe chains the topwear rule drafts; the prefix is `skirt` when it is the only skirt, `skirt_<part>` beside another | `part` |
1566
1593
  | swing | `bottomwear` only: a bone `<prefix>_swing` under `hip` at the centre of the root row, one link long, straight down, with physics (the trunk's stiffness, the root's response); each tree's first link takes the swing's rotation times its scale — a transform `<swing>_<k>`, local source and target, additive, the swing's setup rotation in hip's frame (−90: hip is drafted unturned) subtracted — and no physics of its own | `swing.scales` |
1567
1594
 
1568
1595
  Every link but a swing-driven first link gets `<bone>_physics` (`rotate` 1), and no
@@ -1570,6 +1597,29 @@ idle key: the drafted idle keys none of the trees. A recipe that drafts nothing
1570
1597
  its tag on no part, or `back hair` that ends above the shoulders (a bun) — is refused,
1571
1598
  `PROPOSE_CLOTH_DRAFTED`.
1572
1599
 
1600
+ **A skirt inside topwear (issue #402).** The recipe finds a skirt by the `bottomwear`
1601
+ tag alone. When See-through returns the skirt inside `topwear` (a dress), nothing is
1602
+ tagged `bottomwear`, and the proposer does not pick the dress by its shape: with
1603
+ `--cloth`, a `topwear` part whose box reaches 0.25 face heights below the hip (the
1604
+ topwear rule's own waist line) and whose art is wider across its last 24 rows than in
1605
+ the 24-row band at the hip is **named in a note** — the part, its art's rows below the
1606
+ hip, and the field — and in `PROPOSE_CLOTH_DRAFTED`'s line when a `bottomwear` recipe
1607
+ found no part. The author declares it, `"bottomwear": { …, "part": "<name>" }`, instead
1608
+ of moving the layer. Why a name and not a draft, measured on the public examples' builds
1609
+ (this port's assemble, the proposer's hip): `scarf`'s `topwear`, an outer robe over a
1610
+ separate `bottomwear` skirt, passes the same shape (rows 658 to 890 below the hip at y
1611
+ 657; 287 px across its last rows against 271 at the hip), so a draft by shape would hang
1612
+ a second set of skirt trees on a robe; `wind`'s `topwear`, a blouse whose sleeves reach
1613
+ the hip band, does not (350 px against 493). Without `--cloth` nothing is named, so every
1614
+ example's proposal is the one it was. What a declared dress drafts, measured on the
1615
+ selftest's dress fixture (`fixtures/cloth.ts`, flat colour; RG480 prints the figures):
1616
+ one lattice on chest, hip and the trees, built green through the gate with no split of
1617
+ the mesh; the bodice is not held wholly to the chest — a vertex above the hip carries up
1618
+ to 0.258 of its weight on the trees; and `check`'s `BREATH_VISIBLE`, which reads every
1619
+ `topwear` part as the torso, read the dress's idle heat at 1.592 against the floor
1620
+ 3.809, where the same dress with the robe chains read 3.9 — the half on the trees has
1621
+ no idle key. Neither is barred here; both are the dress's to weigh before declaring it.
1622
+
1573
1623
  **Every spring is stable at its step (A23's inequality).** Per step spine-core does
1574
1624
  `v += −strength·x·step·massInverse`, `x += v·step`, `v *= d` with d = damping^(60·step);
1575
1625
  in (x, v·step) that is the matrix [[1 − k, 1], [−d·k, d]] with
@@ -2010,7 +2060,7 @@ move off it (`AS245`).
2010
2060
  | --- | --- | --- | --- |
2011
2061
  | `layers` | the table, then one `author-made: layer "author:<label>" — …` line per layer the author made (group `author` in the table; §5, *A layer the author made*), then the `WARN` lines | every tag the plan will need has opaque pixels; one `face` in the head run; `0 WARN line(s)` | a run whose layer PNG is not its box's size (`LAYERS_PNG_MATCHES_BBOX`); a `WARN PLAN_LAYER_…` line (§6, *Plausibility*) |
2012
2062
  | `sheet` of both runs | the tile list (and the sheet, if you can see) | eyes, irises, lashes and brows as left/right pairs in the head run | a head box that cut off an ornament: move `head_box`, re-run the head crop |
2013
- | `assemble` | one line per part — its counts (`op=` opaque, `vis=` visible, `src=` taken / candidates, `unproj=` visible but not projected, `drift=<n> (<p>% of core)`, `merged=`, `seam=`; *parts.json*, below). `drift=` is `refused_drift_px` in rig px and its share of the part's candidates, `projected_core_px`, which it is a subset of (issue #314); no bar reads either. On the four public examples the share runs to 94.5 % (`scarf` `hair_back`, 479 of 507) and the count to 26,472 (`scarf` `topwear`, 22.3 %), and the seam override repaints refused top-most pixels afterwards, so a large count says where See-through's colour was not taken, not that the part is unlike the painting: the `drift:` line below is the one that names a body of them another part holds. Then the `pixels:` totals (opaque = visible + occluded; taken; visible but not projected), then `recomposite vs source: mean \|d\|, within 8, error px > 40, uncovered error px`, then `uncovered holes (8-connected): N` and the largest five as `uncovered hole K: <px> px at x,y wxh (between "<part>" <px> px, …)`, then one `uncovered: <n> of the <N> uncovered error px lie on the full run's "<tag>", in a body of <px> px at x,y wxh; <the rule that left it out>` line per full-run layer the plan does not take from the full run whose uncovered error holds a body (5x5-opened, 8-connected, at least 150 full-run px in rig px), then one `drift: "<part>" refuses <n> px of <run>:<tag> (its colour more than 90 off the painting, max channel), in a body of <px> px at x,y wxh (…); by the plan's draw order "<holder>" holds <px> px of it (…), "<holder>" drawn in front of "<part>"` line per part whose drift refusals hold a body (the same opening and bar) that another part holds in the draw order — that layer is not what the painting shows there (none on the five public paintings); and look at `render/recomposite_error_rig.png`. Between the part lines and the totals, one `author-made: part "<part>" (<run>:author:<label>) — …` line per part from a layer the author made (below, *A layer the author made*), then one `cut: "<part>" opaque <n> = "<part>" <kept> + "<piece>" <taken> …` line per part an `assemble.cuts` entry cut (below; it ends `; under <n> px filled, <m> px left empty` when a cut of that part has `under`), then — with `config.limbs` (issue #349) — one `limb cut: "<part>" opaque <n> = "<segment part>" <px> + …` line per part a limb takes and one `limb cap:` line per joint, its cap's pixels from the cap image, from the layer and missing, and its box — under `cap_shape: "disc"` also from the upper segment, under `edge: "feather"` the pixels faded (issue #360) (§3, *Limbs: cut at their joints*), then one `fringe pushed back: "<part>" <px> px, where the painting shows "<holder>" <px> px, …` line per part whose fringe was cleared (below) | on the examples: `reference-sample` 0.83 / 98.0 % / 4,359 / 1,185, 259 holes, the largest 94 px; `reference-demo` 2.34 / 95.8 % / 10,340 / 1,564, 453 holes, the largest 70 px (default rule) — many slivers along part edges, no hole a region could hide | one large hole: part of the figure is in no layer — a plan entry is missing, hair left the head crop sideways (reference-demo's `hair_back` is taken from the full run for that reason), or See-through split one garment into two and left the space between them in neither (a skirt as two trouser legs); the `between` parts say where. When neither run holds it at all, an `assemble.patches` entry cuts it from the painting (below) |
2063
+ | `assemble` | one line per part — its counts (`op=` opaque, `vis=` visible, `src=` taken / candidates, `unproj=` visible but not projected, `drift=<n> (<p>% of core)`, `merged=`, `seam=`; *parts.json*, below). `drift=` is `refused_drift_px` in rig px and its share of the part's candidates, `projected_core_px`, which it is a subset of (issue #314); no bar reads either. On the four public examples the share runs to 94.5 % (`scarf` `hair_back`, 479 of 507) and the count to 26,472 (`scarf` `topwear`, 22.3 %), and the seam override repaints refused top-most pixels afterwards, so a large count says where See-through's colour was not taken, not that the part is unlike the painting: the `drift:` line below is the one that names a body of them another part holds. Then the `pixels:` totals (opaque = visible + occluded; taken; visible but not projected), then `recomposite vs source: mean \|d\|, within 8, error px > 40, uncovered error px`, then `uncovered holes (8-connected): N` and the largest five as `uncovered hole K: <px> px at x,y wxh (between "<part>" <px> px, …)`, then one `uncovered: <n> of the <N> uncovered error px lie on the full run's "<tag>", in a body of <px> px at x,y wxh; <the rule that left it out>` line per full-run layer the plan does not take from the full run whose uncovered error holds a body (5x5-opened, 8-connected, at least 150 full-run px in rig px), then one `drift: "<part>" refuses <n> px of <run>:<tag> (its colour more than 90 off the painting, max channel), in a body of <px> px at x,y wxh (…); by the plan's draw order "<holder>" holds <px> px of it (…), "<holder>" drawn in front of "<part>"` line per part whose drift refusals hold a body (the same opening and bar) that another part holds in the draw order — that layer is not what the painting shows there (none on the five public paintings); and look at `render/recomposite_error_rig.png`. Between the part lines and the totals, one `author-made: part "<part>" (<run>:author:<label>) — …` line per part from a layer the author made (below, *A layer the author made*), then one `cut: "<part>" opaque <n> = "<part>" <kept> + "<piece>" <taken> …` line per part an `assemble.cuts` entry cut (below; it ends `; under <n> px filled, <m> px left empty` when a cut of that part has `under`), then — with `config.limbs` (issue #349) — one `limb cut: "<part>" opaque <n> = "<segment part>" <px> + …` line per part a limb takes and one `limb cap:` line per joint, its cap's pixels from the cap image, from the layer and missing, and its box — under `cap_shape: "disc"` also from the upper segment, under `edge: "feather"` the pixels faded, under `cut_band` the line the cut was placed on and the stroke pixels it and the joint line cross (issue #360) (§3, *Limbs: cut at their joints*), then one `fringe pushed back: "<part>" <px> px, where the painting shows "<holder>" <px> px, …` line per part whose fringe was cleared (below) | on the examples: `reference-sample` 0.83 / 98.0 % / 4,359 / 1,185, 259 holes, the largest 94 px; `reference-demo` 2.34 / 95.8 % / 10,340 / 1,564, 453 holes, the largest 70 px (default rule) — many slivers along part edges, no hole a region could hide | one large hole: part of the figure is in no layer — a plan entry is missing, hair left the head crop sideways (reference-demo's `hair_back` is taken from the full run for that reason), or See-through split one garment into two and left the space between them in neither (a skirt as two trouser legs); the `between` parts say where. When neither run holds it at all, an `assemble.patches` entry cuts it from the painting (below) |
2014
2064
  | `propose` | `note:` lines, `LINT` lines, the `coverage` lines, `landmarks.png`, `basis.json` | no LINT line: every chain link lies on its mesh's art, and the hip is below the chest and the figure's top quarter; the `coverage:` summary says how many bones that verdict covers — a `not checked` bone was read by no check (its line says why), and a `ratio` or `fallback` bone in `basis.json` is a guess | a link off the art (a bone on the background) — move it onto the layer; `LINT <link> at … runs to … N degrees off the head's down axis …` — a fringe link that does not lean with the head (§3, the fringe in the head's frame): move it along the lock it drives; `LINT hip at [x, y] is not below chest at [x, y]: …` or `LINT hip at [x, y] is above 0.25 of the figure height (figure y T..B, so hip y must be at least L): a hip at the shoulders` — move `hip` down to the waist (and `chest` between it and the neck); a `hanging strand … -- no chain proposed` note — that strand hangs stiff until you add a chain down the x and rows it names (§3); a `no blink: …` or `blink without brows: …` note — the idle will not blink (or its brows will not drop), because no part came from an `eyewhite` (or `eyebrow`) layer; the note names the tags looked for; a `no eyewhite part for eye_<s> …` note — the iris and lash parts it names ride `head` and do not blink, because no `eyewhite-<s>` part made that side's eye bone: take the eyewhite from the other run, or keep them on `head`; a `no face part: face box derived from …` note (always the first) — `head`, `neck` and every face-height scale come from a box guessed off the hair and neck (§3): check `head` and `neck` on `landmarks_head.png` and move them; when it adds `the blink shuts the eyes over no face part`, read `BLINK_NO_HOLE` after `check` — an eye with no face under it can open a hole (the `reference-sample` with only its face removed: 587 px). Under `--keypoints`: the `lint rule set:` line first (joints, or screen and why), then the joint notes — `missing: the rule "…" placed bone X instead` is a bone still guessed; `not used — …` names why an arm's joints did not place its sleeve (for a wrist on no part, the nearest part and the `--wrist-snap` that would bind it); a `wrist snap: …` note is a wrist bound past 15 px by the flag — check that chain's tip on `landmarks.png`; a `one handwear part holds both wrists` note is two chains on one mesh — cut the part with `assemble.cuts` to separate them; `LINT chest at … is not between the neck joint …`, `LINT hip at … is not past chest …`, `LINT hip at … is nearer the neck joint …` and `LINT <chain><i> at … does not advance from <s>_shoulder toward <s>_wrist` are the joint-frame lines: move that bone between, past or along the joints they name |
2015
2065
  | `compare` | one line per pair (origin, parent, tip, length, direction — or SKIP and why), then the per-row summary, the unmapped bones of each side, `required:`, each side's roles and the `controls:` line | proposal against the config you corrected: the rows you changed and no others. Config against the `rig.json` `build` writes for it: measured on both examples, every origin within 6.19e-7 px (the rig's offsets are written to 6 places) and every chain link's tip and length within 4.99e-4 px (`length` is written to 3), printed to three places as `0.000` (a signed figure as `+0.000` or `-0.000`); `parent … is the right's ancestor at depth 2, <bone>_ctl between` for every keyed mesh bone, no `DIFFERENT` and no `NOT MAPPED` | `parent DIFFERENT: left a, right b` — a bone hangs from another parent than the other side's; `frames not related` — a rig with no stage (`skeleton.width`/`height`), two configs at different `rig_scale`: the distance rows SKIP, so declare the frame in a `--map` file if the author knows it; `FAIL STRUCTURE_REQUIRED_PRESENT` — a bone the map requires is missing through its pairs |
2016
2066
  | `rig` (inside `build`) | one line per mesh: vertices, triangles, bones, influences, `cover`; the `bones` line; the `idle keys` line; then rigc's gate lines (with A15's declared SKIP under `--idle-keys direct`); in `rig.json`, each chain link's (or its `_ctl`'s) `length` and `rotation` | `cover 1.00000` on every mesh, both gate summaries `0 failed` (the compile and the packed pages); every link's `length` the distance to the next link and `rotation` its direction (Spine degrees, counter-clockwise, y up, local to the parent), every offset under it — a child bone's `x, y`, a weight's bind `x, y`, a region's `x, y` — in that turned frame, and a region on a link carrying `rotation` that turns it back upright. Nothing moved: `flattenRig` (`src/rig.ts`) turns every offset back and gives the unturned numbers | `RIG_LATTICE_ONE_LOOP`: change that mesh's `grid` |
@@ -2219,8 +2269,8 @@ reference's so the examples stay comparable with it. `build` takes both flags.
2219
2269
  **`rig --idle-keys ctl|direct`** (and `build --idle-keys`, which forwards the
2220
2270
  value to its rig stage; without the flag, or with `ctl`, a build writes and prints
2221
2271
  what it did before `build` took the flag). rig-c's `A15_IDLE_NO_MESH_BONE_KEYS`
2222
- (profile `spine-html`) refuses an idle that keys a bone a mesh is weighted to. `ctl`
2223
- (the default, the reference's answer) gives every such bone a same-origin
2272
+ (profile `rig-play`, named `spine-html` before rig-c 2.50.0) refuses an idle that
2273
+ keys a bone a mesh is weighted to. `ctl` (the default, the reference's answer) gives every such bone a same-origin
2224
2274
  `<bone>_ctl` parent and moves its keys there, which passes A15 on any rig-c;
2225
2275
  the stage prints `idle keys ctl: N mesh-driving bone(s) keyed …`. `direct` keys the
2226
2276
  bones themselves and writes `invariants.idleDrivesMeshes: { "why": … }` into
@@ -2523,6 +2573,7 @@ See-through with another seed.
2523
2573
  | <a id="CONFIG_CLOTH_RESPONSE_GROWS_TO_TIP"></a>`CONFIG_CLOTH_RESPONSE_GROWS_TO_TIP` | a `cloth` recipe's `wind` or `gravity` is `[root, tip]` with tip below root: the response grows from the root to the tip, where the motion accumulates down the chain | that pair |
2524
2574
  | <a id="CONFIG_CLOTH_ALTERNATE_DIFFERS"></a>`CONFIG_CLOTH_ALTERNATE_DIFFERS` | a `cloth` recipe's `alternate_damping` without `damping`, or equal to it: neighbouring trees are declared out of phase, and an alternate that alternates nothing declares nothing | `damping` beside it, a different value, or leave `alternate_damping` out |
2525
2575
  | <a id="CONFIG_CLOTH_SWING_SCALE_PER_TREE"></a>`CONFIG_CLOTH_SWING_SCALE_PER_TREE` | `swing` on a tag other than `bottomwear`, or `swing.scales` not one scale per tree (`chains`) | one scale per tree, in tree order across the skirt |
2576
+ | <a id="CONFIG_CLOTH_PART_ON_BOTTOMWEAR"></a>`CONFIG_CLOTH_PART_ON_BOTTOMWEAR` | `part` on a `cloth` recipe for a tag other than `bottomwear` (issue #402) | leave it out there; `part` hands the skirt's recipe to a `topwear` part that holds a skirt (a dress) |
2526
2577
  | <a id="CONFIG_CLOTH_SPRING_STABLE"></a>`CONFIG_CLOTH_SPRING_STABLE` | a `cloth` recipe's strength — declared, or the default 100 / 100 / 50 — whose spring is unstable at a damping the recipe runs at (`damping`, `alternate_damping`, or rig-c's 0.85 when `damping` is left out): k = strength·massInverse·step² at or past 2(1 + damping^(60·step)), step 1/60 and mass 1 (rig-c's defaults; the recipe sets neither). The detail gives k and the bound | a lower strength, or a higher damping |
2527
2578
  | <a id="CONFIG_TURN_BONE_FREE"></a>`CONFIG_TURN_BONE_FREE` | the config has `turn` and `bones` declares a bone named `turn`, the control the rig stage adds | rename that bone |
2528
2579
 
@@ -2590,6 +2641,7 @@ says why each requirement exists and what breaks without it.
2590
2641
  | <a id="ASSEMBLE_UNDER_DRAW"></a>`ASSEMBLE_UNDER_DRAW` | a cut with `under` draws its piece behind its part, which the fill would hide it under | that cut's `draw`: `"front"`, or `{"before": …}` the plan part after its `from` |
2591
2642
  | <a id="ASSEMBLE_LIMB_TAKES"></a><a id="ASSEMBLE_LIMB_PIXELS"></a>`ASSEMBLE_LIMB_TAKES`, `ASSEMBLE_LIMB_PIXELS` | a part a limb takes has no opaque pixel, or a limb segment gets none of it — the joint lines through the bones' origins put none of the limb's pixels on it, or another limb's polyline is nearer every one (issue #349) | the bones: their origins on the limb's art, each joint where the limb bends |
2592
2643
  | <a id="ASSEMBLE_LIMB_JOINT"></a><a id="ASSEMBLE_LIMB_JOINT_ON_ART"></a>`ASSEMBLE_LIMB_JOINT`, `ASSEMBLE_LIMB_JOINT_ON_ART` | a joint has no line — the upper bone has no length, or the limb folds straight back on itself — or its bone's origin lies on none of the limb's art within 1 px along the line, so the limb has no width there to size the cap by (issue #349); under `cap_shape: "disc"`, also a bone's origin on the very edge of the run, which has no half-width about it (issue #360) | the joint's bone: on the limb's art, at the joint |
2644
+ | <a id="ASSEMBLE_LIMB_CUT_BAND"></a>`ASSEMBLE_LIMB_CUT_BAND` | a segment's `cut_band` reaches past the limb: a line of its band, the detail names the one nearest the joint and a point it passes through, crosses none of the limb's art within 1 px of that point, so a cut placed there would cut nothing (issue #360) | `cut_band`: the widest band whose every line crosses the limb, which the detail gives |
2593
2645
  | <a id="ASSEMBLE_LIMB_CAP_PRESENT"></a><a id="ASSEMBLE_LIMB_CAP_DECODES"></a><a id="ASSEMBLE_LIMB_CAP_SIZE"></a><a id="ASSEMBLE_LIMB_CAP_EMPTY"></a>`ASSEMBLE_LIMB_CAP_PRESENT`, `ASSEMBLE_LIMB_CAP_DECODES`, `ASSEMBLE_LIMB_CAP_SIZE`, `ASSEMBLE_LIMB_CAP_EMPTY` | a segment's `cap` names no file (relative to the config's directory) or one that is not a PNG; an image not the size of the cap's box (the detail gives both, and the box's corner); or one transparent over every cap pixel (issue #349) | the image: the box the `limb cap:` line prints, `w`x`h`, its pixel `(i, j)` rig pixel `(x + i, y + j)`; to keep the layer's cap, drop `cap` |
2594
2646
  | <a id="ASSEMBLE_HIDDEN_ONE_SOURCE"></a>`ASSEMBLE_HIDDEN_ONE_SOURCE` | a cut's `under`, or a limb segment's `cap`, names a file, and the part it reads also has a hidden-art layer (`<layer>:hidden`, issue #359): reading either would be a guess | remove the file from the config, or the hidden-art layer from the input |
2595
2647
  | <a id="ASSEMBLE_COUNTS_ADD_UP"></a>`ASSEMBLE_COUNTS_ADD_UP` | a part's visible and occluded counts do not add up to its opaque pixels, or a projected pixel is not visible, or a cut part's pieces do not add up to it — an assembler bug, not an input problem | report it with the part named; nothing was written |
@@ -2603,7 +2655,8 @@ says why each requirement exists and what breaks without it.
2603
2655
  | <a id="PROPOSE_FACE_PRESENT"></a>`PROPOSE_FACE_PRESENT` | no part comes from a `face` layer, and the face-less fallback cannot derive a face box either: it needs the head run's `neck` and at least one head-run `front hair`/`back hair` part whose top is above the neck's, and the message names the half that is missing. With both, `propose` does not refuse — it derives the box and says so in its first note (§5) | `assemble.plan`: take the face, or the head run's hair and neck |
2604
2656
  | <a id="PROPOSE_CUT_FROM_RECORDED"></a>`PROPOSE_CUT_FROM_RECORDED` | two parts share one layer and none of them records `cut_from`: a `parts.json` an `assemble` before 1.6.0 wrote with `assemble.cuts`. The records are in draw order, so which is the plan part and which the piece cannot be read off the file; the message names the parts and the layer. Every other reader still takes the file | `--parts`: re-run assemble (1.6.0+) to record `cut_from` |
2605
2657
  | <a id="PROPOSE_LIMB_PARTS"></a>`PROPOSE_LIMB_PARTS` | `parts.json` holds parts `config.limbs` cut at their joints (issue #349); the limbs are drafted from the parts before the cut, which the rules read by layer | `--parts` a build assembled with the config's `limbs` left out; keep the block the config holds (its caps and ranges are the author's). `propose --from-config` reads the config's bones on either build |
2606
- | <a id="PROPOSE_CLOTH_DRAFTED"></a>`PROPOSE_CLOTH_DRAFTED` | with `--cloth` (issue #364): the config's `cloth` block holds a recipe for a tag the proposer drafts no chain on — no part has that tag, or every `back hair` part ends above the shoulders (a bun bone, no chain) | leave that recipe out, or assemble the layer it is for |
2658
+ | <a id="PROPOSE_CLOTH_DRAFTED"></a>`PROPOSE_CLOTH_DRAFTED` | with `--cloth` (issue #364): the config's `cloth` block holds a recipe for a tag the proposer drafts no chain on — no part has that tag, or every `back hair` part ends above the shoulders (a bun bone, no chain). A `bottomwear` recipe with no `bottomwear` part names every `topwear` part shaped like a skirt (issue #402) | leave that recipe out, or assemble the layer it is for, or declare the named part in `cloth.bottomwear.part` |
2659
+ | <a id="PROPOSE_CLOTH_PART"></a>`PROPOSE_CLOTH_PART` | with `--cloth` (issue #402): `cloth.bottomwear.part` names no part, a part that is not `topwear` (a `bottomwear` part takes the recipe by its tag already), a cut piece (`cut_from`), or a `topwear` whose box ends above the hip + 0.25 face heights, the topwear rule's waist line | name the `topwear` part that holds the skirt, or leave `part` out |
2607
2660
  | <a id="PROPOSE_ACCESSORY_BODY"></a>`PROPOSE_ACCESSORY_BODY` | an accessory has nothing above its pendant rows to hang its bone on | that part's plan entry, or author its bones by hand |
2608
2661
  | <a id="PROPOSE_TURN_RUN_GIVEN"></a><a id="PROPOSE_TURN_LAYER_PRESENT"></a><a id="PROPOSE_TURN_DEPTH_PRESENT"></a>`PROPOSE_TURN_RUN_GIVEN`, `PROPOSE_TURN_LAYER_PRESENT`, `PROPOSE_TURN_DEPTH_PRESENT` | with `--full`/`--head` (issue #251): a part came from a run whose layers were not given, the run given holds no layer of the part's tag, or its layer carries no `depth_median` while another part's layer carries one; a run with no depth on any part's layer (a PSD, or an export of one) is not refused — the turn is skipped, and the note says `turn: SKIP` and names the run (issue #359) | give the run the parts were assembled from, as the wrapper's `layers.json` |
2609
2662
  | <a id="BASIS_RECORDS_EVERY_BONE"></a><a id="BASIS_NAMES_RESOLVE"></a><a id="BASIS_KIND_KNOWN"></a><a id="BASIS_KIND_HOLDS"></a>`BASIS_RECORDS_EVERY_BONE`, `BASIS_NAMES_RESOLVE`, `BASIS_KIND_KNOWN`, `BASIS_KIND_HOLDS` | `propose --keypoints`'s record of how it placed each bone, `basis.json`, does not hold to the proposal it was written with: a proposed bone with no record, one recorded twice or out of the proposal's order; a part, bone or frame quantity it names that is not there; a placement kind outside the known ones; or a placement that does not hold what its kind says (a joint placement with no joint, a non-joint one with a joint, a derived one with no bone, a constant that is not finite). Nothing is written | a proposer bug, not an input problem: report it with the line |
@@ -2779,8 +2832,8 @@ implementation's bars) — each one that measured; a rig with no `parts.json` or
2779
2832
  assemble*, at the end of this section):
2780
2833
 
2781
2834
  - `gate_spine-html.txt`: every summary line `(N passed, 0 failed)` — the packed build
2782
- under the `spine-html` profile, gated once over the compile and once over the packed
2783
- pages on disk. There is no `spine` gate of its own: `spine-html` holds every rule
2835
+ under the `rig-play` profile, gated once over the compile and once over the packed
2836
+ pages on disk. There is no `spine` gate of its own: `rig-play` holds every rule
2784
2837
  `spine` measures (on reference-demo, rigc 1.5.1 and 2.0.3: `validate --profile spine`'s 14
2785
2838
  measured rules are all among the build's 23, the 15 others not in `spine`; rigc
2786
2839
  2.1.3 and 2.10.1: the same 14 among the build's 24, which adds
package/docs/STABILITY.md CHANGED
@@ -126,7 +126,7 @@ part name, `[i]` an entry of a list):
126
126
  - **assemble.cuts[i]** — required: `from`, `into`, `polygon`, `draw`, `overlap`; optional: `under`, `under_fill`
127
127
  - **assemble.cuts[i].draw**, when an object — required: `before`
128
128
  - **limbs.&lt;limb&gt;** — required: `segments` (issue #349)
129
- - **limbs.&lt;limb&gt;.segments[i]** — required: `part`, `from`, `bone`; required below a joint (i > 0): `joint`; optional below a joint: `range`, `cap`, `edge`, `cap_shape`
129
+ - **limbs.&lt;limb&gt;.segments[i]** — required: `part`, `from`, `bone`; required below a joint (i > 0): `joint`; optional below a joint: `range`, `cap`, `edge`, `cap_shape`, `cut_band`
130
130
  - **bones[i]**, a single bone — required: `name`, `parent`, `at`; optional: `tip`, `inherit`
131
131
  - **bones[i]**, a chain — required: `chain`, `parent`, `points`, `tip`
132
132
  - **meshes.&lt;part&gt;** — exactly one of `grid`, `contour`, `auto`; required in every mode: `r`, `segments`; optional in every mode: `exponent`, `rule`; optional with `contour` or `auto`: `ribs`; optional with `grid` or `contour`: `influences` (issue #284; beside `auto` it is refused, CONFIG_INFLUENCES_MODE); optional with `grid`: `stray` (issue #303; beside `contour` or `auto` it is refused, CONFIG_STRAY_MODE)
@@ -147,7 +147,7 @@ part name, `[i]` an entry of a list):
147
147
  - **meshes.&lt;part&gt;.auto.regions[i]** — required: `name`, `shape`, `maxEdgeLength`, `transition`, `grade`, `minArtSamples`, and `cx`, `cy`, `r` for a circle or `points` for a polygon; optional: `bone`, `band` (both or neither; with neither the region is density only)
148
148
  - **meshes.&lt;part&gt;.auto.boundaryRuns** — required: `maxVertices`
149
149
  - **meshes.&lt;part&gt;.auto.stimulus**, or each entry of it when a list — required: `chain`, `degrees`
150
- - **cloth.&lt;tag&gt;**, the tag bottomwear, back hair or front hair (issue #364; read by propose --cloth only) — required: `chains`, `links`, `wind`, `gravity`; optional: `split`, `length_ratio`, `strength`, `damping`, `alternate_damping`, `translate`, `swing` (on bottomwear only)
150
+ - **cloth.&lt;tag&gt;**, the tag bottomwear, back hair or front hair (issue #364; read by propose --cloth only) — required: `chains`, `links`, `wind`, `gravity`; optional: `split`, `length_ratio`, `strength`, `damping`, `alternate_damping`, `translate`, `swing` (on bottomwear only), `part` (on bottomwear only)
151
151
  - **cloth.&lt;tag&gt;.split** — required: `at`, `into`
152
152
  - **cloth.&lt;tag&gt;.strength** — required: `trunk`, `branch`, `edge`
153
153
  - **cloth.&lt;tag&gt;.swing** — required: `scales`
@@ -178,7 +178,7 @@ every number) are AUTHORING §3's tables, and the loader refuses any other by na
178
178
 
179
179
  | file | written by | what is stable |
180
180
  | --- | --- | --- |
181
- | `parts.json`, `parts/<name>.png` | `assemble`, `build` | one record per part: `from` (`<run>:<tag>` with a See-through v3 tag, `<run>:author:<label>` for a layer the author made — issue #256, read by no role rule — or `painting:<name>` for a patch), `cut_from` on a cut's piece only (the plan part it was cut from, issue #230), `limb` on a limb segment's part only (issue #349: `name`, `segment`, `of`, `bone`, and below a joint `joint`, `range` when the config segment declares one (issue #360), and `cap` — `at`, `width`, `radius`, `box`, `layer_px`, `image_px` with a cap image, `image_layer` after it when that image was a hidden-art layer — issue #359, `<run>:<layer>:hidden` — `missing_px`, then `shape` and `upper_px` under the segment's `cap_shape`, and `edge`, `feather_radius` and `feathered_px` under its `edge`, issue #360), the box `x`, `y`, `w`, `h` (rig px), the pixel counts `src/parts.ts` documents (`opaque_px`, `visible_px`, `occluded_px`, `projected_core_px`, `source_px_taken`, `visible_not_projected_px`, `refused_drift_px`, `merged_px`, `seam_override_px`, and `fringe_pushed_back` when not empty); `rig_size`, `scale_rig_per_source`, `ghost_px`, `recomposite`, and `scene` (`figure_alpha_above`, `figure_px`, `figure_mask`) under `config.scene` only, with the figure's mask `figure_rig.png` beside the recomposite (issue #242); `single_run_pad` (`file_size`, `side`, `left`, `top`) last, only for one run whose file is not the `seethrough.resolution` square (issue #366) |
181
+ | `parts.json`, `parts/<name>.png` | `assemble`, `build` | one record per part: `from` (`<run>:<tag>` with a See-through v3 tag, `<run>:author:<label>` for a layer the author made — issue #256, read by no role rule — or `painting:<name>` for a patch), `cut_from` on a cut's piece only (the plan part it was cut from, issue #230), `limb` on a limb segment's part only (issue #349: `name`, `segment`, `of`, `bone`, and below a joint `joint`, `range` when the config segment declares one (issue #360), and `cap` — `at`, `width`, `radius`, `box`, `layer_px`, `image_px` with a cap image, `image_layer` after it when that image was a hidden-art layer — issue #359, `<run>:<layer>:hidden` — `missing_px`, then `shape` and `upper_px` under the segment's `cap_shape`, and `edge`, `feather_radius` and `feathered_px` under its `edge`, and `cut_band`, `cut_offset`, `cut_at`, `cut_crossed`, `joint_crossed`, `band_px` and `stroke_luma_max` (when the band has a split) under its `cut_band`, issue #360), the box `x`, `y`, `w`, `h` (rig px), the pixel counts `src/parts.ts` documents (`opaque_px`, `visible_px`, `occluded_px`, `projected_core_px`, `source_px_taken`, `visible_not_projected_px`, `refused_drift_px`, `merged_px`, `seam_override_px`, and `fringe_pushed_back` when not empty); `rig_size`, `scale_rig_per_source`, `ghost_px`, `recomposite`, and `scene` (`figure_alpha_above`, `figure_px`, `figure_mask`) under `config.scene` only, with the figure's mask `figure_rig.png` beside the recomposite (issue #242); `single_run_pad` (`file_size`, `side`, `left`, `top`) last, only for one run whose file is not the `seethrough.resolution` square (issue #366) |
182
182
  | `rig/rig.json`, `rig/motion.json`, `rig/images/` | `rig`, `build`, `compose` | rig-c's rig spec and motion spec, `spec` `rigc-rig/1` and `rigc-motion/1`: the format is rig-c's, and this package writes only what rig-c's parser accepts; a bone carries `inherit` only where config.bones declares one, rig-c's mode name as written (issue #348) |
183
183
  | `rig/mesh_report.json` | `rig`, `build` | one row per mesh: `part`, `vertices`, `triangles`, `hull`, `bones`, `max_influences`, `mean_influences`, `art_coverage`, then `grid` (a lattice); `mode` "contour" with `params`, `contour`, `regions` (`params.maxEdge` and `contour.outlineCut` only when the mesh declares `contour.maxEdge`; `params.bridges` and `contour.bridges` — `islands`, `units`, `joins`, and `faint` only when an island was left out as faint — only when it declares `contour.bridges`); or `mode` "auto" with `settings`, `source`, `result`, `residuals`, `worst_residual`, `worst_region`, `motion_amplitude`, `termination`, `weights`, `regions`, `deformation`, `quality_report` (rig-c's `mesh-quality-report/1` document whole), `motion_report`, and, only when they apply, `stray_cleared` (after `source`, when `source.stray` is declared), `skinning_residual` and `replay` (`AutoMeshReport` in `src/rig.ts`); in every mode, `exponent` when the mesh declares one (after `grid`, or after `mode`); `influences`, as declared, when a lattice or contour mesh declares it (after `exponent`, or where `exponent` would be); `stray` and `stray_cleared` when a lattice mesh declares `stray` (after `influences`, or where `influences` would be); `ribs` when a contour or auto mesh declares them (after `exponent`, or after `mode`), and then `contour.ribs` (`source.contour.ribs` in the automatic mode) |
184
184
  | `check/check.json` and the rest of `check/` | `check`, `build`, `compose` | the reference's fields in its order (`gate_spine_html_green`, `rigc_entry`, `pack_mode`, `loop_max_diff`, the seam figures — `seam_mean`, `seam_px_over_40`, `seam_px_over_80` and, from issue #216, `seam_frame_scale`, the frame scale the bar divides the count by), `loop_physics` after `loop_max_diff` when the rig declares a physics constraint, `seam_border` after the seam figures when `parts.json` declares a scene (issue #242), `seam_pairs` after the seam figures when the seam bar fails or `--seam-pairs` asks (each row's picture under `check/seam/`; `--keep-stills` leaves the setup-pose still and its `frames.json` under `check/setup_still/`), then the judgement lines (`BREATH_VISIBLE`, `BLINK_NO_HOLE`, `CHAIN_LAG`, `TIP_OVER_ROOT`, `STILL_REGIONS_DARK`, `TEXTURE_STRETCH`), `ANIMATIONS_DO_NOT_FOLD` after them when `motion.json` holds an animation, the idle included — on every rig with an idle since issue #333 (issue #320: `status`, `animations`, `fps`, `physics_left_out`, `folding`, `folding_undeclared`, `declared_not_folding`, `bar`), `FEET_STAY_LEVEL` after it when a `footwear` part rides a bone that hangs from another and `motion.json` holds an animation (issue #348: `status`, `reason` on a SKIP only, `animations`, `fps`, `physics_left_out`, `bar_degrees`, `bar`, `feet` — each `part`, `bone`, `hangs_from`, `status`, `frames_posed`, `worst`), `LIMB_ONE_BONE` after it (and after `STRESS_OFF_CHAIN` where that is written) when `parts.json` holds a limb segment's part (issue #349: `status`, `parts` — each `part`, `limb`, `bone`, `status`, `others`), `SEAM_OVER_RANGE` after it when a limb record carries a `range` (issue #360: `status`, `frame_scale`, `physics_left_out`, `bar` — `mean`, `rig_px_over_40`, `level` — and `joints`, each `part`, `limb`, `segment`, `joint`, `bone`, `range`, `at`, `radius`, `under_px`, `status`, `poses` — each `degrees`, `status`, `mean`, `px_over_40`, `px_over_80`, `rig_px_over_40` — and `unread` on a joint not read), `RECOMPOSITE_HOLES` (its first figure `declared_scene` when `parts.json` declares a scene), `SETUP_POSE_VS_SOURCE`, `skipped`, a `requirements` block under `--requirements`, and `PASS`; `check/build/skeleton.json`, `.atlas` and `.png` are the packed artifact rig-c writes |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/parts",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/assemble.ts CHANGED
@@ -104,7 +104,7 @@ import { type Problem, refuseIfAny } from './errors.ts';
104
104
  import { figuresPhrase, implausibleRules, type Layer, type LayerFigures, layerFigures, type LayerSet, NEAR_WHITE_MIN, OPAQUE_ALPHA_ABOVE, ruleSummary } from './layers.ts';
105
105
  import { padToSquare, squarePad } from './inputs.ts';
106
106
  import { type CapRecord, type LimbRecord, PAINTING_RUN, type PartRecord, type PartsFile, type RecompositeRecord, type SceneRecord, type SingleRunPad } from './parts.ts';
107
- import { type BonePlace, bonePlaces, capBox, coveredRadius, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, nearestLimb, pastJoint, segmentOf } from './limbs.ts';
107
+ import { type BonePlace, bonePlaces, capBox, coveredRadius, type CutPlacement, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, luma601, nearestLimb, pastJoint, placeCut, segmentOf } from './limbs.ts';
108
108
  import {
109
109
  alphaComposite,
110
110
  connectedComponents,
@@ -1859,6 +1859,22 @@ export interface LimbCount {
1859
1859
  joints: Array<{ limb: string; joint: string; part: string; upper: string; cap: CapRecord }>;
1860
1860
  }
1861
1861
 
1862
+ /**
1863
+ * What `cut_band` did at a joint (issue #360, item 14), for the `limb cap:`
1864
+ * line: the line chosen — its offset from the joint line and a point it
1865
+ * passes through — the stroke pixels it crosses, those the joint line
1866
+ * crosses, and the split that made a pixel a stroke.
1867
+ */
1868
+ function cutPhrase(k: CapRecord, upper: string, lower: string): string {
1869
+ const off = k.cut_offset ?? 0;
1870
+ const where = off === 0 ? 'on the joint line' : `${Math.abs(off)} px ${off < 0 ? `before the joint line (toward "${upper}")` : `past the joint line (toward "${lower}")`}`;
1871
+ const stroke =
1872
+ k.stroke_luma_max === undefined
1873
+ ? `no stroke: the ${k.band_px ?? 0} px of the limb's art the band's lines cross hold one luma, so nothing splits from it`
1874
+ : `stroke: luma ${k.stroke_luma_max} or below, the Otsu split of the ${k.band_px ?? 0} px of the limb's art the band's lines cross`;
1875
+ return `cut_band ${k.cut_band ?? 0}: the cut ${where}, through [${(k.cut_at ?? k.at).join(', ')}], crosses ${k.cut_crossed ?? 0} stroke px; the joint line crosses ${k.joint_crossed ?? 0} (${stroke})`;
1876
+ }
1877
+
1862
1878
  /**
1863
1879
  * The lines `assemble` prints for the limbs (issue #349), one per part a limb
1864
1880
  * took — ` limb cut: "<of>" opaque <n> = "<part>" <px> + …` — and one per
@@ -1879,6 +1895,7 @@ export function limbLines(counts: readonly LimbCount[]): string[] {
1879
1895
  : `a disc of radius ${k.radius} px (cap_shape "disc": the joint's distance to the nearer side of the limb, ${k.width} px across the joint line)`;
1880
1896
  const shaped = [
1881
1897
  ...(k.edge === undefined ? [] : [`edge "feather": ${k.feathered_px ?? 0} px of "${j.upper}" faded across the ${k.feather_radius ?? 0} px about the joint that "${j.part}" covers at every turn`]),
1898
+ ...(k.cut_band === undefined ? [] : [cutPhrase(k, j.upper, j.part)]),
1882
1899
  ];
1883
1900
  const miss =
1884
1901
  k.missing_px === 0
@@ -1919,6 +1936,11 @@ export function limbOrder(order: readonly DrawSlot[], plan: readonly PlanEntry[]
1919
1936
  return out;
1920
1937
  }
1921
1938
 
1939
+ /** The point a joint line moved `offset` px along its axis passes through, to 3 places (issue #360, `cut_band`). */
1940
+ function shiftedAt(line: JointLine, offset: number): [number, number] {
1941
+ return [pyRound(line.at[0] + offset * line.axis[0], 3), pyRound(line.at[1] + offset * line.axis[1], 3)];
1942
+ }
1943
+
1922
1944
  /**
1923
1945
  * Cut every declared limb (module comment of `src/limbs.ts`): each part a limb
1924
1946
  * takes is split among the limbs that take it (nearest polyline), then each
@@ -1980,6 +2002,9 @@ function cutLimbs(
1980
2002
  );
1981
2003
  }
1982
2004
  refuseIfAny(problems);
2005
+ // The line each segment's pixels are split by: the joint line, or where cut_band placed the cut (issue #360).
2006
+ const cutLines = new Map([...lines].map(([l, ls]) => [l, [...ls]]));
2007
+ const placements = new Map<string, Extract<CutPlacement, { ok: true }>>();
1983
2008
  // Each part a limb takes, in the order the limbs first take them.
1984
2009
  const sources = [...new Set(parts.map((q) => q.of))];
1985
2010
  const pieces: Array<Built | null> = parts.map(() => null);
@@ -2003,14 +2028,42 @@ function cutLimbs(
2003
2028
  for (let x = 0; x < W; x++) {
2004
2029
  const p = y * W + x;
2005
2030
  if (b.r.data[p * 4 + 3] === 0) continue;
2006
- const li = on.length === 1 ? 0 : nearestLimb(lns, x, y);
2007
- const l = on[li];
2008
- own[p] = names.indexOf(l);
2031
+ own[p] = names.indexOf(on[on.length === 1 ? 0 : nearestLimb(lns, x, y)]);
2032
+ }
2033
+ }
2034
+ // Issue #360 (item 14): each joint of this part that declares cut_band has its cut placed, on the limb's own art.
2035
+ for (const l of on) {
2036
+ const li = names.indexOf(l);
2037
+ limbs[l].segments.forEach((sg, k) => {
2038
+ if (k === 0 || sg.cut_band === undefined || sg.from !== src || limbs[l].segments[k - 1].from !== src) return;
2039
+ const line = (lines.get(l) as Array<JointLine | null>)[k] as JointLine;
2040
+ const art = (x: number, y: number): boolean => x >= 0 && y >= 0 && x < W && y < H && own[y * W + x] === li && b.r.data[(y * W + x) * 4 + 3] > OPAQUE_ALPHA_ABOVE;
2041
+ const luma = (x: number, y: number): number => luma601(b.r.data[(y * W + x) * 4], b.r.data[(y * W + x) * 4 + 1], b.r.data[(y * W + x) * 4 + 2]);
2042
+ // The joint line on no art is ASSEMBLE_LIMB_JOINT_ON_ART at the caps; nothing is placed about it.
2043
+ if (limbRun(line, art, [0, 0, W - 1, H - 1]) === null) return;
2044
+ const placed = placeCut(line, sg.cut_band, art, luma, [0, 0, W - 1, H - 1]);
2045
+ if (!placed.ok) {
2046
+ problems.push({
2047
+ code: 'ASSEMBLE_LIMB_CUT_BAND',
2048
+ object: `config.limbs.${l}.segments[${k}] (joint "${String(sg.joint)}", part "${sg.part}").cut_band`,
2049
+ detail: `is ${sg.cut_band}, and the line ${Math.abs(placed.offset)} px ${placed.offset < 0 ? 'before' : 'past'} the joint line, through [${shiftedAt(line, placed.offset).join(', ')}], crosses none of the limb's art within 1 px of that point — the band reaches past the limb there, and a cut placed off the art is no cut; a band whose every line crosses the limb is required — ${Math.abs(placed.offset) > 1 ? `cut_band ${Math.abs(placed.offset) - 1} or less` : 'leave cut_band out'}`,
2050
+ });
2051
+ return;
2052
+ }
2053
+ (cutLines.get(l) as Array<JointLine | null>)[k] = placed.line;
2054
+ placements.set(`${l}/${k}`, placed);
2055
+ });
2056
+ }
2057
+ for (let y = 0; y < H; y++) {
2058
+ for (let x = 0; x < W; x++) {
2059
+ const p = y * W + x;
2060
+ if (b.r.data[p * 4 + 3] === 0) continue;
2061
+ const l = names[own[p]];
2009
2062
  const segs = limbs[l].segments;
2010
2063
  const first = segs.findIndex((sg) => sg.from === src);
2011
2064
  let last = first;
2012
2065
  while (last + 1 < segs.length && segs[last + 1].from === src) last++;
2013
- const k = segmentOf(lines.get(l) as Array<JointLine | null>, first, last, x, y);
2066
+ const k = segmentOf(cutLines.get(l) as Array<JointLine | null>, first, last, x, y);
2014
2067
  const at = parts.findIndex((q) => q.limb === l && q.segment === k);
2015
2068
  rasters[at].data.set(b.r.data.subarray(p * 4, p * 4 + 4), p * 4);
2016
2069
  if (b.region === null || b.region.data[p] === 1) regions[at].data[p] = 1;
@@ -2102,6 +2155,9 @@ function cutLimbs(
2102
2155
  }
2103
2156
  const lower = rasters[at];
2104
2157
  const lowerSrc = builtOf(sg.from) as Built;
2158
+ // Issue #360 (cut_band): the cap's pixels are the disc's on the upper side of the cut, wherever it was placed.
2159
+ const cut = (cutLines.get(l) as Array<JointLine | null>)[k] as JointLine;
2160
+ const placed = placements.get(`${l}/${k}`);
2105
2161
  const ownLower = owners.get(sg.from) as Int32Array;
2106
2162
  let layerPx = 0;
2107
2163
  let imagePx = 0;
@@ -2109,7 +2165,7 @@ function cutLimbs(
2109
2165
  let missing = 0;
2110
2166
  for (let y = Math.max(0, box[1]); y < Math.min(H, box[1] + box[3]); y++) {
2111
2167
  for (let x = Math.max(0, box[0]); x < Math.min(W, box[0] + box[2]); x++) {
2112
- if (!inDisc(line.at, radius, x, y) || pastJoint(line, x, y)) continue;
2168
+ if (!inDisc(line.at, radius, x, y) || pastJoint(cut, x, y)) continue;
2113
2169
  const p = y * W + x;
2114
2170
  const u = img === null ? -1 : ((y - box[1]) * img.width + (x - box[0])) * 4;
2115
2171
  if (img !== null && img.data[u + 3] > 0) {
@@ -2137,12 +2193,12 @@ function cutLimbs(
2137
2193
  const fb = capBox(line.at, band);
2138
2194
  for (let y = Math.max(0, fb[1]); y < Math.min(H, fb[1] + fb[3]); y++) {
2139
2195
  for (let x = Math.max(0, fb[0]); x < Math.min(W, fb[0] + fb[2]); x++) {
2140
- if (band === 0 || !inDisc(line.at, band, x, y) || pastJoint(line, x, y)) continue;
2196
+ if (band === 0 || !inDisc(line.at, band, x, y) || pastJoint(cut, x, y)) continue;
2141
2197
  const p = y * W + x;
2142
2198
  const ua = upper.data[p * 4 + 3];
2143
2199
  if (ua === 0) continue;
2144
2200
  const o = jointOffsets(line, x, y);
2145
- const na = Math.floor(ua * featherWeight(band, o.along, o.across) + 0.5);
2201
+ const na = Math.floor(ua * featherWeight(band, o.along, o.across, placed?.offset ?? 0) + 0.5);
2146
2202
  if (na === ua) continue;
2147
2203
  if (na === 0) upper.data.fill(0, p * 4, p * 4 + 4);
2148
2204
  else upper.data[p * 4 + 3] = na;
@@ -2161,6 +2217,17 @@ function cutLimbs(
2161
2217
  missing_px: missing,
2162
2218
  ...(disc ? { shape: 'disc' as const, upper_px: upperPx } : {}),
2163
2219
  ...(sg.edge === 'feather' ? { edge: 'feather' as const, feather_radius: band, feathered_px: featheredPx } : {}),
2220
+ ...(placed === undefined
2221
+ ? {}
2222
+ : {
2223
+ cut_band: sg.cut_band as number,
2224
+ cut_offset: placed.offset,
2225
+ cut_at: shiftedAt(line, placed.offset),
2226
+ cut_crossed: placed.crossed,
2227
+ joint_crossed: placed.jointCrossed,
2228
+ band_px: placed.bandPx,
2229
+ ...(placed.strokeLumaMax === null ? {} : { stroke_luma_max: placed.strokeLumaMax }),
2230
+ }),
2164
2231
  };
2165
2232
  if (hidden !== null) readHidden(hidden.layer, `config.limbs.${l}.segments[${k}].cap (part "${sg.part}")`);
2166
2233
  parts[at].record.cap = cap;
package/src/build.ts CHANGED
@@ -357,13 +357,13 @@ function gateRun(label: string, rigc: RigcRunner, args: string[]): GateRun {
357
357
 
358
358
  /**
359
359
  * The motion gate's reference build (issue #135): rigc's `build` under the
360
- * spine-html profile and nothing else — the same gate over the compile that
361
- * the candidate's build runs, without `--pack`. Its model document is all the
362
- * comparison reads, and it differs from a packed build's only in where the
363
- * atlas puts each region (its `pages`), which rig-c's comparison
364
- * allowlists as atlas layout; the pages a reference would pack are never
365
- * written anywhere, so packing them was work nobody read. No render is asked
366
- * of rigc by either build.
360
+ * `rig-play` profile (named `spine-html` before rig-c 2.50.0) and nothing
361
+ * else — the same gate over the compile that the candidate's build runs,
362
+ * without `--pack`. Its model document is all the comparison reads, and it
363
+ * differs from a packed build's only in where the atlas puts each region (its
364
+ * `pages`), which rig-c's comparison allowlists as atlas layout; the pages a
365
+ * reference would pack are never written anywhere, so packing them was work
366
+ * nobody read. No render is asked of rigc by either build.
367
367
  */
368
368
  export const REFERENCE_BUILD_ARGS: readonly string[] = ['--profile', GATE_PROFILE];
369
369
 
@@ -372,9 +372,9 @@ export const REFERENCE_BUILD_LABEL = `build ${REFERENCE_BUILD_ARGS.join(' ')}`;
372
372
 
373
373
  /**
374
374
  * rig-c's gate over the rig in a scratch directory: `build` under the
375
- * spine-html profile with `--pack --page-edges <edges> --pack-shape <shape>`, which runs the gate
375
+ * rig-play profile with `--pack --page-edges <edges> --pack-shape <shape>`, which runs the gate
376
376
  * once over the compile and once over the packed pages on disk. There is no
377
- * second `validate --profile spine` run: spine-html holds every rule spine
377
+ * second `validate --profile spine` run: rig-play holds every rule spine
378
378
  * measures (selftest `CH09`). The files are staged exactly as `--out` will
379
379
  * receive them, so what passed is what is written. The scratch directory is
380
380
  * the caller's, and is emptied here before and after. `images` are the PNG
@@ -506,7 +506,7 @@ function modelAt(buildDir: string): string | null {
506
506
  * The motion gate of every automatic part (issue #126, item 3): for each, the
507
507
  * reference rig — `rig` with that part's attachment swapped for its unreduced
508
508
  * source and nothing else — through rigc's gate ({@link REFERENCE_BUILD_ARGS}:
509
- * the stage's `build` under spine-html, without packing, issue #135), then
509
+ * the stage's `build` under rig-play, without packing, issue #135), then
510
510
  * rig-c's comparison of its `skeleton.model.json` with the candidate's
511
511
  * (`candidateModel`, the stage's own gate build). A part refused before
512
512
  * compiling (no `motion`, no stimulus) costs no build.
@@ -1170,7 +1170,7 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
1170
1170
  log(` ${rigcIdentity(bin, v)}${entryLine === undefined ? '' : `; ${entryLine}`}`);
1171
1171
  const mode: PackMode = { pageEdges: input.pageEdges ?? DEFAULT_PAGE_EDGES, packShape: input.packShape ?? DEFAULT_PACK_SHAPE };
1172
1172
  const r = runCheck(input.rig, input.out, rigc, input.parts, mode, input.source, input.requirements, input.seamPairs === true, input.keepStills === true);
1173
- log(` gate spine-html (rigc ${packedBuildLabel(mode)}), verbatim:`);
1173
+ log(` gate rig-play (rigc ${packedBuildLabel(mode)}), verbatim:`);
1174
1174
  for (const l of r.gateHtml) log(l);
1175
1175
  for (const l of packLines(r)) log(` ${l}`);
1176
1176
  const fig = r.figures;
@@ -1206,7 +1206,7 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
1206
1206
  for (const [name, line] of Object.entries(r.requirements.lines)) log(` ${requirementText(name, line)}`);
1207
1207
  log(` ${summaryText(r.requirements.summary)}`);
1208
1208
  }
1209
- log(` gate: spine-html ${fig.gate_spine_html_green ? 'green' : 'RED'} (${fig.rigc_entry.entry}${fig.rigc_entry.spine_core === null ? ', rigc\'s own validator' : `, the spine-core ${fig.rigc_entry.spine_core} round trip`})`);
1209
+ log(` gate: rig-play ${fig.gate_spine_html_green ? 'green' : 'RED'} (${fig.rigc_entry.entry}${fig.rigc_entry.spine_core === null ? ', rigc\'s own validator' : `, the spine-core ${fig.rigc_entry.spine_core} round trip`})`);
1210
1210
  log(` wrote ${r.written.map((w) => join(input.out, w)).join(', ')}, ${join(input.out, 'build')}/${r.idle === null ? '' : `, ${join(input.out, 'idle_frames')}/`}${r.requirements === null ? '' : `, ${join(input.out, REQUIREMENTS_DIR)}/`}${fig.seam_pairs === undefined ? '' : `, ${join(input.out, SEAM_DIR)}/`}${existsSync(join(input.out, STILL_DIR)) ? `, ${join(input.out, STILL_DIR)}/` : ''}`);
1211
1211
  for (const p of r.problems) log(failLine(p));
1212
1212
  const reqNotPass = r.requirements === null ? 0 : r.requirements.summary.declared - r.requirements.summary.pass;
package/src/check.ts CHANGED
@@ -31,7 +31,7 @@
31
31
  * | output | what |
32
32
  * | --- | --- |
33
33
  * | `build/` | `rigc build --profile rig-play --pack --page-edges free --pack-shape polygon` (or `pot`, `rect`, when the caller names them; {@link PAGE_EDGES}, {@link PACK_SHAPES}) — the packed atlas is the final artifact |
34
- * | `gate_spine-html.txt` | that build's gate lines, verbatim — the one gate: rigc's `build` runs it once over the compile and once over the packed pages on disk, and `spine-html` holds every rule `spine` measures (selftest `CH09`) |
34
+ * | `gate_spine-html.txt` | that build's gate lines, verbatim — the one gate: rigc's `build` runs it once over the compile and once over the packed pages on disk, and `rig-play` holds every rule `spine` measures (selftest `CH09`) |
35
35
  * | `idle_frames/` | `rigc render --animation idle --fps 12 --max 640 --geometry`: `frames.json` + `idle/f*.png` + `idle/geometry.json` (each mesh's skinned vertices, which `TEXTURE_STRETCH` reads, every attachment's posed triangles, which `TIP_OVER_ROOT` and both halves of `STILL_REGIONS_DARK` read since issues #118 and #123, and every bone's world transform, which the face half reads its head bone from) |
36
36
  * | `contact.png` | rigc's own contact sheet of that render, copied out |
37
37
  * | `motion_heat.png` | frame 0 in grey with each pixel's largest change across the idle in red |
package/src/cloth.ts CHANGED
@@ -42,6 +42,12 @@
42
42
  * - **Translate.** `translate`, when declared, is the `x` and `y` mix of a
43
43
  * second physics constraint on the last link of every path, beside its
44
44
  * rotation, with no wind or gravity response ({@link physics} says why).
45
+ * - **Part** (`bottomwear` only, issue #402). `part` names a `topwear` part
46
+ * that takes the skirt's recipe as well: a skirt See-through returned inside
47
+ * `topwear` (a dress). Its trees hang from the hip over its art below the
48
+ * hip, by the skirt's own rule, in place of the robe chains the topwear rule
49
+ * drafts; its art above the hip stays on the chest. The proposer never picks
50
+ * such a part by itself: it names a candidate, and the author declares it.
45
51
  * - **Swing** (`bottomwear` only). `swing.scales` declares one shared pendulum:
46
52
  * a bone `<prefix>swing` under the attachment at the centre of the root row,
47
53
  * one link long, with physics; each tree's first link takes the swing's
@@ -84,6 +90,8 @@ export interface ClothRecipe {
84
90
  gravity: [number, number];
85
91
  translate?: number;
86
92
  swing?: { scales: number[] };
93
+ /** `bottomwear` only (issue #402): a `topwear` part the skirt's trees are drafted on as well — a dress. */
94
+ part?: string;
87
95
  }
88
96
 
89
97
  export type ClothRecipes = Partial<Record<ClothTarget, ClothRecipe>>;
@@ -364,14 +372,18 @@ export function chainConstraints(chain: string, links: number, tree: number, edg
364
372
  return out;
365
373
  }
366
374
 
367
- /** The one note a piece drafted by the recipe gets. */
368
- export function clothNote(part: string, tag: ClothTarget, trees: readonly TreeChain[], r: ClothRecipe, constraints: number, extra: string): string {
375
+ /**
376
+ * The one note a piece drafted by the recipe gets. `via` is the part's own
377
+ * `from` when the recipe reached it by `part` rather than by its tag
378
+ * (issue #402); absent, the note is the one written before the field existed.
379
+ */
380
+ export function clothNote(part: string, tag: ClothTarget, trees: readonly TreeChain[], r: ClothRecipe, constraints: number, extra: string, via?: string): string {
369
381
  const defaults: string[] = [];
370
382
  if (r.length_ratio === undefined) defaults.push(`length_ratio ${RECIPE_LENGTH_RATIO}`);
371
383
  if (r.strength === undefined) defaults.push(`strength ${RECIPE_STRENGTH.trunk}/${RECIPE_STRENGTH.branch}/${RECIPE_STRENGTH.edge}`);
372
384
  const shape = r.split === undefined ? `${r.links} link(s) each` : `a ${r.split.at}-link trunk forking into ${r.split.into} branches, ${r.links} links root to tip`;
373
385
  return (
374
- `${part} (${tag}): config.cloth."${tag}" -> ${r.chains} tree(s)${extra}, ${shape} (${trees.map((t) => t.chain).join(', ')}); ` +
386
+ `${part} (${via === undefined ? tag : `${via}, which config.cloth."${tag}".part names`}): config.cloth."${tag}" -> ${r.chains} tree(s)${extra}, ${shape} (${trees.map((t) => t.chain).join(', ')}); ` +
375
387
  `${constraints} constraint(s), physics on every link, wind ${r.wind[0]} -> ${r.wind[1]} and gravity ${r.gravity[0]} -> ${r.gravity[1]} root to tip (multipliers of the consumer's environment; no direction is drafted), no idle key` +
376
388
  (defaults.length === 0 ? '' : `; the recipe's own defaults, measured on its synthetic fixture (AUTHORING §3): ${defaults.join(', ')}`)
377
389
  );
package/src/config.ts CHANGED
@@ -661,7 +661,10 @@ export interface ConfigConstraint {
661
661
  * piece out across the cap, and `cap_shape: "disc"` sizes the cap by the
662
662
  * limb's half-width about the joint and fills it from the art, the upper
663
663
  * segment's included. Absent, the cut
664
- * is hard and the cap the layer's half-disc of half the limb's width.
664
+ * is hard and the cap the layer's half-disc of half the limb's width. A third,
665
+ * `cut_band: N` (issue #360, item 14), places the cut on the line within N px
666
+ * of the joint line that crosses the fewest stroke pixels; absent, the cut is
667
+ * the joint line.
665
668
  */
666
669
  export interface LimbSegment {
667
670
  part: string;
@@ -672,6 +675,8 @@ export interface LimbSegment {
672
675
  cap?: string;
673
676
  edge?: 'feather';
674
677
  cap_shape?: 'disc';
678
+ /** Issue #360 (item 14): the half-width, whole rig px, of the band about the joint line the cut is placed in (`placeCut` in `src/limbs.ts`). Absent, the cut is the joint line. */
679
+ cut_band?: number;
675
680
  }
676
681
 
677
682
  /** A limb (issue #349): its segments, upper first; each segment's bone is the child of the one before. */
@@ -2202,7 +2207,9 @@ interface LimbNames {
2202
2207
  * is measured from rest, so rest is in it); `cap` a non-empty path; `edge`
2203
2208
  * `"feather"` and `cap_shape` `"disc"` (issue #360), each the one value its
2204
2209
  * field takes — absent is the hard cut and the layer's half-disc
2205
- * (`CONFIG_FIELD_TYPE` on any other). A limb
2210
+ * (`CONFIG_FIELD_TYPE` on any other); `cut_band` a whole number of px, 1 or
2211
+ * more (`CONFIG_FIELD_TYPE`), on a segment that takes the segment above's
2212
+ * part (`CONFIG_KEY_KNOWN`: between two layers nothing is cut). A limb
2206
2213
  * has two segments or more. With `names` null (no `bones`), bones are not
2207
2214
  * resolved. Returns the limb parts and the parts the limbs take.
2208
2215
  */
@@ -2227,13 +2234,13 @@ function checkLimbs(c: Check, v: Json, made: { parts: string[]; patches: string[
2227
2234
  const bones: Array<string | null> = [];
2228
2235
  segs.forEach((entry, i) => {
2229
2236
  const sat = `${at}.segments[${i}]`;
2230
- const e = c.object(sat, entry, ['part', 'from', 'bone'], ['joint', 'range', 'cap', 'edge', 'cap_shape']);
2237
+ const e = c.object(sat, entry, ['part', 'from', 'bone'], ['joint', 'range', 'cap', 'edge', 'cap_shape', 'cut_band']);
2231
2238
  froms.push(null);
2232
2239
  bones.push(null);
2233
2240
  if (e === null) return;
2234
2241
  // The upper segment sits below no joint; every other sits below one, which it names.
2235
2242
  if (i === 0) {
2236
- for (const k of ['joint', 'range', 'cap', 'edge', 'cap_shape'].filter((q) => q in e)) c.fail('CONFIG_KEY_KNOWN', `${sat}.${k}`, `is not a field on the upper segment; it sits below no joint, so ${k} belongs to the segment below the joint it names (segments[1] and on)`);
2243
+ for (const k of ['joint', 'range', 'cap', 'edge', 'cap_shape', 'cut_band'].filter((q) => q in e)) c.fail('CONFIG_KEY_KNOWN', `${sat}.${k}`, `is not a field on the upper segment; it sits below no joint, so ${k} belongs to the segment below the joint it names (segments[1] and on)`);
2237
2244
  } else if (!('joint' in e)) c.fail('CONFIG_FIELD_PRESENT', `${sat}.joint`, 'is absent and required; a segment after the first sits below a joint, at its bone\'s origin, and names it');
2238
2245
  if ('part' in e && c.string(`${sat}.part`, e.part)) {
2239
2246
  const name = e.part;
@@ -2278,6 +2285,14 @@ function checkLimbs(c: Check, v: Json, made: { parts: string[]; patches: string[
2278
2285
  if ('cap_shape' in e && e.cap_shape !== 'disc') {
2279
2286
  c.fail('CONFIG_FIELD_TYPE', `${sat}.cap_shape`, `is ${show(e.cap_shape)}; "disc" is required — the cap a disc of the limb's half-width about the joint, filled from the art, the upper segment's included; leave cap_shape out for the layer's half-disc of half the limb's width`);
2280
2287
  }
2288
+ // Issue #360 (item 14): the band the cut is placed in, whole px, on a joint whose two segments take one part.
2289
+ if ('cut_band' in e && i > 0) {
2290
+ if (!(typeof e.cut_band === 'number' && Number.isInteger(e.cut_band) && e.cut_band >= 1)) {
2291
+ c.fail('CONFIG_FIELD_TYPE', `${sat}.cut_band`, `is ${show(e.cut_band)}; a whole number of rig px, 1 or more, is required — the half-width of the band about the joint line the cut is placed in (the line there that crosses the fewest stroke pixels); leave cut_band out to cut at the joint line`);
2292
+ } else if (typeof e.from === 'string' && typeof froms[i - 1] === 'string' && froms[i - 1] !== e.from) {
2293
+ c.fail('CONFIG_KEY_KNOWN', `${sat}.cut_band`, `is not a field on a segment whose from ("${e.from}") is not the segment above's ("${String(froms[i - 1])}"); no line is cut between two layers — each segment takes its own part whole — so there is no cut to place`);
2294
+ }
2295
+ }
2281
2296
  });
2282
2297
  froms.forEach((f, i) => {
2283
2298
  if (f === null || i === 0 || froms[i - 1] === f) return;
@@ -2648,6 +2663,11 @@ function attachedParts(meshes: Json, regions: Json): Set<string> {
2648
2663
  * not a declaration (`CONFIG_CLOTH_ALTERNATE_DIFFERS`);
2649
2664
  * - `swing` on a tag other than `bottomwear`, or `swing.scales` not one per
2650
2665
  * tree (`CONFIG_CLOTH_SWING_SCALE_PER_TREE`);
2666
+ * - `part` on a tag other than `bottomwear` (`CONFIG_CLOTH_PART_ON_BOTTOMWEAR`):
2667
+ * the field hands the skirt's recipe to a part of another tag (issue #402),
2668
+ * and only the skirt has a recipe that part can take; whether the part
2669
+ * exists, and is a `topwear` that hangs below the hip, is read off the parts
2670
+ * by `propose` (`PROPOSE_CLOTH_PART`);
2651
2671
  * - a strength, declared or the recipe's default, whose spring is unstable at
2652
2672
  * a damping the recipe runs at — k = strength·massInverse·step² at or past
2653
2673
  * 2(1 + damping^(60·step)), rig-c's default fps 60 and mass 1, the damping
@@ -2675,7 +2695,7 @@ function checkCloth(c: Check, v: Json): void {
2675
2695
  for (const tag of CLOTH_TARGETS) {
2676
2696
  if (!(tag in v)) continue;
2677
2697
  const path = `${at}.${JSON.stringify(tag)}`;
2678
- const r = c.object(path, v[tag], ['chains', 'links', 'wind', 'gravity'], ['split', 'length_ratio', 'strength', 'damping', 'alternate_damping', 'translate', 'swing']);
2698
+ const r = c.object(path, v[tag], ['chains', 'links', 'wind', 'gravity'], ['split', 'length_ratio', 'strength', 'damping', 'alternate_damping', 'translate', 'swing', 'part']);
2679
2699
  if (r === null) continue;
2680
2700
  const chains = 'chains' in r && c.int(`${path}.chains`, r.chains, 1) ? (r.chains as number) : null;
2681
2701
  const links = 'links' in r && c.int(`${path}.links`, r.links, 1) ? (r.links as number) : null;
@@ -2728,6 +2748,11 @@ function checkCloth(c: Check, v: Json): void {
2728
2748
  if ('translate' in r && c.number(`${path}.translate`, r.translate, 'unit') && r.translate === 0) {
2729
2749
  c.fail('CONFIG_FIELD_TYPE', `${path}.translate`, 'is 0; a mix above 0 and at most 1 is required (leave translate out for none)');
2730
2750
  }
2751
+ if ('part' in r) {
2752
+ if (tag !== 'bottomwear') {
2753
+ c.fail('CONFIG_CLOTH_PART_ON_BOTTOMWEAR', `${path}.part`, `is declared on "${tag}"; part hands the skirt's recipe (bottomwear) to a topwear part that holds a skirt (a dress) — leave it out here`);
2754
+ } else c.string(`${path}.part`, r.part);
2755
+ }
2731
2756
  if ('swing' in r) {
2732
2757
  if (tag !== 'bottomwear') {
2733
2758
  c.fail('CONFIG_CLOTH_SWING_SCALE_PER_TREE', `${path}.swing`, `is declared on "${tag}"; the shared swing is the skirt's (bottomwear) — leave it out here`);
package/src/limbs.ts CHANGED
@@ -62,6 +62,25 @@
62
62
  * out across its width over art that stays opaque under it at any angle,
63
63
  * so at rest the two pieces composite to what they did and a bend never
64
64
  * shows through it what lies behind the limb.
65
+ * - **`cut_band: N`** (issue #360, item 14; opt-in on the segment below a
66
+ * joint between two segments that take one part). The cut is placed, not
67
+ * moved by hand: of the lines parallel to the joint line at whole-pixel
68
+ * offsets `-N .. N` along the axis, the one that crosses the fewest stroke
69
+ * pixels ({@link placeCut}). A line crosses the pixels a joint line runs
70
+ * through, as {@link limbRun} reads them: the limb's art whose centre lies
71
+ * within half a pixel of it, across the run of art through its point. A
72
+ * **stroke pixel** is one of those, over the whole band, whose luma (the
73
+ * integer BT.601 `(299 R + 587 G + 114 B + 500) / 1000` truncated, the
74
+ * luma `recompositeErrorMap` in `src/assemble.ts` reads) is at or below the
75
+ * Otsu split of their luma histogram ({@link otsuDarkMax}: the dark class
76
+ * of the two that maximise the between-class variance). The split is
77
+ * derived from the band's own art and no number is typed: art of one luma
78
+ * has no split and so no stroke. A tie goes to the line nearer the joint,
79
+ * then to the one on the upper side, so with no stroke in the band the
80
+ * joint line itself is chosen. The bone does not move: the joint, the
81
+ * cap's disc and the limb's width stay where the bone's origin puts them;
82
+ * only the line that splits the pixels between the two pieces moves, and
83
+ * the cap takes the disc's pixels on the upper side of that line.
65
84
  */
66
85
  import type { BoneEntry, Limb } from './config.ts';
67
86
 
@@ -181,6 +200,11 @@ export function limbRun(line: JointLine, art: (x: number, y: number) => boolean,
181
200
  ts.push(-dx * ay + dy * ax);
182
201
  }
183
202
  }
203
+ return runOfOffsets(ts);
204
+ }
205
+
206
+ /** The run through 0 of the offsets `ts` along a line ({@link limbRun}): sorted, the nearest within 1 px, grown while neighbours are at most 1.5 apart. Sorts `ts` in place. */
207
+ function runOfOffsets(ts: number[]): [number, number] | null {
184
208
  if (ts.length === 0) return null;
185
209
  ts.sort((a, b) => a - b);
186
210
  let near = 0;
@@ -249,12 +273,149 @@ export function coveredRadius(at: Pt, radius: number, opaque: (x: number, y: num
249
273
  * `-along / sqrt(radius² - across²)` — 0 on the line, 1 on the disc's arc, so
250
274
  * the overlap band fades out across its width. 1 where the disc has no height.
251
275
  */
252
- export function featherWeight(radius: number, along: number, across: number): number {
276
+ export function featherWeight(radius: number, along: number, across: number, offset = 0): number {
253
277
  const h2 = radius * radius - across * across;
254
278
  if (h2 <= 0) return 1;
279
+ // Issue #360 (cut_band): with the cut `offset` px along the axis, the fade runs from the cut's line to the arc.
280
+ if (offset !== 0) {
281
+ const span = offset + Math.sqrt(h2);
282
+ return span <= 0 ? 1 : Math.max(0, Math.min(1, (offset - along) / span));
283
+ }
255
284
  return Math.max(0, Math.min(1, -along / Math.sqrt(h2)));
256
285
  }
257
286
 
287
+ /** The integer BT.601 luma of a colour, `(299 R + 587 G + 114 B + 500) / 1000` truncated (the one `recompositeErrorMap` reads). */
288
+ export function luma601(r: number, g: number, b: number): number {
289
+ return Math.floor((299 * r + 587 * g + 114 * b + 500) / 1000);
290
+ }
291
+
292
+ /**
293
+ * The Otsu split of a luma histogram (`hist[v]` pixels of luma `v`): the
294
+ * largest luma of the dark class, among the splits `luma <= T | luma > T`
295
+ * with a pixel on each side, that maximises the between-class variance
296
+ * `(T's dark sum · n − dark count · total sum)² / (dark count · light count)`
297
+ * (the variance times n², which ranks the splits alike). Compared exactly, in
298
+ * integers; a tie goes to the lower `T`. Null when no split has a pixel on
299
+ * each side — every pixel of one luma — or when every split's variance is 0.
300
+ */
301
+ export function otsuDarkMax(hist: ArrayLike<number>): number | null {
302
+ let n = 0;
303
+ let sum = 0;
304
+ for (let v = 0; v < hist.length; v++) {
305
+ n += hist[v];
306
+ sum += v * hist[v];
307
+ }
308
+ const N = BigInt(n);
309
+ const S = BigInt(sum);
310
+ let best: number | null = null;
311
+ let bestNum = 0n;
312
+ let bestDen = 1n;
313
+ let n0 = 0;
314
+ let s0 = 0;
315
+ for (let t = 0; t + 1 < hist.length; t++) {
316
+ n0 += hist[t];
317
+ s0 += t * hist[t];
318
+ const n1 = n - n0;
319
+ if (n0 === 0 || n1 === 0) continue;
320
+ const d = BigInt(s0) * N - BigInt(n0) * S;
321
+ const num = d * d;
322
+ const den = BigInt(n0) * BigInt(n1);
323
+ if (num === 0n) continue;
324
+ if (best === null || num * bestDen > bestNum * den) {
325
+ best = t;
326
+ bestNum = num;
327
+ bestDen = den;
328
+ }
329
+ }
330
+ return best;
331
+ }
332
+
333
+ /** A joint line moved `offset` px along its axis (issue #360, `cut_band`): the same axis, through `at + offset · axis`. */
334
+ export function shiftedLine(line: JointLine, offset: number): JointLine {
335
+ return offset === 0 ? line : { at: [line.at[0] + offset * line.axis[0], line.at[1] + offset * line.axis[1]], axis: line.axis };
336
+ }
337
+
338
+ /** One line of a cut's band (issue #360, `cut_band`): its offset along the axis from the joint, and the stroke pixels it crosses. */
339
+ export interface CutCandidate {
340
+ offset: number;
341
+ crossed: number;
342
+ }
343
+
344
+ /** Where `cut_band` put the cut (module comment), or why it could not. */
345
+ export type CutPlacement =
346
+ | {
347
+ ok: true;
348
+ /** The chosen line's offset along the axis from the joint (above 0: past it, toward the lower segment). */
349
+ offset: number;
350
+ line: JointLine;
351
+ crossed: number;
352
+ /** The stroke pixels the joint line itself crosses. */
353
+ jointCrossed: number;
354
+ /** The Otsu split's dark class's largest luma, or null when the band's art has no split (no stroke). */
355
+ strokeLumaMax: number | null;
356
+ /** The art pixels the band's lines cross, counted once each. */
357
+ bandPx: number;
358
+ candidates: CutCandidate[];
359
+ }
360
+ | { ok: false; offset: number };
361
+
362
+ /**
363
+ * Place a joint's cut within `band` px of its line (module comment, `cut_band`):
364
+ * every whole offset `-band .. band` is a candidate line; each crosses the
365
+ * art pixels (`art`) whose centre lies within half a pixel of it, across the
366
+ * run of art through its point ({@link limbRun}); the stroke pixels are those
367
+ * at or below the Otsu split of the luma (`luma`) of every pixel the band's
368
+ * lines cross. The fewest stroke pixels wins, then the smaller offset, then the
369
+ * negative one (the upper side). `{ok: false, offset}` names the offset nearest
370
+ * the joint (the negative one on a tie) whose line crosses no run of art: the
371
+ * band reaches past the limb there, and a band of `|offset| - 1` would not.
372
+ */
373
+ export function placeCut(
374
+ line: JointLine,
375
+ band: number,
376
+ art: (x: number, y: number) => boolean,
377
+ luma: (x: number, y: number) => number,
378
+ box: readonly [number, number, number, number],
379
+ ): CutPlacement {
380
+ const W = box[2] - box[0] + 1;
381
+ // One pass over the box: the art within band + 1 px of the joint line, a margin past every candidate's half pixel.
382
+ const near: Array<[number, number]> = [];
383
+ for (let y = box[1]; y <= box[3]; y++) {
384
+ for (let x = box[0]; x <= box[2]; x++) {
385
+ if (Math.abs(jointOffsets(line, x, y).along) <= band + 1 && art(x, y)) near.push([x, y]);
386
+ }
387
+ }
388
+ const crossedBy: Array<number[] | null> = [];
389
+ for (let t = -band; t <= band; t++) {
390
+ const l = shiftedLine(line, t);
391
+ // The pixels limbRun reads on this line, with their offsets across it.
392
+ const on = near.map(([x, y]) => ({ x, y, o: jointOffsets(l, x, y) })).filter((q) => Math.abs(q.o.along) <= 0.5);
393
+ const run = runOfOffsets(on.map((q) => q.o.across));
394
+ crossedBy.push(run === null ? null : on.filter((q) => q.o.across >= run[0] && q.o.across <= run[1]).map((q) => (q.y - box[1]) * W + (q.x - box[0])));
395
+ }
396
+ // A line off the limb's art is no candidate: the one nearest the joint is named (the upper side first on a tie).
397
+ const off = crossedBy.map((px, i) => (px === null ? i - band : null)).filter((t): t is number => t !== null);
398
+ if (off.length > 0) return { ok: false, offset: off.reduce((a, t) => (Math.abs(t) < Math.abs(a) ? t : a)) };
399
+ const lines = crossedBy as number[][];
400
+ const lumaAt = (p: number): number => luma(box[0] + (p % W), box[1] + Math.floor(p / W));
401
+ const seen = new Set<number>();
402
+ const hist = new Array<number>(256).fill(0);
403
+ for (const px of lines) {
404
+ for (const p of px) {
405
+ if (seen.has(p)) continue;
406
+ seen.add(p);
407
+ hist[lumaAt(p)]++;
408
+ }
409
+ }
410
+ const split = otsuDarkMax(hist);
411
+ const candidates = lines.map((px, i) => ({ offset: i - band, crossed: split === null ? 0 : px.filter((p) => lumaAt(p) <= split).length }));
412
+ let best = candidates[band];
413
+ for (const c of candidates) {
414
+ if (c.crossed < best.crossed || (c.crossed === best.crossed && (Math.abs(c.offset) < Math.abs(best.offset) || (Math.abs(c.offset) === Math.abs(best.offset) && c.offset < best.offset)))) best = c;
415
+ }
416
+ return { ok: true, offset: best.offset, line: shiftedLine(line, best.offset), crossed: best.crossed, jointCrossed: candidates[band].crossed, strokeLumaMax: split, bandPx: seen.size, candidates };
417
+ }
418
+
258
419
  /** The box `[x, y, w, h]` (rig px) of the pixels whose centre lies within `radius` of `at`: the cap image's size and place. */
259
420
  export function capBox(at: Pt, radius: number): [number, number, number, number] {
260
421
  const x0 = Math.ceil(at[0] - radius - 0.5);
package/src/motion.ts CHANGED
@@ -53,14 +53,15 @@
53
53
  *
54
54
  * ## Control bones — `A15_IDLE_NO_MESH_BONE_KEYS`
55
55
  *
56
- * rig-c's `spine-html` profile refuses an `idle` that keys a bone a mesh
57
- * is weighted to (the player skips idle work on meshes). The reference's
58
- * answer, ported as is and still the default (`rig --idle-keys ctl`): for
59
- * every keyed bone that some mesh names among its candidates, add a parent
60
- * `<bone>_ctl` at the SAME origin, re-parent the bone under it, and move the
61
- * keys to the control. The pose is the same up to float rounding: the
62
- * extra bone in each chain moves the rendered idle frames by at most one
63
- * level in a channel (measured on both public examples, rig-parts #13).
56
+ * rig-c's `rig-play` profile (named `spine-html` before rig-c 2.50.0)
57
+ * refuses an `idle` that keys a bone a mesh is weighted to (the player skips
58
+ * idle work on meshes). The reference's answer, ported as is and still the
59
+ * default (`rig --idle-keys ctl`): for every keyed bone that some mesh names
60
+ * among its candidates, add a parent `<bone>_ctl` at the SAME origin,
61
+ * re-parent the bone under it, and move the keys to the control. The pose is
62
+ * the same up to float rounding: the extra bone in each chain moves the
63
+ * rendered idle frames by at most one level in a channel (measured on both
64
+ * public examples, rig-parts #13).
64
65
  *
65
66
  * ⚠️ **This satisfies the rule's wording only.** The meshes are still
66
67
  * deformed every frame — by the control's motion, through the bone they are
package/src/parts.ts CHANGED
@@ -168,10 +168,49 @@ export interface CapRecord {
168
168
  edge?: 'feather';
169
169
  feather_radius?: number;
170
170
  feathered_px?: number;
171
+ /**
172
+ * Issue #360 (item 14), written only under the segment's `cut_band`: the
173
+ * band; the chosen line's offset along the axis from the joint (above 0:
174
+ * past it, toward the lower segment) and a point it passes through; the
175
+ * stroke pixels it crosses and those the joint line crosses; the art
176
+ * pixels the band's lines cross, each once; and the stroke class's largest
177
+ * luma, absent when the band's art has no split (`placeCut` in
178
+ * `src/limbs.ts`). `at`, `width` and `radius` stay the joint's.
179
+ */
180
+ cut_band?: number;
181
+ cut_offset?: number;
182
+ cut_at?: [number, number];
183
+ cut_crossed?: number;
184
+ joint_crossed?: number;
185
+ band_px?: number;
186
+ stroke_luma_max?: number;
171
187
  }
172
188
 
173
189
  const LIMB_KEYS = ['name', 'segment', 'of', 'bone', 'joint', 'range', 'cap'] as const;
174
- const CAP_KEYS = ['at', 'width', 'radius', 'box', 'layer_px', 'image_px', 'image_layer', 'missing_px', 'shape', 'upper_px', 'edge', 'feather_radius', 'feathered_px'] as const;
190
+ const CAP_KEYS = [
191
+ 'at',
192
+ 'width',
193
+ 'radius',
194
+ 'box',
195
+ 'layer_px',
196
+ 'image_px',
197
+ 'image_layer',
198
+ 'missing_px',
199
+ 'shape',
200
+ 'upper_px',
201
+ 'edge',
202
+ 'feather_radius',
203
+ 'feathered_px',
204
+ 'cut_band',
205
+ 'cut_offset',
206
+ 'cut_at',
207
+ 'cut_crossed',
208
+ 'joint_crossed',
209
+ 'band_px',
210
+ 'stroke_luma_max',
211
+ ] as const;
212
+ /** The cap keys only `cut_band` writes (issue #360, item 14). */
213
+ const CUT_KEYS = ['cut_offset', 'cut_at', 'cut_crossed', 'joint_crossed', 'band_px', 'stroke_luma_max'] as const;
175
214
 
176
215
  /** The limb record with its keys in the fixed order, so two runs write the same bytes. */
177
216
  function orderedLimb(l: LimbRecord): Record<string, unknown> {
@@ -516,12 +555,25 @@ function checkParts(raw: unknown, path: string): PartsFile {
516
555
  (!('image_layer' in co) || ('image_px' in co && typeof co.image_layer === 'string' && co.image_layer !== '')) &&
517
556
  // Issue #360: a disc cap carries its count, a feathered edge its band and count, and neither carries them alone.
518
557
  ('shape' in co ? co.shape === 'disc' && isCount(co.upper_px) : !('upper_px' in co)) &&
519
- ('edge' in co ? co.edge === 'feather' && typeof co.feather_radius === 'number' && Number.isFinite(co.feather_radius) && co.feather_radius >= 0 && isCount(co.feathered_px) : !('feather_radius' in co) && !('feathered_px' in co));
558
+ ('edge' in co ? co.edge === 'feather' && typeof co.feather_radius === 'number' && Number.isFinite(co.feather_radius) && co.feather_radius >= 0 && isCount(co.feathered_px) : !('feather_radius' in co) && !('feathered_px' in co)) &&
559
+ // Issue #360 (item 14): a placed cut carries its band, line and counts, the line inside the band; none of them rides alone.
560
+ ('cut_band' in co
561
+ ? isCount(co.cut_band) &&
562
+ co.cut_band >= 1 &&
563
+ Number.isInteger(co.cut_offset) &&
564
+ Math.abs(co.cut_offset as number) <= co.cut_band &&
565
+ pt(co.cut_at, 2) &&
566
+ isCount(co.cut_crossed) &&
567
+ isCount(co.joint_crossed) &&
568
+ isCount(co.band_px) &&
569
+ (co.cut_crossed as number) <= (co.joint_crossed as number) &&
570
+ (!('stroke_luma_max' in co) || (isCount(co.stroke_luma_max) && co.stroke_luma_max <= 255))
571
+ : CUT_KEYS.every((k) => !(k in co)));
520
572
  if (!ok) {
521
573
  fail(
522
574
  'PARTS_FIELD_TYPE',
523
575
  `${object} "cap"`,
524
- `is ${show(c)}; {at: [x, y], width, radius, box: [x, y, w, h], layer_px, image_px?, image_layer? (with image_px), missing_px, shape? ("disc", with upper_px), edge? ("feather", with feather_radius and feathered_px)} is required`,
576
+ `is ${show(c)}; {at: [x, y], width, radius, box: [x, y, w, h], layer_px, image_px?, image_layer? (with image_px), missing_px, shape? ("disc", with upper_px), edge? ("feather", with feather_radius and feathered_px), cut_band? (with cut_offset inside the band, cut_at, cut_crossed at most joint_crossed, band_px, stroke_luma_max? 0..255)} is required`,
525
577
  );
526
578
  }
527
579
  }
package/src/propose.ts CHANGED
@@ -820,6 +820,42 @@ export const HIP_MIN_FRACTION = 0.25;
820
820
  /** A row is a waist when the torso there is at most this fraction of the shoulders' width (the examples' torsos narrow to 0.648 of their shoulders in `demo` and 0.710 in `sample`). */
821
821
  export const WAIST_MAX_OF_SHOULDERS = 0.8;
822
822
 
823
+ /**
824
+ * A `topwear` part hangs below the hip when its box reaches this many face
825
+ * heights below the hip's y: above it, the topwear rule reads a bodice that
826
+ * stops at the waist and drafts no robe chains (the reference's line). Issue
827
+ * #402 reads the same line for a skirt held inside `topwear` (a dress), so
828
+ * the two rules cannot disagree about which topwear hangs.
829
+ */
830
+ export const TOPWEAR_HANGS_FACE_HEIGHTS = 0.25;
831
+
832
+ /**
833
+ * Issue #402: the note naming a `topwear` part shaped like a skirt — its box
834
+ * hanging {@link TOPWEAR_HANGS_FACE_HEIGHTS} face heights past the hip, and
835
+ * its art wider across its last 24 rows than in the 24-row band at the hip
836
+ * (the band the robe rule reads) — or null when it is not. The cloth recipe
837
+ * finds a skirt by the `bottomwear` tag alone, and the shape cannot tell a
838
+ * dress from an outer robe over a skirt, so the proposer drafts nothing on
839
+ * the strength of it: the note names the part, its art's rows below the hip
840
+ * and the field, `cloth.bottomwear.part`, by which the author declares it.
841
+ */
842
+ function skirtInsideNote(p: PartRecord, mask: Mask, hipY: number, fh: number): string | null {
843
+ const bot = p.y + p.h;
844
+ const line = hipY + TOPWEAR_HANGS_FACE_HEIGHTS * fh;
845
+ if (bot < line) return null;
846
+ const span = (xs: number[]): number => (xs.length === 0 ? 0 : xs[xs.length - 1] - xs[0] + 1);
847
+ const atHip = span(colsAny(mask, pyInt(hipY) - 12, pyInt(hipY) + 12));
848
+ const atBottom = span(colsAny(mask, bot - 24, bot));
849
+ if (!(atBottom > atHip)) return null;
850
+ const hipRow = pyRound(hipY);
851
+ let last = bot - 1;
852
+ while (last > p.y && colsAny(mask, last, last + 1).length === 0) last--;
853
+ return (
854
+ `${p.name} (${p.from}): shaped like a skirt — its art's rows ${hipRow + 1} to ${last} lie below hip (y ${hipRow}), past hip + ${TOPWEAR_HANGS_FACE_HEIGHTS} face heights (y ${pyFixed(line, 1)}), and it is wider across its last 24 rows (${atBottom} px) than in the 24-row band at the hip (${atHip} px); ` +
855
+ `the cloth recipe finds a skirt by the bottomwear tag alone, so it drafted no skirt trees on ${p.name}, and the topwear rule drafts it instead. If See-through returned the skirt inside it (a dress), declare config.cloth.bottomwear.part: "${p.name}", and the bottomwear recipe's trees hang from hip over its art below the hip`
856
+ );
857
+ }
858
+
823
859
  /**
824
860
  * One handwear blob is clasped hands, not two sleeves, when it is at most this
825
861
  * fraction of the shoulders' width: two sleeves that hang from the shoulders
@@ -2022,8 +2058,42 @@ export function proposeWithBasis(
2022
2058
  if (hw.length === 1) notes.push(`handwear is one blob (${hw[0].name}): both sleeves in one mesh, split at the eye axis x=${pyFixed(axis, 0)}`);
2023
2059
  }
2024
2060
 
2061
+ // Issue #402: the topwear part config.cloth.bottomwear.part names takes the skirt's rule and recipe below; every
2062
+ // other topwear shaped like a skirt is named in a note when a recipe is in play, never drafted on by its shape.
2063
+ const namedSkirt = ((): PartRecord | null => {
2064
+ const name = recipeOf('bottomwear')?.part;
2065
+ if (name === undefined) return null;
2066
+ const refuse = (detail: string): never => {
2067
+ throw new PartsError([{ code: 'PROPOSE_CLOTH_PART', object: 'config.cloth."bottomwear".part', detail }]);
2068
+ };
2069
+ const q = P.recs.find((x) => x.name === name);
2070
+ if (q === undefined) return refuse(`names "${name}", which is no part in parts.json; a topwear part whose art hangs below the hip (a dress) is required`);
2071
+ if (q.cut_from !== undefined) return refuse(`names "${name}", a piece an assemble.cuts entry took from ${q.cut_from}; name the part the plan made, ${q.cut_from}, or leave part out`);
2072
+ if (!tw.includes(q)) {
2073
+ return refuse(
2074
+ `names "${name}", from ${q.from}; ${splitFrom(q.from)[1] === 'bottomwear' ? 'a bottomwear part takes the recipe by its tag already — leave part out' : "only a topwear part takes the skirt's recipe by name (a skirt See-through returned inside topwear, a dress)"}`,
2075
+ );
2076
+ }
2077
+ const line = hip[1] + TOPWEAR_HANGS_FACE_HEIGHTS * fh;
2078
+ if (q.y + q.h < line) {
2079
+ return refuse(`names "${name}", whose box ends at y=${q.y + q.h}, above hip + ${TOPWEAR_HANGS_FACE_HEIGHTS} face heights (y=${pyFixed(line, 1)}), where the topwear rule reads a bodice that stops at the waist: no skirt hangs below the hip to hang trees on`);
2080
+ }
2081
+ return q;
2082
+ })();
2083
+ const skirtHints = new Map<string, string>();
2084
+ if (cloth !== null) {
2085
+ for (const p of tw) {
2086
+ if (p === namedSkirt) continue;
2087
+ const hint = skirtInsideNote(p, P.alpha(p), hip[1], fh);
2088
+ if (hint !== null) skirtHints.set(p.name, hint);
2089
+ }
2090
+ }
2091
+
2025
2092
  // ---- outer robe (topwear)
2026
2093
  for (const p of tw) {
2094
+ if (p === namedSkirt) continue;
2095
+ const hint = skirtHints.get(p.name);
2096
+ if (hint !== undefined) notes.push(hint);
2027
2097
  const [g, r] = gridR(p);
2028
2098
  const mask = P.alpha(p);
2029
2099
  const top = chest[1] - 0.3 * fh;
@@ -2039,7 +2109,7 @@ export function proposeWithBasis(
2039
2109
  ['chest', rnd(along(hip, trunk.u, artExtent(mask, p, hip, trunk.u)[0])), rnd(along(hip, trunk.u, -20))],
2040
2110
  ['hip', rnd(along(hip, trunk.u, -20)), rnd(along(hip, trunk.u, 100))],
2041
2111
  ];
2042
- if (bw.length > 0 && bot < hip[1] + 0.25 * fh) {
2112
+ if (bw.length > 0 && bot < hip[1] + TOPWEAR_HANGS_FACE_HEIGHTS * fh) {
2043
2113
  // A bodice that stops at the waist: robe chains down to the hem would fall off the art.
2044
2114
  meshes[p.name] = { grid: g, r, segments: segs };
2045
2115
  notes.push(`${p.name} ends at y=${bot} (hip ${pyFixed(hip[1], 0)}): no robe chains -- add a sash chain by hand if one hangs`);
@@ -2086,8 +2156,9 @@ export function proposeWithBasis(
2086
2156
  meshes[p.name] = { grid: g, r, segments: segs };
2087
2157
  }
2088
2158
 
2089
- // ---- skirt (bottomwear)
2090
- for (const p of bw) {
2159
+ // ---- skirt (bottomwear, and the topwear part config.cloth.bottomwear.part names: issue #402)
2160
+ const skirts = namedSkirt === null ? bw : [...bw, namedSkirt];
2161
+ for (const p of skirts) {
2091
2162
  const [g, r] = gridR(p);
2092
2163
  const mask = P.alpha(p);
2093
2164
  const bot = p.y + p.h;
@@ -2122,7 +2193,7 @@ export function proposeWithBasis(
2122
2193
  // Issue #364: with config.cloth.bottomwear, the recipe's trees hang from the hip in place of the three keyed chains.
2123
2194
  const skirtRecipe = recipeOf('bottomwear');
2124
2195
  if (skirtRecipe !== null) {
2125
- const prefix = bw.length === 1 ? 'skirt' : `skirt_${p.name}`;
2196
+ const prefix = skirts.length === 1 ? 'skirt' : `skirt_${p.name}`;
2126
2197
  const trees = T(p, 'bottomwear', skirtRecipe, {
2127
2198
  prefix,
2128
2199
  parent: 'hip',
@@ -2162,6 +2233,7 @@ export function proposeWithBasis(
2162
2233
  skirtRecipe,
2163
2234
  made.length,
2164
2235
  `${swing === null ? '' : ` on one shared swing, ${swing.bone} (each tree's first link takes its rotation times ${skirtRecipe.swing?.scales.join('/')}, its setup rotation ${swing.rest} degrees subtracted)`} from hip, rooted 20 px below its y and tipped 4 px above ${p.name}'s bottom, laid down the screen`,
2236
+ p === namedSkirt ? p.from : undefined,
2165
2237
  ),
2166
2238
  );
2167
2239
  meshes[p.name] = { grid: g, r, segments: segs };
@@ -2316,7 +2388,9 @@ export function proposeWithBasis(
2316
2388
  object: `config.cloth."${t}"`,
2317
2389
  detail:
2318
2390
  P.byTag(t).length === 0 && P.headFirst(t).length === 0
2319
- ? `declares a recipe for "${t}", and no part is tagged "${t}"; leave the recipe out, or assemble the layer it is for`
2391
+ ? t === 'bottomwear' && skirtHints.size > 0
2392
+ ? `declares a recipe for "${t}", and no part is tagged "${t}"; leave the recipe out, assemble the layer it is for, or name the part that holds the skirt — ${[...skirtHints.values()].join('; ')}`
2393
+ : `declares a recipe for "${t}", and no part is tagged "${t}"; leave the recipe out, or assemble the layer it is for`
2320
2394
  : t === 'back hair'
2321
2395
  ? `declares a recipe for "back hair", and every back hair part ends above the shoulders (0.5 face heights below the neck), which the proposer drafts as a bun bone with no chain; leave the recipe out`
2322
2396
  : `declares a recipe for "${t}", and the proposer drafted no chain on it`,
package/src/rig.ts CHANGED
@@ -615,7 +615,7 @@ function applyTurn(
615
615
  * work. `ctl` stays the default because the examples' expected `rig.json` and
616
616
  * `motion.json` are the reference implementation's output, and because the
617
617
  * declaration lives in the rig spec only: `rigc validate <build> --profile
618
- * spine-html`, which has no rig spec to read, refuses a `direct` build once
618
+ * rig-play`, which has no rig spec to read, refuses a `direct` build once
619
619
  * per keyed mesh bone.
620
620
  */
621
621
  export const IDLE_KEYS = ['ctl', 'direct'] as const;