@rig-c/parts 1.40.0 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/AUTHORING.md CHANGED
@@ -113,6 +113,7 @@ read by no CPU stage).
113
113
  | `limbs` | assemble (the cut and the caps), rig (through `regions`), check (`LIMB_ONE_BONE`) | **proposed** by `propose --keypoints` (issue #349), then checked: `{<limb>: {segments: [{part, from, bone}, {part, from, bone, joint, range?, cap?, edge?, cap_shape?, cut_band?}, …]}}`, the upper segment first. The rule is *Limbs: cut at their joints* below the table. `part` is a new part (`CONFIG_PART_NAME`, `CONFIG_PART_UNIQUE` against the plan, patches, cuts and every other limb part); `from` a plan part or a cut's piece (`CONFIG_NAME_RESOLVES`) — the layer the segment's pixels come from, which is cut into the limb parts and is not itself made: a `meshes` or `regions` entry for it is `CONFIG_NAME_RESOLVES`, and the segments of one limb that take one part are consecutive (`CONFIG_LIMB_FROM_RUN`); `bone` a declared bone, each segment's the child of the one before (`CONFIG_LIMB_BONES_CHAIN`); the upper segment names no `joint`, `range`, `cap`, `edge`, `cap_shape` or `cut_band` (`CONFIG_KEY_KNOWN`), every other names its `joint` (`CONFIG_FIELD_PRESENT`) — the joint is its bone's origin; `range` is `[min, max]` degrees from rest with `min <= 0 <= max` (`CONFIG_LIMB_RANGE`), which `assemble` writes into the lower part's `parts.json` record and `check` poses the joint at — its two ends and its middle — reading the seam there (`SEAM_OVER_RANGE`, issue #360; rig-c needs no rotation limit); `cap` a PNG path relative to the config's directory (`CONFIG_FIELD_TYPE`); `edge` `"feather"` and `cap_shape` `"disc"` (issue #360), each the one value its field takes (`CONFIG_FIELD_TYPE` on any other) — the cut's geometry at that joint, *Limbs: cut at their joints* below; absent, the cut is hard and the cap the layer's half-disc of half the limb's width; `cut_band` a whole number of px, 1 or more (`CONFIG_FIELD_TYPE`), on a segment that takes the segment above's part — between two layers nothing is cut, so a band there is `CONFIG_KEY_KNOWN` — places the cut within that many px of the joint line (issue #360, *Limbs: cut at their joints*); absent, the cut is the joint line. Each limb part is attached like any part — `regions.<part>`, which must be the segment's `bone` (`CONFIG_LIMB_BONE`), or a mesh, which `check` holds to that bone alone (`LIMB_ONE_BONE`). With `limbs`, `assemble` reads `bones` too (`CONFIG_FIELD_PRESENT` without it). Absent, nothing is cut at a joint and no byte of any output moves |
114
114
  | `bones` | rig; `propose --from-config` | **proposed** by `propose`, then corrected. A single bone `{name, parent, at, tip?}` or a chain `{chain, parent, points, tip, link_inherit?}` whose links are named `<chain>0 … <chain>n`. Parents come before children. In `rig.json` each link is **turned along its chain** — `rotation` is the direction from its origin to the next link's (the last link's to `tip`) and `length` that distance (issue #73), so a physics constraint added downstream finds a lever; under `--idle-keys ctl` the link's `<link>_ctl` carries the turn and the length and the link sits at local rotation 0 beneath it. A single bone with a `tip` is turned the same way, towards its tip, with that distance as its length (issue #239); a tip on the bone's own origin is refused (`RIG_TIP_DISTINCT`). The five face bones `eye_r`, `eye_l`, `brow_r`, `brow_l` and `mouth` (by name, when one has no tip of its own) are turned to the eye line — the line through the origins of `eye_r` and `eye_l` as `bones` writes them, read image-left to image-right, drawn when parts.json holds both an `eyewhite-r` and an `eyewhite-l` part — so the blink's `scaley` squashes across the eye line on a tilted head; move an eye bone and the line moves with it. With one eyewhite or none, or an eye bone missing, the rig stage's `face axis:` line says so and they keep the page's axes. A bone under a face bone keeps the face's axis. With the line, `rig.json` also declares `invariants.axes` — one entry, `"face"`, through `eye_r` and `eye_l`, holding the turned face bones (and their controls) — so rig-c's gate holds the build to the line; the line is the one rigc draws through the same two bones, so the tolerance is only the float floor — the largest gap the emitted (float32) bones have to it, rounded up to 6 places plus one 6-place unit — and the `face axis:` line prints it. With the line the rig stage also adds `head_up` (issue #250): a slotless bone under `head`, at head's origin, turned to the eye line + 90 degrees and as long as the eye midpoint lies from head's origin along that axis — the head's frame, which a rule that needs it reads; `head` keeps its own frame, so no key on it or under it changes meaning, and a config bone of that name is refused (`RIG_HEAD_UP_NAME_FREE`). A face bone with its own `tip` is held too (issue #258), in a second entry, `"face_tips"`, when its tip lies along the line within whole-pixel rounding — a tip written in whole pixels sits at most sqrt(2)/2 px off the point of the line it stands for, so its direction may sit up to asin((sqrt(2)/2) / length) degrees off — with its tolerance measured the same way; a tip further off is the bone's own axis, and the `face axis:` line names it with its gap and that bound. A failure is rig-c's `A51_BONES_LIE_ALONG_THEIR_DECLARED_AXIS` line, which names the bone and the fix (rig-c's `docs/AUTHORING.md` §3.7 and §5.2); with no line no entry is written and A51 reports SKIP. Every region on a turned bone is turned back, so the setup pose does not move. Any other single bone keeps world rotation 0; one whose parent is a link is turned back upright. A single bone may declare `inherit` (issue #348): what it takes from its parent's transform, one of rig-c's own mode names exactly as rig-c's table spells them — `normal`, `onlyTranslation`, `noRotationOrReflection`, `noScale`, `noScaleOrReflection` (rig-c's `RigBone.inherit`) — written to that bone in `rig.json` as declared; any other spelling, `"NoScale"` included (the runtime would fold its first letter; nothing here folds or maps), is refused (`CONFIG_BONE_INHERIT`), and a chain takes no `inherit` (`CONFIG_KEY_KNOWN`). A chain may instead declare `link_inherit` (issue #369), an object mapping its own expanded link names to those same modes, for example `"link_inherit": {"leg_r1": "noScale"}`. Only the named link changes; omitted links inherit normally. A key outside this chain is `CONFIG_NAME_RESOLVES`, with this chain's valid link names in the detail; a non-object or non-string mode is `CONFIG_FIELD_TYPE`, and another mode spelling is `CONFIG_BONE_INHERIT`. The mode is forwarded to the expanded link, or to its control under `--idle-keys ctl`, by the same rule as a single bone. This is an authored opt-in: `propose` does not add it. Its setup rotation is the turn from where rig-c's own poser puts the bone with no rotation of its own under that mode, so it still stands upright (or along its tip) at the setup pose. Where the idle gives the bone a `<bone>_ctl`, the mode goes on the control: the control is the bone the parent's rotation reaches, and the bone under it inherits normally, so the idle's keys moved onto the control still turn it. A foot that does not take its shin's rotation (`noRotationOrReflection` or `onlyTranslation`) keeps its shoe level while the leg is posed (`FEET_STAY_LEVEL`, §7); which mode is the author's. `noScale` keeps a shin or shoe's shape under a scaled parent but still takes the parent's rotation: a shoe that must also stay level needs a separate rotation constraint, for example a transform constraint from an unrotated bone. This does not change the proposed feet's existing inheritance or `FEET_STAY_LEVEL` default. An automatic mesh weighted through a bone with a mode other than `normal` gets no derived amplitude (its row names the bone) and no residual envelope (rig-c's `SKINNING_RANGE_UNSUPPORTED`). Absent, `rig.json` carries no `inherit` and no byte moves |
115
115
  | `meshes.<part>` | rig | **proposed**, then corrected. Exactly one of `grid` (the lattice: cell size, px — what `propose` writes: by default one spacing for the figure, round(H / 37) rig px with H the height of every part's box together, a part whose tenth of its short side is already coarser keeping that, and under `propose --grid-rule part` the reference's tenth of the part's short side clamped to 5..36, issue #265), `contour` (the outline mode, authored; the next row and "A contour mesh" below) or `auto` (the automatic mode, authored; "An automatic mesh" below) — two, or none, is `CONFIG_MESH_MODE`. In every mode: `r` (added to every distance before weighting: `w = 1/(d + r)²`), `segments` (a chain name, a bone name with a `tip`, or `[bone, [x0,y0], [x1,y1]]`), and, **authored**, optional, `exponent` (issue #161): a number above 0 that replaces the 2 in that rule, `w = 1/(d + r)^exponent` — a larger one hands each vertex more fully to its nearest bone; absent is 2 and changes no byte, a value that is not a number above 0 is `CONFIG_FIELD_TYPE` at `meshes.<part>.exponent`, and a declared one is echoed as `exponent` in the mesh's `mesh_report.json` row; the exponent is the distance rule's, so declared beside `rule: "heat"` it is refused (`CONFIG_FIELD_TYPE` at `meshes.<part>.exponent`). The segment list is the one authored decision about a layer: which bones may pull it. The slot's bone is the first segment's. Optional `rule` (issue #161): `"distance"` — the rule above, and what an absent `rule` means (every byte is the same) — or `"heat"`, bone heat over the part's own silhouette, in every mode: the lattice's art (alpha above 8, less any island a declared `stray` left out) with holes filled, or for `contour` and `auto` the silhouette their outline is traced from (that mode's art — alpha above 8 for `contour`, alpha 1 and above for `auto` — less any island a declared `stray` left out, holes filled, grown by its `margin`); each bound bone's sources are the silhouette pixels whose centre lies within 0.75 px of its segment (a pixel two bones reach goes to the nearer, a tie to the first listed), held at 1 for that bone and 0 for the others; the field is solved by row-major Gauss–Seidel over-relaxation to a sweep change under 1e-7 within 20000 sweeps; a vertex reads the nearest silhouette pixel and takes the same cap and floor (and `regions`) as the distance rule; `r` is not read. The mesh's `mesh_report.json` row gains `heat` (the constants, each bone's sources and sweeps, the residual). Any other value is `CONFIG_FIELD_TYPE`; a bound bone with no source pixel is `RIG_HEAT_BONE_SOURCE`, an island no bone has a source in `RIG_HEAT_ISLAND_SOURCE`, a solve past its sweep bound `RIG_HEAT_CONVERGED` — none is weighted 0. The rule is chosen per mesh, so `RIG_HEAT_BONE_SOURCE` names three remedies: move the segment onto the art, take the bone out of `segments`, or keep this part on the distance rule — the one to take when the bone anchors the part from outside its art (a torso bone under a neck), since the first moves a bone another part placed and the second drops the anchor (issue #303). On a lattice, `RIG_HEAT_ISLAND_SOURCE` on an island that is dust — at most 4 px and at most 0.1 % of the part's art px, `mesh-draft`'s line — names `meshes.<part>.stray` and the figure that leaves it out, with the value declared; an island above that line keeps the segment remedy, a real piece being a real authoring question |
116
+ | `meshes.<part>.influence` | rig | **authored**, optional (issue #378), a mode beside `grid`, `contour` and `auto`: `{cell, radius, across, max, shape}`, every field required, none defaulted. rig-c's `segments` lattice over the part at `cell` px, each vertex pulled by every link of the mesh's `segments` within `radius` px of it — a pull that falls to exactly 0 at `radius` (`shape` `"linear"` or `"smooth"`), across the `segments` entries or only within the nearest one (`across`), the strongest `max` kept. The lattice and the shares are computed by rig-c's own promised functions (`buildSegmentsLattice`, `segmentDistance`, `influenceShares`), so the rule is rig-c's (its AUTHORING §3.4.7), and the mesh is written with explicit weights like every other mode. `radius` is a length on this part: the rig stage measures the farthest lattice vertex's distance to its nearest link and refuses a radius at or under it (`RIG_INFLUENCE_REACH`), naming the distance. `r`, `exponent`, `rule`, `influences`, `stray` and `ribs` belong to the distance rule or another mode and are refused beside it (`CONFIG_INFLUENCE_MODE`). For cloth and hair that should bend as one surface across its chains |
116
117
  | `meshes.<part>.contour` | rig | **authored**, optional (issue #84): `{tolerance, margin, spacing, maxEdge?, budget?, stray?, bridges?, regions?, bust?}`. `tolerance` — rig-c's Douglas–Peucker tolerance on the traced outline, px, 0 or more; `margin` — how far the silhouette grows before it is traced, px: 0, or 1 or more (a pixel joins when its centre lies within `margin` of an art pixel's centre; a value above 0 and below 1 adds nothing and is refused, `CONFIG_FIELD_TYPE`); `spacing` — the background interior spacing, px, above 0; `maxEdge` (issue #265) — the longest outline edge, px, above 0: every simplified edge longer than it is cut into `ceil(length / maxEdge)` equal pieces, each cut point on the 1/256 px grid, before any region or rib touches the outline (absent: nothing is cut, and no byte moves; under 2/256 px the rig stage refuses it, `CONTOUR_PARAMETER`, because two cut points could snap together); the row echoes it in `params` and counts the points it added in `contour.outlineCut`, both only when declared; `budget` — the most vertices the mesh may have (refused above it, nothing thinned); `stray` — the largest island, in art pixels, that may be left out of the mesh (absent: none is); `bridges` (issue #326) — `true`, its one value: islands are read in this order — **dust first** (those `stray` leaves out), **then faint islands** (every pixel's alpha under 64, a quarter of full opacity: left out the same way, their pixels kept in the image but not meshed, so not drawn, and named in the row's `contour.bridges.faint` with their px, brightest alpha and box), **then every visible island is meshed and bridged, whatever the bridge costs** — overdraw is reported, never a reason to drop art; the largest island, or a tie for it, is never left out, faint or not: dropping it would draft the part without its art, and a part whose main body is faint is a question about the layer, which the plan and the author own, not one for the mesh — and the pieces are joined into the one outline rig-c takes by bridges — the kept islands, holes filled, grow together by `margin`, so islands closer than about twice the margin are one grown silhouette, traced as one; each silhouette is traced, simplified, capped, refined and triangulated as a one-island mesh is; then, starting from the silhouette with the most art, the nearest pair of a vertex on the joined outline and one on a silhouette still apart whose quad holds (wound as the mesh, crossing no outline, holding no other vertex, one closed outline after) is joined by that quad, two triangles over no art, until none is apart. Coverage and overshoot read the silhouettes' triangles; a bridge's area is in `meshArea` and in the row's `contour.bridges` (`islands`, `units`, and per join `unit`, `span` — its two crossing edges, px — `area`, `vertices`, `pair`; and `faint`, only when an island was left out as faint), and the row's `params` echoes `bridges`, both only when declared; `art_coverage` counts a faint island's pixels as art not covered. Absent, a second island is refused as below and no byte moves; on one island it writes the mesh the undeclared entry writes. Any other value is `CONFIG_FIELD_TYPE`; beside `ribs` it is `CONTOUR_PARAMETER` (a rib runs across one outline); a join no pair makes is `CONTOUR_BRIDGE`. A bridge stretches with whatever pulls its two ends apart, so it belongs on a part whose pieces ride one bone — the only case `mesh-draft` drafts; `regions` — local deformation regions, each `{name, shape, bone, spacing, band}` with `shape` `"circle"` (`cx, cy, r`) or `"polygon"` (`points`, 3 or more): `bone` is the region's control bone (any bone `bones` declares), `spacing` the interior spacing inside the region and its band, `band` the width the bone's weight falls across. Every length and position is **rig px**, like every other in the config; the part image is the rig less `(x − 4, y − 4)` (its box less the pad), a translation, so a length is the same number in both. A region's `cx`, `cy`, `r`, `band` and `points` are multiples of 1/256 px (`CONFIG_FIELD_TYPE` otherwise); region names are unique per mesh (`CONFIG_REGION_NAME_UNIQUE`). `bust` (issue #475) — `{apex_r, apex_l, cleavage, alpha?: 0.22, clearance?: 3.8, bone_r?: "boob_r", bone_l?: "boob_l", spacing?: 14}`: derives the two circular regions `bust_r` and `bust_l` from the three rig-px landmarks `apex_r`, `apex_l` and `cleavage` (multiples of 1/256 px, `CONFIG_FIELD_TYPE` otherwise; projecting the torso midline `neck → chest → hip` onto `apex_r → apex_l` misses the cleavage by 14–93 px across all five calibrated 3/4-yaw characters, so all three points are required). With `d_s = \|cleavage − apex_s\|` and `D = \|apex_r − apex_l\|`, each side `s ∈ {r, l}` is placed at `cx = apex_s[0]`, `cy = apex_s[1]` with outer radius `R_s = d_s − clearance`, core radius `r_s = round(alpha × R_s)` and `band_s = round(R_s) − r_s` (`alpha` = 0.22, `clearance` = 3.8 px, `spacing` = 14 px, `bone_r` = `"boob_r"`, `bone_l` = `"boob_l"` by default, reproducing the five calibrated example characters within `<= 6 px`, max `\|ΔR\| = 5 px`, max `\|Δr\| = 3 px`). Refused when `clearance <= 0`, `R_r + R_l >= D`, or a derived `r_s` or `band_s` is not positive (`CONFIG_BUST_CLEARANCE`), when `bone_r` or `bone_l` is not declared in `bones` (`CONFIG_NAME_RESOLVES`), or when `contour.regions` also names `bust_r` or `bust_l` (`CONFIG_REGION_NAME_UNIQUE`). Both `propose` and `rig` read `contour.bust` through `contourRegionsOf` (`deriveBustRegions`), and hand-written `contour.regions` entries build byte-identically when `bust` is absent. The alpha threshold is not a field: art is alpha above 8, the lattice's and `check`'s |
117
118
  | `meshes.<part>.ribs` | rig | **authored**, optional (issue #188), in the `contour` and `auto` modes: `{<chain>: {stations}, …}`, each key a chain this mesh's `segments` name. Each link of the chain gets a row of vertices across the part at its origin and at `stations` points evenly between its origin and its end (`stations`, a whole number, 0 or more, required; a chain of L links carries L × (stations + 1) ribs), each rib a row of vertices across the part, kept as a row of locked edges; the rule is "Ribs along a chain" under "A contour mesh". Absent places none and changes no byte. Refused: a lattice mesh with ribs (`CONFIG_RIBS_MODE` — its vertices are its grid's corners), a key that is not one of the mesh's chains (`CONFIG_NAME_RESOLVES`), an object naming no chain or a `stations` that is not a whole number from 0 (`CONFIG_FIELD_TYPE`); at the rig stage `CONTOUR_RIB_ART`, `CONTOUR_RIB_LINK`, `CONTOUR_RIB_CROSSING`, `CONTOUR_RIB_EDGE` (the contour refusals). The mesh's `mesh_report.json` row gains `ribs` — the declaration, the ribs placed and the vertices they hold — and its contour report (the source's, in `auto`) lists each rib's vertices |
118
119
  | `meshes.<part>.influences` | rig | **authored**, optional (issue #284), in the `grid` and `contour` modes: `{maxInfluences?, floor?}`, at least one. `maxInfluences` — the most bones that pull one vertex, a whole number 1 or more, or `null`, no cap (every bone the mesh's `segments` name; `null` is the config's spelling of a bound declared absent, as in `maxOvershoot` and `weightJump`); absent is 4. `floor` — `"cut"` (the capped shares normalised, any under 0.03 dropped, the rest normalised again; what an absent `floor` means) or `"continuous"` (0.03 subtracted from every capped share, those at or below 0 dropped, the rest normalised again, so a bone fades out of a vertex instead of leaving it in one step). Absent, the mesh is weighted at 4 and the cut and every byte is the one written before the field existed; declared, it applies under either `rule`, and is echoed as `influences` in the mesh's `mesh_report.json` row. `propose` never writes it, and `mesh-draft` carries a lattice's declaration to the contour candidate it drafts. A cap that is not a whole number 1 or more or `null` (the string `"none"` included), another `floor`, or an object naming neither is `CONFIG_FIELD_TYPE`; a vertex the declared cut leaves with no bone is `RIG_INFLUENCES_KEPT`; beside `auto` it is `CONFIG_INFLUENCES_MODE` (that mode's cap and floor are `auto.influences`). What each setting trades is "The weight cut" below |
@@ -1278,7 +1279,7 @@ exactly a value rig-c accepts, a field the mode does not have (`CONFIG_FIELD_PRE
1278
1279
 
1279
1280
  | rule | means |
1280
1281
  | --- | --- |
1281
- | <a id="CONFIG_MESH_MODE"></a>`CONFIG_MESH_MODE` | `auto` beside `grid` or `contour`, or no mode at all |
1282
+ | <a id="CONFIG_MESH_MODE"></a>`CONFIG_MESH_MODE` | two of `grid`, `contour`, `auto` and `influence`, or no mode at all |
1282
1283
  | <a id="CONFIG_REGION_NAME_UNIQUE"></a>`CONFIG_REGION_NAME_UNIQUE` | a region named twice in one mesh's `regions` (or `bust_r` / `bust_l` declared in `contour.regions` alongside `contour.bust`) — every one named in one run |
1283
1284
  | <a id="CONFIG_REGION_BAND_NEEDS_BONE"></a><a id="CONFIG_REGION_BONE_NEEDS_BAND"></a>`CONFIG_REGION_BAND_NEEDS_BONE`, `CONFIG_REGION_BONE_NEEDS_BAND` | a region with a `band` and no `bone`, or a `bone` and no `band`: write both for a region that weights its bone, neither for a density-only region (issue #155) |
1284
1285
  | `CONTOUR_*` | the source is refused by the contour mode's own checks at alpha 1 and above — most often `CONTOUR_ONE_ISLAND`: faint pixels the alpha-above-8 modes never saw are islands here |
@@ -2730,6 +2731,7 @@ See-through with another seed.
2730
2731
  | <a id="CONFIG_RIBS_MODE"></a>`CONFIG_RIBS_MODE` | `meshes.<part>.ribs` on a lattice (`grid`) mesh: its vertices are its grid's corners, which no row can move (issue #188) | put the part in `contour` or `auto`, or remove `ribs` |
2731
2732
  | <a id="CONFIG_INFLUENCES_MODE"></a>`CONFIG_INFLUENCES_MODE` | `meshes.<part>.influences` on an automatic (`auto`) mesh: that mode's cap and floor are `auto.influences`, which rig-c's reduction is handed (issue #284) | declare them in `auto.influences`, or remove `influences` |
2732
2733
  | <a id="CONFIG_STRAY_MODE"></a>`CONFIG_STRAY_MODE` | `meshes.<part>.stray` on a contour (`contour`) or automatic (`auto`) mesh: those modes state the largest island they may leave out in `contour.stray` and `auto.source.stray`, which their trace reads (issue #303) | declare it there, or remove `stray` |
2734
+ | <a id="CONFIG_INFLUENCE_MODE"></a>`CONFIG_INFLUENCE_MODE` | `r`, `exponent`, `rule`, `influences`, `stray` or `ribs` beside `meshes.<part>.influence` (issue #378): the field belongs to the distance rule or another mode, and an influence mesh reads none of it | remove the field; the influence block states the reach, the cap and the falloff |
2733
2735
  | <a id="CONFIG_PATCH_BOX"></a>`CONFIG_PATCH_BOX` | an `assemble.patches` box with `x1 <= x0` or `y1 <= y0` | that patch's `box` (`x1`, `y1` are exclusive) |
2734
2736
  | <a id="CONFIG_AMPS_MATCH_CHAIN"></a>`CONFIG_AMPS_MATCH_CHAIN` | a chain track's `amps` is not one per link | that track's `amps` |
2735
2737
  | <a id="CONFIG_PERIOD_DIVIDES_DURATION"></a>`CONFIG_PERIOD_DIVIDES_DURATION` | a period that is not a whole fraction of the idle — the loop could not close | that track's `period`, or `motion.duration` |
@@ -2889,6 +2891,8 @@ says why each requirement exists and what breaks without it.
2889
2891
  | <a id="RIG_BLINK_HOLD_SPANS_A_FRAME"></a>`RIG_BLINK_HOLD_SPANS_A_FRAME` | the tree's `BLINK.hold` is shorter than one frame at `IDLE_FPS`, so for some `motion.blink.t` no idle frame — and no frame of the loop — shows the closed eye; the detail counts the phases that miss and names the first | nothing in the config: `BLINK.hold` in `src/motion.ts`, at least `1/IDLE_FPS` s (§3) |
2890
2892
  | <a id="RIG_STILL_ROW_INSIDE_PART"></a><a id="RIG_STILL_ROW_CLEAR"></a><a id="RIG_STILL_PIECES_HAVE_ART"></a><a id="RIG_STILL_NAME_FREE"></a>`RIG_STILL_ROW_INSIDE_PART`, `RIG_STILL_ROW_CLEAR`, `RIG_STILL_PIECES_HAVE_ART`, `RIG_STILL_NAME_FREE` | a `motion.blink.still` row that is not strictly inside the part, that crosses art (a cut through art changes the render even at rest), that leaves one piece with no art, or whose `<part>_still` slot name another part already has | that entry's `row` — a row with no art between the crease and the lash line — or rename the other part |
2891
2893
  | <a id="RIG_SET_COVERS_BONE"></a>`RIG_SET_COVERS_BONE` | `assemble.alternates[i].drawn.<bone>` (issue #476): a subset set in `parts.json` `alternates` (`parts` present) states a `drawn` world angle for a bone none of its covered slots ride; the detail names the bone, the set, and the covered bones | remove the uncovered bone from that set's `drawn`, or add the part that rides it to `parts` |
2894
+ | <a id="RIG_INFLUENCE_REACH"></a>`RIG_INFLUENCE_REACH` | an influence mesh's `radius` is at or under the distance from its farthest lattice vertex to that vertex's nearest link (issue #378): a link pulls only when it is nearer than `radius`, so that vertex would be pulled by none. The vertex, where it is and the distance are named | a `radius` above the distance named, or a segment nearer that part of the art |
2895
+ | <a id="RIG_INFLUENCE_LATTICE"></a>`RIG_INFLUENCE_LATTICE` | rig-c's segments lattice refused the part at the declared `cell` (no pixel of the part holds art, or the cell is not a whole number of at least 1); rig-c's message is quoted | a part with art, or a whole `cell` of at least 1 |
2892
2896
  | <a id="RIG_RIGC_GREEN"></a>`RIG_RIGC_GREEN` | rig-c refused the rig; its own FAIL or compile-error line is quoted, and nothing was written. A `constraints` field rigc does not read, or a value it refuses, is this line in rigc's words (`constraint "aim" (ik) has a key this compiler does not read: "mixx" (did you mean "mix"?)`), as is `A25_DETACHED_BONE_PARENTAGE` on a declared scene target. So is an ik whose `bones` are more than two, or two of which the second is not the first's child: from rig-c 2.15.0 its rig-spec parser refuses both by name (`ik constraint "reach" names 3 bones …`, `ik constraint "reach": "hem1" is not a child of "body" ("hem0" stands between) …`; firejune/rigc#1205), and this package no longer refuses them itself (issue #103; it did from #92 while rigc's gate passed them). Under `--idle-keys ctl` a two-bone ik over a chain link and its child link is that second refusal too, because the child's `<link>_ctl` stands between them; rigc's remedy names the control, which a config cannot, so when rigc's line says that control alone stands between, the rig stage adds a sentence naming `--idle-keys direct` on the command that ran | the field rigc's line names; for the split pair, `rig --idle-keys direct` or `build --idle-keys direct`, as the line says, which keys the link in place — rig-c's own AUTHORING §5 maps each of its assertions (`node_modules/rig-c/docs/AUTHORING.md`) |
2893
2897
 
2894
2898
  ### mesh-draft
package/docs/STABILITY.md CHANGED
@@ -134,7 +134,8 @@ part name, `[i]` an entry of a list):
134
134
  - **bones[i]**, a chain — required: `chain`, `parent`, `points`, `tip`; optional: `link_inherit`
135
135
  - **stops[i]** — required: `chain`, `against`, `at`, `inward`, `outward`; optional: `links`, `lower` (issue #404)
136
136
  - **stops[i].lower** — required: `inward`, `outward`
137
- - **meshes.&lt;part&gt;** — exactly one of `grid`, `contour`, `auto`; required in every mode: `r`, `segments`; optional in every mode: `exponent`, `rule`; optional with `contour` or `auto`: `ribs`; optional with `grid` or `contour`: `influences` (issue #284; beside `auto` it is refused, CONFIG_INFLUENCES_MODE); optional with `grid`: `stray` (issue #303; beside `contour` or `auto` it is refused, CONFIG_STRAY_MODE)
137
+ - **meshes.&lt;part&gt;** — exactly one of `grid`, `contour`, `auto`, `influence`; required in every mode: `segments`, and `r` in every mode but `influence`, which refuses it; 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)
138
+ - **meshes.&lt;part&gt;.influence** — required: `cell`, `radius`, `across`, `max`, `shape` (issue #378); beside it `r`, `exponent`, `rule`, `influences`, `stray` and `ribs` are refused by name
138
139
  - **meshes.&lt;part&gt;.influences** — optional, at least one: `maxInfluences` (a whole number, 1 or more, or null for no cap), `floor` ("cut" or "continuous")
139
140
  - **meshes.&lt;part&gt;.ribs.&lt;chain&gt;** — required: `stations`
140
141
  - **meshes.&lt;part&gt;.contour** — required: `tolerance`, `margin`, `spacing`; optional: `maxEdge`, `budget`, `stray`, `bridges`, `regions`, `bust`
@@ -190,7 +191,7 @@ every number) are AUTHORING §3's tables, and the loader refuses any other by na
190
191
  | --- | --- | --- |
191
192
  | `parts.json`, `parts/<name>.png` | `assemble`, `build` | one record per part: `from` (`<run>:<tag>` with a See-through v3 tag, `<run>:author:<label>` for a layer the author made — issue #256, read by no role rule — or `painting:<name>` for a patch), `cut_from` on a cut's piece only (the plan part it was cut from, issue #230), `limb` on a limb segment's part only (issue #349: `name`, `segment`, `of`, `bone`, and below a joint `joint`, `range` when the config segment declares one (issue #360), and `cap` — `at`, `width`, `radius`, `box`, `layer_px`, `image_px` with a cap image, `image_layer` after it when that image was a hidden-art layer — issue #359, `<run>:<layer>:hidden` — `missing_px`, then `shape` and `upper_px` under the segment's `cap_shape`, and `edge`, `feather_radius` and `feathered_px` under its `edge`, and `cut_band`, `cut_offset`, `cut_at`, `cut_crossed`, `joint_crossed`, `band_px` and `stroke_luma_max` (when the band has a split) under its `cut_band`, issue #360), the box `x`, `y`, `w`, `h` (rig px), the pixel counts `src/parts.ts` documents (`opaque_px`, `visible_px`, `occluded_px`, `projected_core_px`, `source_px_taken`, `visible_not_projected_px`, `refused_drift_px`, `merged_px`, `seam_override_px`, and `fringe_pushed_back` when not empty); `rig_size`, `scale_rig_per_source`, `ghost_px`, `recomposite`, and `scene` (`figure_alpha_above`, `figure_px`, `figure_mask`) under `config.scene` only, with the figure's mask `figure_rig.png` beside the recomposite (issue #242); `single_run_pad` (`file_size`, `side`, `left`, `top`) last, only for one run whose file is not the `seethrough.resolution` square (issue #366) |
192
193
  | `rig/rig.json`, `rig/motion.json`, `rig/images/` | `rig`, `build`, `compose` | rig-c's rig spec and motion spec, `spec` `rigc-rig/1` and `rigc-motion/1`: the format is rig-c's, and this package writes only what rig-c's parser accepts; a bone carries `inherit` only where config.bones declares one, rig-c's mode name as written (issue #348) |
193
- | `rig/mesh_report.json` | `rig`, `build` | one row per mesh: `part`, `vertices`, `triangles`, `hull`, `bones`, `max_influences`, `mean_influences`, `art_coverage`, then `grid` (a lattice); `mode` "contour" with `params`, `contour`, `regions` (`params.maxEdge` and `contour.outlineCut` only when the mesh declares `contour.maxEdge`; `params.bridges` and `contour.bridges` — `islands`, `units`, `joins`, and `faint` only when an island was left out as faint — only when it declares `contour.bridges`); or `mode` "auto" with `settings`, `source`, `result`, `residuals`, `worst_residual`, `worst_region`, `motion_amplitude`, `termination`, `weights`, `regions`, `deformation`, `quality_report` (rig-c's `mesh-quality-report/1` document whole), `motion_report`, and, only when they apply, `stray_cleared` (after `source`, when `source.stray` is declared), `skinning_residual` and `replay` (`AutoMeshReport` in `src/rig.ts`); in every mode, `exponent` when the mesh declares one (after `grid`, or after `mode`); `influences`, as declared, when a lattice or contour mesh declares it (after `exponent`, or where `exponent` would be); `stray` and `stray_cleared` when a lattice mesh declares `stray` (after `influences`, or where `influences` would be); `ribs` when a contour or auto mesh declares them (after `exponent`, or after `mode`), and then `contour.ribs` (`source.contour.ribs` in the automatic mode) |
194
+ | `rig/mesh_report.json` | `rig`, `build` | one row per mesh: `part`, `vertices`, `triangles`, `hull`, `bones`, `max_influences`, `mean_influences`, `art_coverage`, then `grid` (a lattice); `mode` "contour" with `params`, `contour`, `regions` (`params.maxEdge` and `contour.outlineCut` only when the mesh declares `contour.maxEdge`; `params.bridges` and `contour.bridges` — `islands`, `units`, `joins`, and `faint` only when an island was left out as faint — only when it declares `contour.bridges`); or `mode` "influence" with `influence` (as declared), `reach` (`farthest`, `at`, `nearest`, `capped`, `widest`) and `lattice` (rig-c's `SegmentsLatticeReport`: `cols`, `rows`, `artCells`, `keptCells`, `passes`, `islands`) (issue #378); or `mode` "auto" with `settings`, `source`, `result`, `residuals`, `worst_residual`, `worst_region`, `motion_amplitude`, `termination`, `weights`, `regions`, `deformation`, `quality_report` (rig-c's `mesh-quality-report/1` document whole), `motion_report`, and, only when they apply, `stray_cleared` (after `source`, when `source.stray` is declared), `skinning_residual` and `replay` (`AutoMeshReport` in `src/rig.ts`); in every mode, `exponent` when the mesh declares one (after `grid`, or after `mode`); `influences`, as declared, when a lattice or contour mesh declares it (after `exponent`, or where `exponent` would be); `stray` and `stray_cleared` when a lattice mesh declares `stray` (after `influences`, or where `influences` would be); `ribs` when a contour or auto mesh declares them (after `exponent`, or after `mode`), and then `contour.ribs` (`source.contour.ribs` in the automatic mode) |
194
195
  | `check/check.json` and the rest of `check/` | `check`, `build`, `compose` | the reference's fields in its order (`gate_spine_html_green`, `rigc_entry`, `pack_mode`, `loop_max_diff`, the seam figures — `seam_mean`, `seam_px_over_40`, `seam_px_over_80` and, from issue #216, `seam_frame_scale`, the frame scale the bar divides the count by), `loop_physics` after `loop_max_diff` when the rig declares a physics constraint, `seam_border` after the seam figures when `parts.json` declares a scene (issue #242), `seam_pairs` after the seam figures when the seam bar fails or `--seam-pairs` asks (each row's picture under `check/seam/`; `--keep-stills` leaves the setup-pose still and its `frames.json` under `check/setup_still/`), then the judgement lines (`BREATH_VISIBLE`, `BLINK_NO_HOLE`, `CHAIN_LAG`, `TIP_OVER_ROOT`, `STILL_REGIONS_DARK`, `TEXTURE_STRETCH`), `ANIMATIONS_DO_NOT_FOLD` after them when `motion.json` holds an animation, the idle included — on every rig with an idle since issue #333 (issues #320, #363: `status`, `animations`, `fps`, `physics_left_out`, `folding` — each `animation`, `slot`, `attachment`, `frames`, `worst_frame`, `worst_triangles`, `triangles`, `physics_on`, `physics_off`, `physics_constraints`, `declared`, `line` — `folding_undeclared`, `declared_not_folding`, `bar`), `FEET_STAY_LEVEL` after it when a `footwear` part rides a bone that hangs from another and `motion.json` holds an animation (issue #348: `status`, `reason` on a SKIP only, `animations`, `fps`, `physics_left_out`, `bar_degrees`, `bar`, `feet` — each `part`, `bone`, `hangs_from`, `status`, `frames_posed`, `worst`), `LIMB_ONE_BONE` after it (and after `STRESS_OFF_CHAIN` where that is written) when `parts.json` holds a limb segment's part (issue #349: `status`, `parts` — each `part`, `limb`, `bone`, `status`, `others`), `SEAM_OVER_RANGE` after it when a limb record carries a `range` (issue #360: `status`, `frame_scale`, `physics_left_out`, `bar` — `mean`, `rig_px_over_40`, `level` — and `joints`, each `part`, `limb`, `segment`, `joint`, `bone`, `range`, `at`, `radius`, `under_px`, `status`, `poses` — each `degrees`, `status`, `mean`, `px_over_40`, `px_over_80`, `rig_px_over_40` — and `unread` on a joint not read), `SEAM_OVER_MOTION` after it when `parts.json` holds a limb segment or `--requirements` a `seam` (issue #493, a warning and not a bar: `status` — `WARN`, `CLEAR` or `SKIP` — `reason` on a SKIP only, `fps`, `floor`, `pairs` — each `pair`, `a`, `b`, `declared`, and `unread` on a pair not read — `animations`, `warnings`, `rows` — each `pair`, `animation`, `status`, `drawn`, `banded`, `opens`, `px`, `max_px`, `under_floor`), `CLOTH_SETTLES` after it when the rig declares a physics constraint and has an idle (issue #501, a warning and not a bar: `status` — `WARN` or `CLEAR` — `fps`, `frames`, `duration`, `floor_rig_px_per_s`, `floor`, `levers`, `warnings`, `rows` — each `tip`, `root`, `links`, `point`, `settles_at`, `max_rig_px_per_s`, `min_rig_px_per_s`), `RECOMPOSITE_HOLES` (its first figure `declared_scene` when `parts.json` declares a scene), `SETUP_POSE_VS_SOURCE`, `skipped`, a `requirements` block under `--requirements`, and `PASS`; `check/build/skeleton.json`, `.atlas` and `.png` are the packed artifact rig-c writes |
195
196
  | `layers.json`, `<index>_<name>.png` | `layers --export` | the wrapper form `layers` reads (issue #359): `width`, `height`, then `layers` — each `name`, `filename`, `left`, `top`, `right`, `bottom`, `depth_median` (the input's own; `null` for a PSD, the manifest's order then being the draw order) — drawn layers in draw order, then the hidden-art layers; a PNG's name is its index and its layer's name, and the manifest, not the file name, says which layer it is |
196
197
  | the template `.psd` | `layers --template` | one empty layer per name `templateLayerNames` (`src/layers.ts`) holds, bottom first; the same canvas writes the same bytes |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/parts",
3
- "version": "1.40.0",
3
+ "version": "1.41.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
@@ -1214,6 +1214,13 @@ export function rigStage(input: RigStageInput, rigc: RigcRunner, scratch: string
1214
1214
  ? ''
1215
1215
  : `; replayed to accepted step ${rp.chosen_step} of ${rp.accepted_steps} after ${rp.replays} replay(s); selection ${readingText(rp.selection, roleReadings(run.report).bound)}; held out ${readingText(rp.held_out, roleReadings(run.report).bound)}`;
1216
1216
  log(`${head}auto ${from} -> ${r.boundaryVertices}+${r.interiorVertices} (hull+interior) bindings ${r.bindings} ${infl} ${t.reason}${tried}; worst ${worst}${unboundedClause(m.residuals, m.settings.targets.artFit)}${allocationClause(m.residuals)}${stageBClause(m.settings, m.result)}${residualClause(m.skinning_residual)}${strayClause(m.stray_cleared)}; ${moved}${replayed}`);
1217
+ } else if ('mode' in m && m.mode === 'influence') {
1218
+ // issue #378: rig-c's segments lattice and pull, the figures its own build prints for the generator (AUTHORING §3.4.7).
1219
+ const i = m.influence;
1220
+ const l = m.lattice;
1221
+ log(`${head}influence cell=${i.cell} radius=${i.radius} ${i.shape} ${i.across ? 'across entries' : 'within the nearest entry'} max ${i.max} ${infl}`);
1222
+ log(` reach farthest vertex ${m.reach.farthest}px from its nearest link "${m.reach.nearest}" at (${m.reach.at.join(', ')}), radius ${i.radius}px: ${m.reach.capped} of ${m.vertices} vertices had more links in reach than max (widest ${m.reach.widest})`);
1223
+ log(` lattice cell ${i.cell}px, ${l.cols}x${l.rows} cells, ${l.artCells} with art, ${l.keptCells} kept${l.islands > 1 ? ` (${l.islands} island(s) joined into one outline)` : ''}`);
1217
1224
  } else if ('mode' in m) {
1218
1225
  const c = m.contour;
1219
1226
  const stray = c.strayIslands === 0 ? '' : ` left out ${c.strayIslands} island(s), ${c.strayPixels} px`;
package/src/config.ts CHANGED
@@ -317,7 +317,19 @@ export type Segment = string | [string, Point, Point];
317
317
  * locally refined by rig-c's `reduceMesh` under the author's declared
318
318
  * bounds (`src/automesh.ts`).
319
319
  */
320
- export type MeshSpec = LatticeMeshSpec | ContourMeshSpec | AutoMeshSpec;
320
+ export type MeshSpec = LatticeMeshSpec | ContourMeshSpec | AutoMeshSpec | InfluenceMeshSpec;
321
+
322
+ /**
323
+ * One mesh in the influence mode (issue #378): rig-c's `segments` lattice over the part at `cell` px, every vertex
324
+ * pulled by every chain link within `radius` px of it, falling to zero there (`shape`), the strongest `max` kept —
325
+ * `buildSegmentsLattice` and `influenceShares` from `rig-c/mesh`, promised for this call (rig-c/core#1450), so the
326
+ * rule is core's and the mesh is written with explicit weights like every other mode (`src/rig.ts`). `segments`
327
+ * names the links as in every mode; each entry is one of rig-c's `bones` entries, which `across: false` keeps apart.
328
+ */
329
+ export interface InfluenceMeshSpec {
330
+ influence: { cell: number; radius: number; across: boolean; max: number; shape: 'linear' | 'smooth' };
331
+ segments: Segment[];
332
+ }
321
333
 
322
334
  /**
323
335
  * `meshes.<part>.rule` (issue #161): how a mesh's vertices are weighted. `"distance"` is `influences()`
@@ -2271,17 +2283,20 @@ function checkMeshes(c: Check, v: Json, bones: Set<string>, chains: Map<string,
2271
2283
  const at = `config.meshes.${part}`;
2272
2284
  // The known keys keep their old order (grid, r, segments) with contour after them, and `r` and `segments` are
2273
2285
  // required in the place and words the object check uses, so a lattice mesh's refusals read as they did.
2274
- const m = c.object(at, spec, [], ['grid', 'r', 'segments', 'contour', 'auto', 'exponent', 'rule', 'ribs', 'influences', 'stray']);
2286
+ const m = c.object(at, spec, [], ['grid', 'r', 'segments', 'contour', 'auto', 'exponent', 'rule', 'ribs', 'influences', 'stray', 'influence']);
2275
2287
  if (m === null) continue;
2276
- for (const key of ['r', 'segments']) if (!(key in m)) c.fail('CONFIG_FIELD_PRESENT', `${at}.${key}`, 'is absent and required');
2277
- const modes = ['grid', 'contour', 'auto'].filter((k) => k in m);
2278
- if (modes.length === 2 && !modes.includes('auto')) {
2288
+ // issue #378: the influence mode weights by rig-c's own pull, so `r` (the distance rule's softening) is not one of its
2289
+ // fields — it is refused there below, and required in every other mode as it always was.
2290
+ for (const key of 'influence' in m ? ['segments'] : ['r', 'segments']) if (!(key in m)) c.fail('CONFIG_FIELD_PRESENT', `${at}.${key}`, 'is absent and required');
2291
+ const modes = ['grid', 'contour', 'auto', 'influence'].filter((k) => k in m);
2292
+ if (modes.length === 2 && !modes.includes('auto') && !modes.includes('influence')) {
2279
2293
  c.fail('CONFIG_MESH_MODE', at, 'has both grid (the lattice) and contour; exactly one is required — a mesh is one or the other');
2280
2294
  } else if (modes.length > 1) {
2281
- c.fail('CONFIG_MESH_MODE', at, `has ${modes.join(' and ')}; exactly one of grid (the lattice), contour (the outline mode) and auto (the automatic mode) is required — a mesh is one of them`);
2295
+ c.fail('CONFIG_MESH_MODE', at, `has ${modes.join(' and ')}; exactly one of grid (the lattice), contour (the outline mode), auto (the automatic mode) and influence (rig-c's segments lattice and pull) is required — a mesh is one of them`);
2282
2296
  } else if (modes.length === 0) {
2283
- c.fail('CONFIG_MESH_MODE', at, 'has neither grid (the lattice cell size, px) nor contour (the outline mode) nor auto (the automatic mode); exactly one is required');
2297
+ c.fail('CONFIG_MESH_MODE', at, 'has neither grid (the lattice cell size, px) nor contour (the outline mode) nor auto (the automatic mode) nor influence (rig-c\'s segments lattice and pull); exactly one is required');
2284
2298
  }
2299
+ if ('influence' in m) checkInfluence(c, at, m);
2285
2300
  if ('grid' in m) c.int(`${at}.grid`, m.grid, 1);
2286
2301
  if ('contour' in m) checkContour(c, `${at}.contour`, m.contour, bones);
2287
2302
  if ('auto' in m) checkAuto(c, `${at}.auto`, m.auto, bones);
@@ -2320,6 +2335,29 @@ function checkMeshes(c: Check, v: Json, bones: Set<string>, chains: Map<string,
2320
2335
  }
2321
2336
  }
2322
2337
 
2338
+ /** The fields of the distance rule and of the other modes, which an influence mesh does not read (issue #378). */
2339
+ export const INFLUENCE_FOREIGN_FIELDS = ['r', 'exponent', 'rule', 'influences', 'stray', 'ribs'] as const;
2340
+
2341
+ /**
2342
+ * `meshes.<part>.influence` (issue #378): rig-c's `segments` lattice over the part (`cell`, px) and its `influence`
2343
+ * pull (`radius` px, `across`, `max`, `shape`, AUTHORING §3.4.7 in rig-c), every field required and none defaulted.
2344
+ * A field of the distance rule or of another mode beside it is refused by name (`CONFIG_INFLUENCE_MODE`) rather
2345
+ * than read by nothing. Whether `radius` reaches the part's farthest vertex is the rig stage's to measure, against
2346
+ * the lattice it builds (`RIG_INFLUENCE_REACH`, `src/rig.ts`).
2347
+ */
2348
+ function checkInfluence(c: Check, at: string, m: Record<string, Json>): void {
2349
+ for (const k of INFLUENCE_FOREIGN_FIELDS) {
2350
+ if (k in m) c.fail('CONFIG_INFLUENCE_MODE', `${at}.${k}`, `is ${show(m[k])} on an influence mesh; it pulls each vertex by rig-c's influence (radius, across, max, shape), which reads no ${k} — remove ${k}`);
2351
+ }
2352
+ const o = c.object(`${at}.influence`, m.influence, ['cell', 'radius', 'across', 'max', 'shape'], []);
2353
+ if (o === null) return;
2354
+ if ('cell' in o) c.int(`${at}.influence.cell`, o.cell, 1);
2355
+ if ('radius' in o) c.number(`${at}.influence.radius`, o.radius, 'positive');
2356
+ if ('across' in o && typeof o.across !== 'boolean') c.fail('CONFIG_FIELD_TYPE', `${at}.influence.across`, `is ${show(o.across)}; true (every link within radius pulls, across the segments entries) or false (only the links of the entry nearest the vertex) is required`);
2357
+ if ('max' in o) c.int(`${at}.influence.max`, o.max, 1);
2358
+ if ('shape' in o && o.shape !== 'linear' && o.shape !== 'smooth') c.fail('CONFIG_FIELD_TYPE', `${at}.influence.shape`, `is ${show(o.shape)}; "linear" (1 - x) or "smooth" (1 - x²(3 - 2x)) is required`);
2359
+ }
2360
+
2323
2361
  /**
2324
2362
  * `meshes.<part>.auto.stimulus` (issue #196): a declared bend, `{ chain,
2325
2363
  * degrees }` or a non-empty list of them, for a part no idle key deforms (a
package/src/mesh.ts CHANGED
@@ -311,7 +311,7 @@ export function triangulate(lattice: Lattice, cells: Mask, passes: number): Latt
311
311
  }
312
312
 
313
313
  /** The fraction of art pixels the triangles cover, rasterised as `cv2.fillPoly` would. */
314
- export function artCoverage(mesh: LatticeMesh, art: Mask): number {
314
+ export function artCoverage(mesh: Pick<LatticeMesh, 'vertices' | 'triangles'>, art: Mask): number {
315
315
  const ras = newMask(art.width, art.height);
316
316
  for (let t = 0; t < mesh.triangles.length; t += 3) {
317
317
  const corner = (k: number): [number, number] => {
package/src/meshdraft.ts CHANGED
@@ -133,7 +133,7 @@ export const NOT_COMPARED_SENTENCE = 'mesh-draft drafts lattice entries only, so
133
133
  /** A config entry `mesh-draft` did not draft because it is not a lattice (issue #307), in config order. */
134
134
  export interface NotCompared {
135
135
  part: string;
136
- mode: 'contour' | 'auto';
136
+ mode: 'contour' | 'auto' | 'influence';
137
137
  note: string;
138
138
  }
139
139
 
@@ -142,7 +142,7 @@ export function notCompared(meshes: CharacterConfig['meshes']): NotCompared[] {
142
142
  const out: NotCompared[] = [];
143
143
  for (const [part, spec] of Object.entries(meshes)) {
144
144
  if ('grid' in spec) continue;
145
- const mode = 'auto' in spec ? 'auto' : 'contour';
145
+ const mode = 'auto' in spec ? 'auto' : 'influence' in spec ? 'influence' : 'contour';
146
146
  out.push({ part, mode, note: `its entry is "${mode}", not a lattice: ${NOT_COMPARED_SENTENCE}` });
147
147
  }
148
148
  return out;
package/src/rig.ts CHANGED
@@ -132,13 +132,14 @@
132
132
  * touches the disk, and the same inputs give the same bytes (key order is the
133
133
  * order the objects are built in, and every number is rounded by `pyRound`).
134
134
  */
135
- import { type AutoSpec, type BoneEntry, type WeightRule, type CharacterConfig, type ConfigConstraint, type ConfigStop, CONSTRAINT_FOLLOWS, constraintForRig, contourRegionsOf, type ContourSpec, DEFAULT_BUST_BONE_L, DEFAULT_BUST_BONE_R, type Point, type RibsSpec, ROOT_BONE, stopForRig, weightsABone } from './config.ts';
135
+ import { type AutoSpec, type BoneEntry, type InfluenceMeshSpec, type WeightRule, type CharacterConfig, type ConfigConstraint, type ConfigStop, CONSTRAINT_FOLLOWS, constraintForRig, contourRegionsOf, type ContourSpec, DEFAULT_BUST_BONE_L, DEFAULT_BUST_BONE_R, type Point, type RibsSpec, ROOT_BONE, stopForRig, weightsABone } from './config.ts';
136
136
  import { type BoneTransform, computeExactFrameTransforms, cropToSpineY, normaliseDegrees, toBoneLocal, toWorld } from './coords.ts';
137
137
  import { type Problem, refuseIfAny } from './errors.ts';
138
138
  import { eyeLineDegrees } from './headframe.ts';
139
139
  import type { RigBoneInherit, RigStop } from 'rig-c/src/rig.ts';
140
140
  import { f32 } from 'rig-c/compile';
141
141
  import type { MeshCounts, MeshQualityReport, MeshReductionInput, MotionAmplitude, ReducedMesh, Termination } from 'rig-c/mesh';
142
+ import { buildSegmentsLattice, type EntrySegment, influenceShares, segmentDistance as rigcSegmentDistance, type SegmentsLattice, type SegmentsLatticeReport } from 'rig-c/mesh';
142
143
  import { type AmplitudeRow, amplitudeRow, partAmplitude, withAmplitude } from './autoamplitude.ts';
143
144
  import { type ResidualRow, residualRow, slotEnvelope, withSkinning } from './autoenvelope.ts';
144
145
  import { type AutoMotionCase, type AutoSearch, DEFORM_MAY_FOLD_WHY, type MotionDeformation, type StimulusPose, stimulusAnimationNames } from './automotion.ts';
@@ -708,7 +709,70 @@ export type RigCommand = 'rig' | 'build';
708
709
  export const IDLE_DRIVES_MESHES_WHY = 'painting rig: the idle is meant to deform the meshes it keys (rig-parts rig --idle-keys direct)';
709
710
 
710
711
  /** One row of `mesh_report.json`: a lattice mesh's row is as it always was; a contour mesh's says so. */
711
- export type MeshReport = LatticeMeshReport | ContourMeshReport | AutoMeshReport;
712
+ export type MeshReport = LatticeMeshReport | ContourMeshReport | AutoMeshReport | InfluenceMeshReport;
713
+
714
+ /**
715
+ * An influence mesh's row (issue #378): the lattice's counts and coverage as every row has them, the block as declared,
716
+ * rig-c's lattice report, and the reach — the farthest vertex's distance to its nearest link and where, the vertices
717
+ * the cap dropped a link from (`capped`, more links in reach than `max`) and the most links in reach at one vertex
718
+ * (`widest`, the `max` that would drop none): the two figures rig-c's own `reach` line prints for its generator.
719
+ */
720
+ export interface InfluenceMeshReport {
721
+ part: string;
722
+ vertices: number;
723
+ triangles: number;
724
+ hull: number;
725
+ bones: string[];
726
+ max_influences: number;
727
+ mean_influences: number;
728
+ art_coverage: number;
729
+ mode: 'influence';
730
+ influence: InfluenceMeshSpec['influence'];
731
+ reach: { farthest: number; at: [number, number]; nearest: string; capped: number; widest: number };
732
+ lattice: SegmentsLatticeReport;
733
+ }
734
+
735
+ /**
736
+ * The alpha a pixel must reach to hold a cell of an influence mesh's lattice: this package's art, alpha above
737
+ * {@link ART_ALPHA} (`src/mesh.ts`), which the lattice's own cells and every coverage figure read — so the two
738
+ * modes' coverage is measured over the same art (issue #378, bar 1).
739
+ */
740
+ export const INFLUENCE_THRESHOLD = ART_ALPHA + 1;
741
+
742
+ /** The farthest lattice vertex from its nearest link, part px (issue #378, bar 4): `segmentDistance`, rig-c's. */
743
+ export function influenceReach(points: ReadonlyArray<readonly [number, number]>, segs: readonly EntrySegment[], names: readonly string[]): { distance: number; vertex: number; at: [number, number]; bone: string } {
744
+ let best = { distance: -1, vertex: -1, at: [0, 0] as [number, number], bone: '' };
745
+ points.forEach(([x, y], vi) => {
746
+ let d = Infinity;
747
+ let bone = 0;
748
+ for (const s of segs) {
749
+ const e = rigcSegmentDistance([x, y], s.a, s.b);
750
+ if (e < d) {
751
+ d = e;
752
+ bone = s.bone;
753
+ }
754
+ }
755
+ if (d > best.distance) best = { distance: d, vertex: vi, at: [x, y], bone: names[bone] };
756
+ });
757
+ return best;
758
+ }
759
+
760
+ /**
761
+ * Whether a declared radius reaches a vertex `distance` px from its nearest link: a link pulls only when it is NEARER
762
+ * than radius (rig-c's `d < radius`; the pull is 0 at d = radius), so a radius equal to the distance does not.
763
+ */
764
+ export function influenceReachHolds(radius: number, distance: number): boolean {
765
+ return radius > distance;
766
+ }
767
+
768
+ /** `RIG_INFLUENCE_REACH`: the radius does not exceed the farthest vertex's distance to its nearest link. */
769
+ export function influenceReachProblem(part: string, radius: number, reach: { distance: number; vertex: number; at: [number, number]; bone: string }, ox: number, oy: number): Problem {
770
+ return {
771
+ code: 'RIG_INFLUENCE_REACH',
772
+ object: `config.meshes.${part}.influence.radius`,
773
+ detail: `is ${radius}; vertex ${reach.vertex} of the part's lattice, at (${pyRound(reach.at[0] + ox, 4)}, ${pyRound(reach.at[1] + oy, 4)}) in rig px, is ${pyRound(reach.distance, 4)} px from its nearest link ("${reach.bone}"), and a link pulls a vertex only when it is nearer than radius — a radius above ${pyRound(reach.distance, 4)} is required, or a segment nearer that part of the art`,
774
+ };
775
+ }
712
776
 
713
777
  export interface LatticeMeshReport {
714
778
  part: string;
@@ -1161,6 +1225,9 @@ export function buildRig(
1161
1225
  return { bone, a: [b.x, b.y], b: end };
1162
1226
  };
1163
1227
  const meshSegments = new Map<string, Segment[]>();
1228
+ // issue #378: which `segments` entry each resolved segment came from — rig-c's `bones` entries, which an influence
1229
+ // mesh's `across: false` keeps apart. Every mode resolves them; only the influence mode reads this.
1230
+ const meshSegmentEntries = new Map<string, number[]>();
1164
1231
  for (const [part, m] of Object.entries(cfg.meshes)) {
1165
1232
  if ('contour' in m) {
1166
1233
  (m.contour.regions ?? []).forEach((rg, i) => {
@@ -1181,25 +1248,26 @@ export function buildRig(
1181
1248
  });
1182
1249
  }
1183
1250
  const out: Segment[] = [];
1251
+ const entries: number[] = [];
1184
1252
  m.segments.forEach((sp, i) => {
1185
1253
  const at = `config.meshes.${part}.segments[${i}]`;
1254
+ const push = (s: Segment | null): void => {
1255
+ if (s === null) return;
1256
+ out.push(s);
1257
+ entries.push(i);
1258
+ };
1186
1259
  if (typeof sp === 'string') {
1187
1260
  const links = chains.get(sp);
1188
1261
  if (links !== undefined) {
1189
- for (const l of links) {
1190
- const s = seg(l, `${at} (chain "${sp}" link "${l}")`);
1191
- if (s !== null) out.push(s);
1192
- }
1193
- } else {
1194
- const s = seg(sp, at);
1195
- if (s !== null) out.push(s);
1196
- }
1262
+ for (const l of links) push(seg(l, `${at} (chain "${sp}" link "${l}")`));
1263
+ } else push(seg(sp, at));
1197
1264
  } else {
1198
1265
  if (!B.has(sp[0])) fail('RIG_NAME_RESOLVES', `${at}[0]`, `names the bone "${sp[0]}", which config.bones does not declare`);
1199
- else out.push({ bone: sp[0], a: [sp[1][0], sp[1][1]], b: [sp[2][0], sp[2][1]] });
1266
+ else push({ bone: sp[0], a: [sp[1][0], sp[1][1]], b: [sp[2][0], sp[2][1]] });
1200
1267
  }
1201
1268
  });
1202
1269
  meshSegments.set(part, out);
1270
+ meshSegmentEntries.set(part, entries);
1203
1271
  }
1204
1272
 
1205
1273
  // ---- parts ↔ config ----------------------------------------------------
@@ -1723,6 +1791,87 @@ export function buildRig(
1723
1791
  },
1724
1792
  };
1725
1793
  };
1794
+ // An influence mesh (issue #378): rig-c's segments lattice and its influence pull, both computed by rig-c's own
1795
+ // promised functions (`buildSegmentsLattice`, `segmentDistance`, `influenceShares`, rig-c/core#1450) in the padded
1796
+ // part's pixels — the frame the generator reads — and written as explicit weights, bound exactly as a lattice
1797
+ // vertex is. Before any share is taken the radius is held to the farthest vertex's nearest link
1798
+ // (`RIG_INFLUENCE_REACH`): a vertex no link reaches would be refused by rig-c's own rule, and the figure that
1799
+ // fixes it is that distance.
1800
+ const influenceAttachment = (
1801
+ p: PartsFile['parts'][number],
1802
+ img: Raster,
1803
+ file: string,
1804
+ spec: InfluenceMeshSpec,
1805
+ segs: readonly Segment[],
1806
+ entries: readonly number[],
1807
+ out: Problem[],
1808
+ ): { attachment: MeshAttachment; report: InfluenceMeshReport } | null => {
1809
+ const ox = p.x - PAD;
1810
+ const oy = p.y - PAD;
1811
+ const w = img.width;
1812
+ const h = img.height;
1813
+ const at = `config.meshes.${p.name}.influence`;
1814
+ const alpha = new Uint8Array(w * h);
1815
+ for (let i = 0; i < alpha.length; i++) alpha[i] = img.data[i * 4 + 3];
1816
+ let lattice: SegmentsLattice;
1817
+ try {
1818
+ lattice = buildSegmentsLattice({ mask: { width: w, height: h, alpha }, threshold: INFLUENCE_THRESHOLD, cell: spec.influence.cell });
1819
+ } catch (err) {
1820
+ out.push({ code: 'RIG_INFLUENCE_LATTICE', object: `${at}.cell`, detail: `rig-c's segments lattice refused part "${p.name}" at cell ${spec.influence.cell}: ${(err as Error).message}` });
1821
+ return null;
1822
+ }
1823
+ const names = [...new Set(segs.map((s) => s.bone))];
1824
+ const index = new Map(names.map((n, k) => [n, k]));
1825
+ const local: EntrySegment[] = segs.map((s, k) => ({ bone: index.get(s.bone) as number, entry: entries[k], a: [s.a[0] - ox, s.a[1] - oy], b: [s.b[0] - ox, s.b[1] - oy] }));
1826
+ const reach = influenceReach(lattice.points, local, names);
1827
+ if (!influenceReachHolds(spec.influence.radius, reach.distance)) {
1828
+ out.push(influenceReachProblem(p.name, spec.influence.radius, reach, ox, oy));
1829
+ return null;
1830
+ }
1831
+ const weights: WeightEntry[][] = [];
1832
+ let infl = 0;
1833
+ let maxInfl = 0;
1834
+ let capped = 0;
1835
+ let widest = 0;
1836
+ for (const [vi, [x, y]] of lattice.points.entries()) {
1837
+ const r = influenceShares([x, y], local, spec.influence);
1838
+ if ('nearest' in r) {
1839
+ // Not reached after the reach check passed: a defect here, not an input to word.
1840
+ throw new Error(`influenceAttachment: vertex ${vi} of "${p.name}" is reached by no link after the radius held`);
1841
+ }
1842
+ if (r.inReach > spec.influence.max) capped++;
1843
+ widest = Math.max(widest, r.inReach);
1844
+ const wx = x + ox;
1845
+ const wy = y + oy;
1846
+ const ent: WeightEntry[] = r.weights.map((e) => {
1847
+ const bone = names[e.control ?? 0];
1848
+ const [bx, by] = toBoneLocal(world.get(bone) as BoneTransform, spineX(wx), spineY(wy));
1849
+ return { bone, x: places(bx), y: places(by), weight: e.weight };
1850
+ });
1851
+ weights.push(ent);
1852
+ infl += ent.length;
1853
+ maxInfl = Math.max(maxInfl, ent.length);
1854
+ }
1855
+ const vertices = lattice.points.map(([x, y]) => [x, y] as Point);
1856
+ const n = vertices.length;
1857
+ return {
1858
+ attachment: { type: 'mesh', image: file, width: w, height: h, uvs: lattice.uvs, triangles: lattice.triangles, hull: lattice.hullVertices, weights },
1859
+ report: {
1860
+ part: p.name,
1861
+ vertices: n,
1862
+ triangles: lattice.triangles.length / 3,
1863
+ hull: lattice.hullVertices,
1864
+ bones: [...names].sort(),
1865
+ max_influences: maxInfl,
1866
+ mean_influences: pyRound(infl / n, 2),
1867
+ art_coverage: pyRound(artCoverage({ vertices, triangles: lattice.triangles }, alphaAbove(img, ART_ALPHA)), 5),
1868
+ mode: 'influence',
1869
+ influence: { ...spec.influence },
1870
+ reach: { farthest: pyRound(reach.distance, 4), at: [pyRound(reach.at[0] + ox, 4), pyRound(reach.at[1] + oy, 4)], nearest: reach.bone, capped, widest },
1871
+ lattice: { ...lattice.report },
1872
+ },
1873
+ };
1874
+ };
1726
1875
  // An automatic mesh (issue #126, item 2): the contour source at alpha 1 and above, rig-c's reduceMesh, and
1727
1876
  // the result used only when accepted (`src/automesh.ts`). Its weights are rig-c's by name — a survivor's are
1728
1877
  // the source's bit for bit, an inserted vertex's interpolated — rounded by roundShares (the author's minWeight
@@ -2005,6 +2154,14 @@ export function buildRig(
2005
2154
  meshReport.push(row.report);
2006
2155
  continue;
2007
2156
  }
2157
+ if ('influence' in mesh) {
2158
+ const row = influenceAttachment(p, img, file, mesh, segs, meshSegmentEntries.get(p.name) as number[], problems);
2159
+ if (row === null) continue;
2160
+ skin[p.name] = { [p.name]: row.attachment };
2161
+ slots.push({ name: p.name, bone: segs[0].bone, attachment: p.name });
2162
+ meshReport.push(row.report);
2163
+ continue;
2164
+ }
2008
2165
  const allArt = alphaAbove(img, ART_ALPHA);
2009
2166
  // issue #303: under a declared `stray`, the islands it leaves out are cleared from the art the lattice and its heat
2010
2167
  // silhouette are built over; absent, `art` is `allArt` itself and nothing downstream moves.
@@ -2221,7 +2378,7 @@ export function buildRig(
2221
2378
  segs = yOverlapping.length > 0 ? yOverlapping : [segs[0]];
2222
2379
  }
2223
2380
  const allArt = alphaAbove(img, ART_ALPHA);
2224
- const strayVal = 'auto' in mesh ? mesh.auto.source.stray : ('contour' in mesh ? mesh.contour.stray : mesh.stray);
2381
+ const strayVal = 'auto' in mesh ? mesh.auto.source.stray : 'contour' in mesh ? mesh.contour.stray : 'influence' in mesh ? undefined : mesh.stray;
2225
2382
  const stray = strayVal === undefined ? null : latticeStray(allArt, strayVal);
2226
2383
  const art = stray === null ? allArt : stray.art;
2227
2384
  const grid = 'grid' in mesh ? mesh.grid : 28;
@@ -2237,7 +2394,7 @@ export function buildRig(
2237
2394
  const h = img.height;
2238
2395
  const limits: InfluenceLimits = meshLimits('influences' in mesh ? mesh.influences : undefined);
2239
2396
  const segsAt = dressSegsAt(p, segs);
2240
- const exponent = mesh.exponent ?? DISTANCE_EXPONENT;
2397
+ const exponent = ('exponent' in mesh ? mesh.exponent : undefined) ?? DISTANCE_EXPONENT;
2241
2398
  let touchesArt: boolean[] | null = null;
2242
2399
  if (drawn !== undefined && limits.maxInfluences === 1) {
2243
2400
  const lc = latticeCells(art, grid);
package/src/squeeze.ts CHANGED
@@ -187,8 +187,8 @@ export function chainSqueezes(
187
187
  const pairs: Array<[string, string]> = [];
188
188
  for (let i = 0; i < keyed.length; i++) for (let j = i + 1; j < keyed.length; j++) pairs.push([keyed[i], keyed[j]]);
189
189
  const names = pairs.map(([a, b]) => `${a} and ${b}`).join(', ');
190
- if ('contour' in m || 'auto' in m) {
191
- unread.push(`mesh ${JSON.stringify(mname)} (${names}) is a ${'contour' in m ? 'contour' : 'automatic'} mesh; only a lattice is built here`);
190
+ if ('contour' in m || 'auto' in m || 'influence' in m) {
191
+ unread.push(`mesh ${JSON.stringify(mname)} (${names}) is a ${'contour' in m ? 'contour' : 'auto' in m ? 'automatic' : 'influence'} mesh; only a lattice is built here`);
192
192
  continue;
193
193
  }
194
194
  if (m.rule === 'heat') {
@@ -318,7 +318,7 @@ export function branchSqueezes(
318
318
  }
319
319
 
320
320
  for (const [mname, m] of Object.entries(spec.meshes)) {
321
- if ('contour' in m || 'auto' in m || m.rule === 'heat' || m.r >= m.grid) continue;
321
+ if ('contour' in m || 'auto' in m || 'influence' in m || m.rule === 'heat' || m.r >= m.grid) continue;
322
322
  const byFork = new Map<string, string[]>();
323
323
  for (const sp of m.segments) {
324
324
  if (typeof sp !== 'string') continue;