@rig-c/parts 1.22.0 → 1.24.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
 
@@ -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`,
@@ -1583,6 +1589,7 @@ What each rule drafts (`src/cloth.ts` holds them):
1583
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` |
1584
1590
  | out of phase | the odd trees take `alternate_damping`, the even ones `damping` | `damping`, `alternate_damping` |
1585
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` |
1586
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` |
1587
1594
 
1588
1595
  Every link but a swing-driven first link gets `<bone>_physics` (`rotate` 1), and no
@@ -1590,6 +1597,51 @@ idle key: the drafted idle keys none of the trees. A recipe that drafts nothing
1590
1597
  its tag on no part, or `back hair` that ends above the shoulders (a bun) — is refused,
1591
1598
  `PROPOSE_CLOTH_DRAFTED`.
1592
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
+ Since issue #411 the bar reads the breath alone, and on that fixture the breath moves
1623
+ the dress 0.106 and the robe-chained dress 2.62: both fail, and the 3.9 was the robe
1624
+ chains' keyed swing below the hip, not the breath (the CK502 and CK503 controls).
1625
+
1626
+ **What rides a tail** (issue #391). An accessory wrapped round a tail the `back hair`
1627
+ recipe drafts — a ribbon, in See-through's `headwear` or `earwear` layer — rides that
1628
+ tail's links, not `head`: under the recipe the tail moves by the world, and a part left on
1629
+ `head` stays where the tail was. Which links is read off the overlap, never off the
1630
+ part's name: each of the part's pixels over the tail's art is given to the span of the
1631
+ back hair's mesh nearest it (its fixed segment on `head`, or one tree link, the distance
1632
+ the weights read), and the part rides when one of those spans is a link. Its mesh's
1633
+ segments are then the spans it lies on — each link by name, the head's span written
1634
+ out — so every vertex weights by the rule the tail's own art does, the pixels off the
1635
+ tail (a ribbon's loops) included; no accessory bone, pendant or strand chain is drafted
1636
+ for it, and a note names each span with its pixel count. A part over no link keeps the
1637
+ accessory rule. It is part of the recipe's drafting, not a field: the rule reads only
1638
+ the art, and without the recipe no tail moves by the world and nothing here runs. On
1639
+ `wind` (rig-c 2.54.0, `rigc render --environment`, idle frame 200 of 200 at 60 fps,
1640
+ 0.916 px per rig px), the ribbon pixels painted over the tail that are drawn where the
1641
+ tail has no hair went from 2,429 at calm and 8,363 at wind (10, 0) to 30 and 230; the
1642
+ 230 all lie within 3.6 px of the hair's edge, where the ribbon's mesh and the hair's are
1643
+ two different lattices.
1644
+
1593
1645
  **Every spring is stable at its step (A23's inequality).** Per step spine-core does
1594
1646
  `v += −strength·x·step·massInverse`, `x += v·step`, `v *= d` with d = damping^(60·step);
1595
1647
  in (x, v·step) that is the matrix [[1 − k, 1], [−d·k, d]] with
@@ -2239,8 +2291,8 @@ reference's so the examples stay comparable with it. `build` takes both flags.
2239
2291
  **`rig --idle-keys ctl|direct`** (and `build --idle-keys`, which forwards the
2240
2292
  value to its rig stage; without the flag, or with `ctl`, a build writes and prints
2241
2293
  what it did before `build` took the flag). rig-c's `A15_IDLE_NO_MESH_BONE_KEYS`
2242
- (profile `spine-html`) refuses an idle that keys a bone a mesh is weighted to. `ctl`
2243
- (the default, the reference's answer) gives every such bone a same-origin
2294
+ (profile `rig-play`, named `spine-html` before rig-c 2.50.0) refuses an idle that
2295
+ keys a bone a mesh is weighted to. `ctl` (the default, the reference's answer) gives every such bone a same-origin
2244
2296
  `<bone>_ctl` parent and moves its keys there, which passes A15 on any rig-c;
2245
2297
  the stage prints `idle keys ctl: N mesh-driving bone(s) keyed …`. `direct` keys the
2246
2298
  bones themselves and writes `invariants.idleDrivesMeshes: { "why": … }` into
@@ -2543,6 +2595,7 @@ See-through with another seed.
2543
2595
  | <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 |
2544
2596
  | <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 |
2545
2597
  | <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 |
2598
+ | <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) |
2546
2599
  | <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 |
2547
2600
  | <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 |
2548
2601
 
@@ -2624,7 +2677,8 @@ says why each requirement exists and what breaks without it.
2624
2677
  | <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 |
2625
2678
  | <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` |
2626
2679
  | <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 |
2627
- | <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 |
2680
+ | <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` |
2681
+ | <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 |
2628
2682
  | <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 |
2629
2683
  | <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` |
2630
2684
  | <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 |
@@ -2721,7 +2775,7 @@ documents do not ship). Each is an input this package built; none is an author's
2721
2775
  | <a id="CHECK_LOOP_LAST_FRAME_AT_DURATION"></a>`CHECK_LOOP_LAST_FRAME_AT_DURATION` | the idle's last frame does not sit at `duration` | `motion.duration` — a whole number of 1/12 s |
2722
2776
  | <a id="CHECK_LOOP_CLOSES"></a>`CHECK_LOOP_CLOSES` | frame 0 and the frame at `duration` differ (max and first pixel quoted); with a physics constraint, the frames of the rig with every physics constraint left out, and the object says so (§7, *loop*) | a track whose last key is not its first |
2723
2777
  | <a id="CHECK_SEAM_WITHIN_BAR"></a>`CHECK_SEAM_WITHIN_BAR` | the setup pose does not reproduce the flat stack of parts | read the `seam pair` lines and `check/seam/` pictures (§7; magenta = a counted pixel, cyan = the box round them): the pair, its boxes and the pixels counted. Usually a region or mesh placed off its part; compare with `recomposite_rig.png`. A pair of one layer cut in two with `differing_copies_px` is the cut line: move the polygon's edge, not `overlap` |
2724
- | <a id="CHECK_BREATH_VISIBLE"></a>`CHECK_BREATH_VISIBLE` | the torso (`topwear`), rendered alone, barely moves over the idle — or the feet (`footwear`), rendered alone, move at all | the chest's breath tracks (`motion.tracks` on `chest`), or the torso mesh's `segments`; for the feet, the bone their region rides (`regions.<part>`, `root` in both examples) |
2778
+ | <a id="CHECK_BREATH_VISIBLE"></a>`CHECK_BREATH_VISIBLE` | the breath alone barely moves the torso (`topwear`, rendered alone, the idle with and without its breath tracks — issue #411; the whole idle's figure is printed beside it, and motion that is not the breath's is not counted), or the idle has no breath track at all — or the feet (`footwear`), rendered alone, move at all | the chest's breath tracks (`motion.tracks` on `chest`), or the torso mesh's `segments`; for the feet, the bone their region rides (`regions.<part>`, `root` in both examples) |
2725
2779
  | <a id="CHECK_BLINK_NO_HOLE"></a>`CHECK_BLINK_NO_HOLE` | with the blink held shut, the eyewhite box shows the page where the open eye had art | the layer under the eye: the `face` part has no art there. Take the face from the other run, or add a part under the eye; `motion.blink.squash` only hides the hole less |
2726
2780
  | <a id="CHECK_CHAIN_LAG"></a>`CHECK_CHAIN_LAG` | a rotate track leads (or does not lag) the keyed bone above it, or a chain link swings less than the link above — or, in a chain that carries a part the scene file declares `rests`, more than the link above (issue #245; the object names the part and the file) | that chain track's `phase`/`lag` (a positive `lag`, a child `phase` above its parent's) or its `amps` (non-decreasing toward the tip; non-increasing on a chain declared resting) |
2727
2781
  | <a id="CHECK_TIP_OVER_ROOT"></a>`CHECK_TIP_OVER_ROOT` | a `handwear`/`bottomwear` part's art in the lower half of its box travels less than 1.4725 times as far as in the upper half, measured from the idle's posed geometry (rig px quoted) | the chain track's `amps` (grow toward the tip), or the mesh's `segments` (the chain must be among them), or its mode: on `scarf`'s short skirt the proposal's lattice read 1.207 and the same part in `contour` mode 1.738 with the same segments and idle (issue #118) — both carried the `chest` segment #262 removed, after which the lattice reads 3.487. When the detail says `the root travels with the breath (x px of y px): it is carried by \`<bone>\`` (issue #262) the chain is not the cause: a bone an idle `translate` track moves (the breath) moves the root more than the tip, and with that translate held still (the part posed again without it, in proportion to each vertex's weight on the bone and those under it) the ratio passes — the row adds `carried_by`, `breath_rig_px`, `root_without_breath_rig_px` and `tip_without_breath_rig_px`; take that bone's segment off the mesh, or bind the root to the bone the part hangs from. A part the scene file declares `rests` (issue #245) is held the other way, its tip half's travel at most its root half's (ratio ≤ 1); the detail then reads `the scene file's rests declares its tip at rest, so a ratio <= 1 is required`, and for it the fix is the chain's `amps` (shrinking toward the tip) or the mesh's tip weighted to a bone the idle does not swing |
@@ -2800,8 +2854,8 @@ implementation's bars) — each one that measured; a rig with no `parts.json` or
2800
2854
  assemble*, at the end of this section):
2801
2855
 
2802
2856
  - `gate_spine-html.txt`: every summary line `(N passed, 0 failed)` — the packed build
2803
- under the `spine-html` profile, gated once over the compile and once over the packed
2804
- pages on disk. There is no `spine` gate of its own: `spine-html` holds every rule
2857
+ under the `rig-play` profile, gated once over the compile and once over the packed
2858
+ pages on disk. There is no `spine` gate of its own: `rig-play` holds every rule
2805
2859
  `spine` measures (on reference-demo, rigc 1.5.1 and 2.0.3: `validate --profile spine`'s 14
2806
2860
  measured rules are all among the build's 23, the 15 others not in `spine`; rigc
2807
2861
  2.1.3 and 2.10.1: the same 14 among the build's 24, which adds
@@ -2895,7 +2949,7 @@ the two examples [observed]:
2895
2949
 
2896
2950
  | line | measures | bar | `reference-demo` | `reference-sample` | SKIP when |
2897
2951
  | --- | --- | --- | --- | --- | --- |
2898
- | <a id="BREATH_VISIBLE"></a>`BREATH_VISIBLE` | `topwear` parts rendered alone (`rigc render --slot`): heat mean over their box; `footwear` parts alone: heat max over theirs | torso mean ≥ 3.809; feet max ≤ 0 | 15.251; 0 | 7.617; 0 | no `topwear` and no `footwear` part. One of the two absent (issue #323): the other half is measured and decides the line, which then carries `halves_measured` `"1 of 2"` first, then each half's own status — `torso_status`, `feet_status` — the absent half's `SKIP` with its `torso_reason` or `feet_reason`; a run that measured both halves writes the keys it always wrote |
2952
+ | <a id="BREATH_VISIBLE"></a>`BREATH_VISIBLE` | the torso: the breath alone (issue #411). The breath bones are every bone an idle track translates, and the breath tracks every idle track that translates or scales one of them (the drafted breath: `chest` `translatey` and `scalex`). The `topwear` parts are rendered alone (`rigc render --slot`) from one throwaway build that carries, beside every animation, the idle with those tracks held at rest (0 for a translate, 1 for a scale, at each track's first and last key time — the bone as it stands without them, the idle still keyed to its end), so the two idles share a grid; per pixel, the largest \|(with_t − with_0) − (without_t − without_0)\| over the frames and channels, meaned over their box (`torso_heat_mean`). Motion in both renders — a keyed cloth swing, physics answering the world — cancels; physics the breath sets moving counts. Until #411 the figure was the whole idle's heat over the box, which a keyed swing passed for a torso that did not breathe; a refusal still prints that whole-idle figure beside the breath's. An idle with no breath track reads 0 and fails, naming why — a torso that does not breathe is what the bar finds, so it is not a SKIP. The feet: `footwear` parts alone, heat max over theirs | torso mean ≥ 3.809; feet max ≤ 0 | 15.251; 0 | 7.617; 0 | no `topwear` and no `footwear` part. One of the two absent (issue #323): the other half is measured and decides the line, which then carries `halves_measured` `"1 of 2"` first, then each half's own status — `torso_status`, `feet_status` — the absent half's `SKIP` with its `torso_reason` or `feet_reason`; a run that measured both halves writes the keys it always wrote |
2899
2953
  | <a id="BLINK_NO_HOLE"></a>`BLINK_NO_HOLE` | the setup pose with every `scaley` track on the eyewhite slots' bones held at its closed value, against the setup pose, at full size: pixels in the eyewhite box that show the page where the open eye had art | 0 px | 0 | 0 | no `eyewhite` part, or no `scaley` track on its bones goes below its first key |
2900
2954
  | ″ (reported) | the same box: each closed-eye pixel's max-channel distance to the nearest colour the open eye's box holds — max, and pixels over 40 | none | 15; 0 | 11; 0 | as above |
2901
2955
  | <a id="CHAIN_LAG"></a>`CHAIN_LAG` | `motion.json`'s rotate tracks read as sines (DFT of the keys: period, amplitude, phase) and arranged by the bone tree — a keyed bone's parent is its nearest keyed ancestor | every lag ≥ 0.001 cycle; amplitude non-decreasing down each unbranched chain — non-increasing down a chain that carries a part declared `rests` (issue #245) | lags 0.040 (neck to head) to 0.120; 12 chains | lags 0.040 to 0.100; 9 chains | no rotate track under another of the same period |
package/docs/STABILITY.md CHANGED
@@ -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`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/parts",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/build.ts CHANGED
@@ -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 |
@@ -101,6 +101,7 @@ import {
101
101
  FACE_FEATURE_TAGS,
102
102
  FACE_TAGS,
103
103
  FEET_TAGS,
104
+ breathHeat,
104
105
  frameBox,
105
106
  heatField,
106
107
  partsTagged,
@@ -3133,13 +3134,40 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
3133
3134
  if (r.status !== 0) refuseIfAny(rigcFailed(`render --animation idle --slot ${ps.map((p) => p.name).join(',')}`, r, r.out.split('\n').filter((l) => l.includes('FAIL') || l.includes('rigc:'))));
3134
3135
  return readFrameSet(dir);
3135
3136
  };
3137
+ // Issue #411: the breath alone — a throwaway copy of the build carrying, beside every animation, the idle with its
3138
+ // breath tracks held at rest; the torso rendered alone in both idles, from that one build, so the two share a grid.
3139
+ const breathPair = (ps: readonly PartRecord[]): BreathPair | null => {
3140
+ const tracks = breathTracks(inp.motion);
3141
+ if (tracks.length === 0) return null;
3142
+ const dir = join(isoDir, BREATH_SCRATCH);
3143
+ const anims = isRecord(inp.motion.animations) ? inp.motion.animations : {};
3144
+ const idleAnim = isRecord(anims.idle) ? anims.idle : {};
3145
+ let name = BREATH_ANIMATION;
3146
+ while (name in anims) name = `${name}_`;
3147
+ // Each breath track held at rest over its own span: the idle without the breath, still keyed to its end, which rigc
3148
+ // requires of an animation's last key.
3149
+ const kept = (Array.isArray(idleAnim.tracks) ? idleAnim.tracks : []).map((t) => (isRecord(t) && isBreathTrack(t, tracks) ? heldTrack(t) : t));
3150
+ mkdirSync(dir, { recursive: true });
3151
+ const images = typeof inp.rig.images === 'string' ? resolve(inp.rigDir, inp.rig.images) : inp.rig.images;
3152
+ writeFileSync(join(dir, 'rig.json'), JSON.stringify({ ...inp.rig, images }));
3153
+ writeFileSync(join(dir, 'motion.json'), JSON.stringify({ ...inp.motion, animations: { ...anims, [name]: { ...idleAnim, tracks: kept } } }));
3154
+ const b = rigc(['build', '--rig', join(dir, 'rig.json'), '--motion', join(dir, 'motion.json'), '--out', join(dir, 'build'), ...packedBuildArgs(mode)]);
3155
+ if (b.status !== 0) refuseIfAny(rigcFailed(`${packedBuildLabel(mode)} (BREATH_VISIBLE's copy, the idle beside it with its breath tracks held at rest)`, b, buildGateLines(b.out)));
3156
+ const slots = ps.map((p) => p.name).join(',');
3157
+ const render = (animation: string, label: string): FrameSet => {
3158
+ const r = rigc(['render', '--candidate', join(dir, 'build'), '--animation', animation, '--fps', String(IDLE_FPS), '--max', String(IDLE_MAX_PX), '--slot', slots, '--out', join(dir, label)]);
3159
+ if (r.status !== 0) refuseIfAny(rigcFailed(`render --animation ${animation} --slot ${slots} (BREATH_VISIBLE's copy)`, r, r.out.split('\n').filter((l) => l.includes('FAIL') || l.includes('rigc:'))));
3160
+ return readFrameSet(join(dir, label));
3161
+ };
3162
+ return { with: render('idle', 'with'), without: render(name, 'without'), tracks: tracks.map((t) => `${t.bone} ${t.property}`) };
3163
+ };
3136
3164
  // Issue #231: the footwear parts the scene file declares not planted; none without --requirements or the field.
3137
3165
  const notPlanted = reqFile === null ? [] : reqFile.not_planted;
3138
3166
  let breath: JudgementLine = skip(lacking);
3139
3167
  let tip: JudgementLine = skip(lacking);
3140
3168
  if (full !== null) {
3141
3169
  try {
3142
- breath = breathLine(full, isolated, problems, notPlanted);
3170
+ breath = breathLine(full, isolated, breathPair, problems, notPlanted);
3143
3171
  if (idle !== null) tip = tipLine(full, join(idle.dir, GEOMETRY_FILE), idle.written, problems, reqFile === null ? NO_TIP_EXCEPTIONS : { path: reqFile.path, not_swinging: reqFile.not_swinging, rises: reqFile.rises, rests: reqFile.rests });
3144
3172
  } finally {
3145
3173
  rmSync(isoDir, { recursive: true, force: true });
@@ -3701,33 +3729,32 @@ function noneHeldText(declared: readonly string[]): string {
3701
3729
  * `SKIP` with its reason — so a half nobody read never passes by being silent.
3702
3730
  * With neither, the line is the SKIP it was. A run that measured both halves
3703
3731
  * writes the keys it always wrote.
3732
+ *
3733
+ * Issue #411: the torso half reads the breath alone ({@link torsoBreath}):
3734
+ * `torso_heat_mean` is the heat the breath makes, the idle rendered with and
3735
+ * without its breath tracks, on the same box and against the same floor.
3736
+ * Until #411 it was the whole idle's heat over the box, so a keyed cloth swing
3737
+ * or a physics response to the world inside the torso's box passed the bar
3738
+ * for a torso that did not breathe.
3704
3739
  */
3705
- function breathLine(inp: FullInputs, isolated: Isolate, problems: Problem[], notPlanted: readonly string[] = []): JudgementLine {
3740
+ function breathLine(inp: FullInputs, isolated: Isolate, pair: BreathPairRender, problems: Problem[], notPlanted: readonly string[] = []): JudgementLine {
3706
3741
  const torso = partsTagged(inp.parts, TORSO_TAGS);
3707
3742
  const { all: allFeet, held: feet, declared } = plantedFeet(inp.parts, notPlanted);
3708
3743
  const noTorso = `no part comes from a See-through ${tagWords(TORSO_TAGS)} layer, so there is no torso to see breathe`;
3709
3744
  const noFeet = `no part comes from a See-through ${tagWords(FEET_TAGS)} layer, so there are no feet to hold still`;
3710
3745
  // Issue #323: a figure without one of the two halves still has the other read; with neither, the SKIP it always was.
3711
3746
  if (torso.length === 0 && feet.length === 0) return skip(`${noTorso}${declared.length === 0 ? '' : `; ${declared.map((n) => `"${n}"`).join(', ')} declared not planted`}`);
3712
- if (torso.length === 0) return oneHalf(inp, isolated, problems, 'feet', feet, noTorso, declared);
3713
- if (allFeet.length === 0) return oneHalf(inp, isolated, problems, 'torso', torso, noFeet, []);
3747
+ if (torso.length === 0) return oneHalf(inp, isolated, pair, problems, 'feet', feet, noTorso, declared);
3748
+ if (allFeet.length === 0) return oneHalf(inp, isolated, pair, problems, 'torso', torso, noFeet, []);
3714
3749
  const H = inp.parts.rig_size[1];
3715
- const ts = isolated('torso', torso);
3750
+ const tr = torsoBreath(inp, torso, pair);
3716
3751
  const fs = feet.length === 0 ? null : isolated('feet', feet);
3717
- const tb = frameBox(torso, H, inp.stage, ts.viewport);
3718
3752
  const fb = fs === null ? null : frameBox(feet, H, inp.stage, fs.viewport);
3719
- if (tb === null || (fs !== null && fb === null)) return skip(`the ${tb === null ? 'torso' : 'feet'} box falls outside the idle frame`);
3720
- const th = regionHeat(heatField(ts.frames.map((f) => f.image)), ts.viewport.pixelWidth, tb);
3753
+ if ('skip' in tr || (fs !== null && fb === null)) return skip(`the ${'skip' in tr ? 'torso' : 'feet'} box falls outside the idle frame`);
3721
3754
  const fh = fs === null || fb === null ? null : regionHeat(heatField(fs.frames.map((f) => f.image)), fs.viewport.pixelWidth, fb);
3722
- const mean = round3(th.mean);
3755
+ const mean = tr.mean;
3723
3756
  const ok = mean >= BREATH_TORSO_MEAN_FLOOR && (fh === null || fh.max <= BREATH_FEET_MAX_CEILING);
3724
- if (mean < BREATH_TORSO_MEAN_FLOOR) {
3725
- problems.push({
3726
- code: 'CHECK_BREATH_VISIBLE',
3727
- object: `torso ${quoteParts(torso)} rendered alone, frame box ${boxLabel(tb)}`,
3728
- detail: `heat mean ${mean}/255 over the idle; >= ${BREATH_TORSO_MEAN_FLOOR} is required — the chest's breath track moves too little, or the torso is not weighted to the bone it keys`,
3729
- });
3730
- }
3757
+ if (mean < BREATH_TORSO_MEAN_FLOOR) problems.push(torsoProblem(torso, tr, ''));
3731
3758
  if (fh !== null && fb !== null && fh.max > BREATH_FEET_MAX_CEILING) {
3732
3759
  problems.push({
3733
3760
  code: 'CHECK_BREATH_VISIBLE',
@@ -3755,22 +3782,15 @@ function breathLine(inp: FullInputs, isolated: Isolate, problems: Problem[], not
3755
3782
  * `halves_measured`, says `1 of 2` — after `declared_not_planted` when the scene
3756
3783
  * file declares some of the feet read (issue #231), which stays the first.
3757
3784
  */
3758
- function oneHalf(inp: FullInputs, isolated: Isolate, problems: Problem[], half: 'torso' | 'feet', ps: readonly PartRecord[], reason: string, declared: readonly string[]): JudgementLine {
3785
+ function oneHalf(inp: FullInputs, isolated: Isolate, pair: BreathPairRender, problems: Problem[], half: 'torso' | 'feet', ps: readonly PartRecord[], reason: string, declared: readonly string[]): JudgementLine {
3759
3786
  const H = inp.parts.rig_size[1];
3760
- const fs = isolated(half, ps);
3761
- const box = frameBox(ps, H, inp.stage, fs.viewport);
3762
- if (box === null) return skip(`the ${half} box falls outside the idle frame, and ${reason}`);
3763
- const heat = regionHeat(heatField(fs.frames.map((f) => f.image)), fs.viewport.pixelWidth, box);
3764
3787
  if (half === 'torso') {
3765
- const mean = round3(heat.mean);
3788
+ // Issue #411: the torso half is the breath alone.
3789
+ const tr = torsoBreath(inp, ps, pair);
3790
+ if ('skip' in tr) return skip(`the ${half} box falls outside the idle frame, and ${reason}`);
3791
+ const mean = tr.mean;
3766
3792
  const ok = mean >= BREATH_TORSO_MEAN_FLOOR;
3767
- if (!ok) {
3768
- problems.push({
3769
- code: 'CHECK_BREATH_VISIBLE',
3770
- object: `torso ${quoteParts(ps)} rendered alone, frame box ${boxLabel(box)}; the feet half not measured: ${reason}`,
3771
- detail: `heat mean ${mean}/255 over the idle; >= ${BREATH_TORSO_MEAN_FLOOR} is required — the chest's breath track moves too little, or the torso is not weighted to the bone it keys`,
3772
- });
3773
- }
3793
+ if (!ok) problems.push(torsoProblem(ps, tr, `; the feet half not measured: ${reason}`));
3774
3794
  return {
3775
3795
  status: ok ? 'PASS' : 'FAIL',
3776
3796
  halves_measured: '1 of 2',
@@ -3782,6 +3802,10 @@ function oneHalf(inp: FullInputs, isolated: Isolate, problems: Problem[], half:
3782
3802
  feet_reason: reason,
3783
3803
  };
3784
3804
  }
3805
+ const fs = isolated(half, ps);
3806
+ const box = frameBox(ps, H, inp.stage, fs.viewport);
3807
+ if (box === null) return skip(`the ${half} box falls outside the idle frame, and ${reason}`);
3808
+ const heat = regionHeat(heatField(fs.frames.map((f) => f.image)), fs.viewport.pixelWidth, box);
3785
3809
  const ok = heat.max <= BREATH_FEET_MAX_CEILING;
3786
3810
  if (!ok) {
3787
3811
  problems.push({
@@ -3803,6 +3827,130 @@ function oneHalf(inp: FullInputs, isolated: Isolate, problems: Problem[], half:
3803
3827
  };
3804
3828
  }
3805
3829
 
3830
+ /** The throwaway animation BREATH_VISIBLE adds beside the idle (issue #411): the idle with its breath tracks held at rest; a trailing `_` is added while the rig already has an animation of the name. */
3831
+ export const BREATH_ANIMATION = 'idle_without_breath';
3832
+ /** Where BREATH_VISIBLE's copy is built and rendered, under the stage's scratch; removed before the stage returns. */
3833
+ const BREATH_SCRATCH = 'breath';
3834
+
3835
+ /** The idle track properties that make up the breath on a breath bone (issue #411): it moves and it swells; the drafted breath is `chest` `translatey` and `scalex` (src/propose.ts). */
3836
+ const BREATH_TRACK_PROPS: readonly string[] = ['translate', 'translatex', 'translatey', 'scale', 'scalex', 'scaley'];
3837
+
3838
+ /**
3839
+ * The breath's tracks (issue #411), in the idle's order: the breath bones are
3840
+ * every bone an idle track translates ({@link BREATH_PROPS}, issue #262), and
3841
+ * their breath tracks every idle track that translates or scales one of them
3842
+ * ({@link BREATH_TRACK_PROPS}). A track that turns a breath bone, a group's
3843
+ * track and every track on another bone are not the breath. Empty when no
3844
+ * idle track translates a bone.
3845
+ */
3846
+ export function breathTracks(motion: Record<string, unknown>): Array<{ bone: string; property: string }> {
3847
+ const anims = isRecord(motion.animations) ? motion.animations : {};
3848
+ const idle = isRecord(anims.idle) ? anims.idle : {};
3849
+ const tracks = (Array.isArray(idle.tracks) ? idle.tracks : []).filter(isRecord).filter((t) => typeof t.bone === 'string' && typeof t.property === 'string');
3850
+ const bones = new Set(tracks.filter((t) => BREATH_PROPS.includes(String(t.property))).map((t) => String(t.bone)));
3851
+ return tracks.filter((t) => bones.has(String(t.bone)) && BREATH_TRACK_PROPS.includes(String(t.property))).map((t) => ({ bone: String(t.bone), property: String(t.property) }));
3852
+ }
3853
+
3854
+ /**
3855
+ * A breath track held at rest (issue #411): the setup pose's value — 0 for a translate, 1 for a scale, one per axis
3856
+ * the track's first key gives — at its first and last key times, no curve. That is the track removed, as the bone
3857
+ * stands without it, while the idle stays keyed to its end: a dropped track could leave the idle's last key before
3858
+ * its duration, which rigc refuses. (Held at its first key instead, the bone would stand offset from frame 0 on and
3859
+ * the physics under it would answer that start, which is not the idle without its breath.)
3860
+ */
3861
+ function heldTrack(t: Record<string, unknown>): Record<string, unknown> {
3862
+ const keys = (Array.isArray(t.keys) ? t.keys : []).filter(isRecord);
3863
+ if (keys.length === 0) return t;
3864
+ const first = keys[0];
3865
+ const last = keys[keys.length - 1];
3866
+ const rest = String(t.property).startsWith('scale') ? 1 : 0;
3867
+ const v = (Array.isArray(first.v) ? first.v : [first.v]).map(() => rest);
3868
+ return { ...t, keys: keys.length === 1 ? [{ t: first.t, v }] : [{ t: first.t, v }, { t: last.t, v }] };
3869
+ }
3870
+
3871
+ function isBreathTrack(t: Record<string, unknown>, tracks: ReadonlyArray<{ bone: string; property: string }>): boolean {
3872
+ return tracks.some((b) => b.bone === t.bone && b.property === t.property);
3873
+ }
3874
+
3875
+ /** The torso rendered alone twice from one build (issue #411): the idle (`with`) and the idle less its breath tracks (`without`), and those tracks as `bone property`. */
3876
+ export interface BreathPair {
3877
+ with: FrameSet;
3878
+ without: FrameSet;
3879
+ tracks: string[];
3880
+ }
3881
+
3882
+ /** Renders {@link BreathPair} for the torso parts; null when the idle has no breath track. */
3883
+ export type BreathPairRender = (ps: readonly PartRecord[]) => BreathPair | null;
3884
+
3885
+ /**
3886
+ * Why the two renders of a {@link BreathPair} cannot be compared pixel for
3887
+ * pixel, or null when they can: one grid (the viewport), one background, the
3888
+ * same number of frames, each of one size. Both come from one build, so a
3889
+ * difference is rigc's, refused by name (`CHECK_BREATH_VISIBLE`) rather than
3890
+ * read.
3891
+ */
3892
+ export function breathPairProblem(pair: BreathPair): Problem | null {
3893
+ const a = pair.with;
3894
+ const b = pair.without;
3895
+ const size = (s: FrameSet): string => [...new Set(s.frames.map((f) => `${f.image.width}x${f.image.height}`))].join(',');
3896
+ if (sameViewport(a.viewport, b.viewport) && a.background.join(',') === b.background.join(',') && a.frames.length === b.frames.length && size(a) === size(b) && !size(a).includes(',')) return null;
3897
+ return {
3898
+ code: 'CHECK_BREATH_VISIBLE',
3899
+ object: `the torso's two idle renders (with and without the breath tracks ${pair.tracks.join(', ')})`,
3900
+ detail: `are ${a.frames.length} frame(s) of ${size(a)} on ${JSON.stringify(a.viewport)} over ${JSON.stringify(a.background)} and ${b.frames.length} frame(s) of ${size(b)} on ${JSON.stringify(b.viewport)} over ${JSON.stringify(b.background)}; the breath is read pixel for pixel between them, which needs one grid, one background and one frame count`,
3901
+ };
3902
+ }
3903
+
3904
+ /** The torso half's reading (issue #411): the breath's heat mean over the box, the whole idle's beside it, and the breath tracks; `none` when the idle has no breath track. */
3905
+ type TorsoBreath = { box: PixelBox; mean: number; whole: number; tracks: string[] } | { none: string; mean: number } | { skip: true };
3906
+
3907
+ /**
3908
+ * `BREATH_VISIBLE`'s torso half (issue #411): the breath alone. The breath
3909
+ * bones are every bone an idle track translates, and the breath tracks every
3910
+ * idle track that translates or scales one of them ({@link breathTracks}).
3911
+ * The torso is rendered alone, idle at its rate and size, from one throwaway
3912
+ * build carrying every animation of the rig and, beside them, the idle with
3913
+ * its breath tracks held at rest ({@link heldTrack}: the bone as it stands
3914
+ * without them, the idle still keyed to its end) — so both renders share a
3915
+ * grid. Per pixel, the largest
3916
+ * |(with_t - with_0) - (without_t - without_0)| over the frames and the RGB
3917
+ * channels ({@link breathHeat}), meaned over the torso's frame box. Motion that
3918
+ * is not the breath's — a keyed cloth swing, physics answering the world, a
3919
+ * head turn — is in both renders and cancels; physics the breath sets moving
3920
+ * is counted. The whole idle's heat over the same box, the reading until #411,
3921
+ * is carried for the refusal's sentence only.
3922
+ *
3923
+ * With no breath track the figure is 0, by the definition (the idle with and
3924
+ * without its breath is one idle), and the bar fails naming why: a torso with
3925
+ * no breath is what the bar exists to find, so it is not a SKIP; nothing is
3926
+ * rendered.
3927
+ */
3928
+ function torsoBreath(inp: FullInputs, ps: readonly PartRecord[], pair: BreathPairRender): TorsoBreath {
3929
+ const got = pair(ps);
3930
+ if (got === null) return { none: 'no idle track translates a bone, so the rig has no breath to read (the breath bones are every bone an idle track translates); whatever else the idle moves is not counted', mean: 0 };
3931
+ const grid = breathPairProblem(got);
3932
+ if (grid !== null) refuseIfAny([grid]);
3933
+ const box = frameBox(ps, inp.parts.rig_size[1], inp.stage, got.with.viewport);
3934
+ if (box === null) return { skip: true };
3935
+ const width = got.with.viewport.pixelWidth;
3936
+ const withFrames = got.with.frames.map((f) => f.image);
3937
+ const mean = round3(regionHeat(breathHeat(withFrames, got.without.frames.map((f) => f.image)), width, box).mean);
3938
+ const whole = round3(regionHeat(heatField(withFrames), width, box).mean);
3939
+ return { box, mean, whole, tracks: got.tracks };
3940
+ }
3941
+
3942
+ /** The torso half's refusal (issue #411): the breath's figure, the tracks it was read from, and the whole idle's beside it. */
3943
+ function torsoProblem(ps: readonly PartRecord[], tr: Exclude<TorsoBreath, { skip: true }>, tail: string): Problem {
3944
+ if ('none' in tr) {
3945
+ return { code: 'CHECK_BREATH_VISIBLE', object: `torso ${quoteParts(ps)}${tail}`, detail: `breath heat mean 0/255: ${tr.none}; >= ${BREATH_TORSO_MEAN_FLOOR} is required — key the chest's breath (a translate track on the bone the torso is weighted to)` };
3946
+ }
3947
+ return {
3948
+ code: 'CHECK_BREATH_VISIBLE',
3949
+ object: `torso ${quoteParts(ps)} rendered alone, frame box ${boxLabel(tr.box)}${tail}`,
3950
+ detail: `breath heat mean ${tr.mean}/255 over the idle — the idle with and without its breath tracks (${tr.tracks.join(', ')}), on one grid; the whole idle reads ${tr.whole} over the box, and what is not the breath's is not counted; >= ${BREATH_TORSO_MEAN_FLOOR} is required — the chest's breath track moves too little, or the torso is not weighted to the bone it keys`,
3951
+ };
3952
+ }
3953
+
3806
3954
  /** The scene file's exceptions to `TIP_OVER_ROOT` (issues #231, #245), and the file they were read from, which a refusal names. */
3807
3955
  export interface TipExceptions {
3808
3956
  path: string;
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
@@ -56,7 +62,9 @@
56
62
  * Pure: no clock, no randomness; every value is a function of its inputs.
57
63
  */
58
64
  import type { ConfigConstraint, Point } from './config.ts';
65
+ import type { Mask } from './raster/types.ts';
59
66
  import { pyRound } from './round.ts';
67
+ import { segmentDistance } from './weights.ts';
60
68
 
61
69
  /** The tags a `cloth` recipe may name: the parts the proposer drafts chains on that hang. */
62
70
  export const CLOTH_TARGETS = ['bottomwear', 'back hair', 'front hair'] as const;
@@ -84,6 +92,8 @@ export interface ClothRecipe {
84
92
  gravity: [number, number];
85
93
  translate?: number;
86
94
  swing?: { scales: number[] };
95
+ /** `bottomwear` only (issue #402): a `topwear` part the skirt's trees are drafted on as well — a dress. */
96
+ part?: string;
87
97
  }
88
98
 
89
99
  export type ClothRecipes = Partial<Record<ClothTarget, ClothRecipe>>;
@@ -364,15 +374,83 @@ export function chainConstraints(chain: string, links: number, tree: number, edg
364
374
  return out;
365
375
  }
366
376
 
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 {
377
+ /**
378
+ * The one note a piece drafted by the recipe gets. `via` is the part's own
379
+ * `from` when the recipe reached it by `part` rather than by its tag
380
+ * (issue #402); absent, the note is the one written before the field existed.
381
+ */
382
+ export function clothNote(part: string, tag: ClothTarget, trees: readonly TreeChain[], r: ClothRecipe, constraints: number, extra: string, via?: string): string {
369
383
  const defaults: string[] = [];
370
384
  if (r.length_ratio === undefined) defaults.push(`length_ratio ${RECIPE_LENGTH_RATIO}`);
371
385
  if (r.strength === undefined) defaults.push(`strength ${RECIPE_STRENGTH.trunk}/${RECIPE_STRENGTH.branch}/${RECIPE_STRENGTH.edge}`);
372
386
  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
387
  return (
374
- `${part} (${tag}): config.cloth."${tag}" -> ${r.chains} tree(s)${extra}, ${shape} (${trees.map((t) => t.chain).join(', ')}); ` +
388
+ `${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
389
  `${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
390
  (defaults.length === 0 ? '' : `; the recipe's own defaults, measured on its synthetic fixture (AUTHORING §3): ${defaults.join(', ')}`)
377
391
  );
378
392
  }
393
+
394
+ /**
395
+ * Issue #391: a part wrapped round a tail the recipe drafted rides that tail's links. One span of the tail: a segment
396
+ * of the back hair's mesh as the recipe drafts it — the head's fixed segment, or one tree link from its origin to the
397
+ * next link (the last to the chain's tip), named by the link's bone.
398
+ */
399
+ export interface TailSpan {
400
+ bone: string;
401
+ a: Point;
402
+ b: Point;
403
+ /** Whether the span is a tree link (false: the head's fixed segment). */
404
+ link: boolean;
405
+ }
406
+
407
+ /** A tail the recipe drafted: the back hair part, its opaque mask on the rig canvas, and its mesh's spans in segment order. */
408
+ export interface Tail {
409
+ part: string;
410
+ mask: Mask;
411
+ spans: TailSpan[];
412
+ }
413
+
414
+ /** Where a part's opaque pixels lie against a drafted tail. */
415
+ export interface TailOverlap {
416
+ /** Per span, in the tail's order: the part's pixels over the tail's art whose nearest span it is. */
417
+ counts: number[];
418
+ /** The part's pixels over the tail's art (the sum of `counts`). */
419
+ over: number;
420
+ /** The part's opaque pixels in all. */
421
+ total: number;
422
+ }
423
+
424
+ /**
425
+ * Which span of the tail each of the part's pixels over the tail's art belongs to: every pixel where both masks are
426
+ * set is given to the span nearest it — the distance the weights read (`segmentDistance`, `src/weights.ts`), so a
427
+ * span here is the art the tail's own weights give mostly to that bone — the first in the tail's order on a tie. No
428
+ * threshold: a span the part touches by one pixel is one the part overlaps, and the counts are said in the note.
429
+ * Pure; the part's mask and the tail's are on the same canvas.
430
+ */
431
+ export function tailOverlap(tail: Tail, part: Mask, box: { x: number; y: number; w: number; h: number }): TailOverlap {
432
+ const counts = tail.spans.map(() => 0);
433
+ let over = 0;
434
+ let total = 0;
435
+ const W = part.width;
436
+ for (let y = box.y; y < box.y + box.h; y++) {
437
+ for (let x = box.x; x < box.x + box.w; x++) {
438
+ const i = y * W + x;
439
+ if (part.data[i] === 0) continue;
440
+ total++;
441
+ if (tail.mask.data[i] === 0) continue;
442
+ over++;
443
+ let best = 0;
444
+ let bd = Infinity;
445
+ tail.spans.forEach((s, k) => {
446
+ const d = segmentDistance([x, y], s.a, s.b);
447
+ if (d < bd) {
448
+ bd = d;
449
+ best = k;
450
+ }
451
+ });
452
+ counts[best]++;
453
+ }
454
+ }
455
+ return { counts, over, total };
456
+ }
package/src/config.ts CHANGED
@@ -2663,6 +2663,11 @@ function attachedParts(meshes: Json, regions: Json): Set<string> {
2663
2663
  * not a declaration (`CONFIG_CLOTH_ALTERNATE_DIFFERS`);
2664
2664
  * - `swing` on a tag other than `bottomwear`, or `swing.scales` not one per
2665
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`);
2666
2671
  * - a strength, declared or the recipe's default, whose spring is unstable at
2667
2672
  * a damping the recipe runs at — k = strength·massInverse·step² at or past
2668
2673
  * 2(1 + damping^(60·step)), rig-c's default fps 60 and mass 1, the damping
@@ -2690,7 +2695,7 @@ function checkCloth(c: Check, v: Json): void {
2690
2695
  for (const tag of CLOTH_TARGETS) {
2691
2696
  if (!(tag in v)) continue;
2692
2697
  const path = `${at}.${JSON.stringify(tag)}`;
2693
- 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']);
2694
2699
  if (r === null) continue;
2695
2700
  const chains = 'chains' in r && c.int(`${path}.chains`, r.chains, 1) ? (r.chains as number) : null;
2696
2701
  const links = 'links' in r && c.int(`${path}.links`, r.links, 1) ? (r.links as number) : null;
@@ -2743,6 +2748,11 @@ function checkCloth(c: Check, v: Json): void {
2743
2748
  if ('translate' in r && c.number(`${path}.translate`, r.translate, 'unit') && r.translate === 0) {
2744
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)');
2745
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
+ }
2746
2756
  if ('swing' in r) {
2747
2757
  if (tag !== 'bottomwear') {
2748
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`);
@@ -137,6 +137,38 @@ export function heatField(frames: readonly Raster[]): Uint8Array {
137
137
  return d;
138
138
  }
139
139
 
140
+ /**
141
+ * The breath alone (issue #411): each pixel's largest per-channel RGB change
142
+ * that the breath makes, read off the idle rendered twice on one grid — with
143
+ * its breath tracks (`withBreath`) and without them (`withoutBreath`). At
144
+ * frame t the breath's own change at a pixel is (with_t - with_0) -
145
+ * (without_t - without_0): motion that is the same in both renders (a keyed
146
+ * cloth swing, a physics response to the world, a head turn) cancels, and so
147
+ * does a constant offset the breath holds from frame 0 on, while physics that
148
+ * the breath sets moving stays. The field is that change's largest magnitude
149
+ * over the frames and the three channels, capped at 255 — {@link heatField}'s
150
+ * reading when the render without the breath does not move. Both lists hold
151
+ * the same number of frames of one size; the caller holds the grid.
152
+ */
153
+ export function breathHeat(withBreath: readonly Raster[], withoutBreath: readonly Raster[]): Uint8Array {
154
+ const w0 = withBreath[0].data;
155
+ const o0 = withoutBreath[0].data;
156
+ const n = withBreath[0].width * withBreath[0].height;
157
+ const d = new Uint8Array(n);
158
+ withBreath.forEach((f, i) => {
159
+ const w = f.data;
160
+ const o = withoutBreath[i].data;
161
+ for (let p = 0; p < n; p++) {
162
+ for (let c = 0; c < 3; c++) {
163
+ const k = p * 4 + c;
164
+ const v = Math.min(255, Math.abs(w[k] - w0[k] - (o[k] - o0[k])));
165
+ if (v > d[p]) d[p] = v;
166
+ }
167
+ }
168
+ });
169
+ return d;
170
+ }
171
+
140
172
  export interface RegionHeat {
141
173
  /** Pixels measured. */
142
174
  px: number;
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/propose.ts CHANGED
@@ -43,7 +43,12 @@
43
43
  * layer with hanging strands ({@link Strand}) gets one pendulum chain per
44
44
  * strand instead of the single pendant chain, and one note naming every
45
45
  * strand and what became of it — a strand left without a chain is never
46
- * silent (issue #24).
46
+ * silent (issue #24). Under the `back hair` cloth recipe (issue #391) a
47
+ * layer of either tag lying on a drafted tail rides the links it overlaps
48
+ * instead: its pixels over the tail's art are each given to the nearest span
49
+ * of the back hair's mesh (`tailOverlap`, `src/cloth.ts`), and when one is a
50
+ * link the part's mesh takes those spans as its segments and no rule above
51
+ * runs for it; a note names each span with its pixel count.
47
52
  * - anything no rule claims rides its nearest trunk bone as a region —
48
53
  * including every part from an author-made layer (`<run>:author:<label>`,
49
54
  * issue #256), which is no See-through tag and so has no role: no rule
@@ -139,7 +144,7 @@ import { AUTHOR_NO_ROLE, isAuthorTag } from './tags.ts';
139
144
  import { TURN_BONE, TURN_CARRIER_TAG, TURN_PLACES, TURN_RIDER_OFFSET, TURN_RIDER_TAGS, turnFractions, turnNearest, turnPivot, turnRiderDepth, type TurnSpec } from './turn.ts';
140
145
  import { edgeLength } from './length.ts';
141
146
  import { chainSqueezes, type SqueezeFinding } from './squeeze.ts';
142
- import { RECIPE_LENGTH_RATIO, chainConstraints, clothNote, type ClothRecipe, type ClothRecipes, type ClothTarget, CLOTH_TARGETS, draftTrees, swingName, treeConstraints, type TreeChain, type TreeInput } from './cloth.ts';
147
+ import { RECIPE_LENGTH_RATIO, chainConstraints, clothNote, type ClothRecipe, type ClothRecipes, type ClothTarget, CLOTH_TARGETS, draftTrees, swingName, type Tail, tailOverlap, type TailSpan, treeConstraints, type TreeChain, type TreeInput } from './cloth.ts';
143
148
  import { TEXTURE_STRETCH_CEILING } from './check.ts';
144
149
 
145
150
  // ---------------------------------------------------------------------------
@@ -820,6 +825,42 @@ export const HIP_MIN_FRACTION = 0.25;
820
825
  /** 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
826
  export const WAIST_MAX_OF_SHOULDERS = 0.8;
822
827
 
828
+ /**
829
+ * A `topwear` part hangs below the hip when its box reaches this many face
830
+ * heights below the hip's y: above it, the topwear rule reads a bodice that
831
+ * stops at the waist and drafts no robe chains (the reference's line). Issue
832
+ * #402 reads the same line for a skirt held inside `topwear` (a dress), so
833
+ * the two rules cannot disagree about which topwear hangs.
834
+ */
835
+ export const TOPWEAR_HANGS_FACE_HEIGHTS = 0.25;
836
+
837
+ /**
838
+ * Issue #402: the note naming a `topwear` part shaped like a skirt — its box
839
+ * hanging {@link TOPWEAR_HANGS_FACE_HEIGHTS} face heights past the hip, and
840
+ * its art wider across its last 24 rows than in the 24-row band at the hip
841
+ * (the band the robe rule reads) — or null when it is not. The cloth recipe
842
+ * finds a skirt by the `bottomwear` tag alone, and the shape cannot tell a
843
+ * dress from an outer robe over a skirt, so the proposer drafts nothing on
844
+ * the strength of it: the note names the part, its art's rows below the hip
845
+ * and the field, `cloth.bottomwear.part`, by which the author declares it.
846
+ */
847
+ function skirtInsideNote(p: PartRecord, mask: Mask, hipY: number, fh: number): string | null {
848
+ const bot = p.y + p.h;
849
+ const line = hipY + TOPWEAR_HANGS_FACE_HEIGHTS * fh;
850
+ if (bot < line) return null;
851
+ const span = (xs: number[]): number => (xs.length === 0 ? 0 : xs[xs.length - 1] - xs[0] + 1);
852
+ const atHip = span(colsAny(mask, pyInt(hipY) - 12, pyInt(hipY) + 12));
853
+ const atBottom = span(colsAny(mask, bot - 24, bot));
854
+ if (!(atBottom > atHip)) return null;
855
+ const hipRow = pyRound(hipY);
856
+ let last = bot - 1;
857
+ while (last > p.y && colsAny(mask, last, last + 1).length === 0) last--;
858
+ return (
859
+ `${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); ` +
860
+ `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`
861
+ );
862
+ }
863
+
823
864
  /**
824
865
  * One handwear blob is clasped hands, not two sleeves, when it is at most this
825
866
  * fraction of the shoulders' width: two sleeves that hang from the shoulders
@@ -1328,6 +1369,8 @@ export function proposeWithBasis(
1328
1369
  const clothConstraints: ConfigConstraint[] = [];
1329
1370
  const clothUsed = new Set<ClothTarget>();
1330
1371
  const recipeOf = (tag: ClothTarget): ClothRecipe | null => cloth?.[tag] ?? null;
1372
+ // Issue #391: the tails the back hair recipe drafts, each with its mesh's spans, which an accessory wrapped round one rides.
1373
+ const tails: Tail[] = [];
1331
1374
  const T = (p: PartRecord, tag: ClothTarget, r: ClothRecipe, input: TreeInput): TreeChain[] => {
1332
1375
  const trees = draftTrees(input, r);
1333
1376
  const constants = [konst('cloth_chains', r.chains), konst('cloth_links', r.links), konst('length_ratio', roundTo(r.length_ratio ?? RECIPE_LENGTH_RATIO, 6))];
@@ -1512,6 +1555,13 @@ export function proposeWithBasis(
1512
1555
  }
1513
1556
  notes.push(clothNote(p.name, 'back hair', all, rcp, n, ' per side of the eye axis, from head, rooted on the eye line and tipped 4 px above its bottom'));
1514
1557
  meshes[p.name] = { grid: g, r, segments: segs };
1558
+ // Issue #391: the spans are this mesh's segments, the head's fixed one and every tree link, in segment order.
1559
+ const spans: TailSpan[] = [{ bone: 'head', a: rnd(head), b: rnd([axis, top + 13]), link: false }];
1560
+ for (const t of all) {
1561
+ const line = [...t.points, t.tip];
1562
+ t.points.forEach((q, i) => spans.push({ bone: `${t.chain}${i}`, a: q, b: line[i + 1], link: true }));
1563
+ }
1564
+ tails.push({ part: p.name, mask, spans });
1515
1565
  } else {
1516
1566
  const mask = P.alpha(p);
1517
1567
  const segs: Segment[] = [['head', rnd(head), rnd([axis, top + 13])]];
@@ -1690,7 +1740,39 @@ export function proposeWithBasis(
1690
1740
  // gets the bone and chain, the rest ride the head rigidly. A stable sort,
1691
1741
  // as Python's `sorted` is.
1692
1742
  const cands = [...P.byTag(tag)].sort((a, b) => b.opaque_px - a.opaque_px);
1743
+ // Issue #391: a layer of the tag lying on a tail the back hair recipe drafted rides the links it overlaps — the
1744
+ // spans of the tail its pixels over the tail's art fall nearest — and not head: its mesh names those bones and no
1745
+ // others, so every vertex weights by the rule the tail's own art does. The links are read off the overlap, never
1746
+ // off the part's name. A layer over no link keeps its rule below. Only with the recipe: without it no tail moves
1747
+ // by the world, and nothing here runs.
1748
+ const rides = (q: PartRecord): boolean => {
1749
+ const segments: Segment[] = [];
1750
+ const links: string[] = [];
1751
+ const said: string[] = [];
1752
+ for (const tail of tails) {
1753
+ const o = tailOverlap(tail, P.alpha(q), q);
1754
+ if (!tail.spans.some((sp, k) => sp.link && o.counts[k] > 0)) continue;
1755
+ const on: string[] = [];
1756
+ tail.spans.forEach((sp, k) => {
1757
+ if (o.counts[k] === 0) return;
1758
+ on.push(`${sp.link ? sp.bone : `${sp.bone}'s fixed segment`} ${o.counts[k]}`);
1759
+ // A link is named, so its segment is the link as the bones declare it; the head's span is written out, as the tail's mesh writes it.
1760
+ segments.push(sp.link ? sp.bone : [sp.bone, sp.a, sp.b]);
1761
+ if (sp.link) links.push(sp.bone);
1762
+ });
1763
+ said.push(`${o.over} of its ${o.total} px lie over ${tail.part}'s art, nearest ${tail.part}'s spans ${on.join(', ')} px`);
1764
+ }
1765
+ if (links.length === 0) return false;
1766
+ const [g, r] = gridR(q);
1767
+ delete regions[q.name];
1768
+ meshes[q.name] = { grid: g, r, segments };
1769
+ notes.push(
1770
+ `${q.name} (${q.from}): wraps a tail config.cloth."back hair" drafts — ${said.join('; ')} — so its mesh's segments are those spans and it rides the links ${links.join(', ')} with the tail, not head; no ${tag} bone, pendant or strand chain is drafted for it (issue #391)`,
1771
+ );
1772
+ return true;
1773
+ };
1693
1774
  for (const q of cands.slice(1)) {
1775
+ if (rides(q)) continue;
1694
1776
  regions[q.name] = 'head';
1695
1777
  notes.push(`${q.name} (${q.from}): second ${tag} layer, rigid on head`);
1696
1778
  // A region cannot swing, so strands found on it are only said.
@@ -1699,6 +1781,7 @@ export function proposeWithBasis(
1699
1781
  if (strands.length > 0) notes.push(strandNote(q, strands, [], strands, 'it rides the head as a region'));
1700
1782
  }
1701
1783
  for (const p of cands.slice(0, 1)) {
1784
+ if (rides(p)) continue;
1702
1785
  const [g, r] = gridR(p);
1703
1786
  const fullMask = dilate(P.alpha(p), 7);
1704
1787
  const onArt = (pts: ReadonlyArray<readonly [number, number]>): boolean => pts.every((q) => isOn(fullMask, q[0], q[1]));
@@ -2022,8 +2105,42 @@ export function proposeWithBasis(
2022
2105
  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
2106
  }
2024
2107
 
2108
+ // Issue #402: the topwear part config.cloth.bottomwear.part names takes the skirt's rule and recipe below; every
2109
+ // other topwear shaped like a skirt is named in a note when a recipe is in play, never drafted on by its shape.
2110
+ const namedSkirt = ((): PartRecord | null => {
2111
+ const name = recipeOf('bottomwear')?.part;
2112
+ if (name === undefined) return null;
2113
+ const refuse = (detail: string): never => {
2114
+ throw new PartsError([{ code: 'PROPOSE_CLOTH_PART', object: 'config.cloth."bottomwear".part', detail }]);
2115
+ };
2116
+ const q = P.recs.find((x) => x.name === name);
2117
+ 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`);
2118
+ 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`);
2119
+ if (!tw.includes(q)) {
2120
+ return refuse(
2121
+ `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)"}`,
2122
+ );
2123
+ }
2124
+ const line = hip[1] + TOPWEAR_HANGS_FACE_HEIGHTS * fh;
2125
+ if (q.y + q.h < line) {
2126
+ 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`);
2127
+ }
2128
+ return q;
2129
+ })();
2130
+ const skirtHints = new Map<string, string>();
2131
+ if (cloth !== null) {
2132
+ for (const p of tw) {
2133
+ if (p === namedSkirt) continue;
2134
+ const hint = skirtInsideNote(p, P.alpha(p), hip[1], fh);
2135
+ if (hint !== null) skirtHints.set(p.name, hint);
2136
+ }
2137
+ }
2138
+
2025
2139
  // ---- outer robe (topwear)
2026
2140
  for (const p of tw) {
2141
+ if (p === namedSkirt) continue;
2142
+ const hint = skirtHints.get(p.name);
2143
+ if (hint !== undefined) notes.push(hint);
2027
2144
  const [g, r] = gridR(p);
2028
2145
  const mask = P.alpha(p);
2029
2146
  const top = chest[1] - 0.3 * fh;
@@ -2039,7 +2156,7 @@ export function proposeWithBasis(
2039
2156
  ['chest', rnd(along(hip, trunk.u, artExtent(mask, p, hip, trunk.u)[0])), rnd(along(hip, trunk.u, -20))],
2040
2157
  ['hip', rnd(along(hip, trunk.u, -20)), rnd(along(hip, trunk.u, 100))],
2041
2158
  ];
2042
- if (bw.length > 0 && bot < hip[1] + 0.25 * fh) {
2159
+ if (bw.length > 0 && bot < hip[1] + TOPWEAR_HANGS_FACE_HEIGHTS * fh) {
2043
2160
  // A bodice that stops at the waist: robe chains down to the hem would fall off the art.
2044
2161
  meshes[p.name] = { grid: g, r, segments: segs };
2045
2162
  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 +2203,9 @@ export function proposeWithBasis(
2086
2203
  meshes[p.name] = { grid: g, r, segments: segs };
2087
2204
  }
2088
2205
 
2089
- // ---- skirt (bottomwear)
2090
- for (const p of bw) {
2206
+ // ---- skirt (bottomwear, and the topwear part config.cloth.bottomwear.part names: issue #402)
2207
+ const skirts = namedSkirt === null ? bw : [...bw, namedSkirt];
2208
+ for (const p of skirts) {
2091
2209
  const [g, r] = gridR(p);
2092
2210
  const mask = P.alpha(p);
2093
2211
  const bot = p.y + p.h;
@@ -2122,7 +2240,7 @@ export function proposeWithBasis(
2122
2240
  // Issue #364: with config.cloth.bottomwear, the recipe's trees hang from the hip in place of the three keyed chains.
2123
2241
  const skirtRecipe = recipeOf('bottomwear');
2124
2242
  if (skirtRecipe !== null) {
2125
- const prefix = bw.length === 1 ? 'skirt' : `skirt_${p.name}`;
2243
+ const prefix = skirts.length === 1 ? 'skirt' : `skirt_${p.name}`;
2126
2244
  const trees = T(p, 'bottomwear', skirtRecipe, {
2127
2245
  prefix,
2128
2246
  parent: 'hip',
@@ -2162,6 +2280,7 @@ export function proposeWithBasis(
2162
2280
  skirtRecipe,
2163
2281
  made.length,
2164
2282
  `${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`,
2283
+ p === namedSkirt ? p.from : undefined,
2165
2284
  ),
2166
2285
  );
2167
2286
  meshes[p.name] = { grid: g, r, segments: segs };
@@ -2316,7 +2435,9 @@ export function proposeWithBasis(
2316
2435
  object: `config.cloth."${t}"`,
2317
2436
  detail:
2318
2437
  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`
2438
+ ? t === 'bottomwear' && skirtHints.size > 0
2439
+ ? `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('; ')}`
2440
+ : `declares a recipe for "${t}", and no part is tagged "${t}"; leave the recipe out, or assemble the layer it is for`
2320
2441
  : t === 'back hair'
2321
2442
  ? `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
2443
  : `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;