@rig-c/parts 1.53.0 → 1.55.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/cli.ts +40 -7
- package/docs/AUTHORING.md +60 -10
- package/docs/STABILITY.md +6 -5
- package/package.json +1 -1
- package/src/assemble.ts +769 -8
- package/src/build.ts +117 -9
- package/src/check.ts +43 -12
- package/src/cloth.ts +10 -3
- package/src/config.ts +27 -6
- package/src/parts.ts +83 -45
- package/src/propose.ts +10 -2
- package/src/remesh.ts +306 -6
- package/src/retune.ts +25 -3
- package/src/rig.ts +18 -6
package/src/retune.ts
CHANGED
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
* (`RETUNE_PRESERVED`, naming the first path that moved).
|
|
28
28
|
* 6. **The gate and check**: the revision goes through rigc's build gate (`RETUNE_RIGC_GREEN`) and through `check`
|
|
29
29
|
* beside the input; every bar the input measured is measured, none the input met is failed (`RETUNE_CHECK_HELD`).
|
|
30
|
+
* Under `--input-check` (issue #617) the input's check is the recorded one when the record is bound to this input
|
|
31
|
+
* (`src/remesh.ts` {@link inputCheckOf}), refused by name otherwise (`RETUNE_INPUT_CHECK_FILE`,
|
|
32
|
+
* `RETUNE_INPUT_CHECK_BOUND`) before the rebuild.
|
|
30
33
|
* 7. **The write**: `--out` receives the revision's files and {@link RETUNE_FILE} — spec {@link RETUNE_SPEC} — with
|
|
31
34
|
* no path and no clock in it, so a second identical request writes the same bytes.
|
|
32
35
|
*
|
|
@@ -37,7 +40,7 @@ import { dirname, join, resolve, sep } from 'node:path';
|
|
|
37
40
|
import { checkStage, gateThroughRigc, type Log, rigStage } from './build.ts';
|
|
38
41
|
import { type CheckReport, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, type PackShape, type PageEdges, rigcRanClause, type RigcRunner } from './check.ts';
|
|
39
42
|
import { PartsError, type Problem, problemLine, refuseIfAny } from './errors.ts';
|
|
40
|
-
import { type CheckSide, checkHeldProblems, checkSide, checkScope, type FileTree, firstDifference, type HashRow, hashRows, inputTreeProblems, perturbed, readTree, sha256 } from './remesh.ts';
|
|
43
|
+
import { type CheckSide, checkHeldProblems, checkSide, checkScope, type FileTree, firstDifference, type HashRow, hashRows, INPUT_CHECK_FILE, type InputCheckBinding, inputCheckHashes, inputCheckMovedProblems, inputCheckOf, inputCheckReusedLine, inputCheckText, inputTreeProblems, perturbed, readTree, sha256 } from './remesh.ts';
|
|
41
44
|
import { DEFAULT_IDLE_KEYS, type IdleKeys, rigJsonText } from './rig.ts';
|
|
42
45
|
|
|
43
46
|
/** The provenance file's spec. */
|
|
@@ -69,6 +72,10 @@ export interface RetuneInput {
|
|
|
69
72
|
pageEdges?: PageEdges;
|
|
70
73
|
packShape?: PackShape;
|
|
71
74
|
requirements?: string;
|
|
75
|
+
/** Issue #617: a recorded input check (`input-check.json`, as `remesh` writes it) reused when it is bound to this run's input. */
|
|
76
|
+
inputCheck?: string;
|
|
77
|
+
/** Issue #617: write `input-check.json` into `out` beside the provenance. Without it, and without `inputCheck`, nothing written moves. */
|
|
78
|
+
recordInputCheck?: boolean;
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
/**
|
|
@@ -80,6 +87,8 @@ export interface RetunePlant {
|
|
|
80
87
|
perturb?: string;
|
|
81
88
|
skipPreserve?: boolean;
|
|
82
89
|
skipHold?: boolean;
|
|
90
|
+
/** Issue #617's mutant: run just before check-input reads the input, after the first snapshot, to change a file under it. */
|
|
91
|
+
beforeInputCheck?: () => void;
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
/** One constraint the request changed: its name and type, and each field whose value moved, in the rebuild's order. */
|
|
@@ -340,6 +349,7 @@ export function retuneStage(input: RetuneInput, rigc: RigcRunner, checkBin: stri
|
|
|
340
349
|
if (outAt.startsWith(`${rigAt}${sep}`)) throw new PartsError([{ code: 'RETUNE_OUT_FRESH', object: input.out, detail: `is inside the input ${input.rig}; a revision is written beside the input, never into it` }]);
|
|
341
350
|
const tree = readTree(rigAt);
|
|
342
351
|
refuseIfAny(inputTreeProblems(tree, input.rig, 'retune', RETUNE_SPLICED));
|
|
352
|
+
const recorded = inputCheckOf(input, rigAt, tree, pageEdges, packShape, versions.parts, rigc, 'retune');
|
|
343
353
|
const inFiles = rigFiles(tree);
|
|
344
354
|
// 2. The rebuild.
|
|
345
355
|
log(`rig-parts retune: ${input.rig}, ${tree.size} file(s); the rebuild is the config as written`);
|
|
@@ -382,9 +392,16 @@ export function retuneStage(input: RetuneInput, rigc: RigcRunner, checkBin: stri
|
|
|
382
392
|
}
|
|
383
393
|
const checkOf = (rig: string, name: string): CheckReport =>
|
|
384
394
|
checkStage({ rig, parts: input.parts, out: join(scratch, name), pageEdges, packShape, ...(input.requirements === undefined ? {} : { requirements: input.requirements }) }, rigc, checkBin, (l) => log(`[${name}] ${l}`));
|
|
385
|
-
|
|
395
|
+
if (recorded.reused !== null) log(inputCheckReusedLine(input.inputCheck as string, recorded.binding as InputCheckBinding));
|
|
396
|
+
let inSide: CheckSide;
|
|
397
|
+
if (recorded.reused !== null) inSide = recorded.reused;
|
|
398
|
+
else {
|
|
399
|
+
plant.beforeInputCheck?.();
|
|
400
|
+
inSide = checkSide(checkOf(rigAt, 'check-input'));
|
|
401
|
+
if (recorded.binding !== null) refuseIfAny(inputCheckMovedProblems(recorded.binding, input, rigAt, 'retune'));
|
|
402
|
+
}
|
|
386
403
|
const revCheck = checkOf(staged, 'check-revision');
|
|
387
|
-
const sides = { input:
|
|
404
|
+
const sides = { input: inSide, revision: checkSide(revCheck) };
|
|
388
405
|
refuseIfAny(checkHeldProblems(sides.input, sides.revision, revCheck.problems, 'retune'));
|
|
389
406
|
const scope = checkScope(sides.revision.physics);
|
|
390
407
|
log(` check: input ${sides.input.pass ? 'PASS' : `FAIL (${sides.input.not_met.join(', ')})`}, revision ${sides.revision.pass ? 'PASS' : `FAIL (${sides.revision.not_met.join(', ')})`}, the same ${sides.revision.measured.length} bar(s) measured; ${scope}`);
|
|
@@ -409,6 +426,11 @@ export function retuneStage(input: RetuneInput, rigc: RigcRunner, checkBin: stri
|
|
|
409
426
|
}
|
|
410
427
|
writeFileSync(join(outAt, RETUNE_FILE), rigJsonText(provenance));
|
|
411
428
|
written.push(RETUNE_FILE);
|
|
429
|
+
if (input.recordInputCheck === true) {
|
|
430
|
+
writeFileSync(join(outAt, INPUT_CHECK_FILE), inputCheckText(recorded.binding as InputCheckBinding, sides.input));
|
|
431
|
+
written.push(INPUT_CHECK_FILE);
|
|
432
|
+
log(` recorded: the input's check in ${INPUT_CHECK_FILE}, bound by ${inputCheckHashes(recorded.binding as InputCheckBinding)} sha256 row(s); pass it as --input-check to a later remesh or retune of ${input.rig}`);
|
|
433
|
+
}
|
|
412
434
|
log(' file sha256 (input) sha256 (revision)');
|
|
413
435
|
const inHash = new Map(hashRows(tree).map((r) => [r.path, r.sha256]));
|
|
414
436
|
for (const r of provenance.revision) log(` ${r.path.padEnd(40)} ${(inHash.get(r.path) ?? 'absent').slice(0, 16)} ${r.sha256.slice(0, 16)}${inHash.get(r.path) === r.sha256 ? '' : ' (spliced)'}`);
|
package/src/rig.ts
CHANGED
|
@@ -400,14 +400,20 @@ export function roundShares(list: readonly Influence[]): Influence[] {
|
|
|
400
400
|
* trunk splits into branches and across adjacent trees' ruffled hem steps.
|
|
401
401
|
* Four Laplacian passes (`FORK_SMOOTH_PASSES`, self share 0.5, floor 0.005, cap
|
|
402
402
|
* 8 influences) diffuse each vertex's shares across its triangle neighbours
|
|
403
|
-
* before rounding with {@link roundShares}.
|
|
403
|
+
* before rounding with {@link roundShares}. Every share is diffused alike —
|
|
404
|
+
* trunk, branch and fixed bones — none is held in place.
|
|
405
|
+
*
|
|
406
|
+
* Issue #615: an influence mesh that declares `influence.hold_tip: true` is
|
|
407
|
+
* smoothed by the same passes with `cap` its declared `influence.max`, so a
|
|
408
|
+
* vertex never binds more bones than the config states; the lattice's call
|
|
409
|
+
* passes no cap and keeps `FORK_SMOOTH_MAX_INFLUENCES`, byte for byte.
|
|
404
410
|
*/
|
|
405
411
|
export const FORK_SMOOTH_PASSES = 4;
|
|
406
412
|
export const FORK_SMOOTH_SELF = 0.5;
|
|
407
413
|
export const FORK_SMOOTH_FLOOR = 0.005;
|
|
408
414
|
export const FORK_SMOOTH_MAX_INFLUENCES = 8;
|
|
409
415
|
|
|
410
|
-
export function smoothForkShares(raw: ReadonlyArray<readonly Influence[]>, triangles: readonly number[]): Influence[][] {
|
|
416
|
+
export function smoothForkShares(raw: ReadonlyArray<readonly Influence[]>, triangles: readonly number[], cap: number = FORK_SMOOTH_MAX_INFLUENCES): Influence[][] {
|
|
411
417
|
const adj: number[][] = raw.map(() => []);
|
|
412
418
|
const addEdge = (u: number, v: number): void => {
|
|
413
419
|
if (!adj[u].includes(v)) adj[u].push(v);
|
|
@@ -435,7 +441,7 @@ export function smoothForkShares(raw: ReadonlyArray<readonly Influence[]>, trian
|
|
|
435
441
|
const kept = [...m.entries()]
|
|
436
442
|
.filter(([, w]) => w >= FORK_SMOOTH_FLOOR)
|
|
437
443
|
.sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
|
|
438
|
-
.slice(0,
|
|
444
|
+
.slice(0, cap);
|
|
439
445
|
const sum = kept.reduce((s, [, w]) => s + w, 0);
|
|
440
446
|
return roundShares(kept.map(([bone, w]) => ({ bone, weight: w / sum })));
|
|
441
447
|
});
|
|
@@ -1912,6 +1918,7 @@ export function buildRig(
|
|
|
1912
1918
|
let maxInfl = 0;
|
|
1913
1919
|
let capped = 0;
|
|
1914
1920
|
let widest = 0;
|
|
1921
|
+
const pulled: Influence[][] = [];
|
|
1915
1922
|
for (const [vi, [x, y]] of lattice.points.entries()) {
|
|
1916
1923
|
const r = influenceShares([x, y], local, spec.influence);
|
|
1917
1924
|
if ('nearest' in r) {
|
|
@@ -1920,12 +1927,17 @@ export function buildRig(
|
|
|
1920
1927
|
}
|
|
1921
1928
|
if (r.inReach > spec.influence.max) capped++;
|
|
1922
1929
|
widest = Math.max(widest, r.inReach);
|
|
1930
|
+
pulled.push(r.weights.map((e) => ({ bone: names[e.control ?? 0], weight: e.weight })));
|
|
1931
|
+
}
|
|
1932
|
+
// Issue #615: `hold_tip: true`, declared on the mesh (propose writes it from the recipe's `split.hold_tip`), smooths
|
|
1933
|
+
// the pulled shares by the lattice's held-fork passes, capped at the declared `max`; absent, the shares are rig-c's.
|
|
1934
|
+
const shares = spec.influence.hold_tip === true ? smoothForkShares(pulled, lattice.triangles, spec.influence.max) : pulled;
|
|
1935
|
+
for (const [vi, [x, y]] of lattice.points.entries()) {
|
|
1923
1936
|
const wx = x + ox;
|
|
1924
1937
|
const wy = y + oy;
|
|
1925
|
-
const ent: WeightEntry[] =
|
|
1926
|
-
const bone = names[e.control ?? 0];
|
|
1938
|
+
const ent: WeightEntry[] = shares[vi].map(({ bone, weight }) => {
|
|
1927
1939
|
const [bx, by] = toBoneLocal(world.get(bone) as BoneTransform, spineX(wx), spineY(wy));
|
|
1928
|
-
return { bone, x: places(bx), y: places(by), weight
|
|
1940
|
+
return { bone, x: places(bx), y: places(by), weight };
|
|
1929
1941
|
});
|
|
1930
1942
|
weights.push(ent);
|
|
1931
1943
|
infl += ent.length;
|