@rig-c/parts 2.47.1 → 2.49.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/docs/AUTHORING.md +180 -77
- package/docs/STABILITY.md +130 -33
- package/package.json +1 -1
- package/src/assembly-reading.ts +35 -9
- package/src/behindseams.ts +223 -101
- package/src/build.ts +47 -6
- package/src/check.ts +2 -0
- package/src/takeregion.ts +4 -2
package/src/behindseams.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
4
|
-
import
|
|
4
|
+
import { Plate } from '@rig-c/core/plate';
|
|
5
5
|
import type { AttachmentRest, Frame } from '@rig-c/core/render-shared';
|
|
6
6
|
import { seamGridOf, seamsOf, setupCellReader, type SeamCell, type SeamGrid } from '@rig-c/core/seam';
|
|
7
7
|
import { DRAWN_ALPHA } from '@rig-c/core/passthrough';
|
|
@@ -14,6 +14,11 @@ export const BEHIND_SEAM_LINE = 'BEHIND_PART_SEAMS';
|
|
|
14
14
|
export const UNDECLARED_BEHIND_SEAM_REASON = 'HOLE: no requirements.behind_seams declares an authored threshold T; not measured, never a pass';
|
|
15
15
|
export const BEHIND_SEAM_CODE = 'CHECK_BEHIND_PART_SEAMS';
|
|
16
16
|
export const BEHIND_SEAM_UNMEASURED_CODE = 'CHECK_BEHIND_PART_SEAMS_UNMEASURED';
|
|
17
|
+
export const NO_PARTS_SETUP_STANDING_REASON = "no --parts manifest was supplied; setup standing compares the setup render with the parts' flat recomposite";
|
|
18
|
+
export const IDLE_STANDING_MOTION_READ_REASON = 'not applicable: motion_opened reads the pair';
|
|
19
|
+
export const IDLE_STANDING_NO_ORACLE_REASON = "idle standing is not measured: idle frames have no recomposite oracle, and the pair's idle reading is motion_opened";
|
|
20
|
+
export const TURN_STANDING_MOTION_READ_REASON = IDLE_STANDING_MOTION_READ_REASON;
|
|
21
|
+
export const TURN_STANDING_NO_ORACLE_REASON = "turn standing is not measured: turn poses have no recomposite oracle, and the pair's turn reading is motion_opened";
|
|
17
22
|
|
|
18
23
|
export interface BehindSeams {
|
|
19
24
|
/** Opt in to the rig's declared ranges; never supplies or guesses a range. */
|
|
@@ -38,9 +43,17 @@ export interface BehindSeamsFramesInput {
|
|
|
38
43
|
pages: Map<string, Plate>;
|
|
39
44
|
stock: readonly BehindSeamsStockPair[] | null;
|
|
40
45
|
fps: number;
|
|
46
|
+
/** Setup recomposite frame rendered onto the pair's seam grid; absent or null when --parts was not supplied. */
|
|
47
|
+
recomposite?: Frame | null;
|
|
41
48
|
turn?: BehindSeamsTurnInput;
|
|
42
49
|
/** Issue #1403 plant only: the samples[] cap; production never sets it ({@link BEHIND_SAMPLE_CAP}). */
|
|
43
50
|
sampleCap?: number;
|
|
51
|
+
/** Issue #1408 plant only: skip the setup recomposite comparison; production never sets it. */
|
|
52
|
+
plantSkipRecomposite?: true;
|
|
53
|
+
/** Issue #1408 plant only: measure standing on idle frames without an oracle; production never sets it. */
|
|
54
|
+
plantMeasureIdleStanding?: true;
|
|
55
|
+
/** Issue #1412 plant only: measure standing on turn poses without an oracle; production never sets it. */
|
|
56
|
+
plantMeasureTurnStanding?: true;
|
|
44
57
|
}
|
|
45
58
|
export interface BehindSeamsTurnPose {
|
|
46
59
|
name: string;
|
|
@@ -68,7 +81,7 @@ export interface BehindSeamsTurnPair {
|
|
|
68
81
|
read_poses: number;
|
|
69
82
|
unmeasured_poses: number;
|
|
70
83
|
motion_opened: { status: BehindSeamsCount['status']; max_px: number };
|
|
71
|
-
standing: { status: BehindSeamsCount['status']; max_px: number };
|
|
84
|
+
standing: { status: BehindSeamsCount['status']; reason?: string; max_px: number };
|
|
72
85
|
}
|
|
73
86
|
export interface BehindSeamsTurnMeasured {
|
|
74
87
|
status: BehindSeamsCount['status'];
|
|
@@ -107,6 +120,8 @@ export interface BehindSeamsUnreadCorridor {
|
|
|
107
120
|
cell_count: number;
|
|
108
121
|
}
|
|
109
122
|
export interface BehindSeamsStanding extends BehindSeamsCount {
|
|
123
|
+
/** Present when standing is SKIP: at setup without --parts, or on every idle frame and turn pose. */
|
|
124
|
+
reason?: string;
|
|
110
125
|
/** Distinct grid cells across all unread corridors, including cross-axis intersections. */
|
|
111
126
|
unread_cells?: number;
|
|
112
127
|
/** Omitted, together with unread_cells, when every corridor's endpoints are readable. */
|
|
@@ -135,6 +150,8 @@ export interface BehindSeamsHit {
|
|
|
135
150
|
}
|
|
136
151
|
export interface BehindSeamsReading {
|
|
137
152
|
status: 'PASS' | 'FAIL' | 'SKIP';
|
|
153
|
+
/** Present on the idle standing summary, which is never measured on idle frames. */
|
|
154
|
+
reason?: string;
|
|
138
155
|
frames: BehindSeamsHit[];
|
|
139
156
|
hit_frames: number;
|
|
140
157
|
max_px: number;
|
|
@@ -177,6 +194,8 @@ export interface BehindSeamsInput {
|
|
|
177
194
|
pairs: readonly MotionSeamPair[];
|
|
178
195
|
stockDir: string | null;
|
|
179
196
|
fps: number;
|
|
197
|
+
/** Flat recomposite of parts at their painted positions from --parts, or null/undefined when --parts was not supplied. */
|
|
198
|
+
recomposite?: { stage: { x: number; y: number; width: number; height: number }; raster: { width: number; height: number; data: ArrayLike<number> } } | null;
|
|
180
199
|
unsupported?: string;
|
|
181
200
|
turnBuild?: { build?: string; reason?: string };
|
|
182
201
|
}
|
|
@@ -315,15 +334,45 @@ function counted(count: BehindSeamsCount, cells: ReadonlySet<number>, grid: Seam
|
|
|
315
334
|
}
|
|
316
335
|
}
|
|
317
336
|
|
|
337
|
+
/** Issue #1405: the unread reason names each ambiguous owner case that occurs, with
|
|
338
|
+
* both members' composite alpha at one endpoint. The named point is the case's first
|
|
339
|
+
* endpoint in scan order, which is `unread_corridors` order: horizontal corridors top
|
|
340
|
+
* to bottom and left to right, then vertical corridors left to right and top to bottom,
|
|
341
|
+
* the left/top endpoint before the right/bottom one. Counts are distinct endpoint cells;
|
|
342
|
+
* a case with none is omitted. */
|
|
343
|
+
export function ambiguousOwnerReason(a: string, b: string, corridors: readonly BehindSeamsUnreadCorridor[], cells: number,
|
|
344
|
+
alpha: (gridX: number, gridY: number) => [number, number]): string {
|
|
345
|
+
const byte = (v: number): string => `${Math.round(v * 255 * 100) / 100}/255`;
|
|
346
|
+
const clauses: string[] = [];
|
|
347
|
+
for (const owner of [0, 3]) {
|
|
348
|
+
const seen = new Set<string>();
|
|
349
|
+
let first: BehindSeamsEndpoint | null = null;
|
|
350
|
+
for (const c of corridors) for (const e of c.endpoints) if (e[4] === owner) { seen.add(`${e[0]},${e[1]}`); first ??= e; }
|
|
351
|
+
if (first === null) continue;
|
|
352
|
+
const [ax, bx] = alpha(first[0], first[1]);
|
|
353
|
+
clauses.push(`${owner === 0 ? `neither "${a}" nor "${b}" reaches` : `both "${a}" and "${b}" reach`} 128/255 at ${seen.size} endpoint cell(s), first at world (${first[2]}, ${first[3]}) ("${a}" ${byte(ax)}, "${b}" ${byte(bx)})`);
|
|
354
|
+
}
|
|
355
|
+
return `standing endpoints include ambiguous half-alpha owners: ${corridors.length} unread corridor(s), ${cells} cell(s); ${clauses.join('; ')}; each endpoint requires exactly one member at 128/255 or more; unread corridors are not zero`;
|
|
356
|
+
}
|
|
357
|
+
|
|
318
358
|
interface Corridor { endpoints: Array<[number, number]> }
|
|
319
359
|
interface RasterCache { full: Plate; hidden: Plate }
|
|
320
360
|
|
|
361
|
+
function overWhite(data: Uint8Array, q: number, c: number): number {
|
|
362
|
+
return Math.round((data[q + c] * data[q + 3]) / 255 + 255 * (1 - data[q + 3] / 255));
|
|
363
|
+
}
|
|
364
|
+
|
|
321
365
|
function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pair: MotionSeamPair, frame: Frame, setup: boolean,
|
|
322
366
|
stock: BehindSeamsStockPair | undefined, threshold: number, allowance: number, unread: (frame: string, reason: string) => void,
|
|
323
367
|
cache: Map<Frame, Map<string, RasterCache>>, pose?: BehindSeamsTurnPose): BehindSeamsFrame {
|
|
368
|
+
const isIdle = !setup && pose === undefined;
|
|
369
|
+
const isTurn = pose !== undefined;
|
|
370
|
+
const plantIdleStanding = isIdle && input.plantMeasureIdleStanding === true;
|
|
371
|
+
const plantTurnStanding = isTurn && input.plantMeasureTurnStanding === true;
|
|
324
372
|
const label = pose !== undefined ? `turn ${pose.name}` : setup ? 'setup' : `idle frame ${frame.index}`;
|
|
325
373
|
const family = pose !== undefined ? 'BEHIND_PART_SEAMS.turn.pairs[].frames' : setup ? 'BEHIND_PART_SEAMS.pairs[].setup' : 'BEHIND_PART_SEAMS.pairs[].frames';
|
|
326
|
-
const row: BehindSeamsFrame = { ...checkRow(family, 'pair', false, [pair.a, pair.b]), animation: pose !== undefined ? 'turn' : setup ? null : 'idle', index: frame.index, time: frame.time, ...(pose === undefined ? {} : { pose: pose.name, values: { ...pose.values }, ...(pose.observed_values === undefined ? {} : { observed_values: pose.observed_values, slider_times: pose.slider_times }) }), behind_slots: [], grid: null, motion_opened: emptyCount(),
|
|
374
|
+
const row: BehindSeamsFrame = { ...checkRow(family, 'pair', false, [pair.a, pair.b]), animation: pose !== undefined ? 'turn' : setup ? null : 'idle', index: frame.index, time: frame.time, ...(pose === undefined ? {} : { pose: pose.name, values: { ...pose.values }, ...(pose.observed_values === undefined ? {} : { observed_values: pose.observed_values, slider_times: pose.slider_times }) }), behind_slots: [], grid: null, motion_opened: emptyCount(),
|
|
375
|
+
standing: isIdle && !plantIdleStanding ? { ...emptyCount('SKIP'), reason: IDLE_STANDING_NO_ORACLE_REASON } : isTurn && !plantTurnStanding ? { ...emptyCount('SKIP'), reason: TURN_STANDING_NO_ORACLE_REASON } : emptyCount() };
|
|
327
376
|
const fail = (reason: string): BehindSeamsFrame => { unread(label, reason); return row; };
|
|
328
377
|
if (pair.unread !== undefined) return fail(pair.unread);
|
|
329
378
|
if (frame.attachments === undefined) return fail('draw order/whole attachment geometry is unavailable');
|
|
@@ -343,55 +392,89 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
343
392
|
const { viewport, cell } = grid, { width, height } = viewport, n = width * height;
|
|
344
393
|
const A = material(n), B = material(n), project = api.projector(viewport);
|
|
345
394
|
try {
|
|
346
|
-
|
|
347
|
-
|
|
395
|
+
// Ordinary official full/hidden rendering, both transparent and on the SAME
|
|
396
|
+
// native seam grid. No --seam/--hide combination and no PNG nearest sampling.
|
|
397
|
+
let frameCache = cache.get(frame);
|
|
398
|
+
if (frameCache === undefined) { frameCache = new Map(); cache.set(frame, frameCache); }
|
|
399
|
+
const cacheKey = JSON.stringify([grid, row.behind_slots]);
|
|
400
|
+
let rasters = frameCache.get(cacheKey);
|
|
401
|
+
const behind = new Set(row.behind_slots);
|
|
402
|
+
if (rasters === undefined) {
|
|
403
|
+
rasters = { full: api.renderFrame(frame, input.pages, viewport, [0, 0, 0, 0]), hidden: api.renderFrame({ ...frame, pieces: frame.pieces.filter(p => !behind.has(p.slot)) }, input.pages, viewport, [0, 0, 0, 0]) };
|
|
404
|
+
frameCache.set(cacheKey, rasters);
|
|
405
|
+
}
|
|
406
|
+
const measureStanding = plantTurnStanding || plantIdleStanding || (setup && input.recomposite !== undefined && input.recomposite !== null);
|
|
407
|
+
let recompositeDiff: ((k: number) => number) | null = null;
|
|
408
|
+
if (setup) {
|
|
409
|
+
if (input.recomposite === undefined || input.recomposite === null) {
|
|
410
|
+
row.standing = { ...emptyCount('SKIP'), reason: NO_PARTS_SETUP_STANDING_REASON };
|
|
411
|
+
unread(label, NO_PARTS_SETUP_STANDING_REASON);
|
|
412
|
+
} else if (input.plantSkipRecomposite !== true) {
|
|
413
|
+
const recompositePlate = api.renderFrame(input.recomposite, input.pages, viewport, [0, 0, 0, 0]);
|
|
414
|
+
recompositeDiff = (k: number): number => {
|
|
415
|
+
const q = k * 4;
|
|
416
|
+
if (recompositePlate.data[q + 3] === 0) return Infinity;
|
|
417
|
+
return Math.max(
|
|
418
|
+
Math.abs(overWhite(rasters!.full.data, q, 0) - overWhite(recompositePlate.data, q, 0)),
|
|
419
|
+
Math.abs(overWhite(rasters!.full.data, q, 1) - overWhite(recompositePlate.data, q, 1)),
|
|
420
|
+
Math.abs(overWhite(rasters!.full.data, q, 2) - overWhite(recompositePlate.data, q, 2)),
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
}
|
|
348
424
|
}
|
|
349
|
-
const half = DRAWN_ALPHA / 255;
|
|
350
|
-
const low = (k: number): boolean => A.alpha[k] + B.alpha[k] * (1 - A.alpha[k]) < half;
|
|
351
|
-
const owner = (k: number): number => A.alpha[k] >= half ? B.alpha[k] >= half ? 3 : 1 : B.alpha[k] >= half ? 2 : 0;
|
|
352
425
|
const corridors = new Map<number, Corridor>();
|
|
353
426
|
const support = new Set<number>();
|
|
354
427
|
const unreadCells = new Set<number>(), unreadCorridors: BehindSeamsUnreadCorridor[] = [];
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
while (j < length
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const
|
|
428
|
+
const half = DRAWN_ALPHA / 255;
|
|
429
|
+
const low = (k: number): boolean => A.alpha[k] + B.alpha[k] * (1 - A.alpha[k]) < half;
|
|
430
|
+
const owner = (k: number): number => A.alpha[k] >= half ? B.alpha[k] >= half ? 3 : 1 : B.alpha[k] >= half ? 2 : 0;
|
|
431
|
+
if (measureStanding) {
|
|
432
|
+
for (const piece of frame.pieces) if (piece.slot === pair.a || piece.slot === pair.b) {
|
|
433
|
+
api.rasterisePiece(api.pageFor(input.pages, piece), piece, project, viewport, (x, y, r, g, b, alpha) => add(piece.slot === pair.a ? A : B, y * width + x, [r, g, b], alpha / 255));
|
|
434
|
+
}
|
|
435
|
+
// A measured overlap is support even when the opening population is empty.
|
|
436
|
+
for (let k = 0; k < n; k++) if (owner(k) === 3) support.add(k);
|
|
437
|
+
for (const [length, lines, step, start] of [[width, height, 1, width], [height, width, width, 1]]) for (let l = 0; l < lines; l++) {
|
|
438
|
+
let j = 0;
|
|
439
|
+
while (j < length) {
|
|
440
|
+
const k = l * start + j * step;
|
|
441
|
+
if (!low(k)) {
|
|
442
|
+
if (j > 0) { const prev = k - step; if (!low(prev) && owner(prev) > 0 && owner(prev) < 3 && owner(k) > 0 && owner(k) < 3 && owner(prev) !== owner(k)) { support.add(prev); support.add(k); } }
|
|
443
|
+
j++; continue;
|
|
444
|
+
}
|
|
445
|
+
const first = j;
|
|
446
|
+
while (j < length && low(l * start + j * step)) j++;
|
|
447
|
+
if (first === 0 || j === length) continue; // outer silhouette, never a bracketed opening
|
|
448
|
+
const left = l * start + (first - 1) * step, right = l * start + j * step;
|
|
449
|
+
const a = owner(left), b = owner(right);
|
|
450
|
+
if (a === 0 || b === 0 || a === 3 || b === 3) {
|
|
451
|
+
const endpoint = (at: number, owner: number): BehindSeamsEndpoint => [at % width, Math.floor(at / width), ...centre(grid, at), owner];
|
|
452
|
+
const cells: Array<[number, number]> = [];
|
|
453
|
+
for (let t = first; t < j; t++) {
|
|
454
|
+
const at = l * start + t * step;
|
|
455
|
+
if (recompositeDiff !== null && recompositeDiff(at) <= threshold) continue;
|
|
456
|
+
unreadCells.add(at); cells.push(centre(grid, at));
|
|
457
|
+
}
|
|
458
|
+
if (cells.length === 0) continue;
|
|
459
|
+
unreadCorridors.push({ ...checkRow('BEHIND_PART_SEAMS.unread_corridors', 'pair', false, [pair.a, pair.b]),
|
|
460
|
+
axis: step === 1 ? 'horizontal' : 'vertical', endpoints: [endpoint(left, a), endpoint(right, b)], cells, cell_count: cells.length });
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (a === b) continue;
|
|
464
|
+
support.add(left); support.add(right);
|
|
465
|
+
const endpoints: [number, number] = a === 1 ? [left, right] : [right, left];
|
|
373
466
|
for (let t = first; t < j; t++) {
|
|
374
467
|
const at = l * start + t * step;
|
|
375
|
-
|
|
468
|
+
const c = corridors.get(at) ?? { endpoints: [] };
|
|
469
|
+
c.endpoints.push(endpoints); corridors.set(at, c);
|
|
376
470
|
}
|
|
377
|
-
unreadCorridors.push({ ...checkRow('BEHIND_PART_SEAMS.unread_corridors', 'pair', false, [pair.a, pair.b]),
|
|
378
|
-
axis: step === 1 ? 'horizontal' : 'vertical', endpoints: [endpoint(left, a), endpoint(right, b)], cells, cell_count: cells.length });
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
if (a === b) continue;
|
|
382
|
-
support.add(left); support.add(right);
|
|
383
|
-
const endpoints: [number, number] = a === 1 ? [left, right] : [right, left];
|
|
384
|
-
for (let t = first; t < j; t++) {
|
|
385
|
-
const at = l * start + t * step;
|
|
386
|
-
const c = corridors.get(at) ?? { endpoints: [] };
|
|
387
|
-
c.endpoints.push(endpoints); corridors.set(at, c);
|
|
388
471
|
}
|
|
389
472
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
473
|
+
row.standing.boundary_cells = support.size;
|
|
474
|
+
if (unreadCorridors.length > 0) {
|
|
475
|
+
row.standing.unread_cells = unreadCells.size;
|
|
476
|
+
row.standing.unread_corridors = unreadCorridors;
|
|
477
|
+
}
|
|
395
478
|
}
|
|
396
479
|
let motionReadable = setup;
|
|
397
480
|
const motionCells = new Map<number, SeamCell>();
|
|
@@ -414,17 +497,6 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
414
497
|
}
|
|
415
498
|
}
|
|
416
499
|
}
|
|
417
|
-
// Ordinary official full/hidden rendering, both transparent and on the SAME
|
|
418
|
-
// native seam grid. No --seam/--hide combination and no PNG nearest sampling.
|
|
419
|
-
let frameCache = cache.get(frame);
|
|
420
|
-
if (frameCache === undefined) { frameCache = new Map(); cache.set(frame, frameCache); }
|
|
421
|
-
const cacheKey = JSON.stringify([grid, row.behind_slots]);
|
|
422
|
-
let rasters = frameCache.get(cacheKey);
|
|
423
|
-
const behind = new Set(row.behind_slots);
|
|
424
|
-
if (rasters === undefined) {
|
|
425
|
-
rasters = { full: api.renderFrame(frame, input.pages, viewport, [0, 0, 0, 0]), hidden: api.renderFrame({ ...frame, pieces: frame.pieces.filter(p => !behind.has(p.slot)) }, input.pages, viewport, [0, 0, 0, 0]) };
|
|
426
|
-
frameCache.set(cacheKey, rasters);
|
|
427
|
-
}
|
|
428
500
|
const targets = new Set([...corridors.keys(), ...motionCells.keys()]);
|
|
429
501
|
const rear = material(n), weights = new Map<number, Map<string, number>>();
|
|
430
502
|
const surviving = new Set<number>(), underflow = new Set<number>();
|
|
@@ -454,31 +526,35 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
454
526
|
contributors: row.behind_slots.filter(slot => (weights.get(k)?.get(slot) ?? 0) > 0).map(slot => ({ ...checkRow('BEHIND_PART_SEAMS.contributors', 'pair', false, [pair.a, pair.b]), slot, weight: weights.get(k)!.get(slot)! })), distances, counted: counts };
|
|
455
527
|
};
|
|
456
528
|
const standingHits = new Set<number>(), motionHits = new Set<number>();
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
529
|
+
const cap = input.sampleCap ?? BEHIND_SAMPLE_CAP;
|
|
530
|
+
if (measureStanding) {
|
|
531
|
+
let standingUnderflow = false;
|
|
532
|
+
const worstStanding = new WorstStanding(cap);
|
|
533
|
+
for (const [k, corridor] of corridors) {
|
|
534
|
+
if (!surviving.has(k)) continue;
|
|
535
|
+
if (rear.alpha[k] <= 0 || underflow.has(k)) { unread(label, 'positive symbolic rear contribution underflowed its numeric colour weight'); standingUnderflow = true; continue; }
|
|
536
|
+
row.standing.geometric_px++;
|
|
537
|
+
const dr = recompositeDiff === null ? Infinity : recompositeDiff(k);
|
|
538
|
+
let chosen: [number, number] | null = null, raw = false, qualifies = false;
|
|
539
|
+
for (const [a, b] of corridor.endpoints) {
|
|
540
|
+
const d: [number, number] = [distance(rear, k, colour(A, a)), distance(rear, k, colour(B, b))];
|
|
541
|
+
const r = d[0] > 0 && d[1] > 0 && dr > 0, q = d[0] > threshold && d[1] > threshold && dr > threshold;
|
|
542
|
+
if (chosen === null || q && !qualifies || r && !raw) chosen = d;
|
|
543
|
+
raw ||= r; qualifies ||= q;
|
|
544
|
+
}
|
|
545
|
+
if (raw) row.standing.raw_px++;
|
|
546
|
+
if (qualifies) standingHits.add(k);
|
|
547
|
+
worstStanding.offer(k, chosen as [number, number], qualifies);
|
|
548
|
+
}
|
|
549
|
+
row.standing.samples = worstStanding.inOrder().map(c => sample(c.k, c.d, c.q));
|
|
550
|
+
if (worstStanding.seen > cap) row.standing.samples_omitted = worstStanding.seen - cap;
|
|
551
|
+
counted(row.standing, standingHits, grid, allowance);
|
|
552
|
+
// Incomplete coverage cannot certify PASS, but cannot hide a measured failure.
|
|
553
|
+
if (support.size === 0 || unreadCorridors.length > 0 || standingUnderflow) {
|
|
554
|
+
if (row.standing.status !== 'FAIL') row.standing.status = 'SKIP';
|
|
555
|
+
if (unreadCorridors.length > 0) unread(label, ambiguousOwnerReason(pair.a, pair.b, unreadCorridors, unreadCells.size, (x, y) => [A.alpha[y * width + x], B.alpha[y * width + x]]));
|
|
556
|
+
else if (support.size === 0) unread(label, 'no A/B boundary support was measured (no overlap, contact or bracketed corridor)');
|
|
469
557
|
}
|
|
470
|
-
if (raw) row.standing.raw_px++;
|
|
471
|
-
if (qualifies) standingHits.add(k);
|
|
472
|
-
worstStanding.offer(k, chosen as [number, number], qualifies);
|
|
473
|
-
}
|
|
474
|
-
row.standing.samples = worstStanding.inOrder().map(c => sample(c.k, c.d, c.q));
|
|
475
|
-
if (worstStanding.seen > cap) row.standing.samples_omitted = worstStanding.seen - cap;
|
|
476
|
-
counted(row.standing, standingHits, grid, allowance);
|
|
477
|
-
// Incomplete coverage cannot certify PASS, but cannot hide a measured failure.
|
|
478
|
-
if (support.size === 0 || unreadCorridors.length > 0 || standingUnderflow) {
|
|
479
|
-
if (row.standing.status !== 'FAIL') row.standing.status = 'SKIP';
|
|
480
|
-
if (unreadCorridors.length > 0) unread(label, 'standing endpoints include ambiguous half-alpha owners; unread corridors are not zero');
|
|
481
|
-
else if (support.size === 0) unread(label, 'no A/B boundary support was measured (no overlap, contact or bracketed corridor)');
|
|
482
558
|
}
|
|
483
559
|
for (const k of motionCells.keys()) {
|
|
484
560
|
if (rasters.hidden.data[k * 4 + 3] !== 0 || rasters.full.data[k * 4 + 3] === 0 || !surviving.has(k)) continue;
|
|
@@ -506,6 +582,17 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
|
|
|
506
582
|
row.motion_opened.geometric_px = motionHits.size; row.motion_opened.raw_px = motionHits.size;
|
|
507
583
|
counted(row.motion_opened, motionHits, grid, allowance);
|
|
508
584
|
if (!motionReadable) row.motion_opened.status = 'SKIP';
|
|
585
|
+
if (isIdle && !plantIdleStanding) {
|
|
586
|
+
row.standing = {
|
|
587
|
+
...emptyCount('SKIP'),
|
|
588
|
+
reason: row.motion_opened.status !== 'SKIP' ? IDLE_STANDING_MOTION_READ_REASON : IDLE_STANDING_NO_ORACLE_REASON,
|
|
589
|
+
};
|
|
590
|
+
} else if (isTurn && !plantTurnStanding) {
|
|
591
|
+
row.standing = {
|
|
592
|
+
...emptyCount('SKIP'),
|
|
593
|
+
reason: row.motion_opened.status !== 'SKIP' ? TURN_STANDING_MOTION_READ_REASON : TURN_STANDING_NO_ORACLE_REASON,
|
|
594
|
+
};
|
|
595
|
+
}
|
|
509
596
|
return { ...row, ...checkRow(family, 'pair', row.standing.status === 'FAIL' || row.motion_opened.status === 'FAIL', [pair.a, pair.b]) };
|
|
510
597
|
} catch (e) { return fail(`official raster/source reading unavailable: ${e instanceof Error ? e.message : String(e)}`); }
|
|
511
598
|
}
|
|
@@ -549,6 +636,8 @@ export function measureBehindSeamFrames(api: BehindSeamsApi, input: BehindSeamsF
|
|
|
549
636
|
problems.push(...shape);
|
|
550
637
|
if (shape.length > 0) { line.status = 'FAIL'; return line; }
|
|
551
638
|
for (const p of declared.pairs ?? []) if (!selected.has(keyOf(p.part, p.neighbour))) unread(null, 'declaration', `override pair "${p.part}|${p.neighbour}" is not in motionSeamSelection; an override does not create an adjacent pair`, true);
|
|
639
|
+
const active = declared.threshold !== undefined || declared.pairs?.some(p => p.threshold !== undefined) === true;
|
|
640
|
+
if (input.pairs.length === 0 && (input.recomposite === undefined || input.recomposite === null)) unread(null, 'setup', NO_PARTS_SETUP_STANDING_REASON, active);
|
|
552
641
|
if (input.pairs.length === 0) unread(null, 'selection', 'no selected motion seam pair; no boundary population was measured', declared.threshold !== undefined);
|
|
553
642
|
const rows = input.pairs.map(pair => {
|
|
554
643
|
const override = declared.pairs?.find(p => keyOf(p.part, p.neighbour) === keyOf(pair.a, pair.b));
|
|
@@ -582,23 +671,29 @@ export function measureBehindSeamFrames(api: BehindSeamsApi, input: BehindSeamsF
|
|
|
582
671
|
for (const r of rows) {
|
|
583
672
|
const { pair, threshold, allowance, setup, frames } = r;
|
|
584
673
|
const parts: [string, string] = [pair.a, pair.b];
|
|
585
|
-
const motion = reading(frames, 'motion_opened', input.fps, allowance, parts)
|
|
674
|
+
const motion = reading(frames, 'motion_opened', input.fps, allowance, parts);
|
|
586
675
|
if ((setup === null || setup.motion_opened.status === 'SKIP') && motion.status !== 'FAIL') motion.status = 'SKIP';
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
}
|
|
676
|
+
const idleStandingReason = motion.status !== 'SKIP' ? IDLE_STANDING_MOTION_READ_REASON : IDLE_STANDING_NO_ORACLE_REASON;
|
|
677
|
+
const rawStanding = reading(frames, 'standing', input.fps, allowance, parts);
|
|
678
|
+
const standing: BehindSeamsReading = input.plantMeasureIdleStanding === true
|
|
679
|
+
? rawStanding
|
|
680
|
+
: { ...rawStanding, status: 'SKIP', reason: idleStandingReason };
|
|
681
|
+
if (motion.max_px > allowance) {
|
|
682
|
+
problems.push({ code: BEHIND_SEAM_CODE, object: `pair "${pair.pair}" motion_opened`, detail: `idle frame ${motion.worst?.index} (${motion.max_px} cells) exceeds allowance ${allowance}; authored threshold ${threshold}, native seam cells, no one-cell floor or rest mask` });
|
|
683
|
+
}
|
|
684
|
+
if ((setup?.standing.px ?? 0) > allowance) {
|
|
685
|
+
problems.push({ code: BEHIND_SEAM_CODE, object: `pair "${pair.pair}" setup standing`, detail: `setup (${setup!.standing.px} cells) exceeds allowance ${allowance}; authored threshold ${threshold}, native seam cells, no one-cell floor or rest mask` });
|
|
686
|
+
}
|
|
687
|
+
if (input.plantMeasureIdleStanding === true && standing.max_px > allowance) {
|
|
688
|
+
problems.push({ code: BEHIND_SEAM_CODE, object: `pair "${pair.pair}" standing`, detail: `idle frame ${standing.worst?.index} (${standing.max_px} cells) exceeds allowance ${allowance}; authored threshold ${threshold}, native seam cells, no one-cell floor or rest mask` });
|
|
594
689
|
}
|
|
595
|
-
const failed = motion.status === 'FAIL' || standing.status === 'FAIL' || line.unmeasured.some(u => u.pair === pair.pair && threshold !== null);
|
|
596
|
-
const readFrames = frames.filter(f => f.motion_opened.status !== 'SKIP' &&
|
|
597
|
-
|
|
690
|
+
const failed = motion.status === 'FAIL' || setup?.standing.status === 'FAIL' || standing.status === 'FAIL' || line.unmeasured.some(u => u.pair === pair.pair && threshold !== null);
|
|
691
|
+
const readFrames = frames.filter(f => f.motion_opened.status !== 'SKIP' &&
|
|
692
|
+
!line.unmeasured.some(u => u.pair === pair.pair && u.frame === `idle frame ${f.index}`)).length;
|
|
598
693
|
line.pairs.push({ ...checkRow('BEHIND_PART_SEAMS.pairs', 'pair', failed, parts), animation: 'idle', pair: pair.pair, parts, declared: [...pair.declared], threshold, allowance, setup, frames, motion_opened: motion, standing,
|
|
599
694
|
sampled_frames: input.idle.length, read_frames: readFrames, unmeasured_frames: input.idle.length - readFrames });
|
|
600
695
|
}
|
|
601
|
-
line.status = problems.length > start ? 'FAIL' : line.pairs.length === 0 || line.pairs.some(p => p.threshold === null || p.
|
|
696
|
+
line.status = problems.length > start ? 'FAIL' : line.pairs.length === 0 || line.pairs.some(p => p.threshold === null || p.setup === null || p.setup.standing.status === 'SKIP' || p.motion_opened.status === 'SKIP') ? 'SKIP' : 'PASS';
|
|
602
697
|
if (declared.turn === true) {
|
|
603
698
|
line.turn = measureBehindTurnFrames(api, input, declared, problems);
|
|
604
699
|
if (line.turn.status === 'FAIL' || problems.length > start) line.status = 'FAIL';
|
|
@@ -611,7 +706,7 @@ export function measureBehindSeamFrames(api: BehindSeamsApi, input: BehindSeamsF
|
|
|
611
706
|
function measureBehindTurnFrames(api: BehindSeamsApi, input: BehindSeamsFramesInput, declared: BehindSeams, problems: Problem[]): BehindSeamsTurnMeasured {
|
|
612
707
|
const turn = input.turn;
|
|
613
708
|
const result: BehindSeamsTurnMeasured = { status: 'SKIP', poses: turn?.poses.map(p => p.name) ?? [], pairs: [], unmeasured: [],
|
|
614
|
-
limitations: 'independent setup-reset turn endpoints and full range corners only; no sweep, idle motion, temporal spans or alternate skins; standing and
|
|
709
|
+
limitations: 'independent setup-reset turn endpoints and full range corners only; no sweep, idle motion, temporal spans or alternate skins; standing is not measured on turn poses, and motion_opened is the turn reading' };
|
|
615
710
|
if (turn?.poser !== undefined) result.limitations += `; poser ${turn.poser}`;
|
|
616
711
|
if (turn?.sourceSkeletonSha256 !== undefined) result.limitations += `; original skeleton sha256 ${turn.sourceSkeletonSha256}`;
|
|
617
712
|
const required = declared.threshold !== undefined || declared.pairs?.some(p => p.threshold !== undefined) === true;
|
|
@@ -628,7 +723,7 @@ function measureBehindTurnFrames(api: BehindSeamsApi, input: BehindSeamsFramesIn
|
|
|
628
723
|
return { ...checkRow('BEHIND_PART_SEAMS.turn.pairs', 'pair', required, [pair.a, pair.b]), pair: pair.pair, parts: [pair.a, pair.b],
|
|
629
724
|
threshold: override?.threshold ?? declared.threshold ?? null, allowance: override?.allowance ?? declared.allowance ?? 0,
|
|
630
725
|
frames: [], sampled_poses: 0, read_poses: 0, unmeasured_poses: 0,
|
|
631
|
-
motion_opened: { status: 'SKIP', max_px: 0 }, standing: { status: 'SKIP', max_px: 0 } };
|
|
726
|
+
motion_opened: { status: 'SKIP', max_px: 0 }, standing: { status: 'SKIP', reason: TURN_STANDING_NO_ORACLE_REASON, max_px: 0 } };
|
|
632
727
|
});
|
|
633
728
|
return result;
|
|
634
729
|
}
|
|
@@ -656,24 +751,32 @@ function measureBehindTurnFrames(api: BehindSeamsApi, input: BehindSeamsFramesIn
|
|
|
656
751
|
const row = readBehindFrame(api, posedInput, pair, frame, false, stockRows.length === 1 ? stockRows[0] : undefined,
|
|
657
752
|
threshold, allowance, (where, why) => unread(pair, where, why, true), cache, pose);
|
|
658
753
|
rows.push(row); cache.clear();
|
|
659
|
-
|
|
660
|
-
object: `pair "${pair.pair}" turn ${pose.name}
|
|
754
|
+
if (row.motion_opened.status === 'FAIL') problems.push({ code: BEHIND_SEAM_CODE,
|
|
755
|
+
object: `pair "${pair.pair}" turn ${pose.name} motion_opened`, detail: `${row.motion_opened.px} native seam cells exceeds allowance ${allowance}; authored threshold ${threshold}; independent declared turn pose` });
|
|
756
|
+
if (input.plantMeasureTurnStanding === true && row.standing.status === 'FAIL') problems.push({ code: BEHIND_SEAM_CODE,
|
|
757
|
+
object: `pair "${pair.pair}" turn ${pose.name} standing`, detail: `${row.standing.px} native seam cells exceeds allowance ${allowance}; authored threshold ${threshold}; independent declared turn pose` });
|
|
661
758
|
}
|
|
662
759
|
}
|
|
663
|
-
|
|
760
|
+
// Both clauses overlap on purpose, as in idle readFrames: every path leaving motion_opened SKIP also records turn.unmeasured[].
|
|
761
|
+
const read = rows.filter(row => row.motion_opened.status !== 'SKIP' &&
|
|
664
762
|
!result.unmeasured.some(u => u.pair === pair.pair && u.frame === `turn ${row.pose}`)).length;
|
|
665
|
-
const aggregate = (kind: 'motion_opened' | 'standing'):
|
|
763
|
+
const aggregate = (kind: 'motion_opened' | 'standing'): { status: BehindSeamsCount['status']; max_px: number } => ({
|
|
666
764
|
status: rows.some(r => r[kind].status === 'FAIL') ? 'FAIL' : complete && rows.length === turn.poses.length && rows.every(r => r[kind].status === 'PASS') ? 'PASS' : 'SKIP',
|
|
667
765
|
max_px: Math.max(0, ...rows.map(r => r[kind].px)),
|
|
668
766
|
});
|
|
669
|
-
const motion = aggregate('motion_opened')
|
|
767
|
+
const motion = aggregate('motion_opened');
|
|
768
|
+
const turnStandingReason = motion.status !== 'SKIP' ? TURN_STANDING_MOTION_READ_REASON : TURN_STANDING_NO_ORACLE_REASON;
|
|
769
|
+
const rawStanding = aggregate('standing');
|
|
770
|
+
const standing: BehindSeamsTurnPair['standing'] = input.plantMeasureTurnStanding === true
|
|
771
|
+
? rawStanding
|
|
772
|
+
: { status: 'SKIP', reason: turnStandingReason, max_px: 0 };
|
|
670
773
|
result.pairs.push({ ...checkRow('BEHIND_PART_SEAMS.turn.pairs', 'pair', motion.status === 'FAIL' || standing.status === 'FAIL' || threshold !== null && read !== turn.poses.length, parts),
|
|
671
774
|
pair: pair.pair, parts, threshold, allowance, frames: rows, sampled_poses: turn.poses.length, read_poses: read, unmeasured_poses: turn.poses.length - read,
|
|
672
775
|
motion_opened: motion, standing });
|
|
673
776
|
}
|
|
674
777
|
if (input.pairs.length === 0) unread(null, 'turn selection', 'no selected seam pair; turn boundary population is unavailable', required);
|
|
675
778
|
result.status = result.pairs.some(p => p.motion_opened.status === 'FAIL' || p.standing.status === 'FAIL') || mandatoryUnread ? 'FAIL'
|
|
676
|
-
: result.pairs.length === 0 || result.pairs.some(p => p.motion_opened.status === 'SKIP'
|
|
779
|
+
: result.pairs.length === 0 || result.pairs.some(p => p.motion_opened.status === 'SKIP') ? 'SKIP' : 'PASS';
|
|
677
780
|
return result;
|
|
678
781
|
}
|
|
679
782
|
|
|
@@ -896,7 +999,23 @@ export function measureBehindSeams(api: typeof import('@rig-c/core/render-shared
|
|
|
896
999
|
if (input.stockDir === null || sampled.setup === null) throw new Error('existing full stock seam render/setup is unavailable');
|
|
897
1000
|
stock = stockOf(input.stockDir, input.pairs.filter(p => p.unread === undefined), input.fps, sampled.setup, sampled.idle, sampled.rest);
|
|
898
1001
|
} catch (e) { stockError = e instanceof Error ? e.message : String(e); }
|
|
899
|
-
const
|
|
1002
|
+
const pages = new Map(candidate.pages);
|
|
1003
|
+
let recomposite: Frame | null = null;
|
|
1004
|
+
if (input.recomposite !== undefined && input.recomposite !== null) {
|
|
1005
|
+
const { stage, raster } = input.recomposite;
|
|
1006
|
+
if (raster.width !== stage.width || raster.height !== stage.height) {
|
|
1007
|
+
return fail(`parts.json rig_size (${raster.width}x${raster.height}) differs from rig stage (${stage.width}x${stage.height}); setup standing does not resample the parts' recomposite`);
|
|
1008
|
+
}
|
|
1009
|
+
const page = new Plate(raster.width, raster.height);
|
|
1010
|
+
page.data.set(raster.data);
|
|
1011
|
+
const pageName = 'behind-seams:recomposite';
|
|
1012
|
+
pages.set(pageName, page);
|
|
1013
|
+
const wx0 = stage.x, wx1 = stage.x + stage.width, wy0 = stage.y, wy1 = stage.y + stage.height;
|
|
1014
|
+
recomposite = { index: 0, time: 0, pieces: [{ kind: 'region', slot: 'recomposite', page: pageName, tint: [1, 1, 1, 1],
|
|
1015
|
+
world: [wx1, wy1, wx0, wy1, wx0, wy0, wx1, wy0], uvs: [1, 0, 0, 0, 0, 1, 1, 1] }] };
|
|
1016
|
+
}
|
|
1017
|
+
const line = measureBehindSeamFrames(api, { ...sampled, pairs: input.pairs, pages, stock, fps: input.fps,
|
|
1018
|
+
recomposite,
|
|
900
1019
|
...(declared.turn === true ? { turn: sampleBehindTurn(api, input, candidate, sampled.setup, acceptedPoser) } : {}) }, declared, problems);
|
|
901
1020
|
if (stockError !== null) {
|
|
902
1021
|
line.status = 'FAIL';
|
|
@@ -915,14 +1034,17 @@ export function behindSeamLines(line: BehindSeamsMeasured | null): string[] {
|
|
|
915
1034
|
const setup = p.setup;
|
|
916
1035
|
const summary = (kind: 'motion_opened' | 'standing'): string => {
|
|
917
1036
|
const r = p[kind], w = r.worst;
|
|
1037
|
+
if (r.reason !== undefined) {
|
|
1038
|
+
return `${BEHIND_SEAM_LINE}: pair "${p.pair}" ${kind} ${r.status} — ${r.reason}; threshold ${p.threshold === null ? 'undeclared' : p.threshold}, allowance ${p.allowance}`;
|
|
1039
|
+
}
|
|
918
1040
|
return `${BEHIND_SEAM_LINE}: pair "${p.pair}" ${kind} ${r.status} — ${r.hit_frames}/${p.frames.length} idle hit frames, sampled/read/unmeasured ${p.sampled_frames ?? p.frames.length}/${p.read_frames ?? 0}/${p.unmeasured_frames ?? 0}, max_px ${r.max_px}, max_run ${r.max_run.frames} frames (${r.max_run.seconds} s), max_spatial_run_cells ${r.max_spatial_run_cells} (${r.max_spatial_run_world} world units), earliest worst ${w === null ? 'none' : `frame ${w.index} t ${w.time}, cell ${w.cell}, box [${w.box.join(', ')}]`}; threshold ${p.threshold === null ? 'undeclared' : p.threshold}, allowance ${p.allowance}`;
|
|
919
1041
|
};
|
|
920
|
-
const setupStanding = setup === null ? '' : setup.standing.px > 0 && setup.standing.status === 'SKIP' ? `${setup.standing.px} cells` : `${setup.standing.status}, ${setup.standing.px} cells`;
|
|
1042
|
+
const setupStanding = setup === null ? '' : setup.standing.reason !== undefined ? `${setup.standing.status} (${setup.standing.reason}), ${setup.standing.px} cells` : setup.standing.px > 0 && setup.standing.status === 'SKIP' ? `${setup.standing.px} cells` : `${setup.standing.status}, ${setup.standing.px} cells`;
|
|
921
1043
|
return [summary('motion_opened'), summary('standing'), `${BEHIND_SEAM_LINE}: pair "${p.pair}" setup ${setup === null ? 'SKIP — HOLE: setup not read' : `standing ${setupStanding}; motion_opened ${setup.motion_opened.status}, ${setup.motion_opened.px} cells; behind [${setup.behind_slots.join(', ')}]`}`];
|
|
922
1044
|
}),
|
|
923
1045
|
...(line.turn === undefined ? [] : [
|
|
924
1046
|
`${BEHIND_SEAM_LINE}: turn ${line.turn.status} — ${line.turn.poses.length} preselected endpoint/corner pose(s); ${line.turn.limitations}`,
|
|
925
|
-
...line.turn.pairs.flatMap(p => p.frames.map(f => `${BEHIND_SEAM_LINE}: pair "${p.pair}" turn ${f.pose} — motion_opened ${f.motion_opened.status}, ${f.motion_opened.px} cells; standing ${f.standing.status}, ${f.standing.px} cells; threshold ${p.threshold}, allowance ${p.allowance}`)),
|
|
1047
|
+
...line.turn.pairs.flatMap(p => p.frames.map(f => `${BEHIND_SEAM_LINE}: pair "${p.pair}" turn ${f.pose} — motion_opened ${f.motion_opened.status}, ${f.motion_opened.px} cells; standing ${f.standing.reason !== undefined ? `${f.standing.status} (${f.standing.reason})` : f.standing.status}, ${f.standing.px} cells; threshold ${p.threshold}, allowance ${p.allowance}`)),
|
|
926
1048
|
...line.turn.unmeasured.map(u => `${BEHIND_SEAM_LINE}: ${u.pair === null ? 'rig' : `pair "${u.pair}"`} ${u.frame} SKIP — ${u.reason}`),
|
|
927
1049
|
]),
|
|
928
1050
|
...line.unmeasured.map(u => {
|
package/src/build.ts
CHANGED
|
@@ -504,8 +504,8 @@ function sourceCoverSet(result: AssembleResult, set: string | null, painting: st
|
|
|
504
504
|
|
|
505
505
|
/** Read, assemble, and write only after every refusal has had its chance. Throws a PartsError on a refusal, having written nothing. */
|
|
506
506
|
export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs, log: Log): AssembleResult {
|
|
507
|
-
//
|
|
508
|
-
//
|
|
507
|
+
// A --requirements file that reaches assembly must be the one config.requirements
|
|
508
|
+
// names (#1418), so the assembly reading sees what assemble read.
|
|
509
509
|
const requirementsFile = input.requirements === undefined ? null : readRequirements(input.requirements);
|
|
510
510
|
const materialAsked = requirementsFile?.cut_material !== undefined;
|
|
511
511
|
// Issue #944: the pinhole bar is measured only when the requirements file declares it required.
|
|
@@ -517,8 +517,19 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
517
517
|
const cfg = { ...projection.config, seethrough: projection.config.seethrough! };
|
|
518
518
|
const supportDeclarations = JSON.stringify(cfg.assemble.cuts ?? []);
|
|
519
519
|
const { seam, project } = effectiveAssemblyRules(cfg.assemble, input);
|
|
520
|
-
const
|
|
520
|
+
const busyVisible = cfg.assemble.ground === 'busy' && project === 'visible';
|
|
521
|
+
const regionTake = (cfg.assemble.take ?? []).some(take => 'seed' in take);
|
|
522
|
+
// Issue #1418: a requirements file whose content reaches assembly must be the one config.requirements names,
|
|
523
|
+
// because assembly_config reads only config.requirements.
|
|
524
|
+
refuseUnnamedAssemblyRequirements(input.requirements, cfg.requirements, input.config, [
|
|
525
|
+
...(regionTake ? ['setup_painting.rgb_tolerance (a region take)'] : []),
|
|
526
|
+
...(busyVisible && requirementsFile?.setup_painting?.figure_mask !== undefined ? ['setup_painting.figure_mask (busy-visible)'] : []),
|
|
527
|
+
]);
|
|
528
|
+
// Where requirements reach assembly, assemble reads them as build does: config.requirements, or the flag when the
|
|
529
|
+
// config declares none, the two being one file when both are given (buildRequirements). Elsewhere nothing here reads them.
|
|
530
|
+
const requirements = busyVisible || regionTake
|
|
521
531
|
? buildRequirements(input.requirements, cfg.requirements, input.config) : null;
|
|
532
|
+
const effectiveSetup = requirements === null ? undefined : readRequirements(requirements.read).setup_painting;
|
|
522
533
|
const src = readSource(input.source);
|
|
523
534
|
const read = readRuns(input.full, input.head);
|
|
524
535
|
// Issue #946: every declared receipt is held to its file, and under `required` every edited image needs one, before anything is assembled.
|
|
@@ -527,11 +538,11 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
527
538
|
// Issue #947: under `trace_parts`, a shape drawn in the config through a part's pixels is refused with them.
|
|
528
539
|
refuseIfAny([...receipts.problems, ...missingReceipts(receipts, [...editedRunImages(read), ...editedConfigImages(input.config, cfg.assemble.cuts ?? [], cfg.limbs)]), ...untracedPartSources(cfg)]);
|
|
529
540
|
const takenRuns = applyTakenLayers(read, src, cfg, input.config);
|
|
530
|
-
const runs = applyTakenRegions(takenRuns, src, cfg, input.config,
|
|
541
|
+
const runs = applyTakenRegions(takenRuns, src, cfg, input.config, effectiveSetup, receipts, input.source, requirements?.read);
|
|
531
542
|
for (const note of runs.notes) log(note.startsWith('WARN ') ? note : `note: ${note}`);
|
|
532
543
|
const fields = projectedStageFields(cfg, runs.single ? { w: src.width, h: src.height } : null);
|
|
533
544
|
const setupPainting = requirements === null || fields.ground !== 'busy' || project !== 'visible' ? undefined
|
|
534
|
-
:
|
|
545
|
+
: effectiveSetup;
|
|
535
546
|
const figureSupport = setupPainting === undefined ? undefined
|
|
536
547
|
: readSetupFigureMask(setupPainting, requirements!.read, src, Math.trunc(src.width * fields.rigScale), Math.trunc(src.height * fields.rigScale));
|
|
537
548
|
const rigSize: [number, number] = [Math.trunc(src.width * fields.rigScale), Math.trunc(src.height * fields.rigScale)];
|
|
@@ -2799,11 +2810,41 @@ export function buildRequirements(flag: string | undefined, declared: string | u
|
|
|
2799
2810
|
{
|
|
2800
2811
|
code: 'BUILD_REQUIREMENTS_CONFLICT',
|
|
2801
2812
|
object: `--requirements ${flag} and config.requirements "${declared}"`,
|
|
2802
|
-
detail: `the flag names ${resolve(flag)} (${shown(flagDigest)}) and the config declares ${fromConfig} (${shown(configDigest)})
|
|
2813
|
+
detail: `the flag names ${resolve(flag)} (${shown(flagDigest)}) and the config declares ${fromConfig} (${shown(configDigest)}). assemble and build read one requirements file, the one config.requirements names, so the flag must name the same file (the same resolved file, or a file of the same bytes) — drop the flag to read the config's file, or point config.requirements at the flag's`,
|
|
2803
2814
|
},
|
|
2804
2815
|
]);
|
|
2805
2816
|
}
|
|
2806
2817
|
|
|
2818
|
+
/**
|
|
2819
|
+
* Issue #1418: `assemble` and `build` read a region take's tolerance and the
|
|
2820
|
+
* busy-visible figure mask from the `--requirements` file, while
|
|
2821
|
+
* `assembly_config` reads `config.requirements` only. So when `reaching` names
|
|
2822
|
+
* a field of that file that assembly uses, the flag must name the file the
|
|
2823
|
+
* config declares: the same file once resolved (the flag against the current
|
|
2824
|
+
* directory, the declaration against the config's directory), or a file of the
|
|
2825
|
+
* same bytes, the rule {@link buildRequirements} holds. With no declaration it
|
|
2826
|
+
* is `ASSEMBLE_REQUIREMENTS_UNDECLARED`; two different files are
|
|
2827
|
+
* `BUILD_REQUIREMENTS_CONFLICT`, naming the fields. A flag none of whose
|
|
2828
|
+
* content reaches assembly is not judged here.
|
|
2829
|
+
*/
|
|
2830
|
+
export function refuseUnnamedAssemblyRequirements(flag: string | undefined, declared: string | undefined, configPath: string, reaching: readonly string[]): void {
|
|
2831
|
+
if (flag === undefined || reaching.length === 0) return;
|
|
2832
|
+
const fields = reaching.join(' and ');
|
|
2833
|
+
if (declared === undefined) {
|
|
2834
|
+
const path = resolve(flag);
|
|
2835
|
+
const digest = existsSync(path) && statSync(path).isFile() ? `sha256 ${createHash('sha256').update(readFileSync(path)).digest('hex').slice(0, 16)}` : 'no such file';
|
|
2836
|
+
throw new PartsError([{
|
|
2837
|
+
code: 'ASSEMBLE_REQUIREMENTS_UNDECLARED',
|
|
2838
|
+
object: `--requirements ${flag}`,
|
|
2839
|
+
detail: `${path} (${digest}) gives assembly ${fields}, and config.requirements is absent; assembly_config reads only config.requirements, so a file that reaches assembly must be named there — add "requirements": ${JSON.stringify(relative(dirname(resolve(configPath)), path).split(sep).join('/'))} to ${configPath}`,
|
|
2840
|
+
}]);
|
|
2841
|
+
}
|
|
2842
|
+
try { buildRequirements(flag, declared, configPath); } catch (error) {
|
|
2843
|
+
if (!(error instanceof PartsError)) throw error;
|
|
2844
|
+
throw new PartsError(error.problems.map(problem => ({ ...problem, detail: `${problem.detail}; the flag's file gives assembly ${fields}` })));
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2807
2848
|
/** The `build` refusal of a `check` flag whose value or report build supplies itself ({@link CHECK_FLAGS_IN_BUILD}), or null for any other flag. */
|
|
2808
2849
|
export function suppliedCheckFlag(flag: string): string | null {
|
|
2809
2850
|
const row = Object.hasOwn(CHECK_FLAGS_IN_BUILD, flag) ? CHECK_FLAGS_IN_BUILD[flag] : undefined;
|
package/src/check.ts
CHANGED
|
@@ -7676,8 +7676,10 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
7676
7676
|
}
|
|
7677
7677
|
}
|
|
7678
7678
|
}
|
|
7679
|
+
const behindSlotOrder = (Array.isArray(inp.rig.slots) ? inp.rig.slots : []).filter(isRecord).map((sl) => String(sl.name));
|
|
7679
7680
|
behindSeams = measureBehindSeams(officialRenderer(), {
|
|
7680
7681
|
build: buildDir, rig: inp.rig, pairs: behindPairs, stockDir: behindStockDir, fps: IDLE_FPS,
|
|
7682
|
+
recomposite: inp.parts === null ? null : { stage: inp.stage, raster: flatComposite(inp.parts, inp.partsDir, [255, 255, 255, 255], behindSlotOrder) },
|
|
7681
7683
|
...(turnBuild === undefined ? {} : { turnBuild }),
|
|
7682
7684
|
...(behindUnsupported.length === 0 ? {} : { unsupported: behindUnsupported.join('; ') }),
|
|
7683
7685
|
}, behindDeclared, problems);
|