rig-parts 1.48.0 → 1.49.2
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 +22 -12
- package/docs/AUTHORING.md +44 -11
- package/docs/STABILITY.md +4 -4
- package/package.json +1 -1
- package/src/build.ts +2 -23
- package/src/check.ts +56 -0
- package/src/clothconfig.ts +175 -15
- package/src/meshdraft.ts +77 -16
- package/src/remesh.ts +15 -5
- package/src/requirements.ts +17 -2
- package/src/rig.ts +16 -0
package/cli.ts
CHANGED
|
@@ -231,16 +231,21 @@ usage:
|
|
|
231
231
|
spliced in (issue #537), the way mesh-draft writes its config, so that
|
|
232
232
|
rig --config <out.json> builds it. What is spliced is measured: the
|
|
233
233
|
same parts drafted again without the recipe, and each config section
|
|
234
|
-
that differs
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
234
|
+
that differs, entry by entry: meshes.<part> and regions.<part>, and
|
|
235
|
+
bones, constraints and motion.tracks by each entry's name (issue
|
|
236
|
+
#552) — an entry the recipe drafts replaced or inserted, one it
|
|
237
|
+
replaces removed, and every other entry, a hand-added one among
|
|
238
|
+
them, kept in its place; a section the input lacks is inserted;
|
|
239
|
+
every other byte as read. The text is written as stated, so a
|
|
240
|
+
relative path in it resolves against <out.json>'s directory (a note
|
|
241
|
+
names each when that is not the input's). Only with --cloth and not
|
|
242
|
+
with --from-config (usage errors); refused, before anything is
|
|
243
|
+
written, when <out.json> exists or is a file this run writes
|
|
244
|
+
(PROPOSE_WRITE_CONFIG_FRESH), when an entry the recipe re-drafts or
|
|
245
|
+
removes was changed by hand, naming the entry and the field
|
|
246
|
+
(PROPOSE_WRITE_CONFIG_CONFLICT), or when the spliced text does not
|
|
247
|
+
parse to the config with the sections set, naming the first key
|
|
248
|
+
that moved (PROPOSE_WRITE_CONFIG_SPLICE).
|
|
244
249
|
|
|
245
250
|
rig-parts propose --parts <dir> --source <painting.png> --out <dir> --from-config <config.json>
|
|
246
251
|
Draw the config's CURRENT bones instead (<out>/render/landmarks_config.png
|
|
@@ -1354,8 +1359,9 @@ function cmdPropose(args: string[]): number {
|
|
|
1354
1359
|
writeArg === undefined || clothArg === undefined
|
|
1355
1360
|
? null
|
|
1356
1361
|
: (() => {
|
|
1357
|
-
const edits = clothConfigEdits(drafted, proposeWithBasis(P, joints, wristSnap, gridRule, null).proposal);
|
|
1358
1362
|
const text = readFileSync(clothArg, 'utf8');
|
|
1363
|
+
// Issue #552: bones, constraints and motion.tracks entry by entry; a hand edit the recipe would drop is refused by name.
|
|
1364
|
+
const edits = clothConfigEdits(drafted, proposeWithBasis(P, joints, wristSnap, gridRule, null).proposal, JSON.parse(text) as unknown);
|
|
1359
1365
|
return { at: writeArg, text: writtenClothConfig(clothArg, text, edits), paths: editPaths(edits), relative: relativeConfigPaths(dirname(resolve(clothArg)), JSON.parse(text) as Record<string, unknown>) };
|
|
1360
1366
|
})();
|
|
1361
1367
|
const bfile = basisFile(P, prop, basis, cfg === null || cmpPath === undefined ? null : { where: cmpPath, config: cfg });
|
|
@@ -1374,7 +1380,11 @@ function cmdPropose(args: string[]): number {
|
|
|
1374
1380
|
printLint(P, prop, joints, draftLint);
|
|
1375
1381
|
console.log(basisLine(bfile, out));
|
|
1376
1382
|
if (written !== null && clothArg !== undefined) {
|
|
1377
|
-
console.log(
|
|
1383
|
+
console.log(
|
|
1384
|
+
written.paths.length > 0
|
|
1385
|
+
? `wrote ${written.at}: ${clothArg}'s text with ${written.paths.join(', ')} spliced in from the draft; every other byte as read`
|
|
1386
|
+
: `wrote ${written.at}: ${clothArg}'s text byte for byte; every entry the recipe drafts is already as drafted`,
|
|
1387
|
+
);
|
|
1378
1388
|
if (written.relative.length > 0 && dirname(resolve(written.at)) !== dirname(resolve(clothArg))) {
|
|
1379
1389
|
console.log(`note: ${written.relative.map((r) => `${r.at} "${r.value}"`).join(', ')} written as stated; the loader resolves each against the directory the config sits in, ${dirname(written.at)} for ${written.at}, not ${dirname(clothArg)}; put the config beside ${clothArg} or rewrite them`);
|
|
1380
1390
|
}
|
package/docs/AUTHORING.md
CHANGED
|
@@ -112,7 +112,7 @@ read by no CPU stage).
|
|
|
112
112
|
| `assemble.head_face_underfill` | assemble, `assemble --propose-plan` | **authored**, optional (issue #492): `boolean` (`CONFIG_FIELD_TYPE` on any other). When both runs exist and `full:face` has at least `200` opaque run px (`PROPOSE_MIN_PX`), the stage maps `full:face` into the head canvas via `fullLayerToHead` and measures how much of its hole-filled silhouette (`alpha > 8`) is covered by `head:face` (`alpha > 8`). A head-run `face` covering less than `75 %` (`HEAD_FACE_COVERAGE_FLOOR`, measured `0.0 %..48.6 %` on hollow/omitted head runs vs `84.8 %..99.6 %` on clean head runs across the 4 public examples and 9-standee corpus) is refused with `SEETHROUGH_HEAD_RUN_HOLLOW` unless `head_face_underfill: true` is declared. When `head_face_underfill: true` is declared and `head:face` exists (`opaqueRunPx >= 200`), `fullLayerToHead(full:face)` is composited under `head:face` on the head canvas (`alpha = max(headAlpha, fullAlpha)`, RGB blended by `headAlpha / 255`) before `head:face` is placed in rig space (`underfill=<N>px(full:face)` on the `face` part log line and a `face: head_face_underfill composited …` note in `assemble --propose-plan`). The fill restores transparent pixels only and leaves the cut's own edge where it is — a hollow whose edge is not under hair stays visible, and that is the author's to fix at the cut. When `head:face` has fewer than `200` opaque pixels, `SEETHROUGH_HEAD_RUN_HOLLOW` still fires even under `head_face_underfill: true` because the head run omitted the face layer and cannot supply a jawline |
|
|
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
|
-
| `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 |
|
|
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. In every mode the mesh's `mesh_report.json` row's `bones` names the bones the emitted model binds for the attachment — the sorted set its weights in the written `rig.json` name, so a `turn` twin (`turn_<part>_<bone>`) or a stopped link's `<link>_d` where those rebind it, never the segment bone it stands for — the same list in every mode, `remesh --delta`'s included (issue #536) |
|
|
116
116
|
| `meshes.<part>.influence` | rig | **authored**, optional (issue #378), a mode beside `grid`, `contour` and `auto`: `{cell, radius, across, max, shape}`, every field required, none defaulted. rig-c's `segments` lattice over the part at `cell` px, each vertex pulled by every link of the mesh's `segments` within `radius` px of it — a pull that falls to exactly 0 at `radius` (`shape` `"linear"` or `"smooth"`), across the `segments` entries or only within the nearest one (`across`), the strongest `max` kept. The lattice and the shares are computed by rig-c's own promised functions (`buildSegmentsLattice`, `segmentDistance`, `influenceShares`), so the rule is rig-c's (its AUTHORING §3.4.7), and the mesh is written with explicit weights like every other mode. `radius` is a length on this part: the rig stage measures the farthest lattice vertex's distance to its nearest link and refuses a radius at or under it (`RIG_INFLUENCE_REACH`), naming the distance. `propose --cloth` drafts it when a recipe declares `influence` and no `radius` (issue #518): the farthest vertex's distance plus 3 of the part's lattice cells, printed on a `LINT` line with both figures. Measured on the cloth fixture and the public `wind` example (#513: 8 covered parts, `render --folds` with the physics on under wind and a hip sway of 8° and 30°): a radius just above the floor folds **more** than the lattice (one skirt went from 0 to 55 folded frames), and a larger one is **not** safer (one fringe folded again at about 3–4× its farthest distance); +2 to +6 cells read 0 on every part, +2 at the edge. No ceiling is drafted, and the 3 is a hypothesis until a third subject — state `radius` in the recipe to keep your own. `r`, `exponent`, `rule`, `influences`, `stray` and `ribs` belong to the distance rule or another mode and are refused beside it (`CONFIG_INFLUENCE_MODE`). For cloth and hair that should bend as one surface across its chains |
|
|
117
117
|
| `meshes.<part>.contour` | rig | **authored**, optional (issue #84): `{tolerance, margin, spacing, maxEdge?, budget?, stray?, bridges?, regions?, bust?}`. `tolerance` — rig-c's Douglas–Peucker tolerance on the traced outline, px, 0 or more; `margin` — how far the silhouette grows before it is traced, px: 0, or 1 or more (a pixel joins when its centre lies within `margin` of an art pixel's centre; a value above 0 and below 1 adds nothing and is refused, `CONFIG_FIELD_TYPE`); `spacing` — the background interior spacing, px, above 0; `maxEdge` (issue #265) — the longest outline edge, px, above 0: every simplified edge longer than it is cut into `ceil(length / maxEdge)` equal pieces, each cut point on the 1/256 px grid, before any region or rib touches the outline (absent: nothing is cut, and no byte moves; under 2/256 px the rig stage refuses it, `CONTOUR_PARAMETER`, because two cut points could snap together); the row echoes it in `params` and counts the points it added in `contour.outlineCut`, both only when declared; `budget` — the most vertices the mesh may have (refused above it, nothing thinned); `stray` — the largest island, in art pixels, that may be left out of the mesh (absent: none is); `bridges` (issue #326) — `true`, its one value: islands are read in this order — **dust first** (those `stray` leaves out), **then faint islands** (every pixel's alpha under 64, a quarter of full opacity: left out the same way, their pixels kept in the image but not meshed, so not drawn, and named in the row's `contour.bridges.faint` with their px, brightest alpha and box), **then every visible island is meshed and bridged, whatever the bridge costs** — overdraw is reported, never a reason to drop art; the largest island, or a tie for it, is never left out, faint or not: dropping it would draft the part without its art, and a part whose main body is faint is a question about the layer, which the plan and the author own, not one for the mesh — and the pieces are joined into the one outline rig-c takes by bridges — the kept islands, holes filled, grow together by `margin`, so islands closer than about twice the margin are one grown silhouette, traced as one; each silhouette is traced, simplified, capped, refined and triangulated as a one-island mesh is; then, starting from the silhouette with the most art, the nearest pair of a vertex on the joined outline and one on a silhouette still apart whose quad holds (wound as the mesh, crossing no outline, holding no other vertex, one closed outline after) is joined by that quad, two triangles over no art, until none is apart. Coverage and overshoot read the silhouettes' triangles; a bridge's area is in `meshArea` and in the row's `contour.bridges` (`islands`, `units`, and per join `unit`, `span` — its two crossing edges, px — `area`, `vertices`, `pair`; and `faint`, only when an island was left out as faint), and the row's `params` echoes `bridges`, both only when declared; `art_coverage` counts a faint island's pixels as art not covered. Absent, a second island is refused as below and no byte moves; on one island it writes the mesh the undeclared entry writes. Any other value is `CONFIG_FIELD_TYPE`; beside `ribs` it is `CONTOUR_PARAMETER` (a rib runs across one outline); a join no pair makes is `CONTOUR_BRIDGE`. A bridge stretches with whatever pulls its two ends apart, so it belongs on a part whose pieces ride one bone — the only case `mesh-draft` drafts; `regions` — local deformation regions, each `{name, shape, bone, spacing, band}` with `shape` `"circle"` (`cx, cy, r`) or `"polygon"` (`points`, 3 or more): `bone` is the region's control bone (any bone `bones` declares), `spacing` the interior spacing inside the region and its band, `band` the width the bone's weight falls across. Every length and position is **rig px**, like every other in the config; the part image is the rig less `(x − 4, y − 4)` (its box less the pad), a translation, so a length is the same number in both. A region's `cx`, `cy`, `r`, `band` and `points` are multiples of 1/256 px (`CONFIG_FIELD_TYPE` otherwise); region names are unique per mesh (`CONFIG_REGION_NAME_UNIQUE`). `bust` (issue #475) — `{apex_r, apex_l, cleavage, alpha?: 0.22, clearance?: 3.8, bone_r?: "boob_r", bone_l?: "boob_l", spacing?: 14}`: derives the two circular regions `bust_r` and `bust_l` from the three rig-px landmarks `apex_r`, `apex_l` and `cleavage` (multiples of 1/256 px, `CONFIG_FIELD_TYPE` otherwise; projecting the torso midline `neck → chest → hip` onto `apex_r → apex_l` misses the cleavage by 14–93 px across all five calibrated 3/4-yaw characters, so all three points are required). With `d_s = \|cleavage − apex_s\|` and `D = \|apex_r − apex_l\|`, each side `s ∈ {r, l}` is placed at `cx = apex_s[0]`, `cy = apex_s[1]` with outer radius `R_s = d_s − clearance`, core radius `r_s = round(alpha × R_s)` and `band_s = round(R_s) − r_s` (`alpha` = 0.22, `clearance` = 3.8 px, `spacing` = 14 px, `bone_r` = `"boob_r"`, `bone_l` = `"boob_l"` by default, reproducing the five calibrated example characters within `<= 6 px`, max `\|ΔR\| = 5 px`, max `\|Δr\| = 3 px`). Refused when `clearance <= 0`, `R_r + R_l >= D`, or a derived `r_s` or `band_s` is not positive (`CONFIG_BUST_CLEARANCE`), when `bone_r` or `bone_l` is not declared in `bones` (`CONFIG_NAME_RESOLVES`), or when `contour.regions` also names `bust_r` or `bust_l` (`CONFIG_REGION_NAME_UNIQUE`). Both `propose` and `rig` read `contour.bust` through `contourRegionsOf` (`deriveBustRegions`), and hand-written `contour.regions` entries build byte-identically when `bust` is absent. The alpha threshold is not a field: art is alpha above 8, the lattice's and `check`'s |
|
|
118
118
|
| `meshes.<part>.ribs` | rig | **authored**, optional (issue #188), in the `contour` and `auto` modes: `{<chain>: {stations}, …}`, each key a chain this mesh's `segments` name. Each link of the chain gets a row of vertices across the part at its origin and at `stations` points evenly between its origin and its end (`stations`, a whole number, 0 or more, required; a chain of L links carries L × (stations + 1) ribs), each rib a row of vertices across the part, kept as a row of locked edges; the rule is "Ribs along a chain" under "A contour mesh". Absent places none and changes no byte. Refused: a lattice mesh with ribs (`CONFIG_RIBS_MODE` — its vertices are its grid's corners), a key that is not one of the mesh's chains (`CONFIG_NAME_RESOLVES`), an object naming no chain or a `stations` that is not a whole number from 0 (`CONFIG_FIELD_TYPE`); at the rig stage `CONTOUR_RIB_ART`, `CONTOUR_RIB_LINK`, `CONTOUR_RIB_CROSSING`, `CONTOUR_RIB_EDGE` (the contour refusals). The mesh's `mesh_report.json` row gains `ribs` — the declaration, the ribs placed and the vertices they hold — and its contour report (the source's, in `auto`) lists each rib's vertices |
|
|
@@ -1652,20 +1652,37 @@ are drafted again without the recipe, and each config section whose value differ
|
|
|
1652
1652
|
the recipe's. An object section is spliced entry by entry — `meshes.<part>` and
|
|
1653
1653
|
`regions.<part>` for each part the recipe moved (a part it takes from `regions` into
|
|
1654
1654
|
`meshes` leaves `regions`), `motion.tracks` and nothing else under `motion`, so
|
|
1655
|
-
`duration`, `blink` and `animations_from` keep their bytes — and `bones
|
|
1656
|
-
`constraints`
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1655
|
+
`duration`, `blink` and `animations_from` keep their bytes — and so are `bones`,
|
|
1656
|
+
`constraints` and `motion.tracks` (issue #552), by each entry's name: a bone by `name`
|
|
1657
|
+
or `chain` (one namespace, as a mesh segment resolves either), a constraint by `name`,
|
|
1658
|
+
a track by `chain` or by `bone` and `prop` together. An entry the recipe drafts (one the
|
|
1659
|
+
draft with the recipe holds and the draft without it lacks or holds differently) is
|
|
1660
|
+
replaced in place, or, when the input lacks it, inserted after the input's entry that
|
|
1661
|
+
precedes it in the drafted array (the nearest earlier drafted entry the array holds),
|
|
1662
|
+
else at the end of the array; an entry the recipe replaces (a plain chain it drafts as
|
|
1663
|
+
trees) is removed; **every other entry is kept, its bytes and its place** — a bone, a
|
|
1664
|
+
chain, a constraint or a track added by hand survives a `--write-config`. An entry the
|
|
1665
|
+
recipe re-drafts or removes that the author changed by hand (it equals neither draft) is
|
|
1666
|
+
not dropped: the run is refused, `PROPOSE_WRITE_CONFIG_CONFLICT`, naming the entry
|
|
1667
|
+
(`config.constraints[40] "skirt0a_0_physics"` in CL207), the first field the hand edit holds and
|
|
1668
|
+
what the draft writes there, every conflict at once and nothing written; take the draft
|
|
1669
|
+
by removing the hand edit, or leave the recipe out for that part. A `meshes.<part>` the
|
|
1670
|
+
recipe drafts is still the draft's whole, as a hand-edited lattice does not survive
|
|
1671
|
+
`mesh-draft`, and a mesh it does not draft keeps its bytes. Every other byte is the
|
|
1672
|
+
input's; a section the input lacks (a config holding only `key` and `cloth`) is
|
|
1673
|
+
inserted whole. On the selftest's cloth fixture (CL201 prints the figures) the recipe
|
|
1674
|
+
removes six plain chains from `bones` and their nine tracks from `motion.tracks`,
|
|
1675
|
+
inserts its trees, moves `meshes.hair_back`, `meshes.hair_front` and `meshes.skirt`,
|
|
1676
|
+
and inserts `constraints`; with bones, constraints, a track and a mesh added by hand
|
|
1677
|
+
(CL205) the written config differs from the input only at those entries; `limbs` is not
|
|
1662
1678
|
moved on the public `wind` example with its keypoints, whose tracked config the flag
|
|
1663
1679
|
wrote back byte for byte (measured once, when the flag landed). The text is written as stated: a relative path in it
|
|
1664
1680
|
(`motion.animations_from`, `generation.control.skeleton`) resolves against the directory
|
|
1665
1681
|
the written config sits in, so the out path belongs beside the input, and when it is not
|
|
1666
1682
|
a note names each such path. Refused before anything is written: `--write-config`
|
|
1667
1683
|
without `--cloth` or beside `--from-config` (`USAGE`), an out path that exists or that
|
|
1668
|
-
the run writes itself (`PROPOSE_WRITE_CONFIG_FRESH`),
|
|
1684
|
+
the run writes itself (`PROPOSE_WRITE_CONFIG_FRESH`), a hand edit to an entry the
|
|
1685
|
+
recipe owns (`PROPOSE_WRITE_CONFIG_CONFLICT`), and a text whose splice does not
|
|
1669
1686
|
parse to the config with the sections set — a key stated twice
|
|
1670
1687
|
(`PROPOSE_WRITE_CONFIG_SPLICE`); a recipe that drafts nothing is
|
|
1671
1688
|
`PROPOSE_CLOTH_DRAFTED` as without the flag.
|
|
@@ -2879,6 +2896,7 @@ says why each requirement exists and what breaks without it.
|
|
|
2879
2896
|
| <a id="PROPOSE_CLOTH_DRAFTED"></a>`PROPOSE_CLOTH_DRAFTED` | with `--cloth` (issue #364): the config's `cloth` block holds a recipe for a tag the proposer drafts no chain on — no part has that tag, or every `back hair` part ends above the shoulders (a bun bone, no chain). A `bottomwear` recipe with no `bottomwear` part names every `topwear` part shaped like a skirt (issue #402) | leave that recipe out, or assemble the layer it is for, or declare the named part in `cloth.bottomwear.part` |
|
|
2880
2897
|
| <a id="PROPOSE_CLOTH_PART"></a>`PROPOSE_CLOTH_PART` | with `--cloth` (issues #402, #437): `cloth.bottomwear.part` (a string) names no part, a part or cut piece whose source is not `topwear` (a `bottomwear` part takes the recipe by its tag already), or a target whose box ends above the hip + 0.25 face heights, the topwear rule's waist line; or `cloth.<tag>.parts` (or `part` as a list, issue #437) names a part not in `parts.json`, a part no link of the drafted tree crosses (`spanCrosses == 0`), or parts out of root-to-tip depth order along the chain | name the `topwear` part or its cut skirt piece that holds the skirt (or leave `part` out), or list only parts in `parts.json` that the drafted tree links cross in root-to-tip order |
|
|
2881
2898
|
| <a id="PROPOSE_WRITE_CONFIG_FRESH"></a>`PROPOSE_WRITE_CONFIG_FRESH` | with `--write-config` (issue #537): the out path exists, or is a file the run writes itself (`proposal.json`, `basis.json` under `--out`); the config is written to a new file, never over the `--cloth` config or an earlier one | name a file that does not exist yet, beside the `--cloth` config |
|
|
2899
|
+
| <a id="PROPOSE_WRITE_CONFIG_CONFLICT"></a>`PROPOSE_WRITE_CONFIG_CONFLICT` | with `--write-config` (issue #552): an entry of `bones`, `constraints` or `motion.tracks` the recipe re-drafts or removes was changed by hand in the `--cloth` config — it equals neither the draft with the recipe nor the draft without it — so the write would drop the hand edit; the object is the entry (`config.constraints[40] "skirt0a_0_physics"` in CL207), the detail names the first field the hand edit holds and what the draft writes there. Also a name the config states twice where the recipe drafts it. Every conflict is named at once and nothing is written | take the draft by removing the hand edit (or the entry), or leave the recipe out for that part (its `cloth` block); state a name once |
|
|
2882
2900
|
| <a id="PROPOSE_WRITE_CONFIG_SPLICE"></a>`PROPOSE_WRITE_CONFIG_SPLICE` | with `--write-config` (issue #537): the `--cloth` config's text with the drafted sections spliced in does not parse to that config with them set, and the message names the first key that moved — the text states a key twice, so the splice lands on the first and the parse keeps the last | state each key once in the `--cloth` config |
|
|
2883
2901
|
| <a id="PROPOSE_CLOTH_BACK_HAIR_CHAINS"></a>`PROPOSE_CLOTH_BACK_HAIR_CHAINS` | with `--cloth` (issues #390, #445, #461): `cloth."back hair".chains` exceeds what the narrower side's opaque width at the eye-line root row holds at the part's mesh grid (`max(1, min(floor(w_r / grid), floor(w_l / grid)))`), or places a tree root outside the 15 px dilated art mask of the `back hair` part (e.g. an inner twin-tail root over the face where the hair has no pixel); the message names the part, each side's root-row width, the grid spacing, and any off-art root with its pixel alpha | lower `cloth."back hair".chains` to at most the max fit named in the message, or omit `chains` so `propose --cloth` derives the tree count per visible hair mass on each side from its root-row width |
|
|
2884
2902
|
| <a id="PROPOSE_ACCESSORY_BODY"></a>`PROPOSE_ACCESSORY_BODY` | an accessory has nothing above its pendant rows to hang its bone on | that part's plan entry, or author its bones by hand |
|
|
@@ -2969,7 +2987,16 @@ outside the part's attachment, and the parts the config does not reproduce — r
|
|
|
2969
2987
|
accepted after the config was written — are carried over as they are. `remesh.json`
|
|
2970
2988
|
names the input's SHA-256 per file, the request, both versions, the part's counts
|
|
2971
2989
|
before and after and both checks, and quotes `check`'s own physics line as the scope
|
|
2972
|
-
of the revision's check.
|
|
2990
|
+
of the revision's check. Each check side carries what the hold reads (`pass`,
|
|
2991
|
+
`measured`, `not_met`, `skipped`, `physics`) and, from issue #541, what `check`
|
|
2992
|
+
itself reports on that tree: `line`, the last line it prints (`check: PASS; …`),
|
|
2993
|
+
byte for byte — one function composes it for both — and `status`, every block's
|
|
2994
|
+
status as that tree's `check.json` records it (`gate`, `loop` and `seam` from their
|
|
2995
|
+
figures, every other block its own `status`: `PASS`, `FAIL`, `SKIP`, `WARN`,
|
|
2996
|
+
`CLEAR`, `REPORTED`). A consumer need not run `check` again on the revision: it
|
|
2997
|
+
binds the block to the files by the `revision` hash rows. A warning's status is
|
|
2998
|
+
carried, never held: a revision whose `CLOTH_SETTLES` is a `WARN` where the input's
|
|
2999
|
+
is `CLEAR` is written.
|
|
2973
3000
|
|
|
2974
3001
|
**`--delta <mesh-edit.json>`** (in place of `--mesh`, exactly one of the two; issue
|
|
2975
3002
|
#526) reads rig-c/review's mesh edit, `rig-review-mesh-edit/1`: `slot`, `skin`,
|
|
@@ -3041,7 +3068,10 @@ the config is left out of the revision — `retune.json`'s `held.not_compared` s
|
|
|
3041
3068
|
what was held, which constraint fields changed (and which constraints were added or
|
|
3042
3069
|
removed), how many idle tracks changed and the idle's duration before and after, both
|
|
3043
3070
|
versions and both checks, and quotes `check`'s own physics line as the scope of the
|
|
3044
|
-
revision's check.
|
|
3071
|
+
revision's check. The check sides are `remesh`'s, `line` and `status` included
|
|
3072
|
+
(issue #541): `check`'s own last line and every block's status on that tree, so a
|
|
3073
|
+
consumer binds them to the revision by the `revision` hash rows instead of running
|
|
3074
|
+
`check` a second time.
|
|
3045
3075
|
|
|
3046
3076
|
### rig-c's mesh refusals, quoted in a line
|
|
3047
3077
|
|
|
@@ -3110,6 +3140,7 @@ documents do not ship). Each is an input this package built; none is an author's
|
|
|
3110
3140
|
| <a id="REQUIREMENTS_CONSTRAINT_DRIVES"></a>`REQUIREMENTS_CONSTRAINT_DRIVES` | a `follow` names a bone its constraint does not constrain, or a property it does not drive: an `ik` drives `rotate` only; a `transform` drives `rotate` when a `to` names `rotate`, `translate` when one names `x` or `y` | the constraint's own bone and property |
|
|
3111
3141
|
| <a id="REQUIREMENTS_TARGET_PARENT"></a>`REQUIREMENTS_TARGET_PARENT` | a scene target's bone is the root or is not parented to it, or the root is not at rest at the origin, or the animation keys the root — a stage point is a bone's position only under a root that stands still at the origin | a bone under the root for the scene to place |
|
|
3112
3142
|
| <a id="REQUIREMENTS_TARGET"></a>`REQUIREMENTS_TARGET` | a scene target places one bone twice for one animation, places it for an animation no requirement measures, has a key outside the animation's `[0, duration]`, or sits in a group the animation translates | one placement per bone and animation, inside it, for an animation a requirement reads |
|
|
3143
|
+
| <a id="REQUIREMENTS_SELF_TARGET"></a>`REQUIREMENTS_SELF_TARGET` | a `contact` whose `target` is its own `bone` and `point` (0 apart by construction), or an `aim` whose `target` is a point of the aimed bone itself — its tip lies on its own axis (0 degrees by construction), its origin gives no line at all (issue #540): a PASS would say nothing. Refused before anything is built, beside the file's other refusals; a bone's tip against its own origin is a contact like any other (it reads the bone's length), and a stage target is never one | a different bone (or a stage point, for an aim), or for a contact the bone's other point |
|
|
3113
3144
|
| <a id="CHECK_REQUIREMENTS_FRAMES"></a>`CHECK_REQUIREMENTS_FRAMES` | a requirement render did not write every frame rigc sampled, or the as-declared, released and full renders of a follow sampled different frames | a rigc problem; report it |
|
|
3114
3145
|
| <a id="CHECK_REQUIREMENT_MET"></a>`CHECK_REQUIREMENT_MET` | a declared requirement measured outside its bar; the figure, its frame and the bar are quoted | the rig or its motion (§7, *Declared requirements*) — or the bar, if the scene asks less |
|
|
3115
3146
|
| <a id="CHECK_REQUIREMENT_MEASURABLE"></a>`CHECK_REQUIREMENT_MEASURABLE` | a declared requirement is NOT MEASURABLE: what it asks is undefined in the frames, and the reason is quoted. Not a pass | the declaration (a bone with a length, a target off the bone's origin, a least drive the constraint reaches) or the rig |
|
|
@@ -3890,6 +3921,8 @@ is `{ "spec": "spine-parts-requirements/1", "fps": 12, "requirements": [], "not_
|
|
|
3890
3921
|
| `follow` | `constraint`, `constraint_type` (`ik` or `transform`), `bone`, `property` (`rotate` or `translate`), `fraction`, `tolerance`, `least_drive` | below | no frame's drive reaches `least_drive` (the line prints the largest drive there was) |
|
|
3891
3922
|
| `seam` | `part`, `neighbour` (two part names: each is drawn by the slot of its name), `within_px` | below | no seam pair reads on any frame (each pixel off its attachment's rest geometry, or the slot shows nothing) |
|
|
3892
3923
|
|
|
3924
|
+
A `contact` held against its own bone and point, and an `aim` at a point of the aimed bone itself, read 0 by construction (or, an aim at its own origin, no line at all), so they are refused before anything is built (`REQUIREMENTS_SELF_TARGET`, issue #540); a bone's tip against its own origin stays a contact, measured.
|
|
3925
|
+
|
|
3893
3926
|
**`follow`**, #87's definition to the letter: "bone A takes a fraction `f` of what
|
|
3894
3927
|
constraint C asks of it" is measured from three poses of the same rig over the same
|
|
3895
3928
|
frames, each posed by rig-c and differing in one thing only — *as declared*, the
|
package/docs/STABILITY.md
CHANGED
|
@@ -192,16 +192,16 @@ every number) are AUTHORING §3's tables, and the loader refuses any other by na
|
|
|
192
192
|
| --- | --- | --- |
|
|
193
193
|
| `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) |
|
|
194
194
|
| `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) |
|
|
195
|
-
| `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) |
|
|
195
|
+
| `rig/mesh_report.json` | `rig`, `build` | one row per mesh: `part`, `vertices`, `triangles`, `hull`, `bones` (the sorted names the attachment's weights bind in the written `rig.json`, in every mode — since 1.49.1 (issue #536) a rig with `turn` or `stops` names the twins and `<link>_d` bones there, where the row named the segment bones they replace: a fix of a wrong name, not a format change; a rig with neither writes the bytes it wrote), `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) |
|
|
196
196
|
| `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`, `environment` after it under `--environment` only (issue #538, additive: `path` as given, `sha256`, `steps`), `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 |
|
|
197
197
|
| `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 |
|
|
198
198
|
| the template `.psd` | `layers --template` | one empty layer per name `templateLayerNames` (`src/layers.ts`) holds, bottom first; the same canvas writes the same bytes |
|
|
199
199
|
| `proposal.json`, `render/landmarks*.png` | `propose` | the config's four rig sections, `constraints` with `--cloth` (issue #364: a physics constraint per tree link named `<bone>_physics`, a dangling end's `<bone>_translate`, and a skirt swing's transforms `<swing>_<tree>`), `turn` with `--full`/`--head`, `proposed_rig_scale` (issue #354), and `notes` |
|
|
200
200
|
| `basis.json` | `propose` | spec `spine-parts-basis/1` |
|
|
201
|
-
| the `--write-config` file | `propose --cloth … --write-config` | the `--cloth` config read, byte for byte, but for the
|
|
201
|
+
| the `--write-config` file | `propose --cloth … --write-config` | the `--cloth` config read, byte for byte, but for the entries the recipe drafts (issue #537), measured against the same parts drafted without it: `meshes.<part>` and `regions.<part>` for each part the recipe moves, and `bones`, `constraints` and `motion.tracks` entry by entry by name (issue #552) — an entry the recipe drafts replaced or inserted, one it replaces removed, every other entry kept with its bytes and its place, and a hand edit to an entry the recipe owns refused by name (`PROPOSE_WRITE_CONFIG_CONFLICT`) rather than dropped; a section the input lacks is inserted |
|
|
202
202
|
| `config.json`, `mesh_draft.json` | `mesh-draft` | `config.json` is the config read, byte for byte, but for each drafted part's `meshes` entry; `mesh_draft.json` is spec `rig-parts-mesh-draft/1`: `rules`, `lattice_check`, `draft_check`, `figure_overdraw`, and per lattice part `part`, `mode`, `lattice`, `candidate` (with `bridges` — `units`, `joins` of `span` and `area_px2`, `area_px2`, `overdraw`, and `faint` only when an island was left out as faint — only when the candidate is a bridged one, issue #326), `delta` (under `--more-triangles` only), `readings`, `gate` (each line's `reading`, `pass`, `text`, `margin`), `note`; and `not_compared` (issue #307), only when the config holds an `auto` or `contour` entry: per such entry, in config order, `part`, `mode` and `note` — the part was neither drafted nor compared, and a config of lattices alone writes no such key |
|
|
203
|
-
| `rig.json`, `motion.json`, `mesh_report.json`, `images/`, `remesh.json` | `remesh` | the input revision's files, `rig.json` and `mesh_report.json` with the part's attachment and row replaced (under `--delta` the row is the input's with its counts, `bones` and influences recomputed and `mode` "delta"), every other file byte for byte; `remesh.json` is spec `rig-parts-remesh/1`: `request` (`part`, `mesh`, `mesh_sha256`, `idle_keys`, `page_edges`, `pack_shape`; under `--delta`, issue #526: `part`, `delta` — the mesh edit as read — `delta_sha256`, `ops`, `applied` — `moved`, `added`, `removed`, `constrained` — `idle_keys`, `page_edges`, `pack_shape`), `versions` (`parts`, `rigc`), `input` (`rig` — `path`, `bytes`, `sha256` per file — `config_sha256`, `parts_json_sha256`), `baseline` (`reproduced`, `not_compared`; under `--delta` `reproduced` holds one sentence: no config is built, the input is the baseline), `target` (`before`, `after`: `vertices`, `triangles`, `hull`), `preserved` (`identical`, `spliced`), `revision` (per file as `input.rig`), `check` (`input`, `revision`: `pass`, `measured`, `not_met`, `skipped`, `physics
|
|
204
|
-
| `rig.json`, `motion.json`, `mesh_report.json`, `images/`, `retune.json` | `retune` | the input revision's files, `rig.json` with `constraints` and `invariants.detached` replaced and `motion.json` with `animations.idle` replaced by the config's build, every other file byte for byte; `retune.json` is spec `rig-parts-retune/1`: `request` (`idle_keys`, `page_edges`, `pack_shape`), `versions` (`parts`, `rigc`), `input` (`rig` — `path`, `bytes`, `sha256` per file — `config_sha256`, `parts_json_sha256`), `held` (`compared`, `not_compared`), `changed` (`constraints` — each `name`, `type`, `fields` — `added`, `removed`, `idle`: `tracks_changed`, `duration` as before and after), `preserved` (`identical`, `spliced`), `revision` (per file as `input.rig`), `check` (`input`, `revision`: `pass`, `measured`, `not_met`, `skipped`, `physics
|
|
203
|
+
| `rig.json`, `motion.json`, `mesh_report.json`, `images/`, `remesh.json` | `remesh` | the input revision's files, `rig.json` and `mesh_report.json` with the part's attachment and row replaced (under `--delta` the row is the input's with its counts, `bones` and influences recomputed and `mode` "delta"), every other file byte for byte; `remesh.json` is spec `rig-parts-remesh/1`: `request` (`part`, `mesh`, `mesh_sha256`, `idle_keys`, `page_edges`, `pack_shape`; under `--delta`, issue #526: `part`, `delta` — the mesh edit as read — `delta_sha256`, `ops`, `applied` — `moved`, `added`, `removed`, `constrained` — `idle_keys`, `page_edges`, `pack_shape`), `versions` (`parts`, `rigc`), `input` (`rig` — `path`, `bytes`, `sha256` per file — `config_sha256`, `parts_json_sha256`), `baseline` (`reproduced`, `not_compared`; under `--delta` `reproduced` holds one sentence: no config is built, the input is the baseline), `target` (`before`, `after`: `vertices`, `triangles`, `hull`), `preserved` (`identical`, `spliced`), `revision` (per file as `input.rig`), `check` (`input`, `revision`: `pass`, `measured`, `not_met`, `skipped`, `physics`, then `line` and `status` — issue #541, additive, the spec stays `rig-parts-remesh/1`: `line` is the last line `check` prints on that tree, byte for byte, and `status` every block's status as that tree's `check.json` records it, by name in the file's order — `gate`, `loop` and `seam` read from their figures, every other block its own `status`, a block the file does not write absent; `scope`) |
|
|
204
|
+
| `rig.json`, `motion.json`, `mesh_report.json`, `images/`, `retune.json` | `retune` | the input revision's files, `rig.json` with `constraints` and `invariants.detached` replaced and `motion.json` with `animations.idle` replaced by the config's build, every other file byte for byte; `retune.json` is spec `rig-parts-retune/1`: `request` (`idle_keys`, `page_edges`, `pack_shape`), `versions` (`parts`, `rigc`), `input` (`rig` — `path`, `bytes`, `sha256` per file — `config_sha256`, `parts_json_sha256`), `held` (`compared`, `not_compared`), `changed` (`constraints` — each `name`, `type`, `fields` — `added`, `removed`, `idle`: `tracks_changed`, `duration` as before and after), `preserved` (`identical`, `spliced`), `revision` (per file as `input.rig`), `check` (`input`, `revision`: `pass`, `measured`, `not_met`, `skipped`, `physics`, then `line` and `status` — issue #541, additive, the spec stays `rig-parts-retune/1`: `line` is the last line `check` prints on that tree, byte for byte, and `status` every block's status as that tree's `check.json` records it, by name in the file's order — `gate`, `loop` and `seam` read from their figures, every other block its own `status`, a block the file does not write absent; `scope`) |
|
|
205
205
|
| the scene report | `compose` | spec `spine-parts-scene-report/1` |
|
|
206
206
|
| `idle.png`, `idle-indexed.png`, `idle.gif` | `loop`, `build --loop` | APNG and GIF encodings of the rendered idle |
|
|
207
207
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rig-parts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.2",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/build.ts
CHANGED
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
splitSchedule,
|
|
71
71
|
untestedIntervals,
|
|
72
72
|
} from './autoreplay.ts';
|
|
73
|
-
import { besideIdleLine, CLOTH_LINE, type ClothLine, clothWarnText, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamWarnText, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, readCheckEnvironment, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR } from './check.ts';
|
|
73
|
+
import { besideIdleLine, checkSummaryLine, CLOTH_LINE, type ClothLine, clothWarnText, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamWarnText, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, readCheckEnvironment, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR } from './check.ts';
|
|
74
74
|
import { type Cut, type Extend, type Limb, loadConfig, loadConfigAndAnimations, loadEarlyConfig, type Patch, type PlanEntry } from './config.ts';
|
|
75
75
|
import { failLine, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
76
76
|
import type { MeshQualityReport, MotionSchedule } from 'rig-c/mesh';
|
|
@@ -1390,18 +1390,6 @@ function showFigure(v: unknown): string {
|
|
|
1390
1390
|
return String(v);
|
|
1391
1391
|
}
|
|
1392
1392
|
|
|
1393
|
-
/**
|
|
1394
|
-
* How many of the bars measured and how many said SKIP, by name — the
|
|
1395
|
-
* summary's second half (issue #77): `PASS` reads only the bars that measured,
|
|
1396
|
-
* so a run that measured one bar says so on the line that says PASS. The
|
|
1397
|
-
* count is every bar `check` tallied: the `BARS` of `src/check.ts`, and
|
|
1398
|
-
* `ANIMATIONS_DO_NOT_FOLD` where it is written (issue #320).
|
|
1399
|
-
*/
|
|
1400
|
-
export function barsSummary(r: CheckReport): string {
|
|
1401
|
-
const { measured, skipped } = r.bars;
|
|
1402
|
-
return `${measured.length} of ${measured.length + skipped.length} bar(s) measured, ${skipped.length} skipped${skipped.length === 0 ? '' : ` (${skipped.map((s) => s.bar).join(', ')})`}`;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
1393
|
/**
|
|
1406
1394
|
* The rig stage's face-axis line (issue #239): the eye line's angle, the parts it runs between and the face bones
|
|
1407
1395
|
* turned to it, or why there is no line and the face bones keep the page's axes — the note a one-eyed painting gets.
|
|
@@ -1561,13 +1549,6 @@ export function clothLines(line: ClothLine, plant: { silent?: boolean } = {}): s
|
|
|
1561
1549
|
];
|
|
1562
1550
|
}
|
|
1563
1551
|
|
|
1564
|
-
/** The summary's warning clause: each warning line that read something, named, with the warnings they printed together; empty when none read. */
|
|
1565
|
-
export function warningsClause(r: Pick<CheckReport, 'motionSeam' | 'cloth'>): string {
|
|
1566
|
-
const read = [...(r.motionSeam.status === 'SKIP' ? [] : [{ name: MOTION_SEAM_LINE, n: r.motionSeam.warnings }]), ...(r.cloth.status === 'SKIP' ? [] : [{ name: CLOTH_LINE, n: r.cloth.warnings }])];
|
|
1567
|
-
if (read.length === 0) return '';
|
|
1568
|
-
return `; ${read.reduce((a, x) => a + x.n, 0)} warning(s) (${read.map((x) => x.name).join(', ')}, not a bar)`;
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
1552
|
/** A requirement's line as the console prints it: its name and status, the reason first when NOT MEASURABLE, then its figures as check.json holds them. */
|
|
1572
1553
|
export function requirementText(name: string, line: RequirementLine): string {
|
|
1573
1554
|
const rest = Object.entries(line).filter(([k]) => k !== 'status' && k !== 'reason');
|
|
@@ -1644,9 +1625,7 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
|
|
|
1644
1625
|
log(` gate: rig-play ${fig.gate_spine_html_green ? 'green' : 'RED'} (${fig.rigc_entry.entry}${fig.rigc_entry.spine_core === null ? ', rigc\'s own validator' : `, the spine-core ${fig.rigc_entry.spine_core} round trip`})`);
|
|
1645
1626
|
log(` wrote ${r.written.map((w) => join(input.out, w)).join(', ')}, ${join(input.out, 'build')}/${r.idle === null ? '' : `, ${join(input.out, 'idle_frames')}/`}${r.requirements === null ? '' : `, ${join(input.out, REQUIREMENTS_DIR)}/`}${fig.seam_pairs === undefined ? '' : `, ${join(input.out, SEAM_DIR)}/`}${existsSync(join(input.out, STILL_DIR)) ? `, ${join(input.out, STILL_DIR)}/` : ''}`);
|
|
1646
1627
|
for (const p of r.problems) log(failLine(p));
|
|
1647
|
-
|
|
1648
|
-
const notMet = r.requirements === null ? `${r.problems.length} bar(s) not met` : `${r.problems.length - reqNotPass} bar(s) not met, ${reqNotPass} declared requirement(s) not PASS`;
|
|
1649
|
-
log(`${fig.PASS ? 'check: PASS' : `check: FAIL — ${notMet}`}; ${barsSummary(r)}${warningsClause(r)}`);
|
|
1628
|
+
log(checkSummaryLine(r));
|
|
1650
1629
|
return r;
|
|
1651
1630
|
}
|
|
1652
1631
|
|
package/src/check.ts
CHANGED
|
@@ -2142,6 +2142,62 @@ export interface CheckReport {
|
|
|
2142
2142
|
cloth: ClothLine;
|
|
2143
2143
|
}
|
|
2144
2144
|
|
|
2145
|
+
/**
|
|
2146
|
+
* How many of the bars measured and how many said SKIP, by name — the
|
|
2147
|
+
* summary's second half (issue #77): `PASS` reads only the bars that measured,
|
|
2148
|
+
* so a run that measured one bar says so on the line that says PASS. The
|
|
2149
|
+
* count is every bar `check` tallied: the {@link BARS}, and
|
|
2150
|
+
* {@link FOLD_LINE} where it is written (issue #320).
|
|
2151
|
+
*/
|
|
2152
|
+
export function barsSummary(r: Pick<CheckReport, 'bars'>): string {
|
|
2153
|
+
const { measured, skipped } = r.bars;
|
|
2154
|
+
return `${measured.length} of ${measured.length + skipped.length} bar(s) measured, ${skipped.length} skipped${skipped.length === 0 ? '' : ` (${skipped.map((s) => s.bar).join(', ')})`}`;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
/** The summary's warning clause: each warning line that read something, named, with the warnings they printed together; empty when none read. */
|
|
2158
|
+
export function warningsClause(r: Pick<CheckReport, 'motionSeam' | 'cloth'>): string {
|
|
2159
|
+
const read = [...(r.motionSeam.status === 'SKIP' ? [] : [{ name: MOTION_SEAM_LINE, n: r.motionSeam.warnings }]), ...(r.cloth.status === 'SKIP' ? [] : [{ name: CLOTH_LINE, n: r.cloth.warnings }])];
|
|
2160
|
+
if (read.length === 0) return '';
|
|
2161
|
+
return `; ${read.reduce((a, x) => a + x.n, 0)} warning(s) (${read.map((x) => x.name).join(', ')}, not a bar)`;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
/**
|
|
2165
|
+
* The last line `check` prints, whole and as printed (`check: PASS; …` or `check: FAIL — …; …`), issue #541: the
|
|
2166
|
+
* one place it is composed. `check` prints it from here, and `remesh.json` / `retune.json` carry it from here
|
|
2167
|
+
* ({@link CheckReport} in, no clock, no path), so a consumer matching the carried line against a `check` run's stdout
|
|
2168
|
+
* compares the same composer's output twice.
|
|
2169
|
+
*/
|
|
2170
|
+
export function checkSummaryLine(r: Pick<CheckReport, 'figures' | 'problems' | 'requirements' | 'bars' | 'motionSeam' | 'cloth'>): string {
|
|
2171
|
+
const reqNotPass = r.requirements === null ? 0 : r.requirements.summary.declared - r.requirements.summary.pass;
|
|
2172
|
+
const notMet = r.requirements === null ? `${r.problems.length} bar(s) not met` : `${r.problems.length - reqNotPass} bar(s) not met, ${reqNotPass} declared requirement(s) not PASS`;
|
|
2173
|
+
return `${r.figures.PASS ? 'check: PASS' : `check: FAIL — ${notMet}`}; ${barsSummary(r)}${warningsClause(r)}`;
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
/** A block's status as {@link checkStatuses} reads it off `check.json`. */
|
|
2177
|
+
export type CheckStatus = 'PASS' | 'FAIL' | 'SKIP' | 'WARN' | 'CLEAR' | 'REPORTED';
|
|
2178
|
+
|
|
2179
|
+
/**
|
|
2180
|
+
* Every block's status as `check.json` records it (issue #541), read off the figures object `check.json` is written
|
|
2181
|
+
* from, in the file's order, one entry per block the file holds. The three bars with figures and no `status` key are
|
|
2182
|
+
* read the way {@link barsNotMet} reads the file: `gate` PASS when `gate_spine_html_green` is true, else FAIL (it is
|
|
2183
|
+
* never skipped); `loop` SKIP when `loop_max_diff` is null, `seam` SKIP when `seam_mean` is null, otherwise FAIL when
|
|
2184
|
+
* {@link barsNotMet} names it and PASS when it does not. Every other block carries its own `status` key and is copied:
|
|
2185
|
+
* the judgement lines, then {@link FOLD_LINE}, {@link LEVEL_LINE}, {@link STRESS_LINE}, {@link LIMB_LINE},
|
|
2186
|
+
* {@link SWEEP_LINE}, {@link MOTION_SEAM_LINE}, {@link CLOTH_LINE}, the reported lines and {@link SOURCE_LINE}, each
|
|
2187
|
+
* where the file writes it. The `requirements` block's lines are not bars and are not read here.
|
|
2188
|
+
*/
|
|
2189
|
+
export function checkStatuses(fig: CheckFigures): Record<string, CheckStatus> {
|
|
2190
|
+
const notMet = barsNotMet(fig as unknown as Record<string, unknown>);
|
|
2191
|
+
const bar = (name: string, measured: boolean): CheckStatus => (!measured ? 'SKIP' : notMet.includes(name) ? 'FAIL' : 'PASS');
|
|
2192
|
+
const out: Record<string, CheckStatus> = { gate: bar('gate', true), loop: bar('loop', fig.loop_max_diff !== null), seam: bar('seam', fig.seam_mean !== null) };
|
|
2193
|
+
for (const n of JUDGEMENT_LINES) out[n] = fig[n].status;
|
|
2194
|
+
for (const n of [FOLD_LINE, LEVEL_LINE, STRESS_LINE, LIMB_LINE, SWEEP_LINE, MOTION_SEAM_LINE, CLOTH_LINE, ...REPORTED_LINES, SOURCE_LINE] as const) {
|
|
2195
|
+
const l = fig[n];
|
|
2196
|
+
if (l !== undefined) out[n] = l.status;
|
|
2197
|
+
}
|
|
2198
|
+
return out;
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2145
2201
|
/**
|
|
2146
2202
|
* The one line `check` prints when `motion.json` holds animations beside the
|
|
2147
2203
|
* idle (issue #183), or null when it holds none, so a rig of the idle alone
|
package/src/clothconfig.ts
CHANGED
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
* (`cloth: null`), and each config section of the proposal ({@link PROPOSAL_CONFIG_SECTIONS}) whose value differs
|
|
8
8
|
* between the two is drafted ({@link clothConfigEdits}). An object section (`meshes`, `regions`, `motion`) is
|
|
9
9
|
* spliced entry by entry — `meshes.<part>` and `regions.<part>` for each part the recipe moved, `motion.tracks` and
|
|
10
|
-
* not the author's `animations_from` — and an array section (`bones`, `constraints
|
|
11
|
-
*
|
|
10
|
+
* not the author's `animations_from` — and so, from issue #552, is an array section (`bones`, `constraints`,
|
|
11
|
+
* `motion.tracks`): its entries are named ({@link ARRAY_SECTIONS}), the entries the recipe produced or changed are
|
|
12
|
+
* replaced in place or inserted, the entries it replaced are removed, and every other entry of the input — one the
|
|
13
|
+
* author added by hand among them — keeps its bytes and its place. A hand edit to an entry the recipe re-drafts or
|
|
14
|
+
* removes is refused by name, `PROPOSE_WRITE_CONFIG_CONFLICT`, rather than dropped. A section the recipe does not
|
|
12
15
|
* move keeps the input's bytes.
|
|
13
16
|
*/
|
|
14
17
|
|
|
15
|
-
import { PartsError } from './errors.ts';
|
|
18
|
+
import { PartsError, type Problem } from './errors.ts';
|
|
16
19
|
import { type ConfigEdit, splicedEdits } from './meshdraft.ts';
|
|
17
20
|
import { PROPOSAL_CONFIG_SECTIONS, type Proposal } from './propose.ts';
|
|
18
21
|
|
|
@@ -20,25 +23,182 @@ function isPlain(v: unknown): v is Record<string, unknown> {
|
|
|
20
23
|
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
/** Key-order-blind JSON text: two entries are the same value when this is the same string. */
|
|
27
|
+
function canon(v: unknown): string {
|
|
28
|
+
if (Array.isArray(v)) return `[${v.map(canon).join(',')}]`;
|
|
29
|
+
if (isPlain(v)) {
|
|
30
|
+
return `{${Object.keys(v)
|
|
31
|
+
.filter((k) => v[k] !== undefined)
|
|
32
|
+
.sort()
|
|
33
|
+
.map((k) => `${JSON.stringify(k)}:${canon(v[k])}`)
|
|
34
|
+
.join(',')}}`;
|
|
35
|
+
}
|
|
36
|
+
return JSON.stringify(v);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** One edit `--write-config` makes, with the words the write line prints for it. */
|
|
40
|
+
export interface ClothEdit extends ConfigEdit {
|
|
41
|
+
label: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
23
44
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
45
|
+
* An array section spliced entry by entry (issue #552), and what names an entry in it: a bone by `name` (a single
|
|
46
|
+
* bone) or `chain` (a chain), one namespace, as a mesh segment resolves either; a constraint by `name`; a track by
|
|
47
|
+
* `chain`, or by `bone` and `prop` (the proposer writes two tracks on one bone, `translatey` and `scalex`). An entry
|
|
48
|
+
* with no such name has no identity: it is never the recipe's, so it is kept.
|
|
49
|
+
*/
|
|
50
|
+
export const ARRAY_SECTIONS: ReadonlyArray<{ path: readonly string[]; identity: (e: unknown) => string | null }> = [
|
|
51
|
+
{ path: ['bones'], identity: (e) => (isPlain(e) ? (typeof e.name === 'string' ? e.name : typeof e.chain === 'string' ? e.chain : null) : null) },
|
|
52
|
+
{ path: ['constraints'], identity: (e) => (isPlain(e) && typeof e.name === 'string' ? e.name : null) },
|
|
53
|
+
{
|
|
54
|
+
path: ['motion', 'tracks'],
|
|
55
|
+
identity: (e) => (isPlain(e) ? (typeof e.chain === 'string' ? e.chain : typeof e.bone === 'string' && typeof e.prop === 'string' ? `${e.bone} ${e.prop}` : null) : null),
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
function valueAt(o: unknown, path: readonly string[]): unknown {
|
|
60
|
+
let v = o;
|
|
61
|
+
for (const k of path) v = isPlain(v) ? v[k] : undefined;
|
|
62
|
+
return v;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Each entry of a drafted array by its name; the proposer names every entry once, and anything else is this module's error. */
|
|
66
|
+
function byName(arr: readonly unknown[], identity: (e: unknown) => string | null, which: string, section: string): Map<string, unknown> {
|
|
67
|
+
const m = new Map<string, unknown>();
|
|
68
|
+
for (const e of arr) {
|
|
69
|
+
const k = identity(e);
|
|
70
|
+
if (k === null) throw new Error(`clothConfigEdits: the ${which} ${section} holds an entry with no name: ${JSON.stringify(e)}`);
|
|
71
|
+
if (m.has(k)) throw new Error(`clothConfigEdits: the ${which} ${section} names "${k}" twice`);
|
|
72
|
+
m.set(k, e);
|
|
73
|
+
}
|
|
74
|
+
return m;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The first field, in the author's order, where the author's entry differs from `ref`; null when the two are not both objects. */
|
|
78
|
+
function firstField(author: unknown, ref: unknown): string | null {
|
|
79
|
+
if (!isPlain(author) || !isPlain(ref)) return null;
|
|
80
|
+
for (const k of [...Object.keys(author), ...Object.keys(ref).filter((k) => !(k in author))]) if (canon(author[k]) !== canon(ref[k])) return k;
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function shown(v: unknown): string {
|
|
85
|
+
const t = JSON.stringify(v);
|
|
86
|
+
return t.length > 60 ? `${t.slice(0, 57)}...` : t;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The edits on one array section, entry by entry (issue #552). With `I` the input's entry of a name, `P` the plain
|
|
91
|
+
* draft's and `D` the recipe's (equality is of the value, key order aside):
|
|
92
|
+
* - owned (D present, and P absent or different): `I` absent is inserted after the input's entry that precedes it in
|
|
93
|
+
* the drafted array (the nearest earlier drafted entry the array holds, one inserted before it included), else at
|
|
94
|
+
* the end; `I` equal to `P` is replaced in place; `I` equal to `D` is left as it is;
|
|
95
|
+
* - removed (P present, D absent — the recipe replaced a plain chain with its trees): `I` equal to `P` is removed;
|
|
96
|
+
* - every other input entry is kept, bytes and order;
|
|
97
|
+
* - an owned or removed `I` that is none of those — changed by hand — is a conflict, as is a name the input states twice.
|
|
98
|
+
*/
|
|
99
|
+
function entryEdits(path: readonly string[], identity: (e: unknown) => string | null, drafted: readonly unknown[], plain: readonly unknown[], input: readonly unknown[], conflicts: Problem[]): ClothEdit[] {
|
|
100
|
+
const section = path.join('.');
|
|
101
|
+
const D = byName(drafted, identity, 'drafted', section);
|
|
102
|
+
const P = byName(plain, identity, 'plain', section);
|
|
103
|
+
const keys = input.map(identity);
|
|
104
|
+
const where = new Map<string, number[]>();
|
|
105
|
+
keys.forEach((k, i) => {
|
|
106
|
+
if (k !== null) where.set(k, [...(where.get(k) ?? []), i]);
|
|
107
|
+
});
|
|
108
|
+
const owned = [...D.keys()].filter((k) => !P.has(k) || canon(P.get(k)) !== canon(D.get(k)));
|
|
109
|
+
const removed = [...P.keys()].filter((k) => !D.has(k));
|
|
110
|
+
const replace: string[] = [];
|
|
111
|
+
const remove: string[] = [];
|
|
112
|
+
const conflict = (k: string, i: number, drafts: boolean): void => {
|
|
113
|
+
const author = input[i];
|
|
114
|
+
const field = firstField(author, P.has(k) ? P.get(k) : D.get(k));
|
|
115
|
+
const fieldOf = (e: unknown, f: string): string => (isPlain(e) && e[f] !== undefined ? `${f} ${shown(e[f])}` : `no ${f}`);
|
|
116
|
+
const held = field === null ? `the entry ${shown(author)}` : fieldOf(author, field);
|
|
117
|
+
const draft = D.get(k);
|
|
118
|
+
const draftSays = !drafts ? 'the draft removes the entry (the recipe drafts that part afresh)' : field === null ? `the draft writes ${shown(draft)}` : `the draft writes ${fieldOf(draft, field)}`;
|
|
119
|
+
conflicts.push({
|
|
120
|
+
code: 'PROPOSE_WRITE_CONFIG_CONFLICT',
|
|
121
|
+
object: `config.${section}[${i}] "${k}"`,
|
|
122
|
+
detail: `${section} entry "${k}" is the recipe's, and it was changed by hand: it holds ${held} where ${draftSays}, so the write would drop the hand edit; take the draft by removing the hand edit (or the entry), or leave the recipe out for that part (its config.cloth block)`,
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
for (const k of [...owned, ...removed]) {
|
|
126
|
+
const at = where.get(k) ?? [];
|
|
127
|
+
if (at.length > 1) {
|
|
128
|
+
conflicts.push({
|
|
129
|
+
code: 'PROPOSE_WRITE_CONFIG_CONFLICT',
|
|
130
|
+
object: `config.${section}[${at[1]}] "${k}"`,
|
|
131
|
+
detail: `${section} names "${k}" ${at.length} times (entries ${at.join(', ')}), and the recipe drafts that name, so the write cannot tell which entry is the recipe's; state it once`,
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (at.length === 0) continue;
|
|
136
|
+
const I = canon(input[at[0]]);
|
|
137
|
+
if (D.has(k)) {
|
|
138
|
+
if (I === canon(D.get(k))) continue;
|
|
139
|
+
if (P.has(k) && I === canon(P.get(k))) replace.push(k);
|
|
140
|
+
else conflict(k, at[0], true);
|
|
141
|
+
} else if (I === canon(P.get(k))) remove.push(k);
|
|
142
|
+
else conflict(k, at[0], false);
|
|
143
|
+
}
|
|
144
|
+
const edits: ClothEdit[] = [];
|
|
145
|
+
const work = [...keys];
|
|
146
|
+
for (const k of replace) edits.push({ path: [...path, work.indexOf(k)], value: D.get(k), label: `${section}["${k}"] replaced` });
|
|
147
|
+
for (const k of remove) {
|
|
148
|
+
const i = work.indexOf(k);
|
|
149
|
+
edits.push({ path: [...path, i], value: undefined, label: `${section}["${k}"] removed` });
|
|
150
|
+
work.splice(i, 1);
|
|
151
|
+
}
|
|
152
|
+
const order = [...D.keys()];
|
|
153
|
+
for (const k of owned) {
|
|
154
|
+
if (work.includes(k)) continue;
|
|
155
|
+
let pos = work.length;
|
|
156
|
+
for (let j = order.indexOf(k) - 1; j >= 0; j--) {
|
|
157
|
+
const before = work.indexOf(order[j]);
|
|
158
|
+
if (before >= 0) {
|
|
159
|
+
pos = before + 1;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
edits.push({ path: [...path, pos], value: D.get(k), insert: true, label: `${section}["${k}"] inserted` });
|
|
164
|
+
work.splice(pos, 0, k);
|
|
165
|
+
}
|
|
166
|
+
return edits;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The edits that turn `input` (the `--cloth` config, parsed) into one holding what the recipe drafts, measured as the
|
|
171
|
+
* difference between the draft with the recipe (`drafted`) and without it (`plain`): for each config section whose
|
|
172
|
+
* value differs, an object section entry by entry (an entry the recipe removed, such as a part it took from `regions`
|
|
173
|
+
* into `meshes`, is removed), an array section of {@link ARRAY_SECTIONS} entry by entry ({@link entryEdits}) where
|
|
174
|
+
* the input holds it as an array, and any other section, or one the input lacks, whole. Every conflict is collected and
|
|
175
|
+
* refused in one throw, `PROPOSE_WRITE_CONFIG_CONFLICT`, before anything is written.
|
|
176
|
+
*
|
|
177
|
+
* `whole` is the selftest's mutant only (issue #552): `bones`, `constraints` and `motion.tracks` replaced whole, as
|
|
178
|
+
* the #537 writer did; no flag or environment reaches it.
|
|
27
179
|
*/
|
|
28
|
-
export function clothConfigEdits(drafted: Proposal, plain: Proposal):
|
|
29
|
-
const edits:
|
|
30
|
-
const
|
|
31
|
-
const
|
|
180
|
+
export function clothConfigEdits(drafted: Proposal, plain: Proposal, input: unknown, whole = false): ClothEdit[] {
|
|
181
|
+
const edits: ClothEdit[] = [];
|
|
182
|
+
const conflicts: Problem[] = [];
|
|
183
|
+
const d = JSON.parse(JSON.stringify(drafted)) as Record<string, unknown>;
|
|
184
|
+
const p = JSON.parse(JSON.stringify(plain)) as Record<string, unknown>;
|
|
185
|
+
const one = (path: readonly string[], a: unknown, b: unknown): void => {
|
|
186
|
+
const s = whole ? undefined : ARRAY_SECTIONS.find((x) => x.path.join('.') === path.join('.'));
|
|
187
|
+
const mine = valueAt(input, path);
|
|
188
|
+
if (s !== undefined && Array.isArray(b) && (a === undefined || Array.isArray(a)) && Array.isArray(mine)) edits.push(...entryEdits(path, s.identity, b, Array.isArray(a) ? a : [], mine, conflicts));
|
|
189
|
+
else edits.push({ path, value: b, label: path.join('.') });
|
|
190
|
+
};
|
|
32
191
|
for (const section of PROPOSAL_CONFIG_SECTIONS) {
|
|
33
192
|
const a = p[section];
|
|
34
193
|
const b = d[section];
|
|
35
194
|
if (JSON.stringify(a) === JSON.stringify(b)) continue;
|
|
36
195
|
if (isPlain(a) && isPlain(b)) {
|
|
37
196
|
for (const k of [...Object.keys(b), ...Object.keys(a).filter((k) => !(k in b))]) {
|
|
38
|
-
if (JSON.stringify(a[k]) !== JSON.stringify(b[k]))
|
|
197
|
+
if (JSON.stringify(a[k]) !== JSON.stringify(b[k])) one([section, k], a[k], b[k]);
|
|
39
198
|
}
|
|
40
|
-
} else
|
|
199
|
+
} else one([section], a, b);
|
|
41
200
|
}
|
|
201
|
+
if (conflicts.length > 0) throw new PartsError(conflicts);
|
|
42
202
|
return edits;
|
|
43
203
|
}
|
|
44
204
|
|
|
@@ -61,7 +221,7 @@ export function writtenClothConfig(where: string, text: string, edits: readonly
|
|
|
61
221
|
return r.text;
|
|
62
222
|
}
|
|
63
223
|
|
|
64
|
-
/**
|
|
65
|
-
export function editPaths(edits: readonly
|
|
66
|
-
return edits.map((e) => e.
|
|
224
|
+
/** What each edit names, in order: what the write line prints. */
|
|
225
|
+
export function editPaths(edits: readonly ClothEdit[]): string[] {
|
|
226
|
+
return edits.map((e) => e.label);
|
|
67
227
|
}
|
package/src/meshdraft.ts
CHANGED
|
@@ -484,10 +484,11 @@ export function partsNamed(p: Problem, among: readonly string[], seams: { draft:
|
|
|
484
484
|
// ---------------------------------------------------------------------------
|
|
485
485
|
|
|
486
486
|
/**
|
|
487
|
-
* Where a JSON value starts and ends in a text, by a path of object keys
|
|
488
|
-
*
|
|
487
|
+
* Where a JSON value starts and ends in a text, by a path of object keys and array indices (a number steps to that
|
|
488
|
+
* element of an array, issue #552), and (for a non-empty path) where the last step starts (`key`: a member's opening
|
|
489
|
+
* quote, or the element itself). Throws when the path does not resolve.
|
|
489
490
|
*/
|
|
490
|
-
export function jsonValueSpan(text: string, path: readonly string[]): { start: number; end: number; key?: number } {
|
|
491
|
+
export function jsonValueSpan(text: string, path: readonly (string | number)[]): { start: number; end: number; key?: number } {
|
|
491
492
|
let i = 0;
|
|
492
493
|
const ws = (): void => {
|
|
493
494
|
while (i < text.length && /\s/.test(text[i])) i++;
|
|
@@ -541,6 +542,22 @@ export function jsonValueSpan(text: string, path: readonly string[]): { start: n
|
|
|
541
542
|
skip();
|
|
542
543
|
return keyAt === undefined ? { start, end: i } : { start, end: i, key: keyAt };
|
|
543
544
|
}
|
|
545
|
+
const step = path[depth];
|
|
546
|
+
if (typeof step === 'number') {
|
|
547
|
+
if (text[i] !== '[') throw new Error(`jsonValueSpan: ${path.slice(0, depth).join('.') || 'the document'} is not an array`);
|
|
548
|
+
i++;
|
|
549
|
+
for (let n = 0; ; n++) {
|
|
550
|
+
ws();
|
|
551
|
+
if (text[i] === ']') throw new Error(`jsonValueSpan: no element ${step} at ${path.slice(0, depth).join('.') || 'the top'}`);
|
|
552
|
+
if (n === step) {
|
|
553
|
+
keyAt = i;
|
|
554
|
+
return find(depth + 1);
|
|
555
|
+
}
|
|
556
|
+
skip();
|
|
557
|
+
ws();
|
|
558
|
+
if (text[i] === ',') i++;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
544
561
|
if (text[i] !== '{') throw new Error(`jsonValueSpan: ${path.slice(0, depth).join('.') || 'the document'} is not an object`);
|
|
545
562
|
i++;
|
|
546
563
|
for (;;) {
|
|
@@ -562,14 +579,20 @@ export function jsonValueSpan(text: string, path: readonly string[]): { start: n
|
|
|
562
579
|
return find(0);
|
|
563
580
|
}
|
|
564
581
|
|
|
565
|
-
/**
|
|
582
|
+
/**
|
|
583
|
+
* One edit {@link splicedEdits} makes: the value at `path` set (replaced, or inserted when absent), or, `undefined`,
|
|
584
|
+
* removed. A path whose last step is an index (issue #552) addresses an array element: set replaces it, `undefined`
|
|
585
|
+
* removes it, and `insert` puts `value` before it (at the array's length: after its last element), every later
|
|
586
|
+
* element moving up one.
|
|
587
|
+
*/
|
|
566
588
|
export interface ConfigEdit {
|
|
567
|
-
path: readonly string[];
|
|
589
|
+
path: readonly (string | number)[];
|
|
568
590
|
value: unknown;
|
|
591
|
+
insert?: boolean;
|
|
569
592
|
}
|
|
570
593
|
|
|
571
594
|
/** The span at `path`, or null where the path does not resolve (a key absent, or a step that is not an object). */
|
|
572
|
-
function spanOrNull(text: string, path: readonly string[]): { start: number; end: number; key?: number } | null {
|
|
595
|
+
function spanOrNull(text: string, path: readonly (string | number)[]): { start: number; end: number; key?: number } | null {
|
|
573
596
|
try {
|
|
574
597
|
return jsonValueSpan(text, path);
|
|
575
598
|
} catch {
|
|
@@ -583,8 +606,32 @@ function indentAt(text: string, at: number): string {
|
|
|
583
606
|
return /^[ \t]*/.exec(text.slice(lineStart))?.[0] ?? '';
|
|
584
607
|
}
|
|
585
608
|
|
|
609
|
+
/** An element inserted into the array at `arrayPath` before its element `index` (at its length: after the last). */
|
|
610
|
+
function insertElement(text: string, arrayPath: readonly (string | number)[], index: number, value: unknown): string {
|
|
611
|
+
const arr = spanOrNull(text, arrayPath);
|
|
612
|
+
if (arr === null || text[arr.start] !== '[') throw new Error(`splicedEdits: ${arrayPath.join('.') || 'the document'} is not an array`);
|
|
613
|
+
const next = spanOrNull(text, [...arrayPath, index]);
|
|
614
|
+
if (next !== null) {
|
|
615
|
+
// Before the element: the new one takes its line, and the old one follows on a line of its own at the same indent.
|
|
616
|
+
const indent = indentAt(text, next.start);
|
|
617
|
+
const body = JSON.stringify(value, null, 2).split('\n').join(`\n${indent}`);
|
|
618
|
+
return `${text.slice(0, next.start)}${body},\n${indent}${text.slice(next.start)}`;
|
|
619
|
+
}
|
|
620
|
+
const prev = index > 0 ? spanOrNull(text, [...arrayPath, index - 1]) : null;
|
|
621
|
+
if (index > 0 && prev === null) throw new Error(`splicedEdits: ${arrayPath.join('.')} has no element ${index - 1}`);
|
|
622
|
+
const indent = prev !== null ? indentAt(text, prev.start) : `${indentAt(text, arr.start)} `;
|
|
623
|
+
const body = JSON.stringify(value, null, 2).split('\n').join(`\n${indent}`);
|
|
624
|
+
if (prev === null) return `${text.slice(0, arr.start + 1)}\n${indent}${body}\n${indentAt(text, arr.start)}${text.slice(arr.end - 1)}`;
|
|
625
|
+
return `${text.slice(0, prev.end)},\n${indent}${body}${text.slice(prev.end)}`;
|
|
626
|
+
}
|
|
627
|
+
|
|
586
628
|
/** One edit on `text`; every byte it does not name is the input's. */
|
|
587
|
-
function spliceOne(text: string, path: readonly string[], value: unknown): string {
|
|
629
|
+
function spliceOne(text: string, path: readonly (string | number)[], value: unknown, insert = false): string {
|
|
630
|
+
const step = path[path.length - 1];
|
|
631
|
+
if (insert) {
|
|
632
|
+
if (typeof step !== 'number') throw new Error(`splicedEdits: an insert names an array index; ${path.join('.')} does not`);
|
|
633
|
+
return insertElement(text, path.slice(0, -1), step, value);
|
|
634
|
+
}
|
|
588
635
|
const at = spanOrNull(text, path);
|
|
589
636
|
if (value === undefined) {
|
|
590
637
|
if (at === null || at.key === undefined) return text;
|
|
@@ -594,6 +641,8 @@ function spliceOne(text: string, path: readonly string[], value: unknown): strin
|
|
|
594
641
|
if (text[before] === ',') return `${text.slice(0, before)}${text.slice(at.end)}`;
|
|
595
642
|
let after = at.end;
|
|
596
643
|
while (after < text.length && /\s/.test(text[after])) after++;
|
|
644
|
+
// An array's only element: the brackets close on each other.
|
|
645
|
+
if (typeof step === 'number' && text[before] === '[' && text[after] === ']') return `${text.slice(0, before + 1)}${text.slice(after)}`;
|
|
597
646
|
if (text[after] === ',') {
|
|
598
647
|
after++;
|
|
599
648
|
while (after < text.length && /\s/.test(text[after])) after++;
|
|
@@ -605,13 +654,14 @@ function spliceOne(text: string, path: readonly string[], value: unknown): strin
|
|
|
605
654
|
const body = JSON.stringify(value, null, 2).split('\n').join(`\n${indentAt(text, at.start)}`);
|
|
606
655
|
return `${text.slice(0, at.start)}${body}${text.slice(at.end)}`;
|
|
607
656
|
}
|
|
657
|
+
if (typeof step === 'number') throw new Error(`splicedEdits: ${path.join('.')} names no element; an element is added by an insert`);
|
|
608
658
|
const parentPath = path.slice(0, -1);
|
|
609
659
|
const parent = spanOrNull(text, parentPath);
|
|
610
660
|
// A parent the text lacks is inserted whole, holding this one member.
|
|
611
|
-
if (parent === null) return spliceOne(text, parentPath, { [
|
|
661
|
+
if (parent === null) return spliceOne(text, parentPath, { [step]: value });
|
|
612
662
|
if (text[parent.start] !== '{') throw new Error(`splicedEdits: ${parentPath.join('.') || 'the document'} is not an object`);
|
|
613
663
|
const indent = `${indentAt(text, parent.start)} `;
|
|
614
|
-
const member = `"${
|
|
664
|
+
const member = `"${step}": ${JSON.stringify(value, null, 2).split('\n').join(`\n${indent}`)}`;
|
|
615
665
|
let last = parent.end - 2;
|
|
616
666
|
while (last > parent.start && /\s/.test(text[last])) last--;
|
|
617
667
|
if (last === parent.start) return `${text.slice(0, parent.start + 1)}\n${indent}${member}\n${indentAt(text, parent.start)}${text.slice(parent.end - 1)}`;
|
|
@@ -634,24 +684,35 @@ function firstMoved(got: unknown, want: unknown, path: readonly string[]): strin
|
|
|
634
684
|
/**
|
|
635
685
|
* The input's own text with each edit made in order: a value present is replaced, as `JSON.stringify(value, null, 2)`
|
|
636
686
|
* indented to the line it starts on; one absent is inserted as the last member of its object (an absent parent
|
|
637
|
-
* inserted with it); `undefined` removes the member.
|
|
687
|
+
* inserted with it); `undefined` removes the member. An index step addresses an array element (issue #552): replaced
|
|
688
|
+
* or removed in place, or, `insert`, put before that element on a line of its own at the neighbours' indent (after
|
|
689
|
+
* the last element at the array's length), and a removed element takes one comma beside it. Every other byte is the
|
|
690
|
+
* input's. The result is parsed and held
|
|
638
691
|
* to the intended document — the input parsed with the same edits made on it — and `moved` names the first path
|
|
639
692
|
* where it is not (a key the text states twice is the way it is not: the edit lands on the first, the parse keeps the
|
|
640
693
|
* last); null when it is.
|
|
641
694
|
*/
|
|
642
695
|
export function splicedEdits(text: string, edits: readonly ConfigEdit[]): { text: string; moved: string | null } {
|
|
643
696
|
let out = text;
|
|
644
|
-
for (const e of edits) out = spliceOne(out, e.path, e.value);
|
|
697
|
+
for (const e of edits) out = spliceOne(out, e.path, e.value, e.insert === true);
|
|
645
698
|
const want = JSON.parse(text) as Record<string, unknown>;
|
|
646
699
|
for (const e of edits) {
|
|
647
|
-
let o = want;
|
|
700
|
+
let o: Record<string | number, unknown> | unknown[] = want;
|
|
648
701
|
for (const k of e.path.slice(0, -1)) {
|
|
649
|
-
|
|
650
|
-
|
|
702
|
+
const rec = o as Record<string | number, unknown>;
|
|
703
|
+
if (typeof rec[k] !== 'object' || rec[k] === null) rec[k] = {};
|
|
704
|
+
o = rec[k] as Record<string | number, unknown> | unknown[];
|
|
651
705
|
}
|
|
652
706
|
const last = e.path[e.path.length - 1];
|
|
653
|
-
if (
|
|
654
|
-
|
|
707
|
+
if (Array.isArray(o) && typeof last === 'number') {
|
|
708
|
+
if (e.insert === true) o.splice(last, 0, e.value);
|
|
709
|
+
else if (e.value === undefined) o.splice(last, 1);
|
|
710
|
+
else o[last] = e.value;
|
|
711
|
+
} else {
|
|
712
|
+
const rec = o as Record<string | number, unknown>;
|
|
713
|
+
if (e.value === undefined) delete rec[last];
|
|
714
|
+
else rec[last] = e.value;
|
|
715
|
+
}
|
|
655
716
|
}
|
|
656
717
|
return { text: out, moved: firstMoved(JSON.parse(out), want, []) };
|
|
657
718
|
}
|
package/src/remesh.ts
CHANGED
|
@@ -61,14 +61,14 @@ import { createHash } from 'node:crypto';
|
|
|
61
61
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
62
62
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
63
63
|
import { checkStage, gateThroughRigc, type Log, RIGC_MODEL_DOCUMENT, rigStage } from './build.ts';
|
|
64
|
-
import { barsNotMet, type CheckReport, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, type PackShape, type PageEdges, rigcRanClause, type RigcRunner } from './check.ts';
|
|
64
|
+
import { barsNotMet, type CheckReport, checkStatuses, type CheckStatus, checkSummaryLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, type PackShape, type PageEdges, rigcRanClause, type RigcRunner } from './check.ts';
|
|
65
65
|
import { loadConfigAndAnimations } from './config.ts';
|
|
66
66
|
import { PartsError, type Problem, problemLine, refuseIfAny } from './errors.ts';
|
|
67
67
|
import { jsonValueSpan, scratchConfig } from './meshdraft.ts';
|
|
68
68
|
import { computeExactFrameTransforms } from './coords.ts';
|
|
69
69
|
import { type PartsFile } from './parts.ts';
|
|
70
70
|
import { applyMeshEdit, type DeltaApplied, type DeltaPlant, deltaSourceProblems, type MeshEditDocument, readMeshEdit } from './remeshdelta.ts';
|
|
71
|
-
import { DEFAULT_IDLE_KEYS, type IdleKeys, type MeshAttachment, rigJsonText, type RigSpec } from './rig.ts';
|
|
71
|
+
import { DEFAULT_IDLE_KEYS, type IdleKeys, type MeshAttachment, meshBoundBones, rigJsonText, type RigSpec } from './rig.ts';
|
|
72
72
|
import { pyRound } from './round.ts';
|
|
73
73
|
|
|
74
74
|
/** The provenance file's spec. */
|
|
@@ -144,13 +144,21 @@ export interface MeshCounts {
|
|
|
144
144
|
hull: number;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* One side of the provenance's check block. The first five fields are what the hold ({@link checkHeldProblems})
|
|
149
|
+
* reads; `line` and `status` (issue #541) are what `check` itself reports on the same tree — its last line, whole,
|
|
150
|
+
* and every block's status as `check.json` records it — so a consumer need not run `check` a second time.
|
|
151
|
+
*/
|
|
148
152
|
export interface CheckSide {
|
|
149
153
|
pass: boolean;
|
|
150
154
|
measured: string[];
|
|
151
155
|
not_met: string[];
|
|
152
156
|
skipped: Array<{ bar: string; reason: string }>;
|
|
153
157
|
physics: string | null;
|
|
158
|
+
/** The last line `check` prints ({@link checkSummaryLine}), byte for byte. */
|
|
159
|
+
line: string;
|
|
160
|
+
/** Every block's status as `check.json` records it, in the file's order ({@link checkStatuses}). */
|
|
161
|
+
status: Record<string, CheckStatus>;
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
/** `remesh.json` (spec {@link REMESH_SPEC}). */
|
|
@@ -461,6 +469,8 @@ export function checkSide(r: CheckReport): CheckSide {
|
|
|
461
469
|
not_met: barsNotMet(r.figures as unknown as Record<string, unknown>),
|
|
462
470
|
skipped: r.bars.skipped.map((s) => ({ bar: s.bar, reason: s.reason })),
|
|
463
471
|
physics: r.loopPhysics,
|
|
472
|
+
line: checkSummaryLine(r),
|
|
473
|
+
status: checkStatuses(r.figures),
|
|
464
474
|
};
|
|
465
475
|
}
|
|
466
476
|
|
|
@@ -555,7 +565,7 @@ const textsOf = (tree: FileTree): Array<readonly [string, string]> => [...tree].
|
|
|
555
565
|
|
|
556
566
|
/**
|
|
557
567
|
* The delta's `mesh_report.json` row (issue #526): the input's row, key for key, with `vertices`, `triangles`, `hull`,
|
|
558
|
-
* `bones` (the sorted set the new weights name), `max_influences` and `mean_influences` recomputed from the new
|
|
568
|
+
* `bones` (the sorted set the new weights name, `meshBoundBones` — the reading every rig row takes), `max_influences` and `mean_influences` recomputed from the new
|
|
559
569
|
* attachment and `mode` "delta" (in place, or last when the row had none). Every other key is the input's and
|
|
560
570
|
* describes the mesh the delta was drawn over.
|
|
561
571
|
*/
|
|
@@ -566,7 +576,7 @@ export function deltaRow(row: Json, att: MeshAttachment): Json {
|
|
|
566
576
|
vertices: n,
|
|
567
577
|
triangles: att.triangles.length / 3,
|
|
568
578
|
hull: att.hull,
|
|
569
|
-
bones:
|
|
579
|
+
bones: meshBoundBones(att),
|
|
570
580
|
max_influences: Math.max(...att.weights.map((w) => w.length)),
|
|
571
581
|
mean_influences: pyRound(entries / n, 2),
|
|
572
582
|
mode: 'delta',
|
package/src/requirements.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* | outcome | when | what it does |
|
|
14
14
|
* | --- | --- | --- |
|
|
15
15
|
* | not declared | the file states no requirement of that kind | the summary names the kind; not a pass, not a skip |
|
|
16
|
-
* | refused | a bone, constraint, mesh or animation does not resolve, a field or bar is missing, a `follow` names a property its constraint does not drive | refused by name before anything is built ({@link readRequirements}, {@link resolveRequirements}) |
|
|
16
|
+
* | refused | a bone, constraint, mesh or animation does not resolve, a field or bar is missing, a `follow` names a property its constraint does not drive, a `contact` is held against its own bone's same point or an `aim` against a point of its own bone (issue #540) | refused by name before anything is built ({@link readRequirements}, {@link resolveRequirements}) |
|
|
17
17
|
* | not measurable | it reads and the rig builds, and the quantity is undefined in the frames | `NOT MEASURABLE — <why>`, with the figures; the run does not PASS |
|
|
18
18
|
* | measured | otherwise | `PASS` or `FAIL` against the author's bar, with the figures and the worst frame |
|
|
19
19
|
*
|
|
@@ -253,7 +253,9 @@ const EXCEPTION_ABSENT: Record<ExceptionList, string> = {
|
|
|
253
253
|
* in `not_swinging` and in `rises` or `rests`;
|
|
254
254
|
* which parts they are is read against parts.json and the rig by `check`),
|
|
255
255
|
* each entry's every field and bar by name, a key the format does not read,
|
|
256
|
-
*
|
|
256
|
+
* a name used twice, and a `contact` against its own bone and point or an
|
|
257
|
+
* `aim` at a point of its own bone (issue #540: each reads 0 by construction,
|
|
258
|
+
* or no line at all). Resolving the names against the rig is
|
|
257
259
|
* {@link resolveRequirements}'s.
|
|
258
260
|
*/
|
|
259
261
|
export function readRequirements(path: string): RequirementsFile {
|
|
@@ -274,6 +276,9 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
274
276
|
const field = (object: string, detail: string): void => {
|
|
275
277
|
problems.push({ code: 'REQUIREMENTS_FIELD', object, detail });
|
|
276
278
|
};
|
|
279
|
+
const selfTarget = (label: string, detail: string): void => {
|
|
280
|
+
problems.push({ code: 'REQUIREMENTS_SELF_TARGET', object: `${label} field "target"`, detail });
|
|
281
|
+
};
|
|
277
282
|
if (raw.spec !== REQUIREMENTS_SPEC) field(`${at} field "spec"`, `is ${JSON.stringify(raw.spec)}; ${JSON.stringify(REQUIREMENTS_SPEC)} is required`);
|
|
278
283
|
for (const k of Object.keys(raw)) if (!['spec', 'fps', 'targets', 'requirements', ...EXCEPTION_LISTS, 'may_fold'].includes(k) && !freeKey(k, raw[k])) field(`${at} field "${k}"`, 'is not a field this format reads (spec, fps, targets, requirements, not_planted, not_swinging, rises, rests, may_fold; note or *_note as a string; x-<name> as a record)');
|
|
279
284
|
let fps = NaN;
|
|
@@ -331,6 +336,11 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
331
336
|
let req: Requirement;
|
|
332
337
|
if (kind === 'contact') {
|
|
333
338
|
req = { ...common, kind, bone: str('bone'), point: point('point', r.point), target: target(), within_px: bar('within_px', (v) => v >= 0, 'a distance in stage px, 0 or more,') };
|
|
339
|
+
// Issue #540: a point against itself is 0 apart on every frame; the bone's other point is a reading (its length).
|
|
340
|
+
if ('bone' in req.target && req.bone.length > 0 && req.target.bone === req.bone && req.target.point === req.point) {
|
|
341
|
+
const other = req.point === 'tip' ? 'origin' : 'tip';
|
|
342
|
+
selfTarget(label, `contact of bone "${req.bone}" ${req.point} against bone "${req.target.bone}" ${req.target.point}, the same point: it measures 0 by construction, so a PASS says nothing — a different bone is required, or the bone's other point ("${other}")`);
|
|
343
|
+
}
|
|
334
344
|
} else if (kind === 'follow') {
|
|
335
345
|
const type = r.constraint_type;
|
|
336
346
|
if (type !== 'ik' && type !== 'transform') field(`${label} field "constraint_type"`, `is ${JSON.stringify(type)}; "ik" or "transform" is required — a constraint resolves by name AND type, as in rig-c`);
|
|
@@ -349,6 +359,11 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
349
359
|
};
|
|
350
360
|
} else if (kind === 'aim') {
|
|
351
361
|
req = { ...common, kind, bone: str('bone'), target: target(), within_degrees: bar('within_degrees', (v) => v >= 0 && v <= 180, 'an angle in degrees from 0 to 180') };
|
|
362
|
+
// Issue #540: the aimed bone's own tip lies on its axis (0 degrees on every frame) and its own origin gives no line at all.
|
|
363
|
+
if ('bone' in req.target && req.bone.length > 0 && req.target.bone === req.bone) {
|
|
364
|
+
const why = req.target.point === 'tip' ? 'its tip lies on its own axis, so the angle measures 0 by construction and a PASS says nothing' : 'its origin is where the line starts, so there is no line to aim along on any frame and nothing is measured';
|
|
365
|
+
selfTarget(label, `aim of bone "${req.bone}" axis against bone "${req.target.bone}" ${req.target.point}, a point of the aimed bone itself: ${why} — a different bone or a stage point is required`);
|
|
366
|
+
}
|
|
352
367
|
} else if (kind === 'range') {
|
|
353
368
|
const lo = bar('lo_degrees', () => true, 'an angle in degrees');
|
|
354
369
|
const hi = bar('hi_degrees', () => true, 'an angle in degrees');
|
package/src/rig.ts
CHANGED
|
@@ -766,6 +766,16 @@ export type RigCommand = 'rig' | 'build';
|
|
|
766
766
|
/** The `why` of the `invariants.idleDrivesMeshes` that `idleKeys: 'direct'` declares. */
|
|
767
767
|
export const IDLE_DRIVES_MESHES_WHY = 'painting rig: the idle is meant to deform the meshes it keys (rig-parts rig --idle-keys direct)';
|
|
768
768
|
|
|
769
|
+
/**
|
|
770
|
+
* The bones a mesh attachment binds: the sorted set of bone names its weights name (issue #536). Every
|
|
771
|
+
* `mesh_report.json` row's `bones` is this reading of the attachment the written `rig.json` holds — after the turn's
|
|
772
|
+
* twins and the stops' drawn links have taken their bones' places — so the row names what the emitted model binds in
|
|
773
|
+
* every mode; `remesh --delta`'s row (`deltaRow`, `src/remesh.ts`) takes the same function.
|
|
774
|
+
*/
|
|
775
|
+
export function meshBoundBones(att: Pick<MeshAttachment, 'weights'>): string[] {
|
|
776
|
+
return [...new Set(att.weights.flatMap((w) => w.map((e) => e.bone)))].sort();
|
|
777
|
+
}
|
|
778
|
+
|
|
769
779
|
/** One row of `mesh_report.json`: a lattice mesh's row is as it always was; a contour mesh's says so. */
|
|
770
780
|
export type MeshReport = LatticeMeshReport | ContourMeshReport | AutoMeshReport | InfluenceMeshReport;
|
|
771
781
|
|
|
@@ -2544,6 +2554,12 @@ export function buildRig(
|
|
|
2544
2554
|
// Only when the config has `turn`: every other build adds nothing here, so no byte moves.
|
|
2545
2555
|
if (cfg.turn !== undefined) refuseIfAny(turnRiderProblems(cfg.turn, cfg, parts.parts));
|
|
2546
2556
|
const turned = cfg.turn === undefined ? null : applyTurn(cfg.turn, parts.parts.map((p) => p.name), bones, slots, skin, cfg.constraints ?? []);
|
|
2557
|
+
// issue #536: every row names the bones the emitted attachment binds, read once the turn and the stops have
|
|
2558
|
+
// rebound the weights; a rig with neither rebinds nothing, so this reads back the names each row already holds.
|
|
2559
|
+
for (const row of meshReport) {
|
|
2560
|
+
const att = skin[row.part]?.[row.part];
|
|
2561
|
+
if (att !== undefined && 'type' in att) row.bones = meshBoundBones(att);
|
|
2562
|
+
}
|
|
2547
2563
|
|
|
2548
2564
|
const name = `${cfg.key}_painting`;
|
|
2549
2565
|
const rig: RigSpec = {
|