@rig-c/parts 1.23.0 → 1.25.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/cli.ts +2 -1
- package/docs/AUTHORING.md +48 -5
- package/docs/STABILITY.md +5 -3
- package/package.json +2 -2
- package/src/assemble.ts +25 -6
- package/src/automesh.ts +2 -1
- package/src/check.ts +184 -33
- package/src/cloth.ts +72 -3
- package/src/config.ts +107 -6
- package/src/instruments.ts +32 -0
- package/src/limbs.ts +171 -0
- package/src/propose.ts +269 -32
- package/src/rig.ts +112 -12
- package/src/squeeze.ts +161 -1
package/cli.ts
CHANGED
|
@@ -27,7 +27,7 @@ import { makeInputs } from './src/inputs.ts';
|
|
|
27
27
|
import { idleKeysOf, isIdleKeys } from './src/rig.ts';
|
|
28
28
|
import { depthSkipLine, exportLayers, figuresPhrase, hiddenLayerLine, implausibleRules, layerFigures, type LayerSet, layerSetDiff, pct, readLayers, readWrapperLayers, ruleSummary, templateLayerNames, templatePsdBytes, times } from './src/layers.ts';
|
|
29
29
|
import { checkImageSize, choosePerson, KEYPOINTS_SPEC, loadKeypoints, type RigJoints, toRigJoints } from './src/keypoints.ts';
|
|
30
|
-
import { basisLines, checkProposal, compare, compareLines, DEFAULT_GRID_RULE, draftTurn, drawLandmarks, FIGURE_GRID_DIVISOR, FRINGE_STEP_PX, GRID_RULES, type GridRule, HIP_MIN_FRACTION, lint, lintLine, type PartSet, proposeWithBasis, readPartSet, serializeProposal, withTurn, WRIST_ON_PART_PX } from './src/propose.ts';
|
|
30
|
+
import { basisLines, branchSqueezeLine, checkProposal, compare, compareLines, DEFAULT_GRID_RULE, draftTurn, drawLandmarks, FIGURE_GRID_DIVISOR, FRINGE_STEP_PX, GRID_RULES, type GridRule, HIP_MIN_FRACTION, lint, lintLine, type PartSet, proposeWithBasis, readPartSet, serializeProposal, withTurn, WRIST_ON_PART_PX } from './src/propose.ts';
|
|
31
31
|
import { BASIS_FILE, BASIS_SPEC, basisFile, basisLine, coverageLines, serializeBasis } from './src/diagnostics.ts';
|
|
32
32
|
import { BEND_DEGREES, BEND_WORST_SHARE, DUST_MAX_PX, DUST_MAX_SHARE, IDLE_BOUND_PX, MESH_DRAFT_REPORT, MESH_DRAFT_SPEC, meshDraftStage, MORE_TRIANGLES_FLAG, TOLERANCE_FIGURE_DIVISOR } from './src/meshdraft.ts';
|
|
33
33
|
import { checkPainting } from './src/paintcheck.ts';
|
|
@@ -1064,6 +1064,7 @@ function printLint(P: PartSet, spec: { bones: CharacterConfig['bones']; meshes:
|
|
|
1064
1064
|
for (const m of res.unknownMeshes) console.log(`note: mesh ${JSON.stringify(m)} names no part in parts.json, so it was not linted`);
|
|
1065
1065
|
for (const w of res.lockUnread) console.log(`note: off-lock not read: ${w}`);
|
|
1066
1066
|
for (const w of res.squeezeUnread) console.log(`note: squeeze not read: ${w}`);
|
|
1067
|
+
for (const b of res.branchSqueezes) console.log(branchSqueezeLine(b));
|
|
1067
1068
|
for (const b of res.missingTorsoBones) {
|
|
1068
1069
|
console.log(
|
|
1069
1070
|
res.basis?.torso.read === true
|
package/docs/AUTHORING.md
CHANGED
|
@@ -121,6 +121,7 @@ read by no CPU stage).
|
|
|
121
121
|
| `motion.blink.still` | rig | **proposed** only for a lash `propose` notes (below), then checked: `{<part>: {row, bone}}` — the rows of that region part above `row` (rig px, y down) are drawn by a second slot `<part>_still` on `bone` and do not blink; rows from `row` down keep the part's slot and blink. The part must be a region on a bone `eyes` names, `bone` one it does not (`CONFIG_STILL_OFF_THE_BLINK`), and `row` a row of the part with no art across its whole width (`RIG_STILL_ROW_CLEAR`) |
|
|
122
122
|
| `motion.animations_from` | rig; check (named; read for folds) | optional, never proposed (issue #183): a path, relative to the config file's directory, to a file in rig-c's motion-spec shape, `{"spec": "rigc-motion/1", "animations": {"<name>": {"duration": …, "tracks": [...]}, …}}` — an expression, a gesture, anything beside the idle. On every `rig` and `build` each of its animations is written into `rig/motion.json` after `idle`, as read: nothing added, re-keyed or judged here, and each is rigc's to accept or refuse at the rig stage's gate, in rigc's words. It may name what `motion.json` already holds — the bones `bones` declares, the easings `shut` and `open`, the groups `eyes` and `brows` when the blink writes them — and nothing else from the file reaches it. The loader refuses, every problem at once: no such file or one that cannot be read (`CONFIG_FILE_PRESENT`), text that is not JSON (`CONFIG_IS_JSON`), a file that is not an object, a `spec` other than `"rigc-motion/1"`, an `animations` that is not a table of objects (`CONFIG_FIELD_TYPE`), any other key — rig-c's `easings`, `groups`, `setup`, `physics`, `mix`, `archetype` and `cut` included, which would be read and not written (`CONFIG_KEY_KNOWN`), an animation named `idle` (`CONFIG_ANIMATION_NAME_FREE`), and a key written twice in one object of the file, which JSON would fold into its last value without a word (`CONFIG_KEY_UNIQUE`). `check` names the others on one line (`beside the idle: …`) and reads each for folds, with the idle — `ANIMATIONS_DO_NOT_FOLD` (§7, issues #320, #333); every other bar reads the idle. Absent, `motion.json` holds the idle alone, byte for byte as before, and `check` reads that idle for folds |
|
|
123
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 |
|
|
124
|
+
| `stops` | rig (handed to rig-c as `rig.json`'s `stops`, and moves slots, mesh weights and child bones on stopped links onto `<link>_d`) | **authored**, optional (issue #404): `[{chain, links?, against, at, inward, outward, lower?: {inward, outward}}]` — rig-c's leg stops (`RigStop`, rig-c 2.56.0, `rig-c/src/stop.ts`). `chain` is a chain `bones` declares (`CONFIG_NAME_RESOLVES`, `RIG_NAME_RESOLVES`); `links`, optional, is a non-empty list of links of that chain (`CONFIG_NAME_RESOLVES`, `CONFIG_FIELD_TYPE`), or absent for every link of `chain` in chain order; `against` is a bone `bones` declares, a chain link as `<chain><i>` (`CONFIG_NAME_RESOLVES`, `RIG_NAME_RESOLVES`); `at` is `[x, y]` in `against`'s local space, as rig-c's stop takes it (`CONFIG_FIELD_TYPE`); `inward`, `outward` and `lower.inward`, `lower.outward` are finite numbers (`CONFIG_FIELD_TYPE`). Every other stop rule — non-negative bounds, each stopped link written by a constraint, `against` not under the stopped chain, the aim not degenerate — is rigc's to accept or refuse at the rig stage's gate, in rigc's words (`RIG_RIGC_GREEN`). For every stopped link `<link>`, the rig stage moves any slot on `<link>`, any mesh weight on `<link>`, and any bone whose parent is `<link>` (a branched cloth tree's branches hanging from `<trunk_last>`, before `--idle-keys ctl` adds `<bone>_ctl` and before `turn` adds `turn_<part>_<bone>`) onto `<link>_d`, the drawn link bone rig-c's `expandStops` creates at `<link>`'s setup frame to carry the clamped rotation. Absent, `rig.json` carries no `stops` and no byte of any output moves |
|
|
124
125
|
| `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 |
|
|
125
126
|
| `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 |
|
|
126
127
|
| `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 |
|
|
@@ -1583,13 +1584,13 @@ What each rule drafts (`src/cloth.ts` holds them):
|
|
|
1583
1584
|
| rule | drafts | from |
|
|
1584
1585
|
| --- | --- | --- |
|
|
1585
1586
|
| where | `bottomwear`: from `hip`, the root row 20 px below hip's y (the keyed chains' row), the tip row 4 px above the part's bottom. `back hair` that reaches below the shoulders: from `head`, per side of the eye axis (twin tails are a side each), the eye line to 4 px above its bottom. `front hair`: each strand that hangs below the chin (the lock rule's), from `head`, 0.22 face heights above the eye line to 5 px below the strand; the fringe's three columns keep their two links and their places | the keyed chains' own rows, which these replace |
|
|
1586
|
-
| trees | tree k of `chains` owns the cell k/N .. (k+1)/N of the art's width in every row, and its links sit at the cell's centre in the 24-row band there, so a piece that widens fans its trees. With `split`, the trunk's tip is the fork, and branch b of `into` follows the centre of its share of the cell. Chains are named `<prefix><k>_` (trunk) and `<prefix><k><a, b, …>_` (branches): `skirt`, `hairback_r`/`hairback_l`, `lockt` | `chains`, `links`, `split` |
|
|
1587
|
+
| trees | tree k of `chains` owns the cell k/N .. (k+1)/N of the art's width in every row, and its links sit at the cell's centre in the 24-row band there, so a piece that widens fans its trees. With `split`, the trunk's tip is the fork, and branch b of `into` follows the centre of its share of the cell. Chains are named `<prefix><k>_` (trunk) and `<prefix><k><a, b, …>_` (branches): `skirt`, `hairback_r`/`hairback_l`, `lockt`. With `split.hold_tip: true` (issue #403), sibling branches keep `strength.branch` across the fork and the mesh's `r` is raised to `grid`, holding the triangles where two branches' cells meet | `chains`, `links`, `split` |
|
|
1587
1588
|
| lengths | link j's length is the first's times q^j, q = `length_ratio`^(1/(links − 1)), the whole spanning root row to tip row: the links shorten toward the tip | `length_ratio` (default 0.5, below) |
|
|
1588
|
-
| stiffness | a trunk link takes `strength.trunk`, a branch link `strength.branch`, and the edge — the outermost branch on each outer side of the piece (both sides of a skirt or a strand; the outer side of each back-hair side), or without `split` the outermost tree — `strength.edge`; a fringe column is a trunk, its outer two the edge. **Strength does not fall along a chain**: a tip reads soft because each link turns on top of every link above it, so the motion accumulates down the chain at one strength. Only the edge is declared softer | `strength` (default trunk 100, branch 100, edge 50, below) |
|
|
1589
|
+
| stiffness | a trunk link takes `strength.trunk`, a branch link `strength.branch`, and the edge — the outermost branch on each outer side of the piece (both sides of a skirt or a strand; the outer side of each back-hair side; or, under `split.hold_tip: true`, kept at `strength.branch` so a fork's sibling branches do not pull apart at 2:1 stiffness), or without `split` the outermost tree — `strength.edge`; a fringe column is a trunk, its outer two the edge. **Strength does not fall along a chain**: a tip reads soft because each link turns on top of every link above it, so the motion accumulates down the chain at one strength. Only the edge is declared softer | `strength` (default trunk 100, branch 100, edge 50, below) |
|
|
1589
1590
|
| 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` |
|
|
1590
1591
|
| out of phase | the odd trees take `alternate_damping`, the even ones `damping` | `damping`, `alternate_damping` |
|
|
1591
1592
|
| 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` |
|
|
1593
|
+
| 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. A `bottomwear` part lying on the named part's tree links rides them and drafts no trees of its own (issue #416, *What rides a dress* below) | `part` |
|
|
1593
1594
|
| 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` |
|
|
1594
1595
|
|
|
1595
1596
|
Every link but a swing-driven first link gets `<bone>_physics` (`rotate` 1), and no
|
|
@@ -1619,6 +1620,48 @@ to 0.258 of its weight on the trees; and `check`'s `BREATH_VISIBLE`, which reads
|
|
|
1619
1620
|
`topwear` part as the torso, read the dress's idle heat at 1.592 against the floor
|
|
1620
1621
|
3.809, where the same dress with the robe chains read 3.9 — the half on the trees has
|
|
1621
1622
|
no idle key. Neither is barred here; both are the dress's to weigh before declaring it.
|
|
1623
|
+
Since issue #411 the bar reads the breath alone, and on that fixture the breath moves
|
|
1624
|
+
the dress 0.106 and the robe-chained dress 2.62: both fail, and the 3.9 was the robe
|
|
1625
|
+
chains' keyed swing below the hip, not the breath (the CK502 and CK503 controls).
|
|
1626
|
+
|
|
1627
|
+
**What rides a dress** (issue #416). With `part` declared, a `bottomwear` part lying on
|
|
1628
|
+
the dress — a ruffle hem See-through returned as a layer of its own — rides the dress's
|
|
1629
|
+
tree links by the rule a part wrapped round a tail does (*What rides a tail*, below): each
|
|
1630
|
+
of its pixels over the dress's art is given to the span of the dress's mesh nearest it
|
|
1631
|
+
(a fixed segment, chest or the waist line, or one tree link), and the part rides when one
|
|
1632
|
+
of those spans is a link. Its mesh's segments are then the spans it lies on, it drafts
|
|
1633
|
+
no trees of its own, and a note names each span with its pixel count; a `bottomwear` part
|
|
1634
|
+
over no link keeps its own trees. Before, the hem took the skirt's recipe by its tag as
|
|
1635
|
+
well, so one skirt carried two sets of trees, each on its own physics. Measured once on
|
|
1636
|
+
the selftest's dress fixture with a 112x26 hem across its last tier (`fixtures/cloth.ts`,
|
|
1637
|
+
`HEM`; the hip from joints at y 164; rig-c 2.54.0, `check`'s idle, physics on), before
|
|
1638
|
+
this rule and with it: the trees drafted went from four (`skirt_hem0_`, `skirt_hem1_`,
|
|
1639
|
+
`skirt_dress0_`, `skirt_dress1_`) to two (`skirt0_`, `skirt1_`), and their physics
|
|
1640
|
+
constraints from 8 to 4; `TEXTURE_STRETCH` read 1.275 both ways (its worst mesh is the
|
|
1641
|
+
back hair), the hem's own mesh 1.034 with its own trees and 1.045 riding, and the largest
|
|
1642
|
+
opening of the hem's seam with the dress 0.502 and 0.432 px (CK510 holds the one set and
|
|
1643
|
+
the pass). The hip rule still reads a `bottomwear` part's top edge as the waist, so a
|
|
1644
|
+
hem and no hip joints put the hip at the hem: on the same fixture without joints, y 277,
|
|
1645
|
+
and the dress's trees run up from y 297 to 286. Without `part` nothing here runs.
|
|
1646
|
+
|
|
1647
|
+
**What rides a tail** (issue #391). An accessory wrapped round a tail the `back hair`
|
|
1648
|
+
recipe drafts — a ribbon, in See-through's `headwear` or `earwear` layer — rides that
|
|
1649
|
+
tail's links, not `head`: under the recipe the tail moves by the world, and a part left on
|
|
1650
|
+
`head` stays where the tail was. Which links is read off the overlap, never off the
|
|
1651
|
+
part's name: each of the part's pixels over the tail's art is given to the span of the
|
|
1652
|
+
back hair's mesh nearest it (its fixed segment on `head`, or one tree link, the distance
|
|
1653
|
+
the weights read), and the part rides when one of those spans is a link. Its mesh's
|
|
1654
|
+
segments are then the spans it lies on — each link by name, the head's span written
|
|
1655
|
+
out — so every vertex weights by the rule the tail's own art does, the pixels off the
|
|
1656
|
+
tail (a ribbon's loops) included; no accessory bone, pendant or strand chain is drafted
|
|
1657
|
+
for it, and a note names each span with its pixel count. A part over no link keeps the
|
|
1658
|
+
accessory rule. It is part of the recipe's drafting, not a field: the rule reads only
|
|
1659
|
+
the art, and without the recipe no tail moves by the world and nothing here runs. On
|
|
1660
|
+
`wind` (rig-c 2.54.0, `rigc render --environment`, idle frame 200 of 200 at 60 fps,
|
|
1661
|
+
0.916 px per rig px), the ribbon pixels painted over the tail that are drawn where the
|
|
1662
|
+
tail has no hair went from 2,429 at calm and 8,363 at wind (10, 0) to 30 and 230; the
|
|
1663
|
+
230 all lie within 3.6 px of the hair's edge, where the ribbon's mesh and the hair's are
|
|
1664
|
+
two different lattices.
|
|
1622
1665
|
|
|
1623
1666
|
**Every spring is stable at its step (A23's inequality).** Per step spine-core does
|
|
1624
1667
|
`v += −strength·x·step·massInverse`, `x += v·step`, `v *= d` with d = damping^(60·step);
|
|
@@ -2753,7 +2796,7 @@ documents do not ship). Each is an input this package built; none is an author's
|
|
|
2753
2796
|
| <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 |
|
|
2754
2797
|
| <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 |
|
|
2755
2798
|
| <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` |
|
|
2756
|
-
| <a id="CHECK_BREATH_VISIBLE"></a>`CHECK_BREATH_VISIBLE` | the torso (`topwear
|
|
2799
|
+
| <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) |
|
|
2757
2800
|
| <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 |
|
|
2758
2801
|
| <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) |
|
|
2759
2802
|
| <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 |
|
|
@@ -2927,7 +2970,7 @@ the two examples [observed]:
|
|
|
2927
2970
|
|
|
2928
2971
|
| line | measures | bar | `reference-demo` | `reference-sample` | SKIP when |
|
|
2929
2972
|
| --- | --- | --- | --- | --- | --- |
|
|
2930
|
-
| <a id="BREATH_VISIBLE"></a>`BREATH_VISIBLE` | `topwear` parts rendered alone (`rigc render --slot`)
|
|
2973
|
+
| <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 |
|
|
2931
2974
|
| <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 |
|
|
2932
2975
|
| ″ (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 |
|
|
2933
2976
|
| <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
|
@@ -112,7 +112,7 @@ The fields, object by object (a bold path is where the object sits; `<part>` is
|
|
|
112
112
|
part name, `[i]` an entry of a list):
|
|
113
113
|
|
|
114
114
|
<!-- stable:config -->
|
|
115
|
-
- **config** — required by the full loader, in front of rig and build: `key`, `assemble`, `bones`, `meshes`, `regions`, `motion`; optional: `generation`, `seethrough`, `limbs`, `constraints`, `turn`, `scene`, `cloth`
|
|
115
|
+
- **config** — required by the full loader, in front of rig and build: `key`, `assemble`, `bones`, `meshes`, `regions`, `motion`; optional: `generation`, `seethrough`, `limbs`, `constraints`, `stops`, `turn`, `scene`, `cloth`
|
|
116
116
|
- **generation** — required: `checkpoint`, `loras`, `trigger`, `identity`, `sampler`, `costume`, `negative_extra`, `style`, `negative_pose`, `latent`, `seed`; optional: `pose`, `control`
|
|
117
117
|
- **generation.loras[i]** — required: `name`, `strength`; optional: `strength_clip`
|
|
118
118
|
- **generation.sampler** — required: `steps`, `cfg`, `sampler`, `scheduler`
|
|
@@ -129,6 +129,8 @@ part name, `[i]` an entry of a list):
|
|
|
129
129
|
- **limbs.<limb>.segments[i]** — required: `part`, `from`, `bone`; required below a joint (i > 0): `joint`; optional below a joint: `range`, `cap`, `edge`, `cap_shape`, `cut_band`
|
|
130
130
|
- **bones[i]**, a single bone — required: `name`, `parent`, `at`; optional: `tip`, `inherit`
|
|
131
131
|
- **bones[i]**, a chain — required: `chain`, `parent`, `points`, `tip`
|
|
132
|
+
- **stops[i]** — required: `chain`, `against`, `at`, `inward`, `outward`; optional: `links`, `lower` (issue #404)
|
|
133
|
+
- **stops[i].lower** — required: `inward`, `outward`
|
|
132
134
|
- **meshes.<part>** — exactly one of `grid`, `contour`, `auto`; required in every mode: `r`, `segments`; optional in every mode: `exponent`, `rule`; optional with `contour` or `auto`: `ribs`; optional with `grid` or `contour`: `influences` (issue #284; beside `auto` it is refused, CONFIG_INFLUENCES_MODE); optional with `grid`: `stray` (issue #303; beside `contour` or `auto` it is refused, CONFIG_STRAY_MODE)
|
|
133
135
|
- **meshes.<part>.influences** — optional, at least one: `maxInfluences` (a whole number, 1 or more, or null for no cap), `floor` ("cut" or "continuous")
|
|
134
136
|
- **meshes.<part>.ribs.<chain>** — required: `stations`
|
|
@@ -148,7 +150,7 @@ part name, `[i]` an entry of a list):
|
|
|
148
150
|
- **meshes.<part>.auto.boundaryRuns** — required: `maxVertices`
|
|
149
151
|
- **meshes.<part>.auto.stimulus**, or each entry of it when a list — required: `chain`, `degrees`
|
|
150
152
|
- **cloth.<tag>**, 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
|
-
- **cloth.<tag>.split** — required: `at`, `into`
|
|
153
|
+
- **cloth.<tag>.split** — required: `at`, `into`; optional: `hold_tip`
|
|
152
154
|
- **cloth.<tag>.strength** — required: `trunk`, `branch`, `edge`
|
|
153
155
|
- **cloth.<tag>.swing** — required: `scales`
|
|
154
156
|
- **regions.<part>** — a bone name
|
|
@@ -161,7 +163,7 @@ part name, `[i]` an entry of a list):
|
|
|
161
163
|
- **turn** — required: `pivot`, `depths`
|
|
162
164
|
- **turn.depths.<part>** — a See-through depth
|
|
163
165
|
- **scene** — no field (`{}`; a record or an annotation only)
|
|
164
|
-
- **proposal.json**, the file propose writes — `bones`, `meshes`, `regions`, `limbs` under `--keypoints` where an arm or a leg is drafted from its joints (issue #349), `motion` under the rules above, `turn` with `--full`/`--head`, and `notes`
|
|
166
|
+
- **proposal.json**, the file propose writes — `bones`, `meshes`, `regions`, `limbs` under `--keypoints` where an arm or a leg is drafted from its joints (issue #349), `stops` when supplied, `motion` under the rules above, `turn` with `--full`/`--head`, and `notes`
|
|
165
167
|
<!-- /stable:config -->
|
|
166
168
|
|
|
167
169
|
`TY14` holds the set of field names in backticks above to the set of names the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/parts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.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": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"ag-psd": "^31.0.2",
|
|
64
|
-
"rig-c": "^2.
|
|
64
|
+
"rig-c": "^2.57.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@esotericsoftware/spine-core": "4.3.13",
|
package/src/assemble.ts
CHANGED
|
@@ -104,7 +104,7 @@ import { type Problem, refuseIfAny } from './errors.ts';
|
|
|
104
104
|
import { figuresPhrase, implausibleRules, type Layer, type LayerFigures, layerFigures, type LayerSet, NEAR_WHITE_MIN, OPAQUE_ALPHA_ABOVE, ruleSummary } from './layers.ts';
|
|
105
105
|
import { padToSquare, squarePad } from './inputs.ts';
|
|
106
106
|
import { type CapRecord, type LimbRecord, PAINTING_RUN, type PartRecord, type PartsFile, type RecompositeRecord, type SceneRecord, type SingleRunPad } from './parts.ts';
|
|
107
|
-
import { type BonePlace, bonePlaces, capBox, coveredRadius, type CutPlacement, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, luma601, nearestLimb, pastJoint, placeCut, segmentOf } from './limbs.ts';
|
|
107
|
+
import { assignOverlappingHands, type BonePlace, bonePlaces, capBox, coveredRadius, type CutPlacement, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, luma601, nearestLimb, pastJoint, placeCut, segmentOf } from './limbs.ts';
|
|
108
108
|
import {
|
|
109
109
|
alphaComposite,
|
|
110
110
|
connectedComponents,
|
|
@@ -2054,16 +2054,35 @@ function cutLimbs(
|
|
|
2054
2054
|
placements.set(`${l}/${k}`, placed);
|
|
2055
2055
|
});
|
|
2056
2056
|
}
|
|
2057
|
+
const segOverride = new Int32Array(W * H).fill(-1);
|
|
2058
|
+
const segAt = (l: string, x: number, y: number): number => {
|
|
2059
|
+
const segs = limbs[l].segments;
|
|
2060
|
+
const first = segs.findIndex((sg) => sg.from === src);
|
|
2061
|
+
let last = first;
|
|
2062
|
+
while (last + 1 < segs.length && segs[last + 1].from === src) last++;
|
|
2063
|
+
return segmentOf(cutLines.get(l) as Array<JointLine | null>, first, last, x, y);
|
|
2064
|
+
};
|
|
2065
|
+
// Issue #400: when two forearm segments share `src` and their hand regions overlap, the overlap goes to the front
|
|
2066
|
+
// piece (the limb later in config.limbs) in one piece, and the back piece ends at its cuff.
|
|
2067
|
+
const forearms = on.flatMap((l) => {
|
|
2068
|
+
const li = names.indexOf(l);
|
|
2069
|
+
return limbs[l].segments.flatMap((sg, k) => {
|
|
2070
|
+
if (k === 0 || sg.joint !== 'elbow' || sg.from !== src) return [];
|
|
2071
|
+
const me = places.get(sg.bone) as BonePlace;
|
|
2072
|
+
return me.end === null ? [] : [{ limb: li, seg: k, elbow: me.at, wrist: me.end, isSeg: (x: number, y: number): boolean => segAt(l, x, y) === k }];
|
|
2073
|
+
});
|
|
2074
|
+
});
|
|
2075
|
+
for (let i = 0; i < forearms.length; i++) {
|
|
2076
|
+
for (let j = i + 1; j < forearms.length; j++) {
|
|
2077
|
+
assignOverlappingHands(forearms[i], forearms[j], W, H, own, segOverride);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2057
2080
|
for (let y = 0; y < H; y++) {
|
|
2058
2081
|
for (let x = 0; x < W; x++) {
|
|
2059
2082
|
const p = y * W + x;
|
|
2060
2083
|
if (b.r.data[p * 4 + 3] === 0) continue;
|
|
2061
2084
|
const l = names[own[p]];
|
|
2062
|
-
const
|
|
2063
|
-
const first = segs.findIndex((sg) => sg.from === src);
|
|
2064
|
-
let last = first;
|
|
2065
|
-
while (last + 1 < segs.length && segs[last + 1].from === src) last++;
|
|
2066
|
-
const k = segmentOf(cutLines.get(l) as Array<JointLine | null>, first, last, x, y);
|
|
2085
|
+
const k = segOverride[p] >= 0 ? segOverride[p] : segAt(l, x, y);
|
|
2067
2086
|
const at = parts.findIndex((q) => q.limb === l && q.segment === k);
|
|
2068
2087
|
rasters[at].data.set(b.r.data.subarray(p * 4, p * 4 + 4), p * 4);
|
|
2069
2088
|
if (b.region === null || b.region.data[p] === 1) regions[at].data[p] = 1;
|
package/src/automesh.ts
CHANGED
|
@@ -212,6 +212,7 @@ export function sourceWeights(
|
|
|
212
212
|
spec: AutoSpec,
|
|
213
213
|
exponent: number = DISTANCE_EXPONENT,
|
|
214
214
|
heat: HeatField | null = null,
|
|
215
|
+
segsAt: (wy: number) => readonly Segment[] = () => segs,
|
|
215
216
|
): { weights: Influence[][]; local: LocalInfluence[] } | { overlap: RegionOverlap; vertex: number; at: Point } {
|
|
216
217
|
const all = spec.regions ?? [];
|
|
217
218
|
const index: number[] = [];
|
|
@@ -225,7 +226,7 @@ export function sourceWeights(
|
|
|
225
226
|
const local: LocalInfluence[] = [];
|
|
226
227
|
for (let v = 0; v < vertices.length; v++) {
|
|
227
228
|
const at: Point = [vertices[v][0] + ox, vertices[v][1] + oy];
|
|
228
|
-
const li = localInfluences(at,
|
|
229
|
+
const li = localInfluences(at, segsAt(at[1]), r, regions, spec.influences, exponent, heat === null ? undefined : heatInfluences(heat, [vertices[v][0], vertices[v][1]], spec.influences));
|
|
229
230
|
if ('first' in li) return { overlap: { ...li, first: index[li.first], second: index[li.second] }, vertex: v, at };
|
|
230
231
|
weights.push(li.influences.map((e) => ({ bone: e.bone, weight: e.weight })));
|
|
231
232
|
local.push(li.region < 0 ? li : { ...li, region: index[li.region] });
|
package/src/check.ts
CHANGED
|
@@ -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,
|
|
@@ -154,7 +155,8 @@ import {
|
|
|
154
155
|
type SeamPair,
|
|
155
156
|
stretchRequirementLine,
|
|
156
157
|
} from './requirements.ts';
|
|
157
|
-
import { RIG_BONE_INHERIT } from 'rig-c/src/rig.ts';
|
|
158
|
+
import { RIG_BONE_INHERIT, type RigSpec as RigcRigSpec } from 'rig-c/src/rig.ts';
|
|
159
|
+
import { expandStops } from 'rig-c/src/stop.ts';
|
|
158
160
|
import { alphaComposite } from './raster/composite.ts';
|
|
159
161
|
import { readPng, writePng } from './raster/png.ts';
|
|
160
162
|
import { newFloatImage, newRaster, type Raster } from './raster/types.ts';
|
|
@@ -1067,9 +1069,11 @@ export function withoutPhysics(rig: Record<string, unknown>, motion: Record<stri
|
|
|
1067
1069
|
const table = isRecord(motion.physics) ? motion.physics : null;
|
|
1068
1070
|
if (table !== null) for (const [name, e] of Object.entries(table)) physics.push({ name, bone: isRecord(e) ? String(e.bone) : '', in: 'motion.json' });
|
|
1069
1071
|
if (physics.length === 0) return null;
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
|
|
1072
|
+
const expanded = Array.isArray(rig.stops) ? (expandStops(rig as unknown as RigcRigSpec, 'rig.json') as unknown as Record<string, unknown>) : rig;
|
|
1073
|
+
const r: Record<string, unknown> = { ...expanded };
|
|
1074
|
+
delete r.stops;
|
|
1075
|
+
if (Array.isArray(r.constraints)) {
|
|
1076
|
+
const kept = r.constraints.filter((c) => !(isRecord(c) && c.type === 'physics'));
|
|
1073
1077
|
if (kept.length > 0) r.constraints = kept;
|
|
1074
1078
|
else delete r.constraints;
|
|
1075
1079
|
}
|
|
@@ -3133,13 +3137,40 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
3133
3137
|
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
3138
|
return readFrameSet(dir);
|
|
3135
3139
|
};
|
|
3140
|
+
// Issue #411: the breath alone — a throwaway copy of the build carrying, beside every animation, the idle with its
|
|
3141
|
+
// breath tracks held at rest; the torso rendered alone in both idles, from that one build, so the two share a grid.
|
|
3142
|
+
const breathPair = (ps: readonly PartRecord[]): BreathPair | null => {
|
|
3143
|
+
const tracks = breathTracks(inp.motion);
|
|
3144
|
+
if (tracks.length === 0) return null;
|
|
3145
|
+
const dir = join(isoDir, BREATH_SCRATCH);
|
|
3146
|
+
const anims = isRecord(inp.motion.animations) ? inp.motion.animations : {};
|
|
3147
|
+
const idleAnim = isRecord(anims.idle) ? anims.idle : {};
|
|
3148
|
+
let name = BREATH_ANIMATION;
|
|
3149
|
+
while (name in anims) name = `${name}_`;
|
|
3150
|
+
// Each breath track held at rest over its own span: the idle without the breath, still keyed to its end, which rigc
|
|
3151
|
+
// requires of an animation's last key.
|
|
3152
|
+
const kept = (Array.isArray(idleAnim.tracks) ? idleAnim.tracks : []).map((t) => (isRecord(t) && isBreathTrack(t, tracks) ? heldTrack(t) : t));
|
|
3153
|
+
mkdirSync(dir, { recursive: true });
|
|
3154
|
+
const images = typeof inp.rig.images === 'string' ? resolve(inp.rigDir, inp.rig.images) : inp.rig.images;
|
|
3155
|
+
writeFileSync(join(dir, 'rig.json'), JSON.stringify({ ...inp.rig, images }));
|
|
3156
|
+
writeFileSync(join(dir, 'motion.json'), JSON.stringify({ ...inp.motion, animations: { ...anims, [name]: { ...idleAnim, tracks: kept } } }));
|
|
3157
|
+
const b = rigc(['build', '--rig', join(dir, 'rig.json'), '--motion', join(dir, 'motion.json'), '--out', join(dir, 'build'), ...packedBuildArgs(mode)]);
|
|
3158
|
+
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)));
|
|
3159
|
+
const slots = ps.map((p) => p.name).join(',');
|
|
3160
|
+
const render = (animation: string, label: string): FrameSet => {
|
|
3161
|
+
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)]);
|
|
3162
|
+
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:'))));
|
|
3163
|
+
return readFrameSet(join(dir, label));
|
|
3164
|
+
};
|
|
3165
|
+
return { with: render('idle', 'with'), without: render(name, 'without'), tracks: tracks.map((t) => `${t.bone} ${t.property}`) };
|
|
3166
|
+
};
|
|
3136
3167
|
// Issue #231: the footwear parts the scene file declares not planted; none without --requirements or the field.
|
|
3137
3168
|
const notPlanted = reqFile === null ? [] : reqFile.not_planted;
|
|
3138
3169
|
let breath: JudgementLine = skip(lacking);
|
|
3139
3170
|
let tip: JudgementLine = skip(lacking);
|
|
3140
3171
|
if (full !== null) {
|
|
3141
3172
|
try {
|
|
3142
|
-
breath = breathLine(full, isolated, problems, notPlanted);
|
|
3173
|
+
breath = breathLine(full, isolated, breathPair, problems, notPlanted);
|
|
3143
3174
|
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
3175
|
} finally {
|
|
3145
3176
|
rmSync(isoDir, { recursive: true, force: true });
|
|
@@ -3701,33 +3732,32 @@ function noneHeldText(declared: readonly string[]): string {
|
|
|
3701
3732
|
* `SKIP` with its reason — so a half nobody read never passes by being silent.
|
|
3702
3733
|
* With neither, the line is the SKIP it was. A run that measured both halves
|
|
3703
3734
|
* writes the keys it always wrote.
|
|
3735
|
+
*
|
|
3736
|
+
* Issue #411: the torso half reads the breath alone ({@link torsoBreath}):
|
|
3737
|
+
* `torso_heat_mean` is the heat the breath makes, the idle rendered with and
|
|
3738
|
+
* without its breath tracks, on the same box and against the same floor.
|
|
3739
|
+
* Until #411 it was the whole idle's heat over the box, so a keyed cloth swing
|
|
3740
|
+
* or a physics response to the world inside the torso's box passed the bar
|
|
3741
|
+
* for a torso that did not breathe.
|
|
3704
3742
|
*/
|
|
3705
|
-
function breathLine(inp: FullInputs, isolated: Isolate, problems: Problem[], notPlanted: readonly string[] = []): JudgementLine {
|
|
3743
|
+
function breathLine(inp: FullInputs, isolated: Isolate, pair: BreathPairRender, problems: Problem[], notPlanted: readonly string[] = []): JudgementLine {
|
|
3706
3744
|
const torso = partsTagged(inp.parts, TORSO_TAGS);
|
|
3707
3745
|
const { all: allFeet, held: feet, declared } = plantedFeet(inp.parts, notPlanted);
|
|
3708
3746
|
const noTorso = `no part comes from a See-through ${tagWords(TORSO_TAGS)} layer, so there is no torso to see breathe`;
|
|
3709
3747
|
const noFeet = `no part comes from a See-through ${tagWords(FEET_TAGS)} layer, so there are no feet to hold still`;
|
|
3710
3748
|
// Issue #323: a figure without one of the two halves still has the other read; with neither, the SKIP it always was.
|
|
3711
3749
|
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, []);
|
|
3750
|
+
if (torso.length === 0) return oneHalf(inp, isolated, pair, problems, 'feet', feet, noTorso, declared);
|
|
3751
|
+
if (allFeet.length === 0) return oneHalf(inp, isolated, pair, problems, 'torso', torso, noFeet, []);
|
|
3714
3752
|
const H = inp.parts.rig_size[1];
|
|
3715
|
-
const
|
|
3753
|
+
const tr = torsoBreath(inp, torso, pair);
|
|
3716
3754
|
const fs = feet.length === 0 ? null : isolated('feet', feet);
|
|
3717
|
-
const tb = frameBox(torso, H, inp.stage, ts.viewport);
|
|
3718
3755
|
const fb = fs === null ? null : frameBox(feet, H, inp.stage, fs.viewport);
|
|
3719
|
-
if (
|
|
3720
|
-
const th = regionHeat(heatField(ts.frames.map((f) => f.image)), ts.viewport.pixelWidth, tb);
|
|
3756
|
+
if ('skip' in tr || (fs !== null && fb === null)) return skip(`the ${'skip' in tr ? 'torso' : 'feet'} box falls outside the idle frame`);
|
|
3721
3757
|
const fh = fs === null || fb === null ? null : regionHeat(heatField(fs.frames.map((f) => f.image)), fs.viewport.pixelWidth, fb);
|
|
3722
|
-
const mean =
|
|
3758
|
+
const mean = tr.mean;
|
|
3723
3759
|
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
|
-
}
|
|
3760
|
+
if (mean < BREATH_TORSO_MEAN_FLOOR) problems.push(torsoProblem(torso, tr, ''));
|
|
3731
3761
|
if (fh !== null && fb !== null && fh.max > BREATH_FEET_MAX_CEILING) {
|
|
3732
3762
|
problems.push({
|
|
3733
3763
|
code: 'CHECK_BREATH_VISIBLE',
|
|
@@ -3755,22 +3785,15 @@ function breathLine(inp: FullInputs, isolated: Isolate, problems: Problem[], not
|
|
|
3755
3785
|
* `halves_measured`, says `1 of 2` — after `declared_not_planted` when the scene
|
|
3756
3786
|
* file declares some of the feet read (issue #231), which stays the first.
|
|
3757
3787
|
*/
|
|
3758
|
-
function oneHalf(inp: FullInputs, isolated: Isolate, problems: Problem[], half: 'torso' | 'feet', ps: readonly PartRecord[], reason: string, declared: readonly string[]): JudgementLine {
|
|
3788
|
+
function oneHalf(inp: FullInputs, isolated: Isolate, pair: BreathPairRender, problems: Problem[], half: 'torso' | 'feet', ps: readonly PartRecord[], reason: string, declared: readonly string[]): JudgementLine {
|
|
3759
3789
|
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
3790
|
if (half === 'torso') {
|
|
3765
|
-
|
|
3791
|
+
// Issue #411: the torso half is the breath alone.
|
|
3792
|
+
const tr = torsoBreath(inp, ps, pair);
|
|
3793
|
+
if ('skip' in tr) return skip(`the ${half} box falls outside the idle frame, and ${reason}`);
|
|
3794
|
+
const mean = tr.mean;
|
|
3766
3795
|
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
|
-
}
|
|
3796
|
+
if (!ok) problems.push(torsoProblem(ps, tr, `; the feet half not measured: ${reason}`));
|
|
3774
3797
|
return {
|
|
3775
3798
|
status: ok ? 'PASS' : 'FAIL',
|
|
3776
3799
|
halves_measured: '1 of 2',
|
|
@@ -3782,6 +3805,10 @@ function oneHalf(inp: FullInputs, isolated: Isolate, problems: Problem[], half:
|
|
|
3782
3805
|
feet_reason: reason,
|
|
3783
3806
|
};
|
|
3784
3807
|
}
|
|
3808
|
+
const fs = isolated(half, ps);
|
|
3809
|
+
const box = frameBox(ps, H, inp.stage, fs.viewport);
|
|
3810
|
+
if (box === null) return skip(`the ${half} box falls outside the idle frame, and ${reason}`);
|
|
3811
|
+
const heat = regionHeat(heatField(fs.frames.map((f) => f.image)), fs.viewport.pixelWidth, box);
|
|
3785
3812
|
const ok = heat.max <= BREATH_FEET_MAX_CEILING;
|
|
3786
3813
|
if (!ok) {
|
|
3787
3814
|
problems.push({
|
|
@@ -3803,6 +3830,130 @@ function oneHalf(inp: FullInputs, isolated: Isolate, problems: Problem[], half:
|
|
|
3803
3830
|
};
|
|
3804
3831
|
}
|
|
3805
3832
|
|
|
3833
|
+
/** 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. */
|
|
3834
|
+
export const BREATH_ANIMATION = 'idle_without_breath';
|
|
3835
|
+
/** Where BREATH_VISIBLE's copy is built and rendered, under the stage's scratch; removed before the stage returns. */
|
|
3836
|
+
const BREATH_SCRATCH = 'breath';
|
|
3837
|
+
|
|
3838
|
+
/** 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). */
|
|
3839
|
+
const BREATH_TRACK_PROPS: readonly string[] = ['translate', 'translatex', 'translatey', 'scale', 'scalex', 'scaley'];
|
|
3840
|
+
|
|
3841
|
+
/**
|
|
3842
|
+
* The breath's tracks (issue #411), in the idle's order: the breath bones are
|
|
3843
|
+
* every bone an idle track translates ({@link BREATH_PROPS}, issue #262), and
|
|
3844
|
+
* their breath tracks every idle track that translates or scales one of them
|
|
3845
|
+
* ({@link BREATH_TRACK_PROPS}). A track that turns a breath bone, a group's
|
|
3846
|
+
* track and every track on another bone are not the breath. Empty when no
|
|
3847
|
+
* idle track translates a bone.
|
|
3848
|
+
*/
|
|
3849
|
+
export function breathTracks(motion: Record<string, unknown>): Array<{ bone: string; property: string }> {
|
|
3850
|
+
const anims = isRecord(motion.animations) ? motion.animations : {};
|
|
3851
|
+
const idle = isRecord(anims.idle) ? anims.idle : {};
|
|
3852
|
+
const tracks = (Array.isArray(idle.tracks) ? idle.tracks : []).filter(isRecord).filter((t) => typeof t.bone === 'string' && typeof t.property === 'string');
|
|
3853
|
+
const bones = new Set(tracks.filter((t) => BREATH_PROPS.includes(String(t.property))).map((t) => String(t.bone)));
|
|
3854
|
+
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) }));
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3857
|
+
/**
|
|
3858
|
+
* A breath track held at rest (issue #411): the setup pose's value — 0 for a translate, 1 for a scale, one per axis
|
|
3859
|
+
* the track's first key gives — at its first and last key times, no curve. That is the track removed, as the bone
|
|
3860
|
+
* stands without it, while the idle stays keyed to its end: a dropped track could leave the idle's last key before
|
|
3861
|
+
* its duration, which rigc refuses. (Held at its first key instead, the bone would stand offset from frame 0 on and
|
|
3862
|
+
* the physics under it would answer that start, which is not the idle without its breath.)
|
|
3863
|
+
*/
|
|
3864
|
+
function heldTrack(t: Record<string, unknown>): Record<string, unknown> {
|
|
3865
|
+
const keys = (Array.isArray(t.keys) ? t.keys : []).filter(isRecord);
|
|
3866
|
+
if (keys.length === 0) return t;
|
|
3867
|
+
const first = keys[0];
|
|
3868
|
+
const last = keys[keys.length - 1];
|
|
3869
|
+
const rest = String(t.property).startsWith('scale') ? 1 : 0;
|
|
3870
|
+
const v = (Array.isArray(first.v) ? first.v : [first.v]).map(() => rest);
|
|
3871
|
+
return { ...t, keys: keys.length === 1 ? [{ t: first.t, v }] : [{ t: first.t, v }, { t: last.t, v }] };
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
function isBreathTrack(t: Record<string, unknown>, tracks: ReadonlyArray<{ bone: string; property: string }>): boolean {
|
|
3875
|
+
return tracks.some((b) => b.bone === t.bone && b.property === t.property);
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
/** 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`. */
|
|
3879
|
+
export interface BreathPair {
|
|
3880
|
+
with: FrameSet;
|
|
3881
|
+
without: FrameSet;
|
|
3882
|
+
tracks: string[];
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3885
|
+
/** Renders {@link BreathPair} for the torso parts; null when the idle has no breath track. */
|
|
3886
|
+
export type BreathPairRender = (ps: readonly PartRecord[]) => BreathPair | null;
|
|
3887
|
+
|
|
3888
|
+
/**
|
|
3889
|
+
* Why the two renders of a {@link BreathPair} cannot be compared pixel for
|
|
3890
|
+
* pixel, or null when they can: one grid (the viewport), one background, the
|
|
3891
|
+
* same number of frames, each of one size. Both come from one build, so a
|
|
3892
|
+
* difference is rigc's, refused by name (`CHECK_BREATH_VISIBLE`) rather than
|
|
3893
|
+
* read.
|
|
3894
|
+
*/
|
|
3895
|
+
export function breathPairProblem(pair: BreathPair): Problem | null {
|
|
3896
|
+
const a = pair.with;
|
|
3897
|
+
const b = pair.without;
|
|
3898
|
+
const size = (s: FrameSet): string => [...new Set(s.frames.map((f) => `${f.image.width}x${f.image.height}`))].join(',');
|
|
3899
|
+
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;
|
|
3900
|
+
return {
|
|
3901
|
+
code: 'CHECK_BREATH_VISIBLE',
|
|
3902
|
+
object: `the torso's two idle renders (with and without the breath tracks ${pair.tracks.join(', ')})`,
|
|
3903
|
+
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`,
|
|
3904
|
+
};
|
|
3905
|
+
}
|
|
3906
|
+
|
|
3907
|
+
/** 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. */
|
|
3908
|
+
type TorsoBreath = { box: PixelBox; mean: number; whole: number; tracks: string[] } | { none: string; mean: number } | { skip: true };
|
|
3909
|
+
|
|
3910
|
+
/**
|
|
3911
|
+
* `BREATH_VISIBLE`'s torso half (issue #411): the breath alone. The breath
|
|
3912
|
+
* bones are every bone an idle track translates, and the breath tracks every
|
|
3913
|
+
* idle track that translates or scales one of them ({@link breathTracks}).
|
|
3914
|
+
* The torso is rendered alone, idle at its rate and size, from one throwaway
|
|
3915
|
+
* build carrying every animation of the rig and, beside them, the idle with
|
|
3916
|
+
* its breath tracks held at rest ({@link heldTrack}: the bone as it stands
|
|
3917
|
+
* without them, the idle still keyed to its end) — so both renders share a
|
|
3918
|
+
* grid. Per pixel, the largest
|
|
3919
|
+
* |(with_t - with_0) - (without_t - without_0)| over the frames and the RGB
|
|
3920
|
+
* channels ({@link breathHeat}), meaned over the torso's frame box. Motion that
|
|
3921
|
+
* is not the breath's — a keyed cloth swing, physics answering the world, a
|
|
3922
|
+
* head turn — is in both renders and cancels; physics the breath sets moving
|
|
3923
|
+
* is counted. The whole idle's heat over the same box, the reading until #411,
|
|
3924
|
+
* is carried for the refusal's sentence only.
|
|
3925
|
+
*
|
|
3926
|
+
* With no breath track the figure is 0, by the definition (the idle with and
|
|
3927
|
+
* without its breath is one idle), and the bar fails naming why: a torso with
|
|
3928
|
+
* no breath is what the bar exists to find, so it is not a SKIP; nothing is
|
|
3929
|
+
* rendered.
|
|
3930
|
+
*/
|
|
3931
|
+
function torsoBreath(inp: FullInputs, ps: readonly PartRecord[], pair: BreathPairRender): TorsoBreath {
|
|
3932
|
+
const got = pair(ps);
|
|
3933
|
+
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 };
|
|
3934
|
+
const grid = breathPairProblem(got);
|
|
3935
|
+
if (grid !== null) refuseIfAny([grid]);
|
|
3936
|
+
const box = frameBox(ps, inp.parts.rig_size[1], inp.stage, got.with.viewport);
|
|
3937
|
+
if (box === null) return { skip: true };
|
|
3938
|
+
const width = got.with.viewport.pixelWidth;
|
|
3939
|
+
const withFrames = got.with.frames.map((f) => f.image);
|
|
3940
|
+
const mean = round3(regionHeat(breathHeat(withFrames, got.without.frames.map((f) => f.image)), width, box).mean);
|
|
3941
|
+
const whole = round3(regionHeat(heatField(withFrames), width, box).mean);
|
|
3942
|
+
return { box, mean, whole, tracks: got.tracks };
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
/** The torso half's refusal (issue #411): the breath's figure, the tracks it was read from, and the whole idle's beside it. */
|
|
3946
|
+
function torsoProblem(ps: readonly PartRecord[], tr: Exclude<TorsoBreath, { skip: true }>, tail: string): Problem {
|
|
3947
|
+
if ('none' in tr) {
|
|
3948
|
+
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)` };
|
|
3949
|
+
}
|
|
3950
|
+
return {
|
|
3951
|
+
code: 'CHECK_BREATH_VISIBLE',
|
|
3952
|
+
object: `torso ${quoteParts(ps)} rendered alone, frame box ${boxLabel(tr.box)}${tail}`,
|
|
3953
|
+
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`,
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3806
3957
|
/** The scene file's exceptions to `TIP_OVER_ROOT` (issues #231, #245), and the file they were read from, which a refusal names. */
|
|
3807
3958
|
export interface TipExceptions {
|
|
3808
3959
|
path: string;
|