@rig-c/parts 1.40.0 → 1.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.ts 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, 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 LimbJointOffArtFinding, 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';
@@ -1112,8 +1112,8 @@ function parseCanvas(v: string): { w: number; h: number } | null {
1112
1112
  return m === null ? null : { w: Number(m[1]), h: Number(m[2]) };
1113
1113
  }
1114
1114
 
1115
- function printLint(P: PartSet, spec: { bones: CharacterConfig['bones']; meshes: CharacterConfig['meshes']; regions: CharacterConfig['regions']; motion: CharacterConfig['motion']; constraints?: CharacterConfig['constraints'] }, joints?: RigJoints): number {
1116
- const res = lint(P, spec, joints);
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 {
1116
+ const res = lint(P, spec, joints, drafted);
1117
1117
  // Under --keypoints only: which rule set read the torso and the chains, and on what basis.
1118
1118
  if (res.basis !== undefined) for (const l of basisLines(res.basis)) console.log(l);
1119
1119
  for (const f of res.findings) console.log(lintLine(f));
@@ -1242,7 +1242,7 @@ function cmdPropose(args: string[]): number {
1242
1242
  }
1243
1243
  const cmpPath = flags.get('--compare');
1244
1244
  const cfg = cmpPath === undefined ? null : loadConfig(cmpPath);
1245
- const { proposal: drafted, basis } = proposeWithBasis(P, joints, wristSnap, gridRule, cloth);
1245
+ const { proposal: drafted, basis, jointsOffArt } = proposeWithBasis(P, joints, wristSnap, gridRule, cloth);
1246
1246
  const fullRun = flags.get('--full');
1247
1247
  const headRun = flags.get('--head');
1248
1248
  const prop =
@@ -1260,7 +1260,7 @@ function cmdPropose(args: string[]): number {
1260
1260
  if (img.head !== null) writePng(join(render, 'landmarks_head.png'), img.head);
1261
1261
  console.log(`wrote proposal.json (${prop.bones.length} bone entries, ${Object.keys(prop.meshes).length} meshes) and render/landmarks.png (+_head) under ${out}`);
1262
1262
  for (const n of prop.notes) console.log(`note: ${n}`);
1263
- printLint(P, prop, joints);
1263
+ printLint(P, prop, joints, jointsOffArt);
1264
1264
  console.log(basisLine(bfile, out));
1265
1265
  if (cfg !== null) for (const l of compareLines(compare(prop.bones, cfg.bones))) console.log(l);
1266
1266
  return EXIT_OK;
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 |
@@ -2234,7 +2235,7 @@ move off it (`AS245`).
2234
2235
  | `layers` | the table, then one `author-made: layer "author:<label>" — …` line per layer the author made (group `author` in the table; §5, *A layer the author made*), then the `WARN` lines | every tag the plan will need has opaque pixels; one `face` in the head run; `0 WARN line(s)` | a run whose layer PNG is not its box's size (`LAYERS_PNG_MATCHES_BBOX`); a `WARN PLAN_LAYER_…` line (§6, *Plausibility*) |
2235
2236
  | `sheet` of both runs | the tile list (and the sheet, if you can see) | eyes, irises, lashes and brows as left/right pairs in the head run | a head box that cut off an ornament: move `head_box`, re-run the head crop |
2236
2237
  | `assemble` | one line per part — its counts (`op=` opaque, `vis=` visible, `src=` taken / candidates, `unproj=` visible but not projected, `drift=<n> (<p>% of core)`, `merged=`, `seam=`; *parts.json*, below). `drift=` is `refused_drift_px` in rig px and its share of the part's candidates, `projected_core_px`, which it is a subset of (issue #314); no bar reads either. On the four public examples the share runs to 94.5 % (`scarf` `hair_back`, 479 of 507) and the count to 26,472 (`scarf` `topwear`, 22.3 %), and the seam override repaints refused top-most pixels afterwards, so a large count says where See-through's colour was not taken, not that the part is unlike the painting: the `drift:` line below is the one that names a body of them another part holds. Then the `pixels:` totals (opaque = visible + occluded; taken; visible but not projected), then `recomposite vs source: mean \|d\|, within 8, error px > 40, uncovered error px`, then `uncovered holes (8-connected): N` and the largest five as `uncovered hole K: <px> px at x,y wxh (between "<part>" <px> px, …)`, then one `uncovered: <n> of the <N> uncovered error px lie on the full run's "<tag>", in a body of <px> px at x,y wxh; <the rule that left it out>` line per full-run layer the plan does not take from the full run whose uncovered error holds a body (5x5-opened, 8-connected, at least 150 full-run px in rig px), then one `drift: "<part>" refuses <n> px of <run>:<tag> (its colour more than 90 off the painting, max channel), in a body of <px> px at x,y wxh (…); by the plan's draw order "<holder>" holds <px> px of it (…), "<holder>" drawn in front of "<part>"` line per part whose drift refusals hold a body (the same opening and bar) that another part holds in the draw order — that layer is not what the painting shows there (none on the five public paintings); and look at `render/recomposite_error_rig.png`. Between the part lines and the totals, one `author-made: part "<part>" (<run>:author:<label>) — …` line per part from a layer the author made (below, *A layer the author made*), then one `cut: "<part>" opaque <n> = "<part>" <kept> + "<piece>" <taken> …` line per part an `assemble.cuts` entry cut (below; it ends `; under <n> px filled, <m> px left empty` when a cut of that part has `under`), then — with `config.limbs` (issue #349) — one `limb cut: "<part>" opaque <n> = "<segment part>" <px> + …` line per part a limb takes and one `limb cap:` line per joint, its cap's pixels from the cap image, from the layer and missing, and its box — under `cap_shape: "disc"` also from the upper segment, under `edge: "feather"` the pixels faded, under `cut_band` the line the cut was placed on and the stroke pixels it and the joint line cross (issue #360) (§3, *Limbs: cut at their joints*), then one `fringe pushed back: "<part>" <px> px, where the painting shows "<holder>" <px> px, …` line per part whose fringe was cleared (below) | on the examples: `reference-sample` 0.83 / 98.0 % / 4,359 / 1,185, 259 holes, the largest 94 px; `reference-demo` 2.34 / 95.8 % / 10,340 / 1,564, 453 holes, the largest 70 px (default rule) — many slivers along part edges, no hole a region could hide | one large hole: part of the figure is in no layer — a plan entry is missing, hair left the head crop sideways (reference-demo's `hair_back` is taken from the full run for that reason), or See-through split one garment into two and left the space between them in neither (a skirt as two trouser legs); the `between` parts say where. When neither run holds it at all, an `assemble.patches` entry cuts it from the painting (below) |
2237
- | `propose` | `note:` lines, `LINT` lines, the `coverage` lines, `landmarks.png`, `basis.json` | no LINT line: every chain link lies on its mesh's art, and the hip is below the chest and the figure's top quarter; the `coverage:` summary says how many bones that verdict covers — a `not checked` bone was read by no check (its line says why), and a `ratio` or `fallback` bone in `basis.json` is a guess | a link off the art (a bone on the background) — move it onto the layer; `LINT <link> at … runs to … N degrees off the head's down axis …` — a fringe link that does not lean with the head (§3, the fringe in the head's frame): move it along the lock it drives; `LINT hairback_… on mesh '<part>' (side <r\|l>): <N> tree(s) for <M> visible hair mass(es) (mass 0 columns x=<minX>..<maxX>, y=<minY>..<maxY>; …)` — back-hair cloth trees whose count does not match the side's visible hair masses (`max(1, floor(w / (4 * grid)) + 1)` per mass) or whose link or tip leaves its mass's column range (issues #445, #461): omit `chains` on `cloth."back hair"` or draft trees per visible hair mass inside its columns; `LINT <a_limb> and <b_limb> on <part> (<from>) cross at [x, y] with no per-limb split: …` — two limbs sharing one layer cross in an X without a per-limb split (issue #446): declare `config.limbs.<covering>.split` (`{ "line": [[x, y], …] }` or `{ "edge": "painting" }`, §3 *Which limb*); `LINT stop on <chain> (<firstLink> at [x0, y0]) against <against> (at [ax, ay]) places <chain>_touch at [tx, ty], above <firstLink>'s root (rest R deg, \|rest\| + outward B deg): …` — a stop's contact point `<chain>_touch` lies above `links[0]`'s root in rig px or pushes `\|rest\| + outward` past `180°` (issue #447, §2 `stops`): stop against the descending limb bone below `firstLink`, set `links` to start at a link below `<chain>_touch`, or omit the stop on a rising limb; `LINT hip at [x, y] is not below chest at [x, y]: …` or `LINT hip at [x, y] is above 0.25 of the figure height (figure y T..B, so hip y must be at least L): a hip at the shoulders` — move `hip` down to the waist (and `chest` between it and the neck); a `hanging strand … -- no chain proposed` note — that strand hangs stiff until you add a chain down the x and rows it names (§3); a `no blink: …` or `blink without brows: …` note — the idle will not blink (or its brows will not drop), because no part came from an `eyewhite` (or `eyebrow`) layer; the note names the tags looked for; a `no eyewhite part for eye_<s> …` note — the iris and lash parts it names ride `head` and do not blink, because no `eyewhite-<s>` part made that side's eye bone: take the eyewhite from the other run, or keep them on `head`; a `no face part: face box derived from …` note (always the first) — `head`, `neck` and every face-height scale come from a box guessed off the hair and neck (§3): check `head` and `neck` on `landmarks_head.png` and move them; when it adds `the blink shuts the eyes over no face part`, read `BLINK_NO_HOLE` after `check` — an eye with no face under it can open a hole (the `reference-sample` with only its face removed: 587 px). Under `--keypoints`: the `lint rule set:` line first (joints, or screen and why), then the joint notes — `missing: the rule "…" placed bone X instead` is a bone still guessed; `not used — …` names why an arm's joints did not place its sleeve (for a wrist on no part, the nearest part and the `--wrist-snap` that would bind it); a `wrist snap: …` note is a wrist bound past 15 px by the flag — check that chain's tip on `landmarks.png`; a `one handwear part holds both wrists` note is two chains on one mesh — cut the part with `assemble.cuts` to separate them; `LINT chest at … is not between the neck joint …`, `LINT hip at … is not past chest …`, `LINT hip at … is nearer the neck joint …` and `LINT <chain><i> at … does not advance from <s>_shoulder toward <s>_wrist` are the joint-frame lines: move that bone between, past or along the joints they name |
2238
+ | `propose` | `note:` lines, `LINT` lines, the `coverage` lines, `landmarks.png`, `basis.json` | no LINT line: every chain link lies on its mesh's art, and the hip is below the chest and the figure's top quarter; the `coverage:` summary says how many bones that verdict covers — a `not checked` bone was read by no check (its line says why), and a `ratio` or `fallback` bone in `basis.json` is a guess | a link off the art (a bone on the background) — move it onto the layer; `LINT <link> at … runs to … N degrees off the head's down axis …` — a fringe link that does not lean with the head (§3, the fringe in the head's frame): move it along the lock it drives; `LINT hairback_… on mesh '<part>' (side <r\|l>): <N> tree(s) for <M> visible hair mass(es) (mass 0 columns x=<minX>..<maxX>, y=<minY>..<maxY>; …)` — back-hair cloth trees whose count does not match the side's visible hair masses (`max(1, floor(w / (4 * grid)) + 1)` per mass) or whose link or tip leaves its mass's column range (issues #445, #461): omit `chains` on `cloth."back hair"` or draft trees per visible hair mass inside its columns; `LINT <a_limb> and <b_limb> on <part> (<from>) cross at [x, y] with no per-limb split: …` — two limbs sharing one layer cross in an X without a per-limb split (issue #446): declare `config.limbs.<covering>.split` (`{ "line": [[x, y], …] }` or `{ "edge": "painting" }`, §3 *Which limb*); `LINT foot_<s> at [x, y], the <s>_ankle joint and leg_<s>1's tip, lies on none of leg_<s>'s art within 1 px along its joint line (the nearest of it on that line is the pixel [x, y], D px from the joint): …` — an ankle keypoint off its leg's art on the line `assemble` sizes the ankle's cap by (issue #517): `propose` drafts every leg without its ankle cut, the shoe layer stays one part, and nothing is moved onto the art; move that ankle keypoint onto the leg's or the shoe's art and re-run `propose` (`(the line crosses none of it)` when no art lies on that line at all); `LINT stop on <chain> (<firstLink> at [x0, y0]) against <against> (at [ax, ay]) places <chain>_touch at [tx, ty], above <firstLink>'s root (rest R deg, \|rest\| + outward B deg): …` — a stop's contact point `<chain>_touch` lies above `links[0]`'s root in rig px or pushes `\|rest\| + outward` past `180°` (issue #447, §2 `stops`): stop against the descending limb bone below `firstLink`, set `links` to start at a link below `<chain>_touch`, or omit the stop on a rising limb; `LINT hip at [x, y] is not below chest at [x, y]: …` or `LINT hip at [x, y] is above 0.25 of the figure height (figure y T..B, so hip y must be at least L): a hip at the shoulders` — move `hip` down to the waist (and `chest` between it and the neck); a `hanging strand … -- no chain proposed` note — that strand hangs stiff until you add a chain down the x and rows it names (§3); a `no blink: …` or `blink without brows: …` note — the idle will not blink (or its brows will not drop), because no part came from an `eyewhite` (or `eyebrow`) layer; the note names the tags looked for; a `no eyewhite part for eye_<s> …` note — the iris and lash parts it names ride `head` and do not blink, because no `eyewhite-<s>` part made that side's eye bone: take the eyewhite from the other run, or keep them on `head`; a `no face part: face box derived from …` note (always the first) — `head`, `neck` and every face-height scale come from a box guessed off the hair and neck (§3): check `head` and `neck` on `landmarks_head.png` and move them; when it adds `the blink shuts the eyes over no face part`, read `BLINK_NO_HOLE` after `check` — an eye with no face under it can open a hole (the `reference-sample` with only its face removed: 587 px). Under `--keypoints`: the `lint rule set:` line first (joints, or screen and why), then the joint notes — `missing: the rule "…" placed bone X instead` is a bone still guessed; `not used — …` names why an arm's joints did not place its sleeve (for a wrist on no part, the nearest part and the `--wrist-snap` that would bind it); a `wrist snap: …` note is a wrist bound past 15 px by the flag — check that chain's tip on `landmarks.png`; a `one handwear part holds both wrists` note is two chains on one mesh — cut the part with `assemble.cuts` to separate them; `LINT chest at … is not between the neck joint …`, `LINT hip at … is not past chest …`, `LINT hip at … is nearer the neck joint …` and `LINT <chain><i> at … does not advance from <s>_shoulder toward <s>_wrist` are the joint-frame lines: move that bone between, past or along the joints they name |
2238
2239
  | `compare` | one line per pair (origin, parent, tip, length, direction — or SKIP and why), then the per-row summary, the unmapped bones of each side, `required:`, each side's roles and the `controls:` line | proposal against the config you corrected: the rows you changed and no others. Config against the `rig.json` `build` writes for it: measured on both examples, every origin within 6.19e-7 px (the rig's offsets are written to 6 places) and every chain link's tip and length within 4.99e-4 px (`length` is written to 3), printed to three places as `0.000` (a signed figure as `+0.000` or `-0.000`); `parent … is the right's ancestor at depth 2, <bone>_ctl between` for every keyed mesh bone, no `DIFFERENT` and no `NOT MAPPED` | `parent DIFFERENT: left a, right b` — a bone hangs from another parent than the other side's; `frames not related` — a rig with no stage (`skeleton.width`/`height`), two configs at different `rig_scale`: the distance rows SKIP, so declare the frame in a `--map` file if the author knows it; `FAIL STRUCTURE_REQUIRED_PRESENT` — a bone the map requires is missing through its pairs |
2239
2240
  | `rig` (inside `build`) | one line per mesh: vertices, triangles, bones, influences, `cover`; the `bones` line; the `idle keys` line; then rigc's gate lines (with A15's declared SKIP under `--idle-keys direct`); in `rig.json`, each chain link's (or its `_ctl`'s) `length` and `rotation` | `cover 1.00000` on every mesh, both gate summaries `0 failed` (the compile and the packed pages); every link's `length` the distance to the next link and `rotation` its direction (Spine degrees, counter-clockwise, y up, local to the parent), every offset under it — a child bone's `x, y`, a weight's bind `x, y`, a region's `x, y` — in that turned frame, and a region on a link carrying `rotation` that turns it back upright. Nothing moved: `flattenRig` (`src/rig.ts`) turns every offset back and gives the unturned numbers | `RIG_LATTICE_ONE_LOOP`: change that mesh's `grid` |
2240
2241
  | `check` (inside `build`) | the gate lines verbatim, the pack line, `loop:` (and `loop physics:` when the rig declares a physics constraint, §7), `seam:`, the six judgement lines, then — when `motion.json` holds an animation, the idle included — `ANIMATIONS_DO_NOT_FOLD` and one `folds` line per folding mesh, rigc's own (issues #320, #333), then — where a `footwear` part rides a bone that hangs from another — `FEET_STAY_LEVEL` and one `foot` line per such part (issue #348), then — when `parts.json` names a `handwear` part and there is an idle — `STRESS_OFF_CHAIN` (issue #347), then — where `parts.json` holds a limb segment's part — `LIMB_ONE_BONE` and one `limb` line per such part (issue #349), then — where a limb record carries a `range` — `SEAM_OVER_RANGE` and one `joint` line per joint and angle (issue #360), then `SEAM_OVER_MOTION` — a SKIP naming why on a rig that declares no neighbour pair, else the pairs read in every animation and one `WARN seam` line per pair and animation over the one-cell floor (issue #493, a warning and never a bar), then `CLOTH_SETTLES` — a SKIP naming why on a rig with no physics constraint, else the chains read and one `WARN chain` line per chain whose tip comes to rest before the idle's loop length (issue #501, a warning and never a bar), `RECOMPOSITE_HOLES` and, under `--source`, `SETUP_POSE_VS_SOURCE` (§7), `check.json`; the last line says how many of the bars measured — nine, ten with the fold bar, one more each with the feet-level bar, the stress bar, the limb bar and the range bar — and names the ones that said SKIP, then — where `SEAM_OVER_MOTION` read a pair — how many warnings it printed, `; N warning(s) (SEAM_OVER_MOTION, not a bar)` — with `CLOTH_SETTLES` named beside it, and N their sum, where the rig declares a physics constraint — which no bar counts | `check: PASS; 11 of 11 bar(s) measured, 0 skipped` on `demo` and `scarf`, whose sleeves each ride one chain; `check: PASS; 10 of 11 bar(s) measured, 1 skipped (STRESS_OFF_CHAIN)` on `reference-demo` and `reference-sample`, whose one `sleeves` mesh rides both sleeve chains (issue #347) — no example writes `FEET_STAY_LEVEL`, every shoe riding `root`; a judgement line SKIP only where the character lacks what it reads; on a rig spec with no `parts.json` or no `idle` (a merged rig, §7 *Measuring a rig rig-parts did not assemble*), PASS with the skipped bars named | `CHECK_SEAM_WITHIN_BAR` or `CHECK_LOOP_CLOSES` (§6); `CHECK_ANIMATIONS_DO_NOT_FOLD` — a clip turns a mesh over (§6); `CHECK_STRESS_OFF_CHAIN` — a sleeve weighted off its chain (§6); `CHECK_LIMB_ONE_BONE` — a limb part on a second bone (§6); `CHECK_SEAM_OVER_RANGE` — a joint that opens when bent (§6) |
@@ -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` |
@@ -2826,7 +2828,7 @@ says why each requirement exists and what breaks without it.
2826
2828
  | <a id="ASSEMBLE_UNDER_FILL_SOURCE"></a>`ASSEMBLE_UNDER_FILL_SOURCE` | a cut declares `under_fill` and has no under to fill with: it names no `under` file and its part has no hidden-art layer (issue #360) | name the cut's `under`, or drop `under_fill` |
2827
2829
  | <a id="ASSEMBLE_UNDER_DRAW"></a>`ASSEMBLE_UNDER_DRAW` | a cut with `under` draws its piece behind its part, which the fill would hide it under | that cut's `draw`: `"front"`, or `{"before": …}` the plan part after its `from` |
2828
2830
  | <a id="ASSEMBLE_LIMB_TAKES"></a><a id="ASSEMBLE_LIMB_PIXELS"></a>`ASSEMBLE_LIMB_TAKES`, `ASSEMBLE_LIMB_PIXELS` | a part a limb takes has no opaque pixel, or a limb segment gets none of it — the joint lines through the bones' origins put none of the limb's pixels on it, or another limb's polyline is nearer every one (issue #349) | the bones: their origins on the limb's art, each joint where the limb bends |
2829
- | <a id="ASSEMBLE_LIMB_JOINT"></a><a id="ASSEMBLE_LIMB_JOINT_ON_ART"></a>`ASSEMBLE_LIMB_JOINT`, `ASSEMBLE_LIMB_JOINT_ON_ART` | a joint has no line — the upper bone has no length, or the limb folds straight back on itself — or its bone's origin lies on none of the limb's art within 1 px along the line, so the limb has no width there to size the cap by (issue #349); under `cap_shape: "disc"`, also a bone's origin on the very edge of the run, which has no half-width about it (issue #360) | the joint's bone: on the limb's art, at the joint |
2831
+ | <a id="ASSEMBLE_LIMB_JOINT"></a><a id="ASSEMBLE_LIMB_JOINT_ON_ART"></a>`ASSEMBLE_LIMB_JOINT`, `ASSEMBLE_LIMB_JOINT_ON_ART` | a joint has no line — the upper bone has no length, or the limb folds straight back on itself — or its bone's origin lies on none of the limb's art within 1 px along the line, so the limb has no width there to size the cap by (issue #349) — the detail names the nearest pixel of the limb's art on that line and its distance from the joint, or says the line crosses none of it (issue #517); under `cap_shape: "disc"`, also a bone's origin on the very edge of the run, which has no half-width about it (issue #360) | the joint's bone: on the limb's art, at the joint |
2830
2832
  | <a id="ASSEMBLE_LIMB_CUT_BAND"></a>`ASSEMBLE_LIMB_CUT_BAND` | a segment's `cut_band` reaches past the limb: a line of its band, the detail names the one nearest the joint and a point it passes through, crosses none of the limb's art within 1 px of that point, so a cut placed there would cut nothing (issue #360) | `cut_band`: the widest band whose every line crosses the limb, which the detail gives |
2831
2833
  | <a id="ASSEMBLE_LIMB_CAP_PRESENT"></a><a id="ASSEMBLE_LIMB_CAP_DECODES"></a><a id="ASSEMBLE_LIMB_CAP_SIZE"></a><a id="ASSEMBLE_LIMB_CAP_EMPTY"></a>`ASSEMBLE_LIMB_CAP_PRESENT`, `ASSEMBLE_LIMB_CAP_DECODES`, `ASSEMBLE_LIMB_CAP_SIZE`, `ASSEMBLE_LIMB_CAP_EMPTY` | a segment's `cap` names no file (relative to the config's directory) or one that is not a PNG; an image not the size of the cap's box (the detail gives both, and the box's corner); or one transparent over every cap pixel (issue #349) | the image: the box the `limb cap:` line prints, `w`x`h`, its pixel `(i, j)` rig pixel `(x + i, y + j)`; to keep the layer's cap, drop `cap` |
2832
2834
  | <a id="ASSEMBLE_HIDDEN_ONE_SOURCE"></a>`ASSEMBLE_HIDDEN_ONE_SOURCE` | a cut's `under`, or a limb segment's `cap`, names a file, and the part it reads also has a hidden-art layer (`<layer>:hidden`, issue #359): reading either would be a guess | remove the file from the config, or the hidden-art layer from the input |
@@ -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.1",
4
4
  "description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/assemble.ts CHANGED
@@ -104,7 +104,7 @@ import { type Problem, refuseIfAny } from './errors.ts';
104
104
  import { figuresPhrase, implausibleRules, type Layer, type LayerFigures, layerFigures, type LayerSet, NEAR_WHITE_MIN, OPAQUE_ALPHA_ABOVE, ruleSummary } from './layers.ts';
105
105
  import { padToSquare, squarePad } from './inputs.ts';
106
106
  import { type CapRecord, type LimbRecord, PAINTING_RUN, type PartRecord, type PartsFile, type RecompositeRecord, type SceneRecord, type SingleRunPad } from './parts.ts';
107
- import { assignCrossedLimbs, assignOverlappingHands, type BonePlace, bonePlaces, capBox, coveredRadius, type CutPlacement, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, luma601, nearestLimb, pastJoint, placeCut, segmentOf } from './limbs.ts';
107
+ import { assignCrossedLimbs, assignOverlappingHands, type BonePlace, bonePlaces, capBox, coveredRadius, type CutPlacement, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, luma601, nearestLimb, nearestOnLine, offLineFigure, pastJoint, placeCut, segmentOf } from './limbs.ts';
108
108
  import {
109
109
  alphaComposite,
110
110
  connectedComponents,
@@ -3000,7 +3000,7 @@ function cutLimbs(
3000
3000
  problems.push({
3001
3001
  code: 'ASSEMBLE_LIMB_JOINT_ON_ART',
3002
3002
  object,
3003
- detail: `the joint, "${sg.bone}"'s origin at [${line.at.join(', ')}], lies on none of the limb's art within 1 px along its joint line, so the limb has no width there to size the cap by; a bone origin on the limb's art (alpha above ${OPAQUE_ALPHA_ABOVE}) is required — move the bone onto the joint`,
3003
+ detail: `the joint, "${sg.bone}"'s origin at [${line.at.join(', ')}], lies on none of the limb's art within 1 px along its joint line (${offLineFigure(nearestOnLine(line, art, [0, 0, W - 1, H - 1]))}), so the limb has no width there to size the cap by; a bone origin on the limb's art (alpha above ${OPAQUE_ALPHA_ABOVE}) is required — move the bone onto the joint`,
3004
3004
  });
3005
3005
  return;
3006
3006
  }
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/limbs.ts CHANGED
@@ -105,6 +105,7 @@
105
105
  * crossing.
106
106
  */
107
107
  import type { BoneEntry, Limb, LimbSplit } from './config.ts';
108
+ import { pyRound } from './round.ts';
108
109
 
109
110
  export type Pt = [number, number];
110
111
 
@@ -317,6 +318,35 @@ export function limbRun(line: JointLine, art: (x: number, y: number) => boolean,
317
318
  return runOfOffsets(ts);
318
319
  }
319
320
 
321
+ /**
322
+ * The pixel of the limb's art on a joint line nearest the joint (issue #517):
323
+ * among the pixels {@link limbRun} reads (centre within half a pixel of the
324
+ * line), the one whose offset along the line is smallest in size — that
325
+ * distance from the joint, and the pixel; the first in row order wins a tie.
326
+ * Null when the line crosses none of the art. Where {@link limbRun} is null
327
+ * this is how far off the art the joint sits along its own line, the figure
328
+ * `ASSEMBLE_LIMB_JOINT_ON_ART` and propose's `limb-joint-off-art` LINT print.
329
+ */
330
+ export function nearestOnLine(line: JointLine, art: (x: number, y: number) => boolean, box: readonly [number, number, number, number]): { distance: number; at: Pt } | null {
331
+ const [ax, ay] = line.axis;
332
+ let best: { distance: number; at: Pt } | null = null;
333
+ for (let y = box[1]; y <= box[3]; y++) {
334
+ for (let x = box[0]; x <= box[2]; x++) {
335
+ const dx = x + 0.5 - line.at[0];
336
+ const dy = y + 0.5 - line.at[1];
337
+ if (Math.abs(dx * ax + dy * ay) > 0.5 || !art(x, y)) continue;
338
+ const d = Math.abs(-dx * ay + dy * ax);
339
+ if (best === null || d < best.distance) best = { distance: d, at: [x, y] };
340
+ }
341
+ }
342
+ return best;
343
+ }
344
+
345
+ /** {@link nearestOnLine}'s figure as the refusal and the LINT word it: the pixel and its distance to 3 places, or that the line crosses none of the art. */
346
+ export function offLineFigure(n: { distance: number; at: Pt } | null): string {
347
+ return n === null ? 'the line crosses none of it' : `the nearest of it on that line is the pixel [${n.at.join(', ')}], ${pyRound(n.distance, 3)} px from the joint`;
348
+ }
349
+
320
350
  /** The run through 0 of the offsets `ts` along a line ({@link limbRun}): sorted, the nearest within 1 px, grown while neighbours are at most 1.5 apart. Sorts `ts` in place. */
321
351
  function runOfOffsets(ts: number[]): [number, number] | null {
322
352
  if (ts.length === 0) return null;
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/propose.ts CHANGED
@@ -148,7 +148,7 @@ import { configRoles, type RoleOf } from './structure.ts';
148
148
  import { AUTHOR_NO_ROLE, isAuthorTag } from './tags.ts';
149
149
  import { TURN_BONE, TURN_CARRIER_TAG, TURN_PLACES, TURN_RIDER_OFFSET, TURN_RIDER_TAGS, turnFractions, turnNearest, turnPivot, turnRiderDepth, type TurnSpec } from './turn.ts';
150
150
  import { edgeLength } from './length.ts';
151
- import { bonePlaces, limbCrossing, limbPolyline, limbWidth } from './limbs.ts';
151
+ import { bonePlaces, jointLine, limbCrossing, limbPolyline, limbRun, limbWidth, nearestLimb, nearestOnLine, offLineFigure, type Pt } from './limbs.ts';
152
152
  import { type BranchSqueezeFinding, branchSqueezes, chainSqueezes, type SqueezeFinding } from './squeeze.ts';
153
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';
154
154
  import { TEXTURE_STRETCH_CEILING } from './check.ts';
@@ -1392,7 +1392,7 @@ export function proposeWithBasis(
1392
1392
  gridRule: GridRule = DEFAULT_GRID_RULE,
1393
1393
  cloth: ClothRecipes | null = null,
1394
1394
  chainRule = true,
1395
- ): { proposal: Proposal; basis: ProposalBasis } {
1395
+ ): { proposal: Proposal; basis: ProposalBasis; jointsOffArt: LimbJointOffArtFinding[] } {
1396
1396
  // Issue #230: a piece is not given its base's rule a second time, which
1397
1397
  // needs to know which part is the piece. A file that cannot say is refused
1398
1398
  // here, and only here: every other reader of parts.json still takes it.
@@ -1423,6 +1423,8 @@ export function proposeWithBasis(
1423
1423
  const records: BoneBasis[] = [];
1424
1424
  /** Issue #349: the limbs `--keypoints` drafts, and the parts they take (not made, so not given a mesh or a region). */
1425
1425
  const limbs: Record<string, Limb> = Object.create(null) as Record<string, Limb>;
1426
+ /** Issue #517: the ankles left uncut because they lie off their leg's art — LINT lines, handed back beside the proposal. */
1427
+ const jointsOffArt: LimbJointOffArtFinding[] = [];
1426
1428
  const consumed = new Set<string>();
1427
1429
  // No prototype: a part may be named anything file-safe, "__proto__" included.
1428
1430
  const meshes = Object.create(null) as Record<string, MeshSpec>;
@@ -3239,7 +3241,11 @@ export function proposeWithBasis(
3239
3241
  // shoes split between one leg's foot and no other would hand that leg the other shoe.
3240
3242
  const legChains = legPlan.chains;
3241
3243
  const feetOn = legChains.map((c) => fw.filter((q) => isOn(nearFoot.get(q) as Mask, c.ankle[0], c.ankle[1])));
3242
- const feetBound = fw.length > 0 && feetOn.every((on) => on.length === 1);
3244
+ // Issue #517: and only when every ankle lies on its leg's art along its joint line, as assemble reads it — or the
3245
+ // config drafted here is one assemble refuses by ASSEMBLE_LIMB_JOINT_ON_ART. An ankle off it is LINTed, not moved.
3246
+ const offArt = fw.length > 0 && feetOn.every((on) => on.length === 1) ? anklesOffArt(P, legChains, feetOn.map((on) => on[0])) : [];
3247
+ jointsOffArt.push(...offArt);
3248
+ const feetBound = fw.length > 0 && feetOn.every((on) => on.length === 1) && offArt.length === 0;
3243
3249
  legChains.forEach((c, ci) => {
3244
3250
  const s = c.side as 'r' | 'l';
3245
3251
  const J = (joints as RigJoints).joints;
@@ -3259,6 +3265,8 @@ export function proposeWithBasis(
3259
3265
  regions[`foot_${s}`] = `foot_${s}`;
3260
3266
  consumed.add(on[0].name);
3261
3267
  foot = `, and foot_${s}, ${on[0].name}'s share below the ankle, on bone foot_${s} at the ${s}_ankle joint under leg_${s}1 with inherit "${FOOT_INHERIT}" — the shoe keeps its setup angle while the leg turns (FEET_STAY_LEVEL)`;
3268
+ } else if (offArt.length > 0) {
3269
+ foot = `; no foot segment: ${offArt.map((f) => `${f.keypoint} at ${fmtAt(f.at)} lies on none of leg_${f.side}'s art within 1 px along its joint line (${offLineFigure(f.nearest)})`).join('; ')}, so assemble could not size the ankle's cap — every leg's ankle must lie on its leg's art for the feet to be drafted, and ${offArt.length === 1 ? 'its' : 'their'} LINT line${offArt.length === 1 ? ' says' : 's say'} how far off; move the ankle keypoint onto the art and re-run propose`;
3262
3270
  } else if (fw.length > 0) {
3263
3271
  const where = (k: number): string => {
3264
3272
  const o = feetOn[k];
@@ -3361,6 +3369,7 @@ export function proposeWithBasis(
3361
3369
  return {
3362
3370
  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 },
3363
3371
  basis: { frame, bones: records },
3372
+ jointsOffArt,
3364
3373
  };
3365
3374
  }
3366
3375
 
@@ -3656,6 +3665,36 @@ function armsFromJoints(
3656
3665
  * joints it runs through, its two links and tip in rig px, and the legwear
3657
3666
  * part its limb takes (issue #349).
3658
3667
  */
3668
+ /**
3669
+ * Issue #517: the ankles of `legs` (each bound to the footwear part `feet[i]`) that lie on none of their leg's art
3670
+ * within 1 px along the joint line, read as assemble's cap reads it (`cutLimbs` in `src/assemble.ts`): the line
3671
+ * through the ankle across the shin bone's direction (knee -> ankle; the foot bone has no tip), the art each leg's
3672
+ * polyline (hip, knee, ankle, as the bones round them) owns by {@link nearestLimb} among the legs taking the same part,
3673
+ * in the legwear part and in its footwear part, alpha above {@link OPAQUE_ALPHA_ABOVE}. Empty when every ankle is on it.
3674
+ */
3675
+ function anklesOffArt(P: PartSet, legs: readonly LegChain[], feet: readonly PartRecord[]): LimbJointOffArtFinding[] {
3676
+ const polys = legs.map((c) => [rnd(c.hip), rnd(c.knee), rnd(c.ankle)] as Pt[]);
3677
+ const box = [0, 0, P.W - 1, P.H - 1] as const;
3678
+ const out: LimbJointOffArtFinding[] = [];
3679
+ legs.forEach((c, i) => {
3680
+ const line = jointLine(rnd(c.knee), rnd(c.ankle), null);
3681
+ if (line === null) return;
3682
+ const takers = (part: PartRecord, of: (k: number) => PartRecord): number[] => legs.map((_, k) => k).filter((k) => of(k).name === part.name);
3683
+ const owned = (part: PartRecord, of: (k: number) => PartRecord): ((x: number, y: number) => boolean) => {
3684
+ const m = P.alpha(part);
3685
+ const ks = takers(part, of);
3686
+ const lines = ks.map((k) => polys[k]);
3687
+ return (x, y) => m.data[y * P.W + x] === 1 && ks[ks.length === 1 ? 0 : nearestLimb(lines, x, y)] === i;
3688
+ };
3689
+ const onLeg = owned(c.part, (k) => legs[k].part);
3690
+ const onFoot = owned(feet[i], (k) => feet[k]);
3691
+ const art = (x: number, y: number): boolean => x >= 0 && y >= 0 && x < P.W && y < P.H && (onLeg(x, y) || onFoot(x, y));
3692
+ if (limbRun(line, art, box) !== null) return;
3693
+ out.push({ kind: 'limb-joint-off-art', side: c.side, limb: `leg_${c.side}`, keypoint: `${c.side}_ankle`, part: `foot_${c.side}`, from: feet[i].name, link: `leg_${c.side}1`, at: rnd(c.ankle), nearest: nearestOnLine(line, art, box) });
3694
+ });
3695
+ return out;
3696
+ }
3697
+
3659
3698
  interface LegChain {
3660
3699
  chain: string;
3661
3700
  side: 'r' | 'l';
@@ -4336,6 +4375,24 @@ export interface StopTouchAboveRootFinding {
4336
4375
  outward: number;
4337
4376
  }
4338
4377
 
4378
+ /**
4379
+ * Issue #517: a leg's ankle keypoint lies on none of the leg's art within 1 px along its joint line, as assemble reads
4380
+ * the joint, so `propose` drafted the leg without its ankle cut ({@link anklesOffArt}): `at` the ankle (rig px), `link`
4381
+ * the chain link whose tip it is, and the nearest pixel of the leg's art on that line, or null when the line crosses
4382
+ * none. Handed to {@link lint} by `propose`; the keypoint is not moved onto the art (no value the author did not state).
4383
+ */
4384
+ export interface LimbJointOffArtFinding {
4385
+ kind: 'limb-joint-off-art';
4386
+ side: 'r' | 'l';
4387
+ limb: string;
4388
+ keypoint: KeypointName;
4389
+ part: string;
4390
+ from: string;
4391
+ link: string;
4392
+ at: Point;
4393
+ nearest: { distance: number; at: Pt } | null;
4394
+ }
4395
+
4339
4396
  export type LintFinding =
4340
4397
  | OffArtFinding
4341
4398
  | OffLockFinding
@@ -4350,7 +4407,8 @@ export type LintFinding =
4350
4407
  | BackHairMassesFinding
4351
4408
  | OverlappingArmsFinding
4352
4409
  | CrossedLimbsFinding
4353
- | StopTouchAboveRootFinding;
4410
+ | StopTouchAboveRootFinding
4411
+ | LimbJointOffArtFinding;
4354
4412
 
4355
4413
  /** Which rule set read the torso and the sleeve chains, under `--keypoints`. */
4356
4414
  export interface LintBasis {
@@ -4452,10 +4510,12 @@ export function lint(
4452
4510
  P: PartSet,
4453
4511
  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[] },
4454
4512
  joints?: RigJoints,
4513
+ drafted: readonly LimbJointOffArtFinding[] = [],
4455
4514
  ): LintResult {
4456
4515
  const { byName } = expand(spec.bones);
4457
4516
  const parts = new Map(P.recs.map((p) => [p.name, p]));
4458
- const findings: LintFinding[] = [];
4517
+ // Issue #517: what the proposer left uncut and why, first: the finding is the draft's, not a check's over the spec.
4518
+ const findings: LintFinding[] = [...drafted];
4459
4519
  const unknownMeshes: string[] = [];
4460
4520
  // Issue #86: which check read which bone, recorded where each check reads it.
4461
4521
  const read = new Map<string, string[]>([...byName.keys()].map((n) => [n, []]));
@@ -4463,6 +4523,7 @@ export function lint(
4463
4523
  const list = read.get(n);
4464
4524
  if (list !== undefined && !list.includes(check)) list.push(check);
4465
4525
  };
4526
+ for (const f of drafted) readBy(f.link, `limb-joint-off-art on ${f.limb}`);
4466
4527
  for (const [mname, m] of Object.entries(spec.meshes)) {
4467
4528
  const part = parts.get(mname);
4468
4529
  if (part === undefined) {
@@ -4900,6 +4961,8 @@ function findingBones(f: LintFinding, bones: readonly BoneEntry[]): string[] {
4900
4961
  case 'off-art':
4901
4962
  case 'off-lock':
4902
4963
  return [f.bone];
4964
+ case 'limb-joint-off-art':
4965
+ return [f.link];
4903
4966
  case 'hip-not-below-chest':
4904
4967
  case 'hip-not-past-chest':
4905
4968
  return ['hip', 'chest'];
@@ -5073,6 +5136,11 @@ export function basisLines(b: LintBasis): string[] {
5073
5136
  */
5074
5137
  export function lintLine(f: LintFinding): string {
5075
5138
  switch (f.kind) {
5139
+ case 'limb-joint-off-art':
5140
+ return (
5141
+ `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)}), ` +
5142
+ `so assemble could not size the ankle's cap (ASSEMBLE_LIMB_JOINT_ON_ART): ${f.limb} is drafted without its ankle cut and ${f.from} stays one part — move the ${f.keypoint} keypoint onto the art of the leg or of ${f.from}, then re-run propose`
5143
+ );
5076
5144
  case 'off-art':
5077
5145
  return `LINT ${f.bone} at ${pyIntList(f.at)} is off the art of mesh ${pyRepr(f.mesh)}`;
5078
5146
  case 'off-lock':
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;