@rig-c/parts 1.41.1 → 1.42.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/NOTICE.md CHANGED
@@ -75,14 +75,16 @@ terms and not a term of this project:
75
75
 
76
76
  1. What rig-parts produces is input to rig-c, whose output **is Spine
77
77
  skeleton data**.
78
- 2. Playing Spine skeleton data in a product requires a Spine Runtime, and the
79
- Spine Runtimes License requires **each user of such a product to own a
80
- Spine Editor license**.
81
- 3. rig-c no longer installs `spine-core`, and rig-parts does not either;
82
- the obligation in 2 attaches to the Spine skeleton data rig-c writes,
83
- which the stages of rig-parts that call it produce, and to `spine-core`
84
- wherever it is installed beside them — this repository's development
85
- dependency included.
78
+ 2. A product that plays it with **a Spine Runtime** has integrated the Spine
79
+ Runtimes; what the terms turn on is **the integration**. Integrating a Spine
80
+ Runtime into a product is permitted **under Section 2 of the Spine Editor
81
+ License Agreement**, or otherwise on the condition that **each user of the
82
+ product obtains their own Spine Editor license** and the product carries the
83
+ Runtimes licence and copyright notice.
84
+ 3. rig-c does not install `spine-core`, and rig-parts does not either. The terms
85
+ in 2 apply where a Spine Runtime is integrated — a product that plays the data
86
+ with one, and this repository, whose development dependency it is — and
87
+ nothing in this chain attaches to the skeleton data as a file.
86
88
 
87
89
  rig-parts also imports rig-c's own modules directly, by deep path: its PNG codec
88
90
  (`tools/plate.ts`, `src/png.ts`), its 5x7 label font (`tools/font5x7.ts`) and
package/README.md CHANGED
@@ -442,10 +442,14 @@ selftest and CI do; `check.json`'s `rigc_entry` records which one gated a build.
442
442
 
443
443
  ## Licence posture
444
444
 
445
- rig-parts is MIT, and it depends on rig-c, whose output is Spine skeleton data:
446
- using what it produces in a product requires a Spine Editor licence, as any Spine data
447
- does. Neither package installs Esoteric Software's `spine-core` any more; this
448
- repository uses it in development, for the round trip in its selftest and CI. [NOTICE.md](NOTICE.md) records that chain and every other
445
+ rig-parts is MIT. It writes rig-c's input, and rig-c writes Spine skeleton data. If a
446
+ product integrates a Spine Runtime to play that data, the integration is under Esoteric
447
+ Software's Spine Runtimes License: permitted under Section 2 of the Spine Editor License
448
+ Agreement, or otherwise on the condition that each user of the product obtains their own
449
+ Spine Editor license. What those terms turn on is the integration, as rig-c's
450
+ [NOTICE.md](https://github.com/rig-c/core/blob/main/NOTICE.md) states it, not the data as
451
+ a file. Neither package installs `spine-core`; this repository uses it in development,
452
+ for the round trip in its selftest and CI. [NOTICE.md](NOTICE.md) records that chain and every other
449
453
  third-party term this package touches, See-through's included.
450
454
 
451
455
  ## Development
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, branchSqueezeLine, checkProposal, compare, compareLines, DEFAULT_GRID_RULE, draftTurn, drawLandmarks, FIGURE_GRID_DIVISOR, FRINGE_STEP_PX, GRID_RULES, type GridRule, HIP_MIN_FRACTION, type LimbJointOffArtFinding, 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, type DraftLintFinding, 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 { PROVENANCE_FILE, REMESH_SPEC, remeshStage } from './src/remesh.ts';
@@ -217,7 +217,12 @@ usage:
217
217
  refused (PROPOSE_CLOTH_DRAFTED). A topwear part shaped like a skirt (a
218
218
  dress) is named in a note, never drafted on its shape; a bottomwear
219
219
  recipe's "part" declares it, and its trees hang from the hip over the
220
- part's art below it (PROPOSE_CLOTH_PART). Without --cloth nothing changes.
220
+ part's art below it (PROPOSE_CLOTH_PART). A recipe's "influence"
221
+ ({across, max, shape}, issue #518) drafts the parts it meshes in the
222
+ influence mode at their lattice's cell, the radius as stated or drafted
223
+ as the farthest lattice vertex from its nearest link plus 3 cells, and
224
+ a LINT line names each drafted radius and both figures. Without --cloth
225
+ nothing changes.
221
226
 
222
227
  rig-parts propose --parts <dir> --source <painting.png> --out <dir> --from-config <config.json>
223
228
  Draw the config's CURRENT bones instead (<out>/render/landmarks_config.png
@@ -1112,7 +1117,7 @@ function parseCanvas(v: string): { w: number; h: number } | null {
1112
1117
  return m === null ? null : { w: Number(m[1]), h: Number(m[2]) };
1113
1118
  }
1114
1119
 
1115
- function printLint(P: PartSet, spec: { bones: CharacterConfig['bones']; meshes: CharacterConfig['meshes']; regions: CharacterConfig['regions']; motion: CharacterConfig['motion']; constraints?: CharacterConfig['constraints'] }, joints?: RigJoints, drafted: readonly LimbJointOffArtFinding[] = []): number {
1120
+ function printLint(P: PartSet, spec: { bones: CharacterConfig['bones']; meshes: CharacterConfig['meshes']; regions: CharacterConfig['regions']; motion: CharacterConfig['motion']; constraints?: CharacterConfig['constraints'] }, joints?: RigJoints, drafted: readonly DraftLintFinding[] = []): number {
1116
1121
  const res = lint(P, spec, joints, drafted);
1117
1122
  // Under --keypoints only: which rule set read the torso and the chains, and on what basis.
1118
1123
  if (res.basis !== undefined) for (const l of basisLines(res.basis)) console.log(l);
@@ -1242,7 +1247,7 @@ function cmdPropose(args: string[]): number {
1242
1247
  }
1243
1248
  const cmpPath = flags.get('--compare');
1244
1249
  const cfg = cmpPath === undefined ? null : loadConfig(cmpPath);
1245
- const { proposal: drafted, basis, jointsOffArt } = proposeWithBasis(P, joints, wristSnap, gridRule, cloth);
1250
+ const { proposal: drafted, basis, draftLint } = proposeWithBasis(P, joints, wristSnap, gridRule, cloth);
1246
1251
  const fullRun = flags.get('--full');
1247
1252
  const headRun = flags.get('--head');
1248
1253
  const prop =
@@ -1260,7 +1265,7 @@ function cmdPropose(args: string[]): number {
1260
1265
  if (img.head !== null) writePng(join(render, 'landmarks_head.png'), img.head);
1261
1266
  console.log(`wrote proposal.json (${prop.bones.length} bone entries, ${Object.keys(prop.meshes).length} meshes) and render/landmarks.png (+_head) under ${out}`);
1262
1267
  for (const n of prop.notes) console.log(`note: ${n}`);
1263
- printLint(P, prop, joints, jointsOffArt);
1268
+ printLint(P, prop, joints, draftLint);
1264
1269
  console.log(basisLine(bfile, out));
1265
1270
  if (cfg !== null) for (const l of compareLines(compare(prop.bones, cfg.bones))) console.log(l);
1266
1271
  return EXIT_OK;
package/docs/AUTHORING.md CHANGED
@@ -113,7 +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
+ | `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. `propose --cloth` drafts it when a recipe declares `influence` and no `radius` (issue #518): the farthest vertex's distance plus 3 of the part's lattice cells, printed on a `LINT` line with both figures. Measured on the cloth fixture and the public `wind` example (#513: 8 covered parts, `render --folds` with the physics on under wind and a hip sway of 8° and 30°): a radius just above the floor folds **more** than the lattice (one skirt went from 0 to 55 folded frames), and a larger one is **not** safer (one fringe folded again at about 3–4× its farthest distance); +2 to +6 cells read 0 on every part, +2 at the edge. No ceiling is drafted, and the 3 is a hypothesis until a third subject — state `radius` in the recipe to keep your own. `r`, `exponent`, `rule`, `influences`, `stray` and `ribs` belong to the distance rule or another mode and are refused beside it (`CONFIG_INFLUENCE_MODE`). For cloth and hair that should bend as one surface across its chains |
117
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 |
118
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 |
119
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 |
@@ -128,7 +128,7 @@ read by no CPU stage).
128
128
  | `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`); `propose --from-config` (`LINT stop on <chain> …`) | **authored**, optional (issues #404, #447): `[{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`): since each chain link (`leg_r0`, `leg_r1`) is turned to point along its segment (`+x` from origin to next link or tip, `+y` 90° counter-clockwise in Spine world), `at: [d, n]` sits `d` px from `against`'s origin toward its end and `n` px perpendicular to it; `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, `\|rest\| + outward <= 180°` (`RIG_STOP_BOUNDS`) — is rigc's to accept or refuse at the rig stage's gate, in rigc's words (`RIG_RIGC_GREEN`). **Rising-limb / prone geometry (issue #447):** rig-c's `expandStops` aims `<chain>_rest` from `links[0]`'s setup origin at `<chain>_touch` (`at` in `against`'s local frame) and clamps `<link>_d` inside `[rest − inward, rest + outward]`; Spine wraps rotation at `±180°`, so `\|rest\| + outward <= 180°` is required (`RIG_STOP_BOUNDS`). Whenever `<chain>_touch` lies **above** `links[0]`'s root in rig pixels (`ty < y0`, i.e. higher Spine `y` — e.g. stopping a hanging cloth chain against a rising shin `leg_<s1>` in a prone or kneeling pose where the knee sits below `links[0]` and the ankle above it, so positive `at[0]` walks upward along the shin past `links[0]`'s root), `rest` lands in the upper half-plane (`\|rest\| > 90°`) and `\|rest\| + outward` exceeds `180°`. Stop against the descending thigh (`leg_<s0>`), set `links` to start at a link whose root sits above `<chain>_touch`, or omit the stop when the rising shin sits outside the hanging chain's sweep; `propose --from-config` prints `LINT stop on <chain> …` with the exact coordinates and angles when `<chain>_touch` lies above `links[0]`'s root or `\|rest\| + outward > 180°`. 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 |
129
129
  | `turn` | rig (adds the turn control) | **proposed** only with `propose --full`/`--head` (issue #251), then corrected: `{pivot, depths, deform?, band?, radius?, surface?: {radius?}, head?: {pivot?, radius?}}`. `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. Optional `deform` (`Partial<FaceDeformFractions>`, issue #436) overrides the Set B ×2.5 face surface deformation table (`FACE_DEFORM_FRACTIONS`, checked against `FACE_DEFORM_RANGES` by `CONFIG_TURN_DEFORM_RANGE`); when `applyFaceSurfaceDeform` runs on a rig whose `motion` carries `tilt` or `turn` slider `derive` keys, it requires `config.turn` (`CONFIG_TURN_REQUIRED`, issue #478; `propose --full`/`--head` drafts it), promotes `face` on `head` (or `turn_face_head` when `turn` is declared) to the uneven 5×5 grid mesh, keys `face`, `hair_front` and `hair_back` deform timelines and ear/topknot tracks from `evalPitchFaceSurface` and `evalYawFaceSurface`, and samples the same deform field across each `features` member's rest span (`featRx = (24 / 106) · W`, `featRy = (12 / 128) · H`) with its depth fraction `z / zRef` as the field's angle input and chord foreshortening (`scalex` narrowing on the leading side and widening on the trailing side, `scaley` on pitch) so every feature's bounding box stays inside the deformed face plate across the rated band (issue #468). On yaw (`issue #479`), `evalYawFaceSurface` evaluates a **cylinder projection** (`cylinderYawDx`: `Δx(x, θ, R) = R · (sin(clamp(arcsin(clamp(x / R, −1, 1)) − θ, −π/2, π/2)) − clamp(x / R, −1, 1))`) of radius `R` (`turnSurfaceRadius`: `turn.surface.radius ?? turn.radius ?? turn.head.radius`, positive rig px checked by `CONFIG_FIELD_TYPE`, defaulting to half the face plate's opaque width `W / 2`) tapered by a cubic Hermite outline weight (`wOutline = 1` for `\|ux\| <= 0.7`, reaching `0` at `\|ux\| = 1.0`) so features slide across a fixed outline (`iris` shift within `±2%` of `cylinderYawDx`), the trailing cheek strip widens (`>= 1.54×` at `±15°`), and the leading jaw edge holds fixed (`0 px` shift) unless explicit horizontal `turn.deform` overrides (`turn_mid_x`, `turn_lead_compress_x`, `turn_trail_shift_x`) request the flat yaw table. On yaw (`issue #478`), `applyFaceSurfaceDeform` also derives a **head-only pivot** (`headTurnPivot`: `turn.head.pivot` when authored, otherwise the `opaque_px`-weighted mean of `depths[part]` across the head parts `DEFAULT_HEAD_TURN_PARTS` — `face`, `hair_front`, `hair_back`, `ear_r`, `ear_l`, `hairpin` — from `parts.json`, falling back to `turn.pivot`) so a forward torso or arm in `turn.depths` does not pull the head's rotation axis in front of `face`: `hair_back` (`depth_median > headPivot`, negative `headTurnFraction`) and `hairpin` behind `headPivot` translate opposite to the face's turn (`dx = s · turn_face_center_x · W · (headPivot − depth) / (headPivot − nearestHeadDepth)`), emerging on the trailing side to compensate for the leading-cheek foreshortening and keeping the combined head silhouette width near-constant across `±15°` without any same-sign `turn_hair_back_cheek_x` term. Optional `band` (`number` or `{yaw?, pitch?}`, positive degrees, issue #472) declares the rig's rated face turn band (default `FACE_RATED_BAND`: `yaw <= 15°`, `pitch <= 12°`); declaring a `turn.band` or a `motion.animations_from` `turn`/`tilt` `derive.degrees` above `±15°` yaw or `±12°` pitch without an `assemble.alternates` entry that replaces `face` is refused (`CONFIG_FACE_BAND_EXCEEDED`), and on a single-plate rig `applyFaceSurfaceDeform` adds self-targeting transform constraints `yaw_clamp` (`[-15, 15]`) and `pitch_clamp` (`[-12, 12]`) ahead of the slider constraints so driving `yaw` or `pitch` beyond the rated band clamps at the boundary. 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 `pivot` nor `depths` has a default (`CONFIG_FIELD_PRESENT`); `pivot` and `head.pivot` must lie behind the nearest part (`CONFIG_TURN_PIVOT_BEHIND_NEAREST`). Absent, no control is added and no byte of any output moves |
130
130
  | `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 |
131
- | `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 or cut-piece name: the `topwear` part that holds a skirt See-through returned inside it (a dress), or its skirt piece cut by `assemble.cuts`, which takes the skirt's trees (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 |
131
+ | `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?, influence?}`. `influence` (issue #518) — `{across, max, shape, radius?}`: the parts this recipe meshes are drafted in the influence mode (`meshes.<part>.influence` above) at their lattice's cell, with `across`, `max` and `shape` as declared (each required — the reading behind the radius did not vary them) and `radius` as declared or, absent, drafted as the farthest vertex's distance plus 3 cells (the `influence.radius` row); without it the parts keep their lattice. `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 or cut-piece name: the `topwear` part that holds a skirt See-through returned inside it (a dress), or its skirt piece cut by `assemble.cuts`, which takes the skirt's trees (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 |
132
132
  | `proposed_rig_scale` | assemble, rig, build, `propose --from-config`/`--compare` | **proposed** by `propose` (issue #354): `parts.json`'s `scale_rig_per_source`, the `assemble.rig_scale` the rig sections (`bones`, `meshes`, `limbs`, `motion`) were drafted at. Held equal to `assemble.rig_scale` when present (`CONFIG_PROPOSED_RIG_SCALE`; 0, negative or not a number: `CONFIG_FIELD_TYPE`). Absent on a hand-authored config, where no byte of any output moves |
133
133
 
134
134
  **One drawing, one band; beyond it, another drawing (issue #472).** A single front-facing
@@ -2698,7 +2698,7 @@ whites, an earring — antialiased strokes that are mostly rim, and the largest
2698
2698
  because an opaque white garment has the page's colour and is a real part.
2699
2699
 
2700
2700
  No example layer crosses a rule, so their proposals are unchanged. For the haze the
2701
- selftest plants (`PL03`, `PL06`: near-white, four pixels in five at alpha 40, 2.000x the
2701
+ selftest plants (`PU03`, `PU06`: near-white, four pixels in five at alpha 40, 2.000x the
2702
2702
  rest of the figure), the `WARN` line and the note say the same thing:
2703
2703
 
2704
2704
  ```
@@ -3620,7 +3620,7 @@ examples `rig.json`, `motion.json`, every image, the atlas, the packed page and
3620
3620
  every idle frame are byte-identical once `<id>:` and `<id>.` are taken off, and
3621
3621
  `skeleton.json` and `skeleton.model.json` equal as values but for Spine's `path`
3622
3622
  and the model's `spine.sha256`, which on each side is the sha256 of its own
3623
- `skeleton.json` and so changes with the names (selftest `SC33`).
3623
+ `skeleton.json` and so changes with the names (selftest `CH910`).
3624
3624
 
3625
3625
  **Not offered.** Reconciling two `rig_scale`s (one is required; `scale` sizes a
3626
3626
  character, it does not resample its art); a non-uniform scale, a flip or a rotation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/parts",
3
- "version": "1.41.1",
3
+ "version": "1.42.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/cloth.ts CHANGED
@@ -101,8 +101,26 @@ export interface ClothRecipe {
101
101
  part?: string | string[];
102
102
  /** A list of parts the recipe's trees run through in order from root to tip, one chain across the union and each link weighted to the part whose pixels it crosses (issue #437; the single-part form is the one-element list). */
103
103
  parts?: string[];
104
+ /**
105
+ * Issue #518: draft the parts this recipe meshes in the influence mode (`meshes.<part>.influence`, issue #378) rather
106
+ * than on a lattice: `across`, `max` and `shape` as declared (no default — the reading that fixed the radius did not
107
+ * vary them), `cell` the lattice cell the part would have had, and `radius` as declared or, absent, drafted as
108
+ * {@link INFLUENCE_RADIUS_CELLS} cells past the part's farthest lattice vertex from its nearest link.
109
+ */
110
+ influence?: { across: boolean; max: number; shape: 'linear' | 'smooth'; radius?: number };
104
111
  }
105
112
 
113
+ /**
114
+ * 📐 Issue #518: the drafted influence radius is the part's farthest lattice vertex from its nearest link (the figure
115
+ * `RIG_INFLUENCE_REACH` holds the radius above) plus this many of the part's lattice cells. Measured in #513 on the
116
+ * cloth fixture and the public `wind` example (8 covered parts, `render --folds` with the physics on under wind
117
+ * +1 -> -1 -> calm and a hip sway of 8 and 30 degrees, max 6, across, smooth): farthest + 2 to + 6 cells read 0
118
+ * folded frames on every part, + 2 at the window's edge on one front-hair part, and a fold returned at 8-11 cells on
119
+ * another. 3 is one cell inside that edge. [Hypothesis until a third subject: each edge rests on one part.] Past the
120
+ * floor alone the mesh folds more than its lattice, and a larger radius is not safer; no ceiling is drafted.
121
+ */
122
+ export const INFLUENCE_RADIUS_CELLS = 3;
123
+
106
124
  export type ClothRecipes = Partial<Record<ClothTarget, ClothRecipe>>;
107
125
 
108
126
  /**
package/src/config.ts CHANGED
@@ -3414,7 +3414,7 @@ function checkCloth(c: Check, v: Json): void {
3414
3414
  for (const tag of CLOTH_TARGETS) {
3415
3415
  if (!(tag in v)) continue;
3416
3416
  const path = `${at}.${JSON.stringify(tag)}`;
3417
- const r = c.object(path, v[tag], ['links', 'wind', 'gravity'], ['chains', 'split', 'length_ratio', 'strength', 'damping', 'alternate_damping', 'translate', 'swing', 'part', 'parts']);
3417
+ const r = c.object(path, v[tag], ['links', 'wind', 'gravity'], ['chains', 'split', 'length_ratio', 'strength', 'damping', 'alternate_damping', 'translate', 'swing', 'part', 'parts', 'influence']);
3418
3418
  if (r === null) continue;
3419
3419
  if (tag !== 'back hair' && !('chains' in r)) c.fail('CONFIG_FIELD_PRESENT', `${path}.chains`, 'is absent and required');
3420
3420
  const chains = 'chains' in r && c.int(`${path}.chains`, r.chains, 1) ? (r.chains as number) : null;
@@ -3431,6 +3431,17 @@ function checkCloth(c: Check, v: Json): void {
3431
3431
  }
3432
3432
  }
3433
3433
  if ('length_ratio' in r) c.number(`${path}.length_ratio`, r.length_ratio, 'positive');
3434
+ // Issue #518: the influence mode for the parts this recipe meshes; the three fields #513 did not vary are the
3435
+ // author's, each required, and radius, when stated, is kept as stated (the rig stage holds it to the reach).
3436
+ if ('influence' in r) {
3437
+ const o = c.object(`${path}.influence`, r.influence, ['across', 'max', 'shape'], ['radius']);
3438
+ if (o !== null) {
3439
+ if ('across' in o && typeof o.across !== 'boolean') c.fail('CONFIG_FIELD_TYPE', `${path}.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`);
3440
+ if ('max' in o) c.int(`${path}.influence.max`, o.max, 1);
3441
+ if ('shape' in o && o.shape !== 'linear' && o.shape !== 'smooth') c.fail('CONFIG_FIELD_TYPE', `${path}.influence.shape`, `is ${show(o.shape)}; "linear" (1 - x) or "smooth" (1 - x²(3 - 2x)) is required`);
3442
+ if ('radius' in o) c.number(`${path}.influence.radius`, o.radius, 'positive');
3443
+ }
3444
+ }
3434
3445
  if ('strength' in r) {
3435
3446
  const st = c.object(`${path}.strength`, r.strength, ['trunk', 'branch', 'edge'], []);
3436
3447
  if (st !== null) for (const k of ['trunk', 'branch', 'edge'] as const) if (k in st) c.number(`${path}.strength.${k}`, st[k], 'positive');
package/src/propose.ts CHANGED
@@ -142,6 +142,8 @@ import { type Mask, newMask, newRaster, type Raster } from './raster/types.ts';
142
142
  import { npMean, npMedian, npPercentile, pyFixed, pyInt, pyIntList, pyRepr, pyRound, pyStrList } from './pyfmt.ts';
143
143
  import type { JointState, RigJoint, RigJoints } from './keypoints.ts';
144
144
  import { IDLE_FPS } from './motion.ts';
145
+ import { influenceFarthest } from './rig.ts';
146
+ import { type Segment as WeightSegment } from './weights.ts';
145
147
  import { pyRound as roundTo } from './round.ts';
146
148
  import { KEYPOINT_NAMES, type KeypointName } from './skeleton.ts';
147
149
  import { configRoles, type RoleOf } from './structure.ts';
@@ -150,7 +152,7 @@ import { TURN_BONE, TURN_CARRIER_TAG, TURN_PLACES, TURN_RIDER_OFFSET, TURN_RIDER
150
152
  import { edgeLength } from './length.ts';
151
153
  import { bonePlaces, jointLine, limbCrossing, limbPolyline, limbRun, limbWidth, nearestLimb, nearestOnLine, offLineFigure, type Pt } from './limbs.ts';
152
154
  import { type BranchSqueezeFinding, branchSqueezes, chainSqueezes, type SqueezeFinding } from './squeeze.ts';
153
- import { backHairMasses, type BackHairMass, backHairMassTrees, RECIPE_BACK_HAIR_CHAINS, RECIPE_LENGTH_RATIO, chainConstraints, clothNote, type ClothRecipe, type ClothRecipes, type ClothTarget, CLOTH_TARGETS, draftTrees, spanCrosses, swingName, type Tail, tailOverlap, type TailOverlap, type TailSpan, treeConstraints, type TreeChain, type TreeInput, type TreeMassInput } from './cloth.ts';
155
+ import { backHairMasses, type BackHairMass, backHairMassTrees, INFLUENCE_RADIUS_CELLS, RECIPE_BACK_HAIR_CHAINS, RECIPE_LENGTH_RATIO, chainConstraints, clothNote, type ClothRecipe, type ClothRecipes, type ClothTarget, CLOTH_TARGETS, draftTrees, spanCrosses, swingName, type Tail, tailOverlap, type TailOverlap, type TailSpan, treeConstraints, type TreeChain, type TreeInput, type TreeMassInput } from './cloth.ts';
154
156
  import { TEXTURE_STRETCH_CEILING } from './check.ts';
155
157
 
156
158
  // ---------------------------------------------------------------------------
@@ -1392,7 +1394,7 @@ export function proposeWithBasis(
1392
1394
  gridRule: GridRule = DEFAULT_GRID_RULE,
1393
1395
  cloth: ClothRecipes | null = null,
1394
1396
  chainRule = true,
1395
- ): { proposal: Proposal; basis: ProposalBasis; jointsOffArt: LimbJointOffArtFinding[] } {
1397
+ ): { proposal: Proposal; basis: ProposalBasis; draftLint: DraftLintFinding[] } {
1396
1398
  // Issue #230: a piece is not given its base's rule a second time, which
1397
1399
  // needs to know which part is the piece. A file that cannot say is refused
1398
1400
  // here, and only here: every other reader of parts.json still takes it.
@@ -1559,6 +1561,8 @@ export function proposeWithBasis(
1559
1561
  // Issue #364: the trees a cloth recipe drafts, their constraints, and the tags it was used on.
1560
1562
  const clothConstraints: ConfigConstraint[] = [];
1561
1563
  const clothUsed = new Set<ClothTarget>();
1564
+ /** Issue #518: each part a recipe meshes, by the target whose recipe drafted its mesh. */
1565
+ const clothMeshed = new Map<string, ClothTarget>();
1562
1566
  const multiPartClaimed = new Set<string>();
1563
1567
  const recipeOf = (tag: ClothTarget): ClothRecipe | null => cloth?.[tag] ?? null;
1564
1568
  const declaredPartsOf = (tag: ClothTarget): { field: 'parts' | 'part'; list: PartRecord[] } | null => {
@@ -1954,6 +1958,7 @@ export function proposeWithBasis(
1954
1958
  linkSummary.push(`${q.name}: ${crossedDesc.join(', ')}`);
1955
1959
  delete regions[q.name];
1956
1960
  meshes[q.name] = { grid: gq, r: rcp.split?.hold_tip === true ? Math.max(rq, gq) : rq, segments: qSegs };
1961
+ clothMeshed.set(q.name, 'back hair');
1957
1962
  multiPartClaimed.add(q.name);
1958
1963
  }
1959
1964
  notes.push(
@@ -2121,6 +2126,7 @@ export function proposeWithBasis(
2121
2126
  ),
2122
2127
  );
2123
2128
  meshes[p.name] = { grid: g, r: rawRcp.split?.hold_tip === true ? Math.max(r, g) : r, segments: segs };
2129
+ clothMeshed.set(p.name, 'back hair');
2124
2130
  // Issue #391: the spans are this mesh's segments, the head's fixed one and every tree link, in segment order.
2125
2131
  const spans: TailSpan[] = [{ bone: 'head', a: rnd(head), b: rnd([axis, top + 13]), link: false }];
2126
2132
  for (const t of all) {
@@ -2297,6 +2303,7 @@ export function proposeWithBasis(
2297
2303
  }
2298
2304
  const frontRcp = recipeOf('front hair');
2299
2305
  meshes[p.name] = { grid: g, r: frontRcp?.split?.hold_tip === true && k > 0 ? Math.max(r, g) : r, segments: segs };
2306
+ if (frontRcp !== null && clothUsed.has('front hair')) clothMeshed.set(p.name, 'front hair');
2300
2307
  }
2301
2308
 
2302
2309
  // ---- accessories: rigid body + pendant chain where the part narrows, or one pendulum chain per hanging strand
@@ -3102,6 +3109,7 @@ export function proposeWithBasis(
3102
3109
  linkSummary.push(`${q.name}: ${crossedDesc.join(', ')}`);
3103
3110
  delete regions[q.name];
3104
3111
  meshes[q.name] = { grid: gq, r: dressRecipe.split?.hold_tip === true ? Math.max(rq, gq) : rq, segments: qSegs };
3112
+ clothMeshed.set(q.name, 'bottomwear');
3105
3113
  multiPartClaimed.add(q.name);
3106
3114
  }
3107
3115
  notes.push(
@@ -3172,6 +3180,7 @@ export function proposeWithBasis(
3172
3180
  ),
3173
3181
  );
3174
3182
  meshes[p.name] = { grid: g, r: skirtRecipe.split?.hold_tip === true ? Math.max(r, g) : r, segments: segs };
3183
+ clothMeshed.set(p.name, 'bottomwear');
3175
3184
  continue;
3176
3185
  }
3177
3186
  for (const [tag, f, ph] of [
@@ -3365,11 +3374,34 @@ export function proposeWithBasis(
3365
3374
  );
3366
3375
  }
3367
3376
  }
3377
+ // Issue #518: a recipe that declares `influence` has the parts it meshes drafted in the influence mode, each at the
3378
+ // cell its lattice had, and — unless the recipe states the radius — at the radius INFLUENCE_RADIUS_CELLS cells past
3379
+ // the farthest lattice vertex from its nearest link, measured as the rig stage measures it (influenceFarthest).
3380
+ const radii: InfluenceRadiusFinding[] = [];
3381
+ for (const [name, tag] of clothMeshed) {
3382
+ const decl = recipeOf(tag)?.influence;
3383
+ const m = meshes[name];
3384
+ if (decl === undefined || m === undefined || !('grid' in m)) continue;
3385
+ const segments = m.segments;
3386
+ const cell = m.grid;
3387
+ let radius = decl.radius;
3388
+ if (radius === undefined) {
3389
+ const rec = P.recs.find((q) => q.name === name) as PartRecord;
3390
+ const farthest = influenceFarthest(P.images.get(name) as Raster, rec.x, rec.y, meshSegmentsOf(bones, segments), cell);
3391
+ if (farthest === null) {
3392
+ notes.push(`${name}: config.cloth.${JSON.stringify(tag)}.influence is declared, and rig-c's segments lattice refuses the part at cell ${cell}, so no radius is measured and it keeps its lattice mesh`);
3393
+ continue;
3394
+ }
3395
+ radius = roundTo(farthest + INFLUENCE_RADIUS_CELLS * cell, 4);
3396
+ radii.push({ kind: 'influence-radius', part: name, tag, radius, farthest: roundTo(farthest, 4), cells: INFLUENCE_RADIUS_CELLS, cell });
3397
+ }
3398
+ meshes[name] = { influence: { cell, radius, across: decl.across, max: decl.max, shape: decl.shape }, segments };
3399
+ }
3368
3400
  const constrained = clothConstraints.length === 0 ? {} : { constraints: clothConstraints };
3369
3401
  return {
3370
3402
  proposal: { bones, meshes, regions, ...drafted, motion: blink === undefined ? { duration: IDLE_SECONDS, tracks: idleTracks } : { duration: IDLE_SECONDS, tracks: idleTracks, blink }, ...constrained, proposed_rig_scale: P.rigScale, notes },
3371
3403
  basis: { frame, bones: records },
3372
- jointsOffArt,
3404
+ draftLint: [...jointsOffArt, ...radii],
3373
3405
  };
3374
3406
  }
3375
3407
 
@@ -3695,6 +3727,39 @@ function anklesOffArt(P: PartSet, legs: readonly LegChain[], feet: readonly Part
3695
3727
  return out;
3696
3728
  }
3697
3729
 
3730
+ /**
3731
+ * Issue #518: a mesh's `segments` resolved to lines on the bones `bones` declares, as the rig stage resolves them
3732
+ * (`src/rig.ts`): a chain's name to each of its links, from the link's origin to the next link's or the tip; a single
3733
+ * bone to its origin and tip; an explicit `[bone, from, to]` as written. A name with no line resolves to nothing — the
3734
+ * rig stage names it (`RIG_SEGMENT_DEFINED`, `RIG_NAME_RESOLVES`).
3735
+ */
3736
+ function meshSegmentsOf(bones: readonly BoneEntry[], segments: readonly Segment[]): WeightSegment[] {
3737
+ const out: WeightSegment[] = [];
3738
+ for (const sp of segments) {
3739
+ if (typeof sp !== 'string') {
3740
+ out.push({ bone: sp[0], a: [sp[1][0], sp[1][1]], b: [sp[2][0], sp[2][1]] });
3741
+ continue;
3742
+ }
3743
+ const chain = bones.find((e) => 'chain' in e && e.chain === sp);
3744
+ if (chain !== undefined && 'chain' in chain) {
3745
+ chain.points.forEach((q, k) => {
3746
+ const end = k + 1 < chain.points.length ? chain.points[k + 1] : chain.tip;
3747
+ out.push({ bone: `${sp}${k}`, a: [q[0], q[1]], b: [end[0], end[1]] });
3748
+ });
3749
+ continue;
3750
+ }
3751
+ const link = bones.flatMap((e) => ('chain' in e ? e.points.map((q, k) => ({ name: `${e.chain}${k}`, a: q, b: k + 1 < e.points.length ? e.points[k + 1] : e.tip })) : []));
3752
+ const l = link.find((x) => x.name === sp);
3753
+ if (l !== undefined) {
3754
+ out.push({ bone: sp, a: [l.a[0], l.a[1]], b: [l.b[0], l.b[1]] });
3755
+ continue;
3756
+ }
3757
+ const single = bones.find((e) => !('chain' in e) && e.name === sp);
3758
+ if (single !== undefined && !('chain' in single) && single.tip !== undefined) out.push({ bone: sp, a: [single.at[0], single.at[1]], b: [single.tip[0], single.tip[1]] });
3759
+ }
3760
+ return out;
3761
+ }
3762
+
3698
3763
  interface LegChain {
3699
3764
  chain: string;
3700
3765
  side: 'r' | 'l';
@@ -4393,6 +4458,24 @@ export interface LimbJointOffArtFinding {
4393
4458
  nearest: { distance: number; at: Pt } | null;
4394
4459
  }
4395
4460
 
4461
+ /**
4462
+ * Issue #518: an influence radius `propose --cloth` drafted (no radius stated in the recipe): the part, the recipe's
4463
+ * target, and the rule's figures — `radius = farthest + cells × cell`, `farthest` the part's farthest lattice vertex
4464
+ * from its nearest link as `RIG_INFLUENCE_REACH` measures it. A LINT so the author sees what was drawn and from what.
4465
+ */
4466
+ export interface InfluenceRadiusFinding {
4467
+ kind: 'influence-radius';
4468
+ part: string;
4469
+ tag: ClothTarget;
4470
+ radius: number;
4471
+ farthest: number;
4472
+ cells: number;
4473
+ cell: number;
4474
+ }
4475
+
4476
+ /** What `propose` hands `lint` beside the proposal: findings of the draft itself, not of a check over the spec. */
4477
+ export type DraftLintFinding = LimbJointOffArtFinding | InfluenceRadiusFinding;
4478
+
4396
4479
  export type LintFinding =
4397
4480
  | OffArtFinding
4398
4481
  | OffLockFinding
@@ -4408,7 +4491,8 @@ export type LintFinding =
4408
4491
  | OverlappingArmsFinding
4409
4492
  | CrossedLimbsFinding
4410
4493
  | StopTouchAboveRootFinding
4411
- | LimbJointOffArtFinding;
4494
+ | LimbJointOffArtFinding
4495
+ | InfluenceRadiusFinding;
4412
4496
 
4413
4497
  /** Which rule set read the torso and the sleeve chains, under `--keypoints`. */
4414
4498
  export interface LintBasis {
@@ -4510,7 +4594,7 @@ export function lint(
4510
4594
  P: PartSet,
4511
4595
  spec: { bones: readonly BoneEntry[]; meshes: Readonly<Record<string, MeshSpec>>; regions?: Readonly<Record<string, string>>; motion?: SkeletonSections['motion']; constraints?: readonly ConfigConstraint[]; limbs?: Readonly<Record<string, Limb>>; stops?: readonly ConfigStop[] },
4512
4596
  joints?: RigJoints,
4513
- drafted: readonly LimbJointOffArtFinding[] = [],
4597
+ drafted: readonly DraftLintFinding[] = [],
4514
4598
  ): LintResult {
4515
4599
  const { byName } = expand(spec.bones);
4516
4600
  const parts = new Map(P.recs.map((p) => [p.name, p]));
@@ -4523,7 +4607,7 @@ export function lint(
4523
4607
  const list = read.get(n);
4524
4608
  if (list !== undefined && !list.includes(check)) list.push(check);
4525
4609
  };
4526
- for (const f of drafted) readBy(f.link, `limb-joint-off-art on ${f.limb}`);
4610
+ for (const f of drafted) if (f.kind === 'limb-joint-off-art') readBy(f.link, `limb-joint-off-art on ${f.limb}`);
4527
4611
  for (const [mname, m] of Object.entries(spec.meshes)) {
4528
4612
  const part = parts.get(mname);
4529
4613
  if (part === undefined) {
@@ -4963,6 +5047,8 @@ function findingBones(f: LintFinding, bones: readonly BoneEntry[]): string[] {
4963
5047
  return [f.bone];
4964
5048
  case 'limb-joint-off-art':
4965
5049
  return [f.link];
5050
+ case 'influence-radius':
5051
+ return [];
4966
5052
  case 'hip-not-below-chest':
4967
5053
  case 'hip-not-past-chest':
4968
5054
  return ['hip', 'chest'];
@@ -5136,6 +5222,11 @@ export function basisLines(b: LintBasis): string[] {
5136
5222
  */
5137
5223
  export function lintLine(f: LintFinding): string {
5138
5224
  switch (f.kind) {
5225
+ case 'influence-radius':
5226
+ return (
5227
+ `LINT ${f.part} on mesh ${pyRepr(f.part)}: influence radius ${f.radius} = farthest ${f.farthest} + ${f.cells} × cell ${f.cell} — drafted by config.cloth.${JSON.stringify(f.tag)}.influence, ` +
5228
+ `the farthest lattice vertex from its nearest link (the figure RIG_INFLUENCE_REACH holds the radius above) plus ${f.cells} cells; a radius at the floor folds more than the lattice and a larger one is not safer (AUTHORING, influence.radius) — state influence.radius in the recipe to keep your own`
5229
+ );
5139
5230
  case 'limb-joint-off-art':
5140
5231
  return (
5141
5232
  `LINT ${f.part} at ${pyIntList(f.at)}, the ${f.keypoint} joint and ${f.link}'s tip, lies on none of ${f.limb}'s art within 1 px along its joint line (${offLineFigure(f.nearest)}), ` +
package/src/rig.ts CHANGED
@@ -757,6 +757,30 @@ export function influenceReach(points: ReadonlyArray<readonly [number, number]>,
757
757
  return best;
758
758
  }
759
759
 
760
+ /**
761
+ * Issue #518: the figure {@link influenceReach} holds an influence mesh's radius above, measured as the rig stage
762
+ * measures it — rig-c's segments lattice at `cell` over the part padded by {@link PAD} (alpha above
763
+ * {@link INFLUENCE_THRESHOLD}), and each vertex's distance to its nearest of `segs` (rig px, as the bones place them)
764
+ * — for `propose` to draft a radius from before any rig is built. Null when rig-c's lattice refuses the part, which
765
+ * the rig stage then names (`RIG_INFLUENCE_LATTICE`).
766
+ */
767
+ export function influenceFarthest(img: Raster, x: number, y: number, segs: readonly Segment[], cell: number): number | null {
768
+ const padded = pad(img, PAD, PAD, PAD, PAD, [0, 0, 0, 0]);
769
+ const alpha = new Uint8Array(padded.width * padded.height);
770
+ for (let i = 0; i < alpha.length; i++) alpha[i] = padded.data[i * 4 + 3];
771
+ let lattice: SegmentsLattice;
772
+ try {
773
+ lattice = buildSegmentsLattice({ mask: { width: padded.width, height: padded.height, alpha }, threshold: INFLUENCE_THRESHOLD, cell });
774
+ } catch {
775
+ return null;
776
+ }
777
+ const ox = x - PAD;
778
+ const oy = y - PAD;
779
+ const names = [...new Set(segs.map((s) => s.bone))];
780
+ const local: EntrySegment[] = segs.map((s) => ({ bone: names.indexOf(s.bone), entry: 0, a: [s.a[0] - ox, s.a[1] - oy], b: [s.b[0] - ox, s.b[1] - oy] }));
781
+ return influenceReach(lattice.points, local, names).distance;
782
+ }
783
+
760
784
  /**
761
785
  * Whether a declared radius reaches a vertex `distance` px from its nearest link: a link pulls only when it is NEARER
762
786
  * than radius (rig-c's `d < radius`; the pull is 0 at d = radius), so a radius equal to the distance does not.