@rig-c/parts 2.40.0 → 2.42.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/README.md +1 -0
- package/cli.ts +76 -20
- package/docs/AUTHORING.md +361 -58
- package/docs/STABILITY.md +136 -11
- package/package.json +4 -2
- package/src/behindseams.ts +622 -0
- package/src/build.ts +76 -9
- package/src/check.ts +157 -25
- package/src/checkrow.ts +21 -0
- package/src/config.ts +29 -3
- package/src/configrelocation.ts +25 -0
- package/src/configwrite.ts +20 -2
- package/src/depthworkflow.ts +3 -4
- package/src/instruments.ts +7 -3
- package/src/meshdraft.ts +10 -10
- package/src/motion.ts +26 -24
- package/src/remesh.ts +18 -12
- package/src/requirements.ts +30 -4
- package/src/retune.ts +8 -5
- package/src/rig.ts +25 -14
- package/src/runstamp.ts +54 -1
- package/tools/configwrite.ts +83 -1
- package/tools/edited-part-cli.ts +61 -0
package/src/checkrow.ts
CHANGED
|
@@ -9,6 +9,27 @@ export const CHECK_ROW_PATHS = {
|
|
|
9
9
|
'ART_JOINT_DISTANCE.joints': ['ART_JOINT_DISTANCE.joints'],
|
|
10
10
|
'BOUNDARY_COLOUR_STEP.over': ['BOUNDARY_COLOUR_STEP.over'],
|
|
11
11
|
'BOUNDARY_COLOUR_STEP.unmeasured': ['BOUNDARY_COLOUR_STEP.unmeasured'],
|
|
12
|
+
'BEHIND_PART_SEAMS.pairs': ['BEHIND_PART_SEAMS.pairs'],
|
|
13
|
+
'BEHIND_PART_SEAMS.pairs[].setup': ['BEHIND_PART_SEAMS.pairs[].setup'],
|
|
14
|
+
'BEHIND_PART_SEAMS.pairs[].frames': ['BEHIND_PART_SEAMS.pairs[].frames'],
|
|
15
|
+
'BEHIND_PART_SEAMS.samples': [
|
|
16
|
+
'BEHIND_PART_SEAMS.pairs[].setup.motion_opened.samples', 'BEHIND_PART_SEAMS.pairs[].setup.standing.samples',
|
|
17
|
+
'BEHIND_PART_SEAMS.pairs[].frames[].motion_opened.samples', 'BEHIND_PART_SEAMS.pairs[].frames[].standing.samples',
|
|
18
|
+
],
|
|
19
|
+
'BEHIND_PART_SEAMS.contributors': [
|
|
20
|
+
'BEHIND_PART_SEAMS.pairs[].setup.motion_opened.samples[].contributors', 'BEHIND_PART_SEAMS.pairs[].setup.standing.samples[].contributors',
|
|
21
|
+
'BEHIND_PART_SEAMS.pairs[].frames[].motion_opened.samples[].contributors', 'BEHIND_PART_SEAMS.pairs[].frames[].standing.samples[].contributors',
|
|
22
|
+
],
|
|
23
|
+
'BEHIND_PART_SEAMS.hits': [
|
|
24
|
+
'BEHIND_PART_SEAMS.pairs[].motion_opened.frames', 'BEHIND_PART_SEAMS.pairs[].standing.frames',
|
|
25
|
+
'BEHIND_PART_SEAMS.pairs[].motion_opened.worst', 'BEHIND_PART_SEAMS.pairs[].standing.worst',
|
|
26
|
+
],
|
|
27
|
+
'BEHIND_PART_SEAMS.spans': ['BEHIND_PART_SEAMS.pairs[].motion_opened.spans', 'BEHIND_PART_SEAMS.pairs[].standing.spans'],
|
|
28
|
+
'BEHIND_PART_SEAMS.unread_corridors': [
|
|
29
|
+
'BEHIND_PART_SEAMS.pairs[].setup.standing.unread_corridors',
|
|
30
|
+
'BEHIND_PART_SEAMS.pairs[].frames[].standing.unread_corridors',
|
|
31
|
+
],
|
|
32
|
+
'BEHIND_PART_SEAMS.unmeasured': ['BEHIND_PART_SEAMS.unmeasured'],
|
|
12
33
|
'CLOTH_SETTLES.rows': ['CLOTH_SETTLES.rows'],
|
|
13
34
|
'CUT_JOINT_MATERIAL.rows': ['CUT_JOINT_MATERIAL.rows'],
|
|
14
35
|
'FEET_STAY_LEVEL.feet': ['FEET_STAY_LEVEL.feet'],
|
package/src/config.ts
CHANGED
|
@@ -1161,7 +1161,7 @@ export interface BlinkStill {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
|
|
1163
1163
|
/**
|
|
1164
|
-
* The idle's
|
|
1164
|
+
* The idle's authored blinks. `eyes` names at least one bone; `brows` and
|
|
1165
1165
|
* `brow_drop` are stated together or not at all, and a stated `brows` names
|
|
1166
1166
|
* at least one bone — rigc refuses a group with no members, and a
|
|
1167
1167
|
* `brow_drop` with no brows is a value nothing reads. A figure with no eye
|
|
@@ -1169,6 +1169,8 @@ export interface BlinkStill {
|
|
|
1169
1169
|
*/
|
|
1170
1170
|
export interface Blink {
|
|
1171
1171
|
t: number;
|
|
1172
|
+
/** Further authored times, strictly increasing after t; omitted for one blink. */
|
|
1173
|
+
more?: number[];
|
|
1172
1174
|
eyes: string[];
|
|
1173
1175
|
brows?: string[];
|
|
1174
1176
|
squash: number;
|
|
@@ -4483,9 +4485,21 @@ function checkMotion(c: Check, v: Json, bones: Set<string>, chains: Map<string,
|
|
|
4483
4485
|
});
|
|
4484
4486
|
}
|
|
4485
4487
|
if ('blink' in m) {
|
|
4486
|
-
const b = c.object(`${p}.blink`, m.blink, ['t', 'eyes', 'squash'], ['brows', 'brow_drop', 'still']);
|
|
4488
|
+
const b = c.object(`${p}.blink`, m.blink, ['t', 'eyes', 'squash'], ['brows', 'brow_drop', 'still', 'more']);
|
|
4487
4489
|
if (b === null) return refuseSharedTargets(c, claims);
|
|
4488
4490
|
if ('t' in b) c.number(`${p}.blink.t`, b.t, 'non-negative');
|
|
4491
|
+
if ('more' in b) {
|
|
4492
|
+
if (!Array.isArray(b.more) || b.more.length === 0) {
|
|
4493
|
+
c.fail('CONFIG_BLINK_MORE_TIMES', `${p}.blink.more`, `is ${show(b.more)}; a non-empty list of finite times strictly increasing after t is required`);
|
|
4494
|
+
} else {
|
|
4495
|
+
Array.from(b.more).forEach((time, i) => {
|
|
4496
|
+
const previous = i === 0 ? b.t : (b.more as Json[])[i - 1];
|
|
4497
|
+
if (typeof time !== 'number' || !Number.isFinite(time) || typeof b.t !== 'number' || !(time > b.t) || typeof previous !== 'number' || !(time > previous)) {
|
|
4498
|
+
c.fail('CONFIG_BLINK_MORE_TIMES', `${p}.blink.more[${i}]`, `is ${show(time)}; a finite time greater than t (${show(b.t)}) and the preceding time (${show(previous)}) is required`);
|
|
4499
|
+
}
|
|
4500
|
+
});
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4489
4503
|
if ('squash' in b) c.number(`${p}.blink.squash`, b.squash, 'positive');
|
|
4490
4504
|
if ('brow_drop' in b) c.number(`${p}.blink.brow_drop`, b.brow_drop);
|
|
4491
4505
|
if ('brows' in b && !('brow_drop' in b)) {
|
|
@@ -4529,7 +4543,19 @@ function checkMotion(c: Check, v: Json, bones: Set<string>, chains: Map<string,
|
|
|
4529
4543
|
}
|
|
4530
4544
|
}
|
|
4531
4545
|
}
|
|
4532
|
-
if ('still' in b)
|
|
4546
|
+
if ('still' in b) {
|
|
4547
|
+
const start = c.problems.length;
|
|
4548
|
+
checkBlinkStill(c, b.still, b.eyes, bones, regions);
|
|
4549
|
+
// All blinks use the same groups and cut-offs. Keep scalar diagnostics
|
|
4550
|
+
// unchanged; for multiple blinks name each entry owning a failed cut.
|
|
4551
|
+
if (Array.isArray(b.more) && b.more.length > 0) {
|
|
4552
|
+
const stillProblems = c.problems.splice(start);
|
|
4553
|
+
for (const problem of stillProblems) {
|
|
4554
|
+
if (problem.code !== 'CONFIG_STILL_OFF_THE_BLINK') { c.problems.push(problem); continue; }
|
|
4555
|
+
for (let i = 0; i <= b.more.length; i++) c.problems.push({ ...problem, object: `${problem.object} (${i === 0 ? `${p}.blink.t` : `${p}.blink.more[${i - 1}]`})` });
|
|
4556
|
+
}
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4533
4559
|
}
|
|
4534
4560
|
refuseSharedTargets(c, claims);
|
|
4535
4561
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Config writers relocate edited directories once, without rewriting authored receipt files. */
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { configFileReferences } from './config.ts';
|
|
4
|
+
|
|
5
|
+
function object(value: unknown): value is Record<string, unknown> {
|
|
6
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Preserve the public reference inventory while giving writers canonical edited-part paths. */
|
|
10
|
+
export function relocateConfigReferences(raw: unknown, configDir: string, out: string, mode: 'relative' | 'absolute'): void {
|
|
11
|
+
const refs = configFileReferences(raw);
|
|
12
|
+
const assemble = object(raw) ? raw.assemble : undefined;
|
|
13
|
+
const edited = object(assemble) ? assemble.edited_parts : undefined;
|
|
14
|
+
// Do not repair invalid dirs or replace the loader's existing relative-only refusals.
|
|
15
|
+
if (object(edited) && typeof edited.dir === 'string' && edited.dir.trim() !== '' &&
|
|
16
|
+
!isAbsolute(edited.dir) && !/^(?:[\\/]|[A-Za-z]:[\\/])/.test(edited.dir)) {
|
|
17
|
+
edited.dir = relative(resolve(out), resolve(configDir, edited.dir)).split(sep).join('/') || '.';
|
|
18
|
+
}
|
|
19
|
+
for (const ref of refs) {
|
|
20
|
+
if (ref.at.startsWith('assemble.edited_parts.receipts[')) continue;
|
|
21
|
+
if (mode === 'absolute' && isAbsolute(ref.value)) continue;
|
|
22
|
+
const target = resolve(configDir, ref.value);
|
|
23
|
+
ref.set(mode === 'relative' ? relative(resolve(out), target) : target);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/configwrite.ts
CHANGED
|
@@ -11,14 +11,16 @@
|
|
|
11
11
|
import type { PlanProposal } from './assemble.ts';
|
|
12
12
|
import type { HeadBoxProposal } from './headbox.ts';
|
|
13
13
|
import type { CharacterConfig } from './config.ts';
|
|
14
|
+
import type { EditedPartReceipt } from './editedparts.ts';
|
|
14
15
|
import type { Proposal, PROPOSAL_CONFIG_SECTIONS } from './propose.ts';
|
|
15
16
|
import { PartsError } from './errors.ts';
|
|
16
|
-
import { parseProposalSections } from './config.ts';
|
|
17
|
+
import { parseConfig, parseProposalSections } from './config.ts';
|
|
17
18
|
import type { ConfigEdit } from './meshdraft.ts';
|
|
18
19
|
|
|
19
20
|
export type ConfigJson = null | boolean | number | string | ConfigJson[] | ConfigObject;
|
|
20
21
|
export interface ConfigObject { [key: string]: ConfigJson }
|
|
21
22
|
export type ConfigWritePatch =
|
|
23
|
+
| { kind: 'edited-part-receipt'; receipt: EditedPartReceipt }
|
|
22
24
|
| { kind: 'neck-unit'; config: CharacterConfig }
|
|
23
25
|
| { kind: 'head-box'; head_box: HeadBoxProposal['head_box'] }
|
|
24
26
|
| { kind: 'assemble-plan'; plan: PlanProposal['plan']; extend_below_crop: PlanProposal['extend_below_crop'] }
|
|
@@ -93,6 +95,22 @@ export function mergeConfigProposal(raw: unknown, patch: ConfigWritePatch): Conf
|
|
|
93
95
|
const config = clone(before, 'config') as ConfigObject;
|
|
94
96
|
const edits: ConfigEdit[] = [];
|
|
95
97
|
switch (patch.kind) {
|
|
98
|
+
case 'edited-part-receipt': {
|
|
99
|
+
const checked = parseConfig(before);
|
|
100
|
+
const spec = checked.assemble.edited_parts;
|
|
101
|
+
if (spec === undefined) throw new PartsError([{ code: 'EDITED_PART_BLOCK', object: 'config.assemble.edited_parts', detail: 'has no assemble.edited_parts; declare {dir, receipts: []} before recording an edited part' }]);
|
|
102
|
+
const { part, file, sha256, from_sha256, editor } = patch.receipt;
|
|
103
|
+
if (!checked.assemble.plan.some(([name]) => name === part)) throw new PartsError([{ code: 'ASSEMBLE_EDITED_PART_UNKNOWN', object: part, detail: 'is not in assemble.plan; an existing plan part is required' }]);
|
|
104
|
+
const found = spec.receipts.findIndex(row => row.part === part);
|
|
105
|
+
const index = found === -1 ? spec.receipts.length : found;
|
|
106
|
+
const value = clone({ part, file, sha256, from_sha256, editor }, 'receipt');
|
|
107
|
+
const receipts = ((config.assemble as ConfigObject).edited_parts as ConfigObject).receipts as ConfigJson[];
|
|
108
|
+
if (found !== -1 && equal(receipts[index], value)) return { config, changes: [], edits: [] };
|
|
109
|
+
receipts[index] = value;
|
|
110
|
+
// This patch owns one row, never the ledger or the whole assemble block.
|
|
111
|
+
return { config, changes: [{ path: `assemble.edited_parts.receipts[${index}]`, kind: found === -1 ? 'added' : 'replaced' }],
|
|
112
|
+
edits: [{ path: ['assemble', 'edited_parts', 'receipts', index], value, insert: found === -1 }] };
|
|
113
|
+
}
|
|
96
114
|
case 'neck-unit': {
|
|
97
115
|
const values = { bones: patch.config.bones, meshes: patch.config.meshes, regions: patch.config.regions, turn: patch.config.turn };
|
|
98
116
|
for (const [key, value] of Object.entries(values)) {
|
|
@@ -211,7 +229,7 @@ export function mergeConfigProposal(raw: unknown, patch: ConfigWritePatch): Conf
|
|
|
211
229
|
}
|
|
212
230
|
return { config, changes: added, edits };
|
|
213
231
|
}
|
|
214
|
-
default: return refuse('write-config', 'has no supported operation; head-box, assemble-plan, proposal or proposal-missing is required');
|
|
232
|
+
default: return refuse('write-config', 'has no supported operation; edited-part-receipt, neck-unit, head-box, assemble-plan, proposal or proposal-missing is required');
|
|
215
233
|
}
|
|
216
234
|
return { config, changes: changes(before, config), edits };
|
|
217
235
|
}
|
package/src/depthworkflow.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { createHash } from 'node:crypto';
|
|
6
6
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
8
|
-
import {
|
|
8
|
+
import { loadConfigAndAnimations, parseConfig } from './config.ts';
|
|
9
|
+
import { relocateConfigReferences } from './configrelocation.ts';
|
|
9
10
|
import { depthReading, readSourceDepth } from './depthsheets.ts';
|
|
10
11
|
import { alphaSupport, depthMapFail as fail, floatBox, integrateNormals, mapToSheet, readNumericMap, type NumericMap } from './depthmaps.ts';
|
|
11
12
|
import { depthImageReference, partImageReference, readParts } from './parts.ts';
|
|
@@ -229,9 +230,7 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
229
230
|
if (group.unitDepths !== undefined) target.unitDepths = group.unitDepths;
|
|
230
231
|
}
|
|
231
232
|
// Keep relative paths portable when relocating the output directory with its inputs.
|
|
232
|
-
|
|
233
|
-
ref.set(relative(resolve(input.out), resolve(dirname(input.rigConfig), ref.value)));
|
|
234
|
-
}
|
|
233
|
+
relocateConfigReferences(raw, dirname(input.rigConfig), input.out, 'relative');
|
|
235
234
|
parseConfig(raw);
|
|
236
235
|
const warnings: string[] = [];
|
|
237
236
|
const writes = new Map<string, Uint8Array>(), rows: Obj[] = [], recs = rawParts.parts as Obj[];
|
package/src/instruments.ts
CHANGED
|
@@ -672,7 +672,7 @@ export interface BlinkTrack {
|
|
|
672
672
|
target: { bone: string } | { group: string };
|
|
673
673
|
/** The smallest `scaley` it keys — the closed eye. */
|
|
674
674
|
closed: number;
|
|
675
|
-
/**
|
|
675
|
+
/** One contiguous run of keys at that value, never spanning an open interval. */
|
|
676
676
|
window: [number, number];
|
|
677
677
|
}
|
|
678
678
|
|
|
@@ -712,8 +712,12 @@ export function blinkTracks(motion: Record<string, unknown>, eyes: ReadonlySet<s
|
|
|
712
712
|
if (target === null || keys === null || keys.length === 0) continue;
|
|
713
713
|
const closed = Math.min(...keys.map((k) => k.v[0]));
|
|
714
714
|
if (!(closed < keys[0].v[0])) continue;
|
|
715
|
-
|
|
716
|
-
|
|
715
|
+
for (let i = 0; i < keys.length; i++) {
|
|
716
|
+
if (keys[i].v[0] !== closed) continue;
|
|
717
|
+
const from = keys[i].t;
|
|
718
|
+
while (i + 1 < keys.length && keys[i + 1].v[0] === closed) i++;
|
|
719
|
+
out.push({ target, closed, window: [from, keys[i].t] });
|
|
720
|
+
}
|
|
717
721
|
}
|
|
718
722
|
return out;
|
|
719
723
|
}
|
package/src/meshdraft.ts
CHANGED
|
@@ -60,14 +60,15 @@
|
|
|
60
60
|
* but the process is injected, exactly as `src/check.ts` and `src/build.ts` take it.
|
|
61
61
|
*/
|
|
62
62
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
63
|
-
import { dirname, isAbsolute, join,
|
|
63
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
64
64
|
import type { AlphaMask, MeasureRow, MeshQualityReport, MotionSchedule } from '@rig-c/core/mesh';
|
|
65
65
|
import { compareMeshesInMotion, type MotionComparisonInput } from '@rig-c/core/meshcompare';
|
|
66
66
|
import { MeshReductionError } from '@rig-c/core/mesh';
|
|
67
67
|
import { explicitFrameId, idleSchedule } from './automotion.ts';
|
|
68
68
|
import { checkStage, gateThroughRigc, type Log, RIGC_MODEL_DOCUMENT, rigStage } from './build.ts';
|
|
69
|
-
import { BARS, type CheckReport, type PackShape, type PageEdges, type RigcRunner } from './check.ts';
|
|
69
|
+
import { BARS, type CheckReport, type PackShape, type PageEdges, parsePageSize, type RigcRunner } from './check.ts';
|
|
70
70
|
import { type CharacterConfig, configFileReferences, type ConfigFileReference, type ContourMeshSpec, type LatticeMeshSpec, loadConfigAndAnimations, type Segment } from './config.ts';
|
|
71
|
+
import { relocateConfigReferences } from './configrelocation.ts';
|
|
71
72
|
import { PartsError, type Problem, problemLine } from './errors.ts';
|
|
72
73
|
import { IDLE_FPS } from './motion.ts';
|
|
73
74
|
import { type ContourBridges, FAINT_ALPHA } from './contour.ts';
|
|
@@ -729,16 +730,13 @@ export function relativeConfigPaths(_configDir: string, o: Json): RelativeConfig
|
|
|
729
730
|
/**
|
|
730
731
|
* A config the stage builds, written as `<dir>/config.json`: `text` (the author's config at `configPath`) with
|
|
731
732
|
* `meshes.<part>` replaced for every part in `meshes`, and each of its {@link relativeConfigPaths} rebased to
|
|
732
|
-
* the file the author's config names. Edited
|
|
733
|
-
* other references become absolute. `remesh` (issue #495) builds through the same door.
|
|
733
|
+
* the file the author's config names. Edited directories become relative to the destination config directory,
|
|
734
|
+
* with receipt files unchanged; other references become absolute. `remesh` (issue #495) builds through the same door.
|
|
734
735
|
*/
|
|
735
736
|
export function scratchConfig(configPath: string, text: string, dir: string, meshes: ReadonlyMap<string, unknown>): string {
|
|
736
737
|
const configDir = dirname(resolve(configPath));
|
|
737
738
|
const o = JSON.parse(text) as Json;
|
|
738
|
-
|
|
739
|
-
const target = resolve(configDir, r.value);
|
|
740
|
-
r.set(r.at.startsWith('assemble.edited_parts.receipts[') ? relative(resolve(dir), target).replaceAll('\\', '/') : target);
|
|
741
|
-
}
|
|
739
|
+
relocateConfigReferences(o, configDir, dir, 'absolute');
|
|
742
740
|
o.meshes = { ...(o.meshes as Json), ...Object.fromEntries(meshes) };
|
|
743
741
|
mkdirSync(dir, { recursive: true });
|
|
744
742
|
writeFileSync(join(dir, 'config.json'), `${JSON.stringify(o, null, 2)}\n`);
|
|
@@ -758,6 +756,7 @@ export interface MeshDraftInput {
|
|
|
758
756
|
idleKeys?: IdleKeys;
|
|
759
757
|
pageEdges?: PageEdges;
|
|
760
758
|
packShape?: PackShape;
|
|
759
|
+
pageSize?: number;
|
|
761
760
|
/** `--more-triangles` ({@link MORE_TRIANGLES_FLAG}): reading 5 is reported, not a line. Absent or false: it is a line. */
|
|
762
761
|
moreTriangles?: boolean;
|
|
763
762
|
}
|
|
@@ -848,6 +847,7 @@ function attachmentOf(rig: RigSpec, part: string): MeshAttachment {
|
|
|
848
847
|
* PASS, and returns the rows.
|
|
849
848
|
*/
|
|
850
849
|
export function meshDraftStage(input: MeshDraftInput, rigc: RigcRunner, checkBin: string, scratch: string, log: Log): MeshDraftResult {
|
|
850
|
+
const pageSize = parsePageSize(input.pageSize);
|
|
851
851
|
const text = readFileSync(input.config, 'utf8');
|
|
852
852
|
const { config: cfg, animations } = loadConfigAndAnimations(input.config);
|
|
853
853
|
const raw = JSON.parse(text) as Json;
|
|
@@ -868,9 +868,9 @@ export function meshDraftStage(input: MeshDraftInput, rigc: RigcRunner, checkBin
|
|
|
868
868
|
const rigDir = join(scratch, name, 'rig');
|
|
869
869
|
const at = configWith(name, meshes);
|
|
870
870
|
try {
|
|
871
|
-
rigStage({ config: at, parts: input.parts, out: rigDir, ...(input.idleKeys === undefined ? {} : { idleKeys: input.idleKeys }), ...(input.pageEdges === undefined ? {} : { pageEdges: input.pageEdges }), ...(input.packShape === undefined ? {} : { packShape: input.packShape }) }, rigc, join(scratch, name, 'gate'), (l) => log(`[${name}:rig] ${l}`));
|
|
871
|
+
rigStage({ config: at, parts: input.parts, out: rigDir, ...(input.idleKeys === undefined ? {} : { idleKeys: input.idleKeys }), ...(input.pageEdges === undefined ? {} : { pageEdges: input.pageEdges }), ...(input.packShape === undefined ? {} : { packShape: input.packShape }), ...(pageSize === undefined ? {} : { pageSize }) }, rigc, join(scratch, name, 'gate'), (l) => log(`[${name}:rig] ${l}`));
|
|
872
872
|
if (!check) return { rigDir };
|
|
873
|
-
const report = checkStage({ rig: rigDir, parts: input.parts, out: join(scratch, name, 'check'), seamPairs: true, ...(input.requirements === undefined ? {} : { requirements: input.requirements }), ...(input.pageEdges === undefined ? {} : { pageEdges: input.pageEdges }), ...(input.packShape === undefined ? {} : { packShape: input.packShape }) }, rigc, checkBin, (l) => log(`[${name}:check] ${l}`));
|
|
873
|
+
const report = checkStage({ rig: rigDir, parts: input.parts, out: join(scratch, name, 'check'), seamPairs: true, ...(input.requirements === undefined ? {} : { requirements: input.requirements }), ...(input.pageEdges === undefined ? {} : { pageEdges: input.pageEdges }), ...(input.packShape === undefined ? {} : { packShape: input.packShape }), ...(pageSize === undefined ? {} : { pageSize }) }, rigc, checkBin, (l) => log(`[${name}:check] ${l}`));
|
|
874
874
|
return { rigDir, report };
|
|
875
875
|
} catch (err) {
|
|
876
876
|
if (!(err instanceof PartsError)) throw err;
|
package/src/motion.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The idle: every channel a sine,
|
|
2
|
+
* The idle: every channel a sine, authored blinks, and the control bones that move
|
|
3
3
|
* idle keys off the bones a mesh is weighted to.
|
|
4
4
|
*
|
|
5
5
|
* ## Sines
|
|
@@ -211,38 +211,35 @@ export function idleMotion(cfg: CharacterConfig, chains: ReadonlyMap<string, str
|
|
|
211
211
|
const groups: Record<string, string[]> = {};
|
|
212
212
|
const bl = mc.blink;
|
|
213
213
|
if (bl !== undefined) {
|
|
214
|
-
const tb = bl.t;
|
|
215
214
|
groups.eyes = [...bl.eyes];
|
|
216
|
-
// A blink without brows (no eyebrow part) writes no brows group: rigc
|
|
217
|
-
// refuses a group with no members, and the loader refuses an empty one.
|
|
218
215
|
if (bl.brows !== undefined) groups.brows = [...bl.brows];
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
216
|
+
const eyeKeys: MotionKey[] = [{ t: 0, v: [1] }];
|
|
217
|
+
const browKeys: MotionKey[] = [{ t: 0, v: [0] }];
|
|
218
|
+
// Config order is time order. Each key is computed from its authored
|
|
219
|
+
// start, never from a preceding blink or an accumulated time delta.
|
|
220
|
+
for (const tb of blinkTimes(bl)) {
|
|
221
|
+
const at = (dt: number): number => pyRound(tb + dt, 6);
|
|
222
|
+
eyeKeys.push(
|
|
225
223
|
{ t: tb, v: [1], ease: 'shut' },
|
|
226
224
|
{ t: at(BLINK.shut), v: [bl.squash] },
|
|
227
225
|
{ t: at(BLINK.shut + BLINK.hold), v: [bl.squash], ease: 'open' },
|
|
228
226
|
{ t: at(BLINK.shut + BLINK.hold + BLINK.open), v: [1] },
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (bl.brows !== undefined && drop !== undefined) {
|
|
234
|
-
tracks.push({
|
|
235
|
-
group: 'brows',
|
|
236
|
-
property: 'translatey',
|
|
237
|
-
keys: [
|
|
238
|
-
{ t: 0, v: [0] },
|
|
227
|
+
);
|
|
228
|
+
const drop = bl.brow_drop;
|
|
229
|
+
if (bl.brows !== undefined && drop !== undefined) {
|
|
230
|
+
browKeys.push(
|
|
239
231
|
{ t: tb, v: [0], ease: 'shut' },
|
|
240
232
|
{ t: at(BLINK.browShut), v: [-drop] },
|
|
241
233
|
{ t: at(BLINK.browShut + BLINK.browHold), v: [-drop], ease: 'open' },
|
|
242
234
|
{ t: at(BLINK.browShut + BLINK.browHold + BLINK.browOpen), v: [0] },
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
eyeKeys.push({ t: T, v: [1] });
|
|
239
|
+
tracks.push({ group: 'eyes', property: 'scaley', keys: eyeKeys });
|
|
240
|
+
if (bl.brows !== undefined && bl.brow_drop !== undefined) {
|
|
241
|
+
browKeys.push({ t: T, v: [0] });
|
|
242
|
+
tracks.push({ group: 'brows', property: 'translatey', keys: browKeys });
|
|
246
243
|
}
|
|
247
244
|
}
|
|
248
245
|
const name = `${cfg.key}_painting`;
|
|
@@ -252,7 +249,7 @@ export function idleMotion(cfg: CharacterConfig, chains: ReadonlyMap<string, str
|
|
|
252
249
|
cut: name,
|
|
253
250
|
easings: { shut: [...EASINGS.shut], open: [...EASINGS.open] },
|
|
254
251
|
groups,
|
|
255
|
-
animations: { idle: { duration: T, loop: true, note: IDLE_NOTE, tracks } },
|
|
252
|
+
animations: { idle: { duration: T, loop: true, note: bl?.more === undefined ? IDLE_NOTE : IDLE_NOTE.replace('one blink', 'authored blinks'), tracks } },
|
|
256
253
|
};
|
|
257
254
|
}
|
|
258
255
|
|
|
@@ -317,6 +314,11 @@ const HOLD_MISSES = new Map<string, Readonly<HoldMisses>>();
|
|
|
317
314
|
/** The last time any blink key sits at before the closing key, in seconds after `blink.t`, for a blink with brows. */
|
|
318
315
|
export const BLINK_SPAN = Math.max(BLINK.shut + BLINK.hold + BLINK.open, BLINK.browShut + BLINK.browHold + BLINK.browOpen);
|
|
319
316
|
|
|
317
|
+
/** Authored order, validated by the config reader; the scalar stays scalar on disk. */
|
|
318
|
+
export function blinkTimes(bl: { t: number; more?: readonly number[] }): number[] {
|
|
319
|
+
return [bl.t, ...(bl.more ?? [])];
|
|
320
|
+
}
|
|
321
|
+
|
|
320
322
|
/** {@link BLINK_SPAN} for this blink: without brows, only the eyes' keys have to fit inside the idle. */
|
|
321
323
|
export function blinkSpan(bl: { brows?: readonly string[] }): number {
|
|
322
324
|
return bl.brows === undefined ? BLINK.shut + BLINK.hold + BLINK.open : BLINK_SPAN;
|
package/src/remesh.ts
CHANGED
|
@@ -65,7 +65,7 @@ import { createHash } from 'node:crypto';
|
|
|
65
65
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
66
66
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
67
67
|
import { checkStage, gateThroughRigc, type Log, RIGC_MODEL_DOCUMENT, rigStage } from './build.ts';
|
|
68
|
-
import { barsNotMet, type CheckReport, checkStatuses, type CheckStatus, checkSummaryLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, type PackShape, type PageEdges, rigcRanClause, type RigcRunner } from './check.ts';
|
|
68
|
+
import { barsNotMet, type CheckReport, checkStatuses, type CheckStatus, checkSummaryLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, type PackMode, type PackShape, type PageEdges, parsePageSize, rigcRanClause, type RigcRunner } from './check.ts';
|
|
69
69
|
import { loadConfigAndAnimations } from './config.ts';
|
|
70
70
|
import { PartsError, type Problem, problemLine, refuseIfAny } from './errors.ts';
|
|
71
71
|
import { jsonValueSpan, scratchConfig } from './meshdraft.ts';
|
|
@@ -113,6 +113,7 @@ export interface RemeshInput {
|
|
|
113
113
|
idleKeys?: IdleKeys;
|
|
114
114
|
pageEdges?: PageEdges;
|
|
115
115
|
packShape?: PackShape;
|
|
116
|
+
pageSize?: number;
|
|
116
117
|
requirements?: string;
|
|
117
118
|
/** Issue #617: a {@link INPUT_CHECK_FILE} an earlier run wrote over this input; its check is reused when it is bound to this run's input. */
|
|
118
119
|
inputCheck?: string;
|
|
@@ -520,7 +521,7 @@ export const INPUT_CHECK_FILE = 'input-check.json';
|
|
|
520
521
|
*/
|
|
521
522
|
export interface InputCheckBinding {
|
|
522
523
|
versions: { parts: string; rigc: string };
|
|
523
|
-
options: { page_edges: PageEdges; pack_shape: PackShape; requirements: { path: string; sha256: string } | null };
|
|
524
|
+
options: { page_edges: PageEdges; pack_shape: PackShape; page_size?: number; requirements: { path: string; sha256: string } | null };
|
|
524
525
|
rig: { dir: string; files: HashRow[] };
|
|
525
526
|
parts: { dir: string; files: HashRow[] };
|
|
526
527
|
}
|
|
@@ -540,7 +541,7 @@ export function rigcVersionText(rigc: RigcRunner, op: 'remesh' | 'retune'): stri
|
|
|
540
541
|
}
|
|
541
542
|
|
|
542
543
|
/** The binding of this run's input: what the input's `check` would read now ({@link InputCheckBinding}). */
|
|
543
|
-
export function inputCheckBinding(rigAt: string, tree: FileTree, partsDir: string, requirements: string | undefined, pageEdges: PageEdges, packShape: PackShape, versions: { parts: string; rigc: string }): InputCheckBinding {
|
|
544
|
+
export function inputCheckBinding(rigAt: string, tree: FileTree, partsDir: string, requirements: string | undefined, pageEdges: PageEdges, packShape: PackShape, versions: { parts: string; rigc: string }, pageSize?: number): InputCheckBinding {
|
|
544
545
|
const partsAt = resolve(partsDir);
|
|
545
546
|
const partsTree: FileTree = new Map();
|
|
546
547
|
const json = join(partsAt, 'parts.json');
|
|
@@ -555,7 +556,7 @@ export function inputCheckBinding(rigAt: string, tree: FileTree, partsDir: strin
|
|
|
555
556
|
}
|
|
556
557
|
return {
|
|
557
558
|
versions: { parts: versions.parts, rigc: versions.rigc },
|
|
558
|
-
options: { page_edges: pageEdges, pack_shape: packShape, requirements: req },
|
|
559
|
+
options: { page_edges: pageEdges, pack_shape: packShape, ...(pageSize === undefined ? {} : { page_size: pageSize }), requirements: req },
|
|
559
560
|
rig: { dir: resolve(rigAt), files: hashRows(tree) },
|
|
560
561
|
parts: { dir: partsAt, files: hashRows(new Map([...partsTree].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))) },
|
|
561
562
|
};
|
|
@@ -604,7 +605,8 @@ export function readInputCheck(path: string, op: 'remesh' | 'retune'): InputChec
|
|
|
604
605
|
field('versions', isRecord(v) && typeof v.parts === 'string' && typeof v.rigc === 'string', '{ parts, rigc } as strings');
|
|
605
606
|
const o = raw.options;
|
|
606
607
|
const req = isRecord(o) ? o.requirements : undefined;
|
|
607
|
-
|
|
608
|
+
const psOk = isRecord(o) && (!Object.hasOwn(o, 'page_size') || o.page_size === undefined || (typeof o.page_size === 'number' && Number.isSafeInteger(o.page_size) && o.page_size >= 1));
|
|
609
|
+
field('options', isRecord(o) && typeof o.page_edges === 'string' && typeof o.pack_shape === 'string' && psOk && (req === null || (isRecord(req) && typeof req.path === 'string' && typeof req.sha256 === 'string')), '{ page_edges, pack_shape, page_size?: integer >= 1, requirements: null or { path, sha256 } }');
|
|
608
610
|
for (const k of ['rig', 'parts'] as const) {
|
|
609
611
|
const t = raw[k];
|
|
610
612
|
field(k, isRecord(t) && typeof t.dir === 'string' && isRows(t.files), '{ dir, files: [{ path, bytes, sha256 }] }');
|
|
@@ -642,6 +644,7 @@ export function inputCheckBoundProblems(recorded: InputCheckBinding, now: InputC
|
|
|
642
644
|
if (recorded.versions.rigc !== now.versions.rigc) moved('versions.rigc', recorded.versions.rigc, now.versions.rigc, 'the check was measured under another rigc');
|
|
643
645
|
if (recorded.options.page_edges !== now.options.page_edges) moved('options.page_edges', recorded.options.page_edges, now.options.page_edges, 'the check packed its pages another way');
|
|
644
646
|
if (recorded.options.pack_shape !== now.options.pack_shape) moved('options.pack_shape', recorded.options.pack_shape, now.options.pack_shape, 'the check packed its pages another way');
|
|
647
|
+
if (recorded.options.page_size !== now.options.page_size) moved('options.page_size', recorded.options.page_size ?? 'absent', now.options.page_size ?? 'absent', 'the check packed its pages another way');
|
|
645
648
|
const ra = recorded.options.requirements;
|
|
646
649
|
const rb = now.options.requirements;
|
|
647
650
|
if (ra === null || rb === null) {
|
|
@@ -686,10 +689,11 @@ export function inputCheckOf(
|
|
|
686
689
|
partsVersion: string,
|
|
687
690
|
rigc: RigcRunner,
|
|
688
691
|
op: 'remesh' | 'retune',
|
|
692
|
+
pageSize?: number,
|
|
689
693
|
): { binding: InputCheckBinding | null; reused: CheckSide | null } {
|
|
690
694
|
if (req.inputCheck === undefined && req.recordInputCheck !== true) return { binding: null, reused: null };
|
|
691
695
|
const recorded = req.inputCheck === undefined ? null : readInputCheck(req.inputCheck, op);
|
|
692
|
-
const binding = inputCheckBinding(rigAt, tree, req.parts, req.requirements, pageEdges, packShape, { parts: partsVersion, rigc: rigcVersionText(rigc, op) });
|
|
696
|
+
const binding = inputCheckBinding(rigAt, tree, req.parts, req.requirements, pageEdges, packShape, { parts: partsVersion, rigc: rigcVersionText(rigc, op) }, pageSize);
|
|
693
697
|
if (recorded === null) return { binding, reused: null };
|
|
694
698
|
refuseIfAny(inputCheckBoundProblems(recorded, binding, req.inputCheck as string, op));
|
|
695
699
|
return { binding, reused: canonicalSide(recorded.check) };
|
|
@@ -703,7 +707,7 @@ export function inputCheckOf(
|
|
|
703
707
|
*/
|
|
704
708
|
export function inputCheckMovedProblems(first: InputCheckBinding, req: { requirements?: string; parts: string }, rigAt: string, op: 'remesh' | 'retune'): Problem[] {
|
|
705
709
|
const code = REVISION_CODES[op].inputCheckMoved;
|
|
706
|
-
const second = inputCheckBinding(rigAt, readTree(rigAt), req.parts, req.requirements, first.options.page_edges, first.options.pack_shape, first.versions);
|
|
710
|
+
const second = inputCheckBinding(rigAt, readTree(rigAt), req.parts, req.requirements, first.options.page_edges, first.options.pack_shape, first.versions, first.options.page_size);
|
|
707
711
|
const out: Problem[] = [];
|
|
708
712
|
const row = (r: HashRow | undefined): string => (r === undefined ? 'absent' : `${r.bytes} bytes sha256 ${r.sha256}`);
|
|
709
713
|
const moved = (object: string, before: string, after: string): void => {
|
|
@@ -909,6 +913,8 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
909
913
|
const idleKeys = input.idleKeys ?? DEFAULT_IDLE_KEYS;
|
|
910
914
|
const pageEdges = input.pageEdges ?? DEFAULT_PAGE_EDGES;
|
|
911
915
|
const packShape = input.packShape ?? DEFAULT_PACK_SHAPE;
|
|
916
|
+
const pageSize = parsePageSize(input.pageSize);
|
|
917
|
+
const mode: PackMode = { pageEdges, packShape, ...(pageSize === undefined ? {} : { pageSize }) };
|
|
912
918
|
// 1. The input, the out and the request.
|
|
913
919
|
const outAt = resolve(input.out);
|
|
914
920
|
const rigAt = resolve(input.rig);
|
|
@@ -918,7 +924,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
918
924
|
const tree = readTree(rigAt);
|
|
919
925
|
refuseIfAny(inputTreeProblems(tree, input.rig));
|
|
920
926
|
if ((input.mesh === undefined) === (input.delta === undefined)) throw new Error('remeshStage: exactly one of mesh, delta is required');
|
|
921
|
-
const recorded = inputCheckOf(input, rigAt, tree, pageEdges, packShape, versions.parts, rigc, 'remesh');
|
|
927
|
+
const recorded = inputCheckOf(input, rigAt, tree, pageEdges, packShape, versions.parts, rigc, 'remesh', pageSize);
|
|
922
928
|
const meshReq = input.mesh === undefined ? null : readMeshRequest(input.mesh);
|
|
923
929
|
const deltaReq = input.delta === undefined ? null : readDeltaRequest(input.delta);
|
|
924
930
|
const configText = readFileSync(input.config, 'utf8');
|
|
@@ -941,7 +947,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
941
947
|
const auto = 'auto' in meshReq.entry;
|
|
942
948
|
const build = (name: string, config: string): Built => {
|
|
943
949
|
const out = join(scratch, name, 'rig');
|
|
944
|
-
rigStage({ config, parts: input.parts, out, idleKeys, pageEdges, packShape }, rigc, join(scratch, name, 'gate'), (l) => log(`[${name}:rig] ${l}`));
|
|
950
|
+
rigStage({ config, parts: input.parts, out, idleKeys, pageEdges, packShape, ...(pageSize === undefined ? {} : { pageSize }) }, rigc, join(scratch, name, 'gate'), (l) => log(`[${name}:rig] ${l}`));
|
|
945
951
|
return readBuilt(out, part);
|
|
946
952
|
};
|
|
947
953
|
// 3. The baseline.
|
|
@@ -978,7 +984,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
978
984
|
refuseIfAny(deltaSourceProblems(doc, part, inAtt, deltaPath));
|
|
979
985
|
log(`rig-parts remesh: ${part} of ${input.rig}, ${tree.size} file(s); the request is a mesh edit of ${doc.ops.length} op(s), the baseline is the input itself`);
|
|
980
986
|
let model = null as string | null;
|
|
981
|
-
const inGate = gateThroughRigc(pngsOf(tree), textsOf(tree, plant.unfilteredGateTexts === true), rigc, join(scratch, 'gate-input'),
|
|
987
|
+
const inGate = gateThroughRigc(pngsOf(tree), textsOf(tree, plant.unfilteredGateTexts === true), rigc, join(scratch, 'gate-input'), mode, (dir) => {
|
|
982
988
|
const p = join(dir, RIGC_MODEL_DOCUMENT);
|
|
983
989
|
model = existsSync(p) ? readFileSync(p, 'utf8') : null;
|
|
984
990
|
});
|
|
@@ -1015,7 +1021,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
1015
1021
|
log(` ${part}: v=${before.vertices} t=${before.triangles} hull=${before.hull} -> v=${after.vertices} t=${after.triangles} hull=${after.hull}`);
|
|
1016
1022
|
log(` preserved: ${identical.filter((p) => p !== PROVENANCE_FILE && !(input.recordInputCheck === true && p === INPUT_CHECK_FILE)).length} file(s) byte-identical to the input; rig.json identical outside skins.default.${part}.${part}; mesh_report.json identical but the "${part}" row`);
|
|
1017
1023
|
// 7. The gate and check.
|
|
1018
|
-
const gate = gateThroughRigc(pngsOf(revision), textsOf(revision, plant.unfilteredGateTexts === true), rigc, join(scratch, 'gate'),
|
|
1024
|
+
const gate = gateThroughRigc(pngsOf(revision), textsOf(revision, plant.unfilteredGateTexts === true), rigc, join(scratch, 'gate'), mode);
|
|
1019
1025
|
for (const g of gate) {
|
|
1020
1026
|
log(` rigc ${g.label}, the revision: exit ${g.status}`);
|
|
1021
1027
|
for (const l of g.lines) log(` ${l.trim()}`);
|
|
@@ -1027,7 +1033,7 @@ export function remeshStage(input: RemeshInput, rigc: RigcRunner, checkBin: stri
|
|
|
1027
1033
|
writeFileSync(join(staged, k), b);
|
|
1028
1034
|
}
|
|
1029
1035
|
const checkOf = (rig: string, name: string): CheckReport =>
|
|
1030
|
-
checkStage({ rig, parts: input.parts, out: join(scratch, name), pageEdges, packShape, ...(input.requirements === undefined ? {} : { requirements: input.requirements }) }, rigc, checkBin, (l) => log(`[${name}] ${l}`));
|
|
1036
|
+
checkStage({ rig, parts: input.parts, out: join(scratch, name), pageEdges, packShape, ...(pageSize === undefined ? {} : { pageSize }), ...(input.requirements === undefined ? {} : { requirements: input.requirements }) }, rigc, checkBin, (l) => log(`[${name}] ${l}`));
|
|
1031
1037
|
if (recorded.reused !== null) log(inputCheckReusedLine(input.inputCheck as string, recorded.binding as InputCheckBinding));
|
|
1032
1038
|
let inSide: CheckSide;
|
|
1033
1039
|
if (recorded.reused !== null) inSide = recorded.reused;
|
package/src/requirements.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { setupPaintingProblems, type SetupPainting } from './setuppainting.ts';
|
|
|
2
2
|
import { jointMaterialProblems, type JointMaterial } from './cutmaterial.ts';
|
|
3
3
|
import { fixedSkeletonProblems, type FixedSkeleton } from './artjoints.ts';
|
|
4
4
|
import { boundaryColourProblems, type BoundaryColour } from './boundarycolour.ts';
|
|
5
|
+
import { behindSeamsProblems, type BehindSeams } from './behindseams.ts';
|
|
6
|
+
import { motionSeamProblems, type MotionSeamDeclaration } from './motionseams.ts';
|
|
5
7
|
/**
|
|
6
8
|
* What a scene requires of a rig's motion, declared in a file `check` is given
|
|
7
9
|
* (`--requirements`, issue #93, increment 2 of #87) and measured from the
|
|
@@ -209,8 +211,12 @@ export interface RequirementsFile {
|
|
|
209
211
|
pinholes?: PinholesDeclaration;
|
|
210
212
|
/** Issue #941: `check`'s background bar over every declared seam pair and every frame, only under `required: true`; absent when the file does not declare it. */
|
|
211
213
|
seam_over_motion?: SeamOverMotionDeclaration;
|
|
214
|
+
/** Issue #1269: motion coverage without a distance bar; absence and an explicit empty inventory stay distinct. */
|
|
215
|
+
motion_seams?: MotionSeamDeclaration[];
|
|
212
216
|
/** Issue #942: the boundary colour-step bar against the rig's own pieces, measured by `check` only when declared. */
|
|
213
217
|
boundary_colour?: BoundaryColour;
|
|
218
|
+
/** Issue #1314: required behind-part seam readings when declared; an absent threshold is unmeasured, never defaulted. */
|
|
219
|
+
behind_seams?: BehindSeams;
|
|
214
220
|
}
|
|
215
221
|
|
|
216
222
|
/**
|
|
@@ -329,7 +335,8 @@ const EXCEPTION_ABSENT: Record<ExceptionList, string> = {
|
|
|
329
335
|
* a name used twice, and a `contact` against its own bone and point or an
|
|
330
336
|
* `aim` at a point of its own bone (issue #540: each reads 0 by construction,
|
|
331
337
|
* or no line at all). Resolving the names against the rig is
|
|
332
|
-
* {@link resolveRequirements}'s.
|
|
338
|
+
* {@link resolveRequirements}'s. Optional `motion_seams` declares motion coverage
|
|
339
|
+
* without a distance bar; its part names resolve through the same rig and parts readers.
|
|
333
340
|
*/
|
|
334
341
|
export function readRequirements(path: string): RequirementsFile {
|
|
335
342
|
const at = resolve(path);
|
|
@@ -353,10 +360,19 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
353
360
|
problems.push({ code: 'REQUIREMENTS_SELF_TARGET', object: `${label} field "target"`, detail });
|
|
354
361
|
};
|
|
355
362
|
if (raw.spec !== REQUIREMENTS_SPEC) field(`${at} field "spec"`, `is ${JSON.stringify(raw.spec)}; ${JSON.stringify(REQUIREMENTS_SPEC)} is required`);
|
|
356
|
-
for (const k of Object.keys(raw)) if (!['spec', 'fps', 'targets', 'requirements', ...EXCEPTION_LISTS, 'may_fold', 'fixed_skeleton', 'cut_material', 'setup_painting', 'pinholes', 'seam_over_motion', 'boundary_colour'].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, fixed_skeleton, cut_material, setup_painting, pinholes, seam_over_motion, boundary_colour; note or *_note as a string; x-<name> as a record)');
|
|
363
|
+
for (const k of Object.keys(raw)) if (!['spec', 'fps', 'targets', 'requirements', ...EXCEPTION_LISTS, 'may_fold', 'fixed_skeleton', 'cut_material', 'setup_painting', 'pinholes', 'seam_over_motion', 'motion_seams', 'boundary_colour', 'behind_seams'].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, fixed_skeleton, cut_material, setup_painting, pinholes, seam_over_motion, motion_seams, boundary_colour, behind_seams; note or *_note as a string; x-<name> as a record)');
|
|
364
|
+
if ('motion_seams' in raw) {
|
|
365
|
+
// Shape uses the shared reader; actual names resolve against the rig and parts below.
|
|
366
|
+
const names = new Set<string>();
|
|
367
|
+
if (Array.isArray(raw.motion_seams)) for (const row of raw.motion_seams) if (isRecord(row)) {
|
|
368
|
+
for (const name of [row.part, row.neighbour]) if (typeof name === 'string') names.add(name);
|
|
369
|
+
}
|
|
370
|
+
problems.push(...motionSeamProblems(raw.motion_seams, names, `${at} motion_seams`, 'REQUIREMENTS_FIELD'));
|
|
371
|
+
}
|
|
357
372
|
if ('pinholes' in raw) problems.push(...pinholesProblems(raw.pinholes, `${at} pinholes`));
|
|
358
373
|
if ('seam_over_motion' in raw) problems.push(...seamOverMotionProblems(raw.seam_over_motion, `${at} seam_over_motion`));
|
|
359
374
|
if ('boundary_colour' in raw) problems.push(...boundaryColourProblems(raw.boundary_colour, `${at} boundary_colour`));
|
|
375
|
+
if ('behind_seams' in raw) problems.push(...behindSeamsProblems(raw.behind_seams, `${at} behind_seams`));
|
|
360
376
|
if ('setup_painting' in raw) problems.push(...setupPaintingProblems(raw.setup_painting, `${at} setup_painting`));
|
|
361
377
|
if ('cut_material' in raw) problems.push(...jointMaterialProblems(raw.cut_material, `${at} cut_material`));
|
|
362
378
|
if ('fixed_skeleton' in raw) problems.push(...fixedSkeletonProblems(raw.fixed_skeleton, `${at} fixed_skeleton`));
|
|
@@ -545,7 +561,7 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
545
561
|
}
|
|
546
562
|
const fps = finite(raw.fps) ? raw.fps : undefined;
|
|
547
563
|
refuseIfAny(problems);
|
|
548
|
-
return { path: at, fps, targets, requirements, not_planted: lists.not_planted, not_swinging: lists.not_swinging, rises: lists.rises, rests: lists.rests, may_fold: mayFold, ...(raw.fixed_skeleton === undefined ? {} : { fixed_skeleton: raw.fixed_skeleton as FixedSkeleton }), ...(raw.cut_material === undefined ? {} : { cut_material: raw.cut_material as JointMaterial[] }), ...(raw.setup_painting === undefined ? {} : { setup_painting: raw.setup_painting as SetupPainting }), ...(raw.pinholes === undefined ? {} : { pinholes: { required: (raw.pinholes as PinholesDeclaration).required } }), ...(raw.seam_over_motion === undefined ? {} : { seam_over_motion: { required: (raw.seam_over_motion as SeamOverMotionDeclaration).required } }), ...(raw.boundary_colour === undefined ? {} : { boundary_colour: { max_step_excess: (raw.boundary_colour as BoundaryColour).max_step_excess } }) };
|
|
564
|
+
return { path: at, fps, targets, requirements, not_planted: lists.not_planted, not_swinging: lists.not_swinging, rises: lists.rises, rests: lists.rests, may_fold: mayFold, ...(raw.motion_seams === undefined ? {} : { motion_seams: raw.motion_seams as MotionSeamDeclaration[] }), ...(raw.fixed_skeleton === undefined ? {} : { fixed_skeleton: raw.fixed_skeleton as FixedSkeleton }), ...(raw.cut_material === undefined ? {} : { cut_material: raw.cut_material as JointMaterial[] }), ...(raw.setup_painting === undefined ? {} : { setup_painting: raw.setup_painting as SetupPainting }), ...(raw.pinholes === undefined ? {} : { pinholes: { required: (raw.pinholes as PinholesDeclaration).required } }), ...(raw.seam_over_motion === undefined ? {} : { seam_over_motion: { required: (raw.seam_over_motion as SeamOverMotionDeclaration).required } }), ...(raw.boundary_colour === undefined ? {} : { boundary_colour: { max_step_excess: (raw.boundary_colour as BoundaryColour).max_step_excess } }), ...(raw.behind_seams === undefined ? {} : { behind_seams: raw.behind_seams as BehindSeams }) };
|
|
549
565
|
}
|
|
550
566
|
|
|
551
567
|
// ---------------------------------------------------------------------------
|
|
@@ -623,6 +639,10 @@ export function resolveRequirements(file: RequirementsFile, rig: Record<string,
|
|
|
623
639
|
const target = (object: string, t: TargetRef): void => {
|
|
624
640
|
if ('bone' in t) bone(`${object} target`, t.bone);
|
|
625
641
|
};
|
|
642
|
+
if (file.motion_seams !== undefined) {
|
|
643
|
+
const slots = new Set((Array.isArray(rig.slots) ? rig.slots : []).filter(isRecord).map(s => s.name).filter((name): name is string => typeof name === 'string'));
|
|
644
|
+
problems.push(...motionSeamProblems(file.motion_seams, slots, 'requirements.motion_seams', 'REQUIREMENTS_RESOLVES'));
|
|
645
|
+
}
|
|
626
646
|
for (const j of file.fixed_skeleton?.joints ?? []) bone(`fixed_skeleton joint "${j.name}"`, j.bone);
|
|
627
647
|
for (const r of file.requirements) {
|
|
628
648
|
const object = `requirement "${r.name}" (${r.kind})`;
|
|
@@ -1263,11 +1283,17 @@ export function seamPairs(part: PlacedArt, neighbour: PlacedArt): SeamPair[] {
|
|
|
1263
1283
|
* (`REQUIREMENTS_SEAM`, quoting why there is none); a part `parts.json` does not
|
|
1264
1284
|
* list is unresolved (`REQUIREMENTS_RESOLVES`); and two parts whose art does
|
|
1265
1285
|
* not meet at the setup pose share no seam (`REQUIREMENTS_SEAM`). `art` is
|
|
1266
|
-
* asked only for parts `parts.json` lists.
|
|
1286
|
+
* asked only for parts `parts.json` lists. Bar-free `motion_seams` names also
|
|
1287
|
+
* resolve here against parts.json, without reading distance art or requiring adjacency.
|
|
1267
1288
|
*/
|
|
1268
1289
|
export function resolveSeams(file: RequirementsFile, partNames: readonly string[] | null, noParts: string | null, art: (part: string) => PlacedArt): Map<string, SeamPair[]> {
|
|
1269
1290
|
const problems: Problem[] = [];
|
|
1270
1291
|
const out = new Map<string, SeamPair[]>();
|
|
1292
|
+
if (file.motion_seams !== undefined) {
|
|
1293
|
+
if (partNames === null && file.motion_seams.length > 0) {
|
|
1294
|
+
problems.push({ code: 'REQUIREMENTS_SEAM', object: 'requirements.motion_seams', detail: `requires parts.json to resolve the declared part names; none was read: ${noParts ?? 'no parts.json'}` });
|
|
1295
|
+
} else problems.push(...motionSeamProblems(file.motion_seams, new Set(partNames ?? []), 'requirements.motion_seams', 'REQUIREMENTS_RESOLVES'));
|
|
1296
|
+
}
|
|
1271
1297
|
const cache = new Map<string, PlacedArt>();
|
|
1272
1298
|
const artOf = (n: string): PlacedArt => {
|
|
1273
1299
|
const hit = cache.get(n);
|