@rig-c/parts 1.41.0 → 1.41.1

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