@rig-c/parts 1.52.0 → 1.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/parts.ts CHANGED
@@ -169,9 +169,18 @@ export interface CapRecord {
169
169
  * lower's layer had none (`upper_px`). `radius` is then the half-width about the
170
170
  * joint, at most half of `width`. Issue #557: without the shape the half-disc
171
171
  * takes them too, and `upper_px` is written there only when above 0.
172
+ * Issue #579: `"ball"` under the segment's `cap_shape: "ball"` — the same
173
+ * disc and upper half, and its half on the lower side of the cut too: the
174
+ * pixels written there into the lower piece from the cap image where the
175
+ * piece's own pixel was transparent (alpha 0, `lower_px`), those left as
176
+ * painted (`lower_kept_px`), and those the image gave none for
177
+ * (`lower_missing_px`), which `missing_px` and `short_px` count as well.
172
178
  */
173
- shape?: 'disc';
179
+ shape?: 'disc' | 'ball';
174
180
  upper_px?: number;
181
+ lower_px?: number;
182
+ lower_kept_px?: number;
183
+ lower_missing_px?: number;
175
184
  /**
176
185
  * Issue #360, written only under the segment's `edge: "feather"`: the edge,
177
186
  * the radius of the band it fades over (the disc the lower piece covers at
@@ -212,6 +221,9 @@ const CAP_KEYS = [
212
221
  'short_px',
213
222
  'shape',
214
223
  'upper_px',
224
+ 'lower_px',
225
+ 'lower_kept_px',
226
+ 'lower_missing_px',
215
227
  'edge',
216
228
  'feather_radius',
217
229
  'feathered_px',
@@ -223,6 +235,8 @@ const CAP_KEYS = [
223
235
  'band_px',
224
236
  'stroke_luma_max',
225
237
  ] as const;
238
+ /** The cap keys only `cap_shape: "ball"` writes (issue #579). */
239
+ const BALL_KEYS = ['lower_px', 'lower_kept_px', 'lower_missing_px'] as const;
226
240
  /** The cap keys only `cut_band` writes (issue #360, item 14). */
227
241
  const CUT_KEYS = ['cut_offset', 'cut_at', 'cut_crossed', 'joint_crossed', 'band_px', 'stroke_luma_max'] as const;
228
242
 
@@ -633,7 +647,11 @@ function checkParts(raw: unknown, path: string): PartsFile {
633
647
  (!('image_px' in co) || isCount(co.image_px)) &&
634
648
  (!('image_layer' in co) || ('image_px' in co && typeof co.image_layer === 'string' && co.image_layer !== '')) &&
635
649
  // Issue #360: a disc cap carries its count, a feathered edge its band and count, and neither carries them alone.
636
- ('shape' in co ? co.shape === 'disc' && isCount(co.upper_px) : !('upper_px' in co) || (isCount(co.upper_px) && co.upper_px > 0)) &&
650
+ ('shape' in co ? (co.shape === 'disc' || co.shape === 'ball') && isCount(co.upper_px) : !('upper_px' in co) || (isCount(co.upper_px) && co.upper_px > 0)) &&
651
+ // Issue #579: a ball cap carries its lower half's three counts, its missing ones inside missing_px; no other cap carries them.
652
+ (co.shape === 'ball'
653
+ ? isCount(co.lower_px) && isCount(co.lower_kept_px) && isCount(co.lower_missing_px) && isCount(co.missing_px) && co.lower_missing_px <= co.missing_px
654
+ : BALL_KEYS.every((k) => !(k in co))) &&
637
655
  // Issue #557: the shortfall by side, when written, adds up to the missing pixels, and is never written for none.
638
656
  (!('short_px' in co) || shortSides(co.short_px, co.missing_px)) &&
639
657
  ('edge' in co ? co.edge === 'feather' && typeof co.feather_radius === 'number' && Number.isFinite(co.feather_radius) && co.feather_radius >= 0 && isCount(co.feathered_px) : !('feather_radius' in co) && !('feathered_px' in co)) &&
@@ -654,7 +672,7 @@ function checkParts(raw: unknown, path: string): PartsFile {
654
672
  fail(
655
673
  'PARTS_FIELD_TYPE',
656
674
  `${object} "cap"`,
657
- `is ${show(c)}; {at: [x, y], width, radius, box: [x, y, w, h], layer_px, image_px?, image_layer? (with image_px), missing_px, short_px? ({left, right}, adding up to missing_px, above 0), shape? ("disc", with upper_px; without it upper_px? above 0), edge? ("feather", with feather_radius and feathered_px), cut_band? (with cut_offset inside the band, cut_at, cut_crossed at most joint_crossed, band_px, stroke_luma_max? 0..255)} is required`,
675
+ `is ${show(c)}; {at: [x, y], width, radius, box: [x, y, w, h], layer_px, image_px?, image_layer? (with image_px), missing_px, short_px? ({left, right}, adding up to missing_px, above 0), shape? ("disc" or "ball", with upper_px; "ball" with lower_px, lower_kept_px and lower_missing_px, at most missing_px; without it upper_px? above 0), edge? ("feather", with feather_radius and feathered_px), cut_band? (with cut_offset inside the band, cut_at, cut_crossed at most joint_crossed, band_px, stroke_luma_max? 0..255)} is required`,
658
676
  );
659
677
  }
660
678
  }
package/src/propose.ts CHANGED
@@ -99,7 +99,11 @@
99
99
  * ankle of a leg whose hip, knee and ankle are given is meshed on a leg chain
100
100
  * (hip -> knee, tip at the ankle; one per leg, or one through the midpoints
101
101
  * when the part's art does not separate the legs — {@link legsFromJoints}),
102
- * where without them it rides `hip` as a region. And with a joint at either
102
+ * where without them it rides `hip` as a region. A limb whose tagged route has
103
+ * no part at all — no handwear or no legwear part over 500 px — is drafted from
104
+ * the one `topwear` part that holds its joints, the figure layer of a figure of
105
+ * one material, with the trunk a limb on it too (issue #577,
106
+ * {@link figureLayerOf}). And with a joint at either
103
107
  * end of the trunk (issue #243), the trunk parts' fixed segments run along
104
108
  * neck -> hip, the line the chest is placed on, instead of down the screen
105
109
  * ({@link trunkLineOf}).
@@ -127,7 +131,7 @@
127
131
  import { existsSync } from 'node:fs';
128
132
  import { join } from 'node:path';
129
133
  import { drawText, GLYPH_H } from 'rig-c/tools/font5x7.ts';
130
- import { type BoneEntry, type ConfigConstraint, type ConfigStop, contourRegionsOf, deriveBustRegions, type Limb, type MeshSpec, type PartBinding, parseConfig, type Point, type Segment, type SkeletonSections, turnRidersByBone } from './config.ts';
134
+ import { type BoneEntry, type CharacterConfig, type ConfigConstraint, type ConfigStop, contourRegionsOf, deriveBustRegions, type Limb, type MeshSpec, type PartBinding, parseConfig, type Point, type Segment, type SkeletonSections, turnRidersByBone } from './config.ts';
131
135
  export { contourRegionsOf, deriveBustRegions };
132
136
  import { computeExactFrameTransforms, cropToSpineY, normaliseDegrees, toWorld } from './coords.ts';
133
137
  import { PartsError, type Problem, refuseIfAny } from './errors.ts';
@@ -154,6 +158,7 @@ import { bonePlaces, jointLine, limbCrossing, limbPolyline, limbRun, limbWidth,
154
158
  import { type BranchSqueezeFinding, branchSqueezes, chainSqueezes, type SqueezeFinding } from './squeeze.ts';
155
159
  import { backHairMasses, type BackHairMass, backHairMassTrees, INFLUENCE_RADIUS_CELLS, RECIPE_BACK_HAIR_CHAINS, RECIPE_LENGTH_RATIO, chainConstraints, clothNote, type ClothRecipe, type ClothRecipes, type ClothTarget, CLOTH_TARGETS, draftTrees, spanCrosses, swingName, type Tail, tailOverlap, type TailOverlap, type TailSpan, treeConstraints, type TreeChain, type TreeInput, type TreeMassInput } from './cloth.ts';
156
160
  import { TEXTURE_STRETCH_CEILING } from './check.ts';
161
+ import { linePixels } from './paintcheck.ts';
157
162
 
158
163
  // ---------------------------------------------------------------------------
159
164
  // the output shape — config-shaped, key order as the reference writes it
@@ -453,9 +458,18 @@ export function proposalAssemble(P: PartSet): Record<string, unknown> {
453
458
  * refusals.
454
459
  */
455
460
  export function checkProposal(P: PartSet, p: Proposal): void {
461
+ proposalAsConfig(P, p);
462
+ }
463
+
464
+ /**
465
+ * The config sections of a proposal (or of a config: issue #572 reads `--write-config`'s text through it) parsed as
466
+ * the config loader parses them, beside this part set's `assemble`: what {@link checkProposal} refuses by, and what
467
+ * `propose --cloth` reads its chains' amplitudes off (`chainsLeftBehind`, `src/clothconfig.ts`).
468
+ */
469
+ export function proposalAsConfig(P: PartSet, p: { readonly [K in (typeof PROPOSAL_CONFIG_SECTIONS)[number]]?: unknown }): CharacterConfig {
456
470
  const sections: Record<string, unknown> = {};
457
471
  for (const k of PROPOSAL_CONFIG_SECTIONS) if (p[k] !== undefined) sections[k] = p[k];
458
- parseConfig({ key: 'proposal', assemble: proposalAssemble(P), ...sections });
472
+ return parseConfig({ key: 'proposal', assemble: proposalAssemble(P), ...sections });
459
473
  }
460
474
 
461
475
  /** Fixed key order, two-space indent, trailing newline: the same inputs write the same bytes. */
@@ -2570,6 +2584,29 @@ export function proposeWithBasis(
2570
2584
  // A cut's piece counts here (issue #230): the sleeve rule names its chains by side, not once per part, so a piece
2571
2585
  // never repeats one, and cutting one sleeve out of a both-arms part is how #199's note says to separate them.
2572
2586
  const hw = [...P.byTag('handwear-r', undefined, true), ...P.byTag('handwear-l', undefined, true)].filter((p) => p.opaque_px > 500);
2587
+ // Issue #577: a figure of one material (a mannequin, a statue) reaches See-through as one garment, so no handwear or
2588
+ // legwear part carries its limbs. With joints, when the tagged route has no part for a complete limb, the one topwear
2589
+ // part that holds every such limb's joints is the figure layer: the trunk and those limbs split it by the cut.
2590
+ const lwTagged = P.byTag('legwear', undefined, true).filter((p) => p.opaque_px > 500);
2591
+ const figure = joints === undefined ? null : figureLayerOf(P, hw, lwTagged, joints, { hip, chest, neck: neckAt });
2592
+ if (figure !== null && figure.part === null) notes.push(figure.note);
2593
+ const figPart = figure === null ? null : figure.part;
2594
+ if (figure !== null && figPart !== null) {
2595
+ // The trunk is a limb too: a limb takes every pixel of its part, so without one the torso and the neck would go
2596
+ // to the nearest arm or leg. Three segments on the three trunk bones, cut at the chest's and the neck's origins.
2597
+ limbs.trunk = {
2598
+ segments: [
2599
+ { part: 'trunk_hip', from: figPart.name, bone: 'hip' },
2600
+ { part: 'trunk_chest', from: figPart.name, bone: 'chest', joint: 'chest' },
2601
+ { part: 'trunk_neck', from: figPart.name, bone: 'neck', joint: 'neck' },
2602
+ ],
2603
+ };
2604
+ regions.trunk_hip = 'hip';
2605
+ regions.trunk_chest = 'chest';
2606
+ regions.trunk_neck = 'neck';
2607
+ consumed.add(figPart.name);
2608
+ notes.push(figure.note);
2609
+ }
2573
2610
  const sides = new Map<'r' | 'l', PartRecord[]>();
2574
2611
  for (const p of hw) {
2575
2612
  const s = center(p)[0] < axis ? 'r' : 'l';
@@ -2580,7 +2617,12 @@ export function proposeWithBasis(
2580
2617
  // Issue #75: arms from joints, when every handwear part carries the wrist of
2581
2618
  // an arm whose shoulder, elbow and wrist are all given; otherwise the rule
2582
2619
  // below places every sleeve chain, and the notes say why.
2583
- const armPlan = joints !== undefined && clasped === null && hw.length > 0 ? armsFromJoints(P, hw, joints, wristSnap, chainRule) : null;
2620
+ const armPlan =
2621
+ joints !== undefined && clasped === null && hw.length > 0
2622
+ ? armsFromJoints(P, hw, joints, wristSnap, chainRule)
2623
+ : figPart !== null && figure !== null && figure.arms
2624
+ ? armsFromJoints(P, [figPart], joints as RigJoints, null, false)
2625
+ : null;
2584
2626
  let sleeveRule = '';
2585
2627
  if (clasped !== null) {
2586
2628
  sleeveRule = 'the clasped-hands rule (the handwear is a region on hip, with no sleeve chain)';
@@ -2792,7 +2834,7 @@ export function proposeWithBasis(
2792
2834
 
2793
2835
  // ---- outer robe (topwear)
2794
2836
  for (const p of tw) {
2795
- if (p === namedSkirt || multiPartClaimed.has(p.name)) continue;
2837
+ if (p === namedSkirt || multiPartClaimed.has(p.name) || p === figPart) continue;
2796
2838
  const hint = skirtHints.get(p.name);
2797
2839
  if (hint !== undefined) notes.push(hint);
2798
2840
  const [g, r] = gridR(p);
@@ -3259,8 +3301,14 @@ export function proposeWithBasis(
3259
3301
  // meshed on a leg chain hip -> knee, tip at the ankle; without them no line below runs, and the part stays the
3260
3302
  // region the trunk rule gives it, its note unchanged. No idle track is written for a leg chain: the chain is
3261
3303
  // drafted whatever the pose, and a standing figure's legs are planted — whether they move is the scene's.
3262
- const lw = P.byTag('legwear', undefined, true).filter((p) => p.opaque_px > 500);
3263
- const legPlan = joints !== undefined && lw.length > 0 ? legsFromJoints(P, lw, joints) : null;
3304
+ const lw = lwTagged;
3305
+ // Issue #577: the figure layer's legs are the leg rule's, on that one part; its note is the figure note above.
3306
+ const legPlan =
3307
+ joints !== undefined && lw.length > 0
3308
+ ? legsFromJoints(P, lw, joints)
3309
+ : figPart !== null && figure !== null && figure.legs
3310
+ ? { chains: legsFromJoints(P, [figPart], joints as RigJoints).chains, notes: [], why: null }
3311
+ : null;
3264
3312
  if (legPlan !== null && legPlan.chains !== null) {
3265
3313
  for (const c of legPlan.chains) {
3266
3314
  const J = (joints as RigJoints).joints;
@@ -3344,7 +3392,7 @@ export function proposeWithBasis(
3344
3392
  }
3345
3393
  }
3346
3394
  if (trunk !== null) {
3347
- const laid = [...P.headFirst('neck'), ...tw, ...bw].map((p) => p.name);
3395
+ const laid = [...P.headFirst('neck'), ...tw, ...bw].filter((p) => !consumed.has(p.name)).map((p) => p.name);
3348
3396
  if (laid.length > 0) {
3349
3397
  notes.push(
3350
3398
  `trunk segments (${laid.join(', ')}): laid along neck -> hip, the line the chest was placed on (${pyFixed((Math.atan2(trunk.u[0], trunk.u[1]) * 180) / Math.PI, 1)} degrees off the screen's downward vertical, positive towards +x): each [bone, from, to] segment the rule drafts down the screen runs along that line instead, and the waist segment across it`,
@@ -3365,6 +3413,7 @@ export function proposeWithBasis(
3365
3413
  armWhy: armPlan === null ? null : armPlan.why,
3366
3414
  legs: legPlan === null ? null : legPlan.chains,
3367
3415
  arms: armPlan === null ? null : armPlan.arms,
3416
+ figure: figPart,
3368
3417
  wristSnap,
3369
3418
  eyes: (['r', 'l'] as const).map((s) => {
3370
3419
  const e = eyes.get(s);
@@ -3866,6 +3915,123 @@ function legsFromJoints(P: PartSet, lw: readonly PartRecord[], joints: RigJoints
3866
3915
  return { chains, notes, why: null };
3867
3916
  }
3868
3917
 
3918
+ /**
3919
+ * The figure layer (issue #577): a figure of one material — a wooden
3920
+ * mannequin, a statue, a robot of one finish — reaches See-through as one
3921
+ * garment, so no `handwear-*` or `legwear` part carries its limbs and the
3922
+ * sleeve and leg rules above draft none. With joints, a limb whose tagged
3923
+ * route has **no part** (no handwear part over 500 px for an arm, no legwear
3924
+ * part over 500 px for a leg — the floors those rules read) and whose three
3925
+ * joints are all given (the completeness {@link armsFromJoints} and
3926
+ * {@link legsFromJoints} read) is drafted from the figure layer when one
3927
+ * exists:
3928
+ *
3929
+ * - **the candidates** are the `topwear` parts over 500 px (no cut piece)
3930
+ * whose art holds, within {@link WRIST_ON_PART_PX} px by the larger of the
3931
+ * x and y gaps (the tolerance the two rules bind a wrist or an ankle by),
3932
+ * the origins of `hip`, `chest` and `neck` — the trunk limb's bones — and
3933
+ * every joint of every limb to draft; and, when both legs are drafted, whose
3934
+ * art breaks on the line from `r_knee` to `l_knee` and on the line from
3935
+ * `r_ankle` to `l_ankle` (the reading `PAINTING_LEGS_APART` makes, sampled
3936
+ * by `linePixels`): a garment hung over both legs is one column there, and
3937
+ * would be split into legs it does not have. Only `topwear`: `bottomwear`
3938
+ * would split a skirt into legs, and the head run's tags carry the head;
3939
+ * - **one candidate** is the figure layer;
3940
+ * - **several**: the one with the most opaque px in the
3941
+ * `(2 x WRIST_ON_PART_PX + 1)`-square about each of those points, summed (the
3942
+ * square the tolerance reads), and two or more tied at the most are refused
3943
+ * by name, `PROPOSE_FIGURE_LAYER` — nothing says which is the figure;
3944
+ * - **none**, with some topwear part over 500 px: `part` is null and the note
3945
+ * names, for each, the first point it misses; with no topwear part over
3946
+ * 500 px, `null` — nothing is said, and the proposal is the one before the
3947
+ * rule existed.
3948
+ *
3949
+ * `null` too when no limb qualifies: then no line here runs.
3950
+ */
3951
+ function figureLayerOf(
3952
+ P: PartSet,
3953
+ hw: readonly PartRecord[],
3954
+ lw: readonly PartRecord[],
3955
+ joints: RigJoints,
3956
+ trunk: { hip: [number, number]; chest: [number, number]; neck: [number, number] },
3957
+ ): { part: PartRecord | null; arms: boolean; legs: boolean; note: string } | null {
3958
+ const J = joints.joints;
3959
+ const given = (a: KeypointName, b: KeypointName, c: KeypointName): boolean => {
3960
+ const p = J[a].at;
3961
+ const q = J[b].at;
3962
+ return p !== null && q !== null && J[c].at !== null && !(p[0] === q[0] && p[1] === q[1]);
3963
+ };
3964
+ const armSides = hw.length > 0 ? [] : (['r', 'l'] as const).filter((s) => given(`${s}_shoulder`, `${s}_elbow`, `${s}_wrist`));
3965
+ const legSides = lw.length > 0 ? [] : (['r', 'l'] as const).filter((s) => given(`${s}_hip`, `${s}_knee`, `${s}_ankle`));
3966
+ if (armSides.length === 0 && legSides.length === 0) return null;
3967
+ const tw = P.byTag('topwear').filter((p) => p.opaque_px > 500);
3968
+ if (tw.length === 0) return null;
3969
+ const limbNames = [...armSides.map((s) => `arm_${s}`), ...legSides.map((s) => `leg_${s}`)];
3970
+ const points: Array<[string, [number, number]]> = [
3971
+ ['the hip bone', trunk.hip],
3972
+ ['the chest bone', trunk.chest],
3973
+ ['the neck bone', trunk.neck],
3974
+ ...armSides.flatMap((s) => ([`${s}_shoulder`, `${s}_elbow`, `${s}_wrist`] as const).map((n): [string, [number, number]] => [n, J[n].at as [number, number]])),
3975
+ ...legSides.flatMap((s) => ([`${s}_hip`, `${s}_knee`, `${s}_ankle`] as const).map((n): [string, [number, number]] => [n, J[n].at as [number, number]])),
3976
+ ];
3977
+ const lack = legSides.length > 0 ? [armSides.length > 0 ? 'no handwear part' : null, 'no legwear part'] : ['no handwear part'];
3978
+ const why = `${lack.filter((x): x is string => x !== null).join(' and ')} ${lack.filter((x) => x !== null).length === 1 ? 'is' : 'are'} over 500 px`;
3979
+ const pairs: Array<[KeypointName, KeypointName]> = legSides.length === 2 ? [['r_knee', 'l_knee'], ['r_ankle', 'l_ankle']] : [];
3980
+ const misses = (p: PartRecord): string | null => {
3981
+ const m = P.alpha(p);
3982
+ const near = dilate(m, 2 * WRIST_ON_PART_PX + 1);
3983
+ const off = points.find(([, q]) => !isOn(near, q[0], q[1]));
3984
+ if (off !== undefined) return `${p.name} holds no art within ${WRIST_ON_PART_PX} px of ${off[0]} at ${fmtAt(off[1])}`;
3985
+ for (const [a, b] of pairs) {
3986
+ if (linePixels(J[a].at as [number, number], J[b].at as [number, number], P.W, P.H).every(([x, y]) => m.data[y * P.W + x] === 1)) {
3987
+ return `${p.name}'s art does not break on the line from ${a} to ${b}: the legs are one column there, as a garment over both legs is`;
3988
+ }
3989
+ }
3990
+ return null;
3991
+ };
3992
+ const read = tw.map((p) => ({ p, miss: misses(p) }));
3993
+ const holds = read.filter((r) => r.miss === null).map((r) => r.p);
3994
+ const what = `every joint of ${limbNames.join(', ')} and the origins of hip, chest and neck`;
3995
+ if (holds.length === 0) {
3996
+ return {
3997
+ part: null,
3998
+ arms: false,
3999
+ legs: false,
4000
+ note: `figure layer: ${why}, and no topwear part over 500 px holds within ${WRIST_ON_PART_PX} px ${what} (${read.map((r) => r.miss as string).join('; ')}), so ${limbNames.join(', ')} ${limbNames.length === 1 ? 'is' : 'are'} not drafted from one layer (issue #577)`,
4001
+ };
4002
+ }
4003
+ const half = WRIST_ON_PART_PX;
4004
+ const held = (p: PartRecord): number => {
4005
+ const m = P.alpha(p);
4006
+ let n = 0;
4007
+ for (const [, q] of points) {
4008
+ const cx = pyInt(q[0]);
4009
+ const cy = pyInt(q[1]);
4010
+ for (let y = Math.max(0, cy - half); y <= Math.min(P.H - 1, cy + half); y++) for (let x = Math.max(0, cx - half); x <= Math.min(P.W - 1, cx + half); x++) n += m.data[y * P.W + x];
4011
+ }
4012
+ return n;
4013
+ };
4014
+ const scored = holds.map((p) => ({ p, n: held(p) })).sort((a, b) => b.n - a.n);
4015
+ const top = scored.filter((c) => c.n === scored[0].n);
4016
+ if (top.length > 1) {
4017
+ throw new PartsError([
4018
+ {
4019
+ code: 'PROPOSE_FIGURE_LAYER',
4020
+ object: `parts ${top.map((c) => `"${c.p.name}"`).join(', ')} (topwear)`,
4021
+ detail: `${why}, and each of these holds within ${WRIST_ON_PART_PX} px ${what}, with ${top[0].n} opaque px in the ${2 * half + 1}x${2 * half + 1} squares about those points; one figure layer is required — nothing says which of them is the figure, so leave the others out of assemble.plan, or give the arms and legs their own handwear and legwear layers`,
4022
+ },
4023
+ ]);
4024
+ }
4025
+ const fig = scored[0].p;
4026
+ const over = scored.length > 1 ? `; of the ${scored.length} topwear parts that hold them it has the most opaque px in the ${2 * half + 1}x${2 * half + 1} squares about those points, ${scored.map((c) => `${c.p.name} ${c.n}`).join(', ')}` : '';
4027
+ return {
4028
+ part: fig,
4029
+ arms: armSides.length > 0,
4030
+ legs: legSides.length > 0,
4031
+ note: `${fig.name} (${fig.from}): the figure layer — ${why}, and its art holds within ${WRIST_ON_PART_PX} px ${what}${over}; limbs trunk (trunk_hip on hip, trunk_chest on chest, trunk_neck on neck, cut at the chest's and the neck's origins) and ${limbNames.join(', ')} split it between them by the cut, each pixel to the limb whose bones pass nearest it — the rule one legwear part holding both legs is split by (issue #577)`,
4032
+ };
4033
+ }
4034
+
3869
4035
  /** A rig-px point as the notes and LINT lines print it: one decimal place. */
3870
4036
  function fmtAt(p: readonly [number, number]): string {
3871
4037
  return `[${pyFixed(p[0], 1)}, ${pyFixed(p[1], 1)}]`;
@@ -3891,6 +4057,8 @@ interface JointNoteFacts {
3891
4057
  sleeveRule: string;
3892
4058
  armWhy: string | null;
3893
4059
  arms: JointArm[] | null;
4060
+ /** Issue #577: the figure layer the arms and legs were split from, or `null`: then every arm is on a handwear part. */
4061
+ figure: PartRecord | null;
3894
4062
  /** The leg chains drafted (issue #241), or `null` when none was: then no line here names a leg joint. */
3895
4063
  legs: LegChain[] | null;
3896
4064
  /** `propose --wrist-snap`, or `null` without it. */
@@ -3984,7 +4152,7 @@ function jointNotes(joints: RigJoints, f: JointNoteFacts): string[] {
3984
4152
  }
3985
4153
  }
3986
4154
  // Issue #199: two chains on one part are said, not left to share its mesh unremarked.
3987
- const both = f.arms !== null && f.arms.length === 2 && f.arms[0].part === f.arms[1].part ? f.arms[0].part.name : null;
4155
+ const both = f.arms !== null && f.arms.length === 2 && f.arms[0].part === f.arms[1].part && f.arms[0].part !== f.figure ? f.arms[0].part.name : null;
3988
4156
  if (both !== null) {
3989
4157
  out.push(
3990
4158
  `one handwear part holds both wrists: r_wrist and l_wrist both end on ${both}, so limbs arm_r and arm_l both take it, and the cut gives each pixel to the arm whose bones pass nearest it; ` +
@@ -4499,8 +4667,26 @@ export interface InfluenceRadiusFinding {
4499
4667
  cell: number;
4500
4668
  }
4501
4669
 
4670
+ /**
4671
+ * Issue #572: a link of a keyed chain `CHAIN_LAG` would read only after `propose --cloth` took the idle keys off the
4672
+ * trees it drafted — `above`'s other keyed children (`siblings`) are gone, so `above > bone` is one unbranched run —
4673
+ * whose amplitude falls below the link above's (`amp` under `aboveAmp`, three places as check reads them). `chain` is
4674
+ * the run from its first link; `field` the config field that keys `bone`. A LINT, not an edit: the amplitude is the
4675
+ * author's, and `aboveAmp` is the least that passes the amplitude rule.
4676
+ */
4677
+ export interface ChainLeftBehindFinding {
4678
+ kind: 'chain-left-behind';
4679
+ bone: string;
4680
+ above: string;
4681
+ chain: string[];
4682
+ amp: number;
4683
+ aboveAmp: number;
4684
+ siblings: string[];
4685
+ field: string;
4686
+ }
4687
+
4502
4688
  /** What `propose` hands `lint` beside the proposal: findings of the draft itself, not of a check over the spec. */
4503
- export type DraftLintFinding = LimbJointOffArtFinding | InfluenceRadiusFinding;
4689
+ export type DraftLintFinding = LimbJointOffArtFinding | InfluenceRadiusFinding | ChainLeftBehindFinding;
4504
4690
 
4505
4691
  export type LintFinding =
4506
4692
  | OffArtFinding
@@ -4518,7 +4704,8 @@ export type LintFinding =
4518
4704
  | CrossedLimbsFinding
4519
4705
  | StopTouchAboveRootFinding
4520
4706
  | LimbJointOffArtFinding
4521
- | InfluenceRadiusFinding;
4707
+ | InfluenceRadiusFinding
4708
+ | ChainLeftBehindFinding;
4522
4709
 
4523
4710
  /** Which rule set read the torso and the sleeve chains, under `--keypoints`. */
4524
4711
  export interface LintBasis {
@@ -5074,6 +5261,7 @@ function findingBones(f: LintFinding, bones: readonly BoneEntry[]): string[] {
5074
5261
  case 'limb-joint-off-art':
5075
5262
  return [f.link];
5076
5263
  case 'influence-radius':
5264
+ case 'chain-left-behind':
5077
5265
  return [];
5078
5266
  case 'hip-not-below-chest':
5079
5267
  case 'hip-not-past-chest':
@@ -5248,6 +5436,11 @@ export function basisLines(b: LintBasis): string[] {
5248
5436
  */
5249
5437
  export function lintLine(f: LintFinding): string {
5250
5438
  switch (f.kind) {
5439
+ case 'chain-left-behind':
5440
+ return (
5441
+ `LINT ${f.bone} under ${f.above}: amplitude ${f.amp.toFixed(3)} below the link above's ${f.aboveAmp.toFixed(3)} in the keyed chain ${f.chain.join(' > ')}, which check reads only now that the recipe took the idle keys off ${f.above}'s other keyed children (${f.siblings.join(', ')}), ` +
5442
+ `so CHECK_CHAIN_LAG refuses the build ("amps" grow toward the tip; check names a bone by its control, <bone>_ctl, where --idle-keys ctl gives it one) — ${f.field} at ${f.aboveAmp.toFixed(3)} or more in size passes; the draft leaves it as keyed, the amplitude is the author's`
5443
+ );
5251
5444
  case 'influence-radius':
5252
5445
  return (
5253
5446
  `LINT ${f.part} on mesh ${pyRepr(f.part)}: influence radius ${f.radius} = farthest ${f.farthest} + ${f.cells} × cell ${f.cell} — drafted by config.cloth.${JSON.stringify(f.tag)}.influence, ` +