@rig-c/parts 2.50.0 → 2.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.ts +130 -14
- package/docs/AUTHORING.md +163 -56
- package/docs/DEPTH.md +22 -2
- package/docs/STABILITY.md +81 -24
- package/package.json +3 -2
- package/src/build.ts +2 -0
- package/src/bustlandmarks.ts +64 -8
- package/src/check.ts +55 -26
- package/src/checkrow.ts +1 -0
- package/src/cloth-targets.json +10 -0
- package/src/config.ts +50 -43
- package/src/configwrite.ts +70 -12
- package/src/depthworkflow.ts +38 -4
- package/src/editedparts.ts +43 -1
- package/src/instruments.ts +2 -2
- package/src/outputpaths.ts +24 -0
- package/src/parts.ts +35 -2
- package/src/physicscontrib.ts +311 -0
- package/src/propose.ts +30 -22
- package/src/rig.ts +13 -0
package/src/checkrow.ts
CHANGED
|
@@ -46,6 +46,7 @@ export const CHECK_ROW_PATHS = {
|
|
|
46
46
|
'PART_SUPPORT_REPORT.pairs': ['PART_SUPPORT_REPORT.pairs'],
|
|
47
47
|
'PART_SUPPORT_REPORT.raw_pairs': ['PART_SUPPORT_REPORT.raw_pairs'],
|
|
48
48
|
'PART_SUPPORT_REPORT.unowned.regions': ['PART_SUPPORT_REPORT.unowned.regions'],
|
|
49
|
+
'PHYSICS_CONTRIBUTES.rows': ['PHYSICS_CONTRIBUTES.rows'],
|
|
49
50
|
'SEAM_OVER_MOTION.pairs': ['SEAM_OVER_MOTION.pairs'],
|
|
50
51
|
'SEAM_OVER_MOTION.required.pairs': ['SEAM_OVER_MOTION.required.pairs'],
|
|
51
52
|
'SEAM_OVER_MOTION.required.pairs[].open_frames': ['SEAM_OVER_MOTION.required.pairs[].open_frames'],
|
package/src/config.ts
CHANGED
|
@@ -3792,6 +3792,54 @@ function checkRibs(c: Check, at: string, m: Record<string, Json>, chains: Map<st
|
|
|
3792
3792
|
}
|
|
3793
3793
|
}
|
|
3794
3794
|
|
|
3795
|
+
/**
|
|
3796
|
+
* The `CONFIG_BUST_CLEARANCE` rule over three landmarks and the shape's `alpha` and `clearance` (issue #475): the
|
|
3797
|
+
* refusal's detail, or null when the points pass. The loader reads it for a config's `contour.bust`, and issue #1441's
|
|
3798
|
+
* callers read it with the effective shape (`effectiveBustShape`, src/bustlandmarks.ts) before that shape is written.
|
|
3799
|
+
*/
|
|
3800
|
+
export function bustClearanceDetail(points: { apex_r: Point; apex_l: Point; cleavage: Point }, alpha: number, clearance: number): string | null {
|
|
3801
|
+
const [rx, ry] = points.apex_r;
|
|
3802
|
+
const [lx, ly] = points.apex_l;
|
|
3803
|
+
const [kx, ky] = points.cleavage;
|
|
3804
|
+
const D = edgeLength(lx - rx, ly - ry);
|
|
3805
|
+
const dR = edgeLength(kx - rx, ky - ry);
|
|
3806
|
+
const dL = edgeLength(kx - lx, ky - ly);
|
|
3807
|
+
const RR = Math.round(dR - clearance);
|
|
3808
|
+
const RL = Math.round(dL - clearance);
|
|
3809
|
+
const rR = Math.round(alpha * RR);
|
|
3810
|
+
const rL = Math.round(alpha * RL);
|
|
3811
|
+
const bandR = RR - rR;
|
|
3812
|
+
const bandL = RL - rL;
|
|
3813
|
+
if (clearance <= 0 || RR + RL >= D || rR <= 0 || rL <= 0 || bandR < 0 || bandL < 0) {
|
|
3814
|
+
// Invalid coordinates already have named problems, but c.point accepts any finite pair.
|
|
3815
|
+
// Restrict only this diagnostic search to onGrid's existing domain, not the refusal rule.
|
|
3816
|
+
let remedy = `clearance hint unavailable: correct the CONFIG_FIELD_TYPE landmark coordinates to the 1/${GRID} px grid within ±${MAX_SIDE} px first`;
|
|
3817
|
+
if ([rx, ry, lx, ly, kx, ky].every((n) => Number.isInteger(n * GRID) && Math.abs(n) <= MAX_SIDE)) {
|
|
3818
|
+
let low = 1;
|
|
3819
|
+
let high = Math.ceil(Math.max(dR, dL) * 100) + 100;
|
|
3820
|
+
// The coordinate domain bounds high below 2^24; binary search needs at most 24 steps.
|
|
3821
|
+
const maxSteps = Math.ceil(Math.log2(high));
|
|
3822
|
+
for (let step = 0; low < high && step < maxSteps; step++) {
|
|
3823
|
+
const mid = low + Math.floor((high - low) / 2);
|
|
3824
|
+
if (Math.round(dR - mid / 100) + Math.round(dL - mid / 100) < D) high = mid;
|
|
3825
|
+
else low = mid + 1;
|
|
3826
|
+
}
|
|
3827
|
+
if (low === high) {
|
|
3828
|
+
const candidate = low / 100;
|
|
3829
|
+
const nextRR = Math.round(dR - candidate);
|
|
3830
|
+
const nextRL = Math.round(dL - candidate);
|
|
3831
|
+
const nextR = Math.round(alpha * nextRR);
|
|
3832
|
+
const nextL = Math.round(alpha * nextRL);
|
|
3833
|
+
remedy = nextRR + nextRL < D && nextR > 0 && nextL > 0 && nextRR - nextR >= 0 && nextRL - nextL >= 0
|
|
3834
|
+
? `the first passing clearance in 0.01 px steps is ${candidate} px for these landmarks and alpha; set clearance to that value`
|
|
3835
|
+
: 'no clearance in 0.01 px steps meets all these rounded-radius checks; move cleavage or the apices, or change alpha, and retry';
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
return `is ${clearance} (giving R_r = ${RR}, R_l = ${RL}, R_r + R_l = ${RR + RL} px against apex distance D = ${pyRound(D, 2)} px, r_r = ${rR}, band_r = ${bandR}, r_l = ${rL}, band_l = ${bandL}); a clearance > 0 with R_r + R_l < D and positive core radii and non-negative bands is required; ${remedy}`;
|
|
3839
|
+
}
|
|
3840
|
+
return null;
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3795
3843
|
/**
|
|
3796
3844
|
* `meshes.<part>.contour` (issue #84). `tolerance`, `margin` and `spacing` are
|
|
3797
3845
|
* required — nothing is defaulted; `maxEdge`, `budget`, `stray` and `regions` are
|
|
@@ -3902,49 +3950,8 @@ function checkContour(c: Check, at: string, v: Json, bones: Set<string>): void {
|
|
|
3902
3950
|
}
|
|
3903
3951
|
}
|
|
3904
3952
|
if (ptsOk && alphaOk && clearanceOk) {
|
|
3905
|
-
const
|
|
3906
|
-
|
|
3907
|
-
const [kx, ky] = b.cleavage as Point;
|
|
3908
|
-
const D = edgeLength(lx - rx, ly - ry);
|
|
3909
|
-
const dR = edgeLength(kx - rx, ky - ry);
|
|
3910
|
-
const dL = edgeLength(kx - lx, ky - ly);
|
|
3911
|
-
const RR = Math.round(dR - clearance);
|
|
3912
|
-
const RL = Math.round(dL - clearance);
|
|
3913
|
-
const rR = Math.round(alpha * RR);
|
|
3914
|
-
const rL = Math.round(alpha * RL);
|
|
3915
|
-
const bandR = RR - rR;
|
|
3916
|
-
const bandL = RL - rL;
|
|
3917
|
-
if (clearance <= 0 || RR + RL >= D || rR <= 0 || rL <= 0 || bandR < 0 || bandL < 0) {
|
|
3918
|
-
// Invalid coordinates already have named problems, but c.point accepts any finite pair.
|
|
3919
|
-
// Restrict only this diagnostic search to onGrid's existing domain, not the refusal rule.
|
|
3920
|
-
let remedy = `clearance hint unavailable: correct the CONFIG_FIELD_TYPE landmark coordinates to the 1/${GRID} px grid within ±${MAX_SIDE} px first`;
|
|
3921
|
-
if ([rx, ry, lx, ly, kx, ky].every((n) => Number.isInteger(n * GRID) && Math.abs(n) <= MAX_SIDE)) {
|
|
3922
|
-
let low = 1;
|
|
3923
|
-
let high = Math.ceil(Math.max(dR, dL) * 100) + 100;
|
|
3924
|
-
// The coordinate domain bounds high below 2^24; binary search needs at most 24 steps.
|
|
3925
|
-
const maxSteps = Math.ceil(Math.log2(high));
|
|
3926
|
-
for (let step = 0; low < high && step < maxSteps; step++) {
|
|
3927
|
-
const mid = low + Math.floor((high - low) / 2);
|
|
3928
|
-
if (Math.round(dR - mid / 100) + Math.round(dL - mid / 100) < D) high = mid;
|
|
3929
|
-
else low = mid + 1;
|
|
3930
|
-
}
|
|
3931
|
-
if (low === high) {
|
|
3932
|
-
const candidate = low / 100;
|
|
3933
|
-
const nextRR = Math.round(dR - candidate);
|
|
3934
|
-
const nextRL = Math.round(dL - candidate);
|
|
3935
|
-
const nextR = Math.round(alpha * nextRR);
|
|
3936
|
-
const nextL = Math.round(alpha * nextRL);
|
|
3937
|
-
remedy = nextRR + nextRL < D && nextR > 0 && nextL > 0 && nextRR - nextR >= 0 && nextRL - nextL >= 0
|
|
3938
|
-
? `the first passing clearance in 0.01 px steps is ${candidate} px for these landmarks and alpha; set clearance to that value`
|
|
3939
|
-
: 'no clearance in 0.01 px steps meets all these rounded-radius checks; move cleavage or the apices, or change alpha, and retry';
|
|
3940
|
-
}
|
|
3941
|
-
}
|
|
3942
|
-
c.fail(
|
|
3943
|
-
'CONFIG_BUST_CLEARANCE',
|
|
3944
|
-
`${bat}.clearance`,
|
|
3945
|
-
`is ${clearance} (giving R_r = ${RR}, R_l = ${RL}, R_r + R_l = ${RR + RL} px against apex distance D = ${pyRound(D, 2)} px, r_r = ${rR}, band_r = ${bandR}, r_l = ${rL}, band_l = ${bandL}); a clearance > 0 with R_r + R_l < D and positive core radii and non-negative bands is required; ${remedy}`,
|
|
3946
|
-
);
|
|
3947
|
-
}
|
|
3953
|
+
const detail = bustClearanceDetail({ apex_r: b.apex_r as Point, apex_l: b.apex_l as Point, cleavage: b.cleavage as Point }, alpha, clearance);
|
|
3954
|
+
if (detail !== null) c.fail('CONFIG_BUST_CLEARANCE', `${bat}.clearance`, detail);
|
|
3948
3955
|
}
|
|
3949
3956
|
}
|
|
3950
3957
|
}
|
package/src/configwrite.ts
CHANGED
|
@@ -33,11 +33,39 @@ export type ConfigWritePatch =
|
|
|
33
33
|
| { kind: 'proposal-missing'; proposal: Proposal; parts: ReadonlyArray<{ name: string; from: string }> }
|
|
34
34
|
/** `bust-landmarks --write-config` (issue #1382): set or remove named shape fields of one part's existing
|
|
35
35
|
* `meshes.<part>.contour.bust`; a field with no value is removed, every other key is kept where it is. */
|
|
36
|
-
| { kind: 'bust-shape'; part: string; fields: ReadonlyArray<{ key: BustShapeKey; value?: number | string }> }
|
|
36
|
+
| { kind: 'bust-shape'; part: string; fields: ReadonlyArray<{ key: BustShapeKey; value?: number | string }> }
|
|
37
|
+
/** The chest-only write on a sampled body-turn neck config (issue #1436): one carrier's `contour.bust` points (null
|
|
38
|
+
* removes the bust) and the `boob_r` / `boob_l` bones, every other entry kept where it is. The carrier's previous
|
|
39
|
+
* shape fields stay, and a pending reviewed shape takes their place, in the shorthand's key order. */
|
|
40
|
+
| { kind: 'bust'; part: string; bust: { apex_r: readonly number[]; apex_l: readonly number[]; cleavage: readonly number[] } | null; bones: ReadonlyArray<{ name: string; parent: string; at: readonly number[] }>; bustShape?: PendingBustShape };
|
|
37
41
|
/** The `contour.bust` fields the landmarks file does not carry, the only ones a `bust-shape` patch writes. */
|
|
38
42
|
export type BustShapeKey = (typeof BUST_SHAPE_FIELDS)[number];
|
|
39
43
|
/** A reviewed shape `bust-landmarks` left pending in its sidecar (issue #1382): `propose --write-config` writes it
|
|
40
44
|
* onto the drafted chest carrier's `contour.bust`, after the three points, in the shorthand's key order. */
|
|
45
|
+
/**
|
|
46
|
+
* The parts `--only-missing` (issue #671) leaves alone, each with what attaches it in the destination config: a
|
|
47
|
+
* `meshes` or `regions` entry, a limb's segment source, or an assemble patch. The `proposal-missing` write skips
|
|
48
|
+
* exactly these, and `propose` reads the same map (issue #1441's review) so a carrier it skips is not checked
|
|
49
|
+
* against the shape its config entry declares.
|
|
50
|
+
*/
|
|
51
|
+
export function onlyMissingAttachments(config: unknown): Map<string, string> {
|
|
52
|
+
const attachments = new Map<string, string>();
|
|
53
|
+
if (!object(config)) return attachments;
|
|
54
|
+
for (const section of ['meshes', 'regions'] as const) {
|
|
55
|
+
const entries = config[section];
|
|
56
|
+
if (object(entries)) for (const part of Object.keys(entries)) attachments.set(part, field(`config.${section}`, part));
|
|
57
|
+
}
|
|
58
|
+
if (object(config.limbs)) for (const [limb, spec] of Object.entries(config.limbs)) {
|
|
59
|
+
if (object(spec) && Array.isArray(spec.segments)) for (const segment of spec.segments) {
|
|
60
|
+
if (object(segment) && typeof segment.from === 'string') attachments.set(segment.from, `${field('config.limbs', limb)} (source cut into its segment parts)`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (object(config.assemble) && Array.isArray(config.assemble.patches)) for (const patch of config.assemble.patches) {
|
|
64
|
+
if (object(patch) && typeof patch.name === 'string') attachments.set(patch.name, 'config.assemble.patches (a patch is always a region)');
|
|
65
|
+
}
|
|
66
|
+
return attachments;
|
|
67
|
+
}
|
|
68
|
+
|
|
41
69
|
export interface PendingBustShape { part: string; fields: Partial<Record<BustShapeKey, number | string>> }
|
|
42
70
|
export interface ConfigWriteChange {
|
|
43
71
|
path: string;
|
|
@@ -200,19 +228,10 @@ export function mergeConfigProposal(raw: unknown, patch: ConfigWritePatch, recei
|
|
|
200
228
|
case 'proposal-missing': {
|
|
201
229
|
// Read attachment ownership from the destination, even without --keypoints. A limb's source is consumed;
|
|
202
230
|
// the loader requires regions for its segment parts instead. Patches are always regions.
|
|
203
|
-
const attachments = new Map<string, string>();
|
|
204
231
|
for (const section of ['meshes', 'regions'] as const) {
|
|
205
232
|
if (config[section] !== undefined && !object(config[section])) return refuse(`config.${section}`, 'is not an object; an object of part entries is required before an entry is added to it');
|
|
206
|
-
if (object(config[section])) for (const part of Object.keys(config[section])) attachments.set(part, field(`config.${section}`, part));
|
|
207
|
-
}
|
|
208
|
-
if (object(config.limbs)) for (const [limb, spec] of Object.entries(config.limbs)) {
|
|
209
|
-
if (object(spec) && Array.isArray(spec.segments)) for (const segment of spec.segments) {
|
|
210
|
-
if (object(segment) && typeof segment.from === 'string') attachments.set(segment.from, `${field('config.limbs', limb)} (source cut into its segment parts)`);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (object(config.assemble) && Array.isArray(config.assemble.patches)) for (const patch of config.assemble.patches) {
|
|
214
|
-
if (object(patch) && typeof patch.name === 'string') attachments.set(patch.name, 'config.assemble.patches (a patch is always a region)');
|
|
215
233
|
}
|
|
234
|
+
const attachments = onlyMissingAttachments(config);
|
|
216
235
|
// This mode appends diagnostics to the proposal's existing notes output, never to the destination config.
|
|
217
236
|
const note = (part: string, why: string): void => {
|
|
218
237
|
const line = `--only-missing: skipped part "${part}" — ${why}; no entry or plan row added`;
|
|
@@ -292,7 +311,46 @@ export function mergeConfigProposal(raw: unknown, patch: ConfigWritePatch, recei
|
|
|
292
311
|
if (!equal(bust as ConfigObject, next)) edits.push({ path: ['meshes', patch.part, 'contour', 'bust'], value: next });
|
|
293
312
|
break;
|
|
294
313
|
}
|
|
295
|
-
|
|
314
|
+
case 'bust': {
|
|
315
|
+
const at = `${field('config.meshes', patch.part)}.contour`;
|
|
316
|
+
const meshes = config.meshes;
|
|
317
|
+
const mesh = object(meshes) && own(meshes, patch.part) ? meshes[patch.part] : undefined;
|
|
318
|
+
const contour = object(mesh) ? mesh.contour : undefined;
|
|
319
|
+
if (!object(contour)) return refuse(at, 'is absent or not an object; the chest carrier must already be a contour mesh before its contour.bust is written');
|
|
320
|
+
if (!Array.isArray(config.bones)) return refuse('config.bones', 'is not an array; the bones list is required before the bust bones are written');
|
|
321
|
+
const prevBust = object(contour.bust) ? contour.bust : null;
|
|
322
|
+
if (patch.bust === null) delete contour.bust;
|
|
323
|
+
else {
|
|
324
|
+
const merged: ConfigObject = {};
|
|
325
|
+
for (const k of BUST_LANDMARK_FIELDS) merged[k] = clone(patch.bust[k], `bust.${k}`);
|
|
326
|
+
const pending = patch.bustShape?.part === patch.part ? patch.bustShape.fields : undefined;
|
|
327
|
+
for (const k of BUST_SHAPE_FIELDS) {
|
|
328
|
+
const value = pending?.[k];
|
|
329
|
+
if (value !== undefined) merged[k] = value;
|
|
330
|
+
else if (prevBust !== null && own(prevBust, k)) merged[k] = prevBust[k];
|
|
331
|
+
}
|
|
332
|
+
contour.bust = merged;
|
|
333
|
+
}
|
|
334
|
+
// The bust bones: replaced where they stand, appended where new (the proposer's order), removed with the bust.
|
|
335
|
+
const bones = config.bones;
|
|
336
|
+
const index = (name: string): number => bones.findIndex((b) => object(b) && b.name === name);
|
|
337
|
+
for (const name of ['boob_r', 'boob_l']) {
|
|
338
|
+
if (patch.bones.some((b) => b.name === name)) continue;
|
|
339
|
+
const i = index(name);
|
|
340
|
+
if (i >= 0) bones.splice(i, 1);
|
|
341
|
+
}
|
|
342
|
+
for (const bone of patch.bones) {
|
|
343
|
+
const value = clone(bone, `bust.bones.${bone.name}`);
|
|
344
|
+
const i = index(bone.name);
|
|
345
|
+
if (i >= 0) bones[i] = value;
|
|
346
|
+
else bones.push(value);
|
|
347
|
+
}
|
|
348
|
+
// This patch owns the bones list's two entries and the carrier's contour.bust, never another section.
|
|
349
|
+
if (!equal(before.bones, config.bones)) edits.push({ path: ['bones'], value: config.bones });
|
|
350
|
+
if (!equal(((before.meshes as ConfigObject)[patch.part] as ConfigObject).contour, contour)) edits.push({ path: ['meshes', patch.part, 'contour'], value: contour });
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
default: return refuse('write-config', 'has no supported operation; edited-part-receipt, neck-unit, head-box, assemble-plan, proposal, proposal-missing, bust-shape or bust is required');
|
|
296
354
|
}
|
|
297
355
|
return { config, changes: changes(before, config), edits };
|
|
298
356
|
}
|
package/src/depthworkflow.ts
CHANGED
|
@@ -6,6 +6,7 @@ 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
8
|
import { refuseStaleAssembly } from './assembly-reading.ts';
|
|
9
|
+
import { PartsError, type Problem } from './errors.ts';
|
|
9
10
|
import { loadConfigAndAnimations, parseConfig } from './config.ts';
|
|
10
11
|
import { relocateConfigReferences } from './configrelocation.ts';
|
|
11
12
|
import { depthReading, readSourceDepth } from './depthsheets.ts';
|
|
@@ -213,8 +214,25 @@ function mapBinding(mapPath: string, bytes: Uint8Array, part: PreparedPart): str
|
|
|
213
214
|
if (r.inputSha256 !== part.inputSha256) return refuse(`inference input sha found ${r.inputSha256}; required ${part.inputSha256}`);
|
|
214
215
|
return undefined;
|
|
215
216
|
}
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
/** `depth-apply --groups` (#1449): the recipe's groups the run applies, in the recipe's declaration order.
|
|
218
|
+
* Every problem in the list is collected and refused at once; absent, every group applies. */
|
|
219
|
+
function groupSelection(recipe: DepthRecipe, groups: readonly string[] | undefined): string[] | undefined {
|
|
220
|
+
if (groups === undefined) return undefined;
|
|
221
|
+
const declared = Object.keys(recipe.groups), has = `the recipe's groups are ${declared.map(g => JSON.stringify(g)).join(', ')}`;
|
|
222
|
+
const problems: Problem[] = [], seen = new Set<string>(), repeated = new Set<string>();
|
|
223
|
+
const refuse = (detail: string): void => { problems.push({ code: 'DEPTH_GROUP_SELECTION', object: 'depth-apply --groups', detail }); };
|
|
224
|
+
if (groups.length === 0) refuse(`found an empty list; required one or more group names, comma-separated; ${has}`);
|
|
225
|
+
for (const name of groups) {
|
|
226
|
+
if (seen.has(name)) { if (!repeated.has(name)) refuse(`found ${JSON.stringify(name)} more than once; required each group named once; ${has}`); repeated.add(name); continue; }
|
|
227
|
+
seen.add(name);
|
|
228
|
+
if (!declared.includes(name)) refuse(`found ${JSON.stringify(name)}, which the recipe does not declare; required a group the recipe declares; ${has}`);
|
|
229
|
+
}
|
|
230
|
+
if (problems.length) throw new PartsError(problems);
|
|
231
|
+
return declared.filter(g => seen.has(g));
|
|
232
|
+
}
|
|
233
|
+
export function applyDepth(input: { parts: string; manifest: string; config: string; rigConfig: string; out: string; groups?: readonly string[] }, log: (line: string) => void = console.warn): Obj {
|
|
234
|
+
const recipe = parseDepthRecipe(readJson(input.config)), selection = groupSelection(recipe, input.groups), applied = (group: string): boolean => selection === undefined || selection.includes(group);
|
|
235
|
+
const expected = preparedParts(input.parts, recipe);
|
|
218
236
|
const supplied = readJson(input.manifest);
|
|
219
237
|
if (text(supplied) !== text(expected.manifest)) fail('DEPTH_INPUT_BINDING', input.manifest, 'does not match the recipe, parts.json, art hashes, crop or padding; run depth-prepare again for these exact inputs');
|
|
220
238
|
for (const p of expected.manifest.parts) {
|
|
@@ -223,11 +241,23 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
223
241
|
}
|
|
224
242
|
emptyOutput(input.out, [input.parts, input.config, input.manifest, input.rigConfig, ...Object.values(recipe.parts).flatMap(p => { const map = resolve(dirname(input.config), p.map); return [map, map + '.binding.json']; })]);
|
|
225
243
|
const rawParts = object(readJson(join(input.parts, 'parts.json')), 'parts.json'), file = readParts(join(input.parts, 'parts.json'));
|
|
226
|
-
for (const p of file.parts) if (Object.hasOwn(recipe.parts, p.name) && p.provenance?.depth?.kind === 'authored-unit') fail('DEPTH_AUTHORED_UNIT_CONFLICT', `part "${p.name}"`, 'has provenance.depth.kind "authored-unit"; a transported scalar reference cannot coexist with authored unit depth — retain the unit declaration or supply an explicitly reassembled scalar-compatible input; no automatic transition is made');
|
|
244
|
+
for (const p of file.parts) if (Object.hasOwn(recipe.parts, p.name) && applied(recipe.parts[p.name].group) && p.provenance?.depth?.kind === 'authored-unit') fail('DEPTH_AUTHORED_UNIT_CONFLICT', `part "${p.name}"`, 'has provenance.depth.kind "authored-unit"; a transported scalar reference cannot coexist with authored unit depth — retain the unit declaration or supply an explicitly reassembled scalar-compatible input; no automatic transition is made');
|
|
227
245
|
const { config } = loadConfigAndAnimations(input.rigConfig);
|
|
228
246
|
refuseStaleAssembly(input.rigConfig, file, config);
|
|
229
247
|
const raw = object(readJson(input.rigConfig), 'rig config'), turn = object(raw.turn, 'config.turn');
|
|
248
|
+
// A group left out must not turn: the rig builds a group's turn from its config block, not from its sheets.
|
|
249
|
+
// An applied body group still requires config.turn.body; every such problem is refused at once.
|
|
250
|
+
const turnProblems: Problem[] = [];
|
|
251
|
+
for (const name of Object.keys(recipe.groups)) {
|
|
252
|
+
if (applied(name)) {
|
|
253
|
+
if (name !== 'head' && (turn.body === null || typeof turn.body !== 'object' || Array.isArray(turn.body))) turnProblems.push({ code: 'DEPTH_RECIPE', object: 'config.turn.body', detail: 'requires an object with the documented fields' });
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
for (const field of name === 'head' ? ['roles', 'depths'] : ['body']) if (turn[field] !== undefined) turnProblems.push({ code: 'DEPTH_GROUP_LEFT_OUT', object: `config.turn.${field}`, detail: `declares the ${name} turn, and depth-apply --groups ${(selection as string[]).join(',')} leaves the recipe's ${name} group out; required no config.turn.${field} in the rig config when the ${name} group is left out, or ${name} named in --groups` });
|
|
257
|
+
}
|
|
258
|
+
if (turnProblems.length) throw new PartsError(turnProblems);
|
|
230
259
|
for (const [name, group] of Object.entries(recipe.groups)) {
|
|
260
|
+
if (!applied(name)) continue;
|
|
231
261
|
const target = name === 'head' ? turn : object(turn.body, 'config.turn.body'); target.pivot = group.pivot;
|
|
232
262
|
if (group.unitDepths !== undefined) target.unitDepths = group.unitDepths;
|
|
233
263
|
}
|
|
@@ -252,6 +282,8 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
252
282
|
const name = p.name, bytes = readFileSync(join(input.parts, partImageReference(p).path)), art = decodePngBytes(bytes, name), rec = recs.find(r => r.name === name) as Obj;
|
|
253
283
|
writes.set(`${name}.png`, bytes);
|
|
254
284
|
const declaration = Object.hasOwn(recipe.parts, name) ? recipe.parts[name] : undefined;
|
|
285
|
+
// A left-out group's part gets no new sheet, and any sheet it carried is dropped, never retained stale.
|
|
286
|
+
if (declaration !== undefined && !applied(declaration.group)) { if (p.depth !== undefined) retained.delete(depthImageReference(p.depth).path); delete rec.depth; continue; }
|
|
255
287
|
if (declaration === undefined) {
|
|
256
288
|
if (recipe.clear.includes(name)) { if (p.depth !== undefined) retained.delete(depthImageReference(p.depth).path); delete rec.depth; }
|
|
257
289
|
else if (p.depth !== undefined) { const depthPath = join(input.parts, depthImageReference(p.depth).path); readSourceDepth(depthPath, art, null); writes.set(p.depth.image, readFileSync(depthPath)); }
|
|
@@ -285,13 +317,15 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
285
317
|
}
|
|
286
318
|
// A replacement must share near/zScale with every retained part in its actual group.
|
|
287
319
|
for (const [name, g] of Object.entries(recipe.groups)) {
|
|
320
|
+
if (!applied(name)) continue;
|
|
288
321
|
const target = name === 'head' ? turn : object(turn.body, 'config.turn.body'), roles = object(target.roles, `config.turn.${name}.roles`);
|
|
289
322
|
for (const rec of recs) if (Object.hasOwn(roles, String(rec.name)) && rec.depth !== undefined) {
|
|
290
323
|
const d = rec.depth as Obj;
|
|
291
324
|
if (d.near !== g.near || d.zScale !== g.zScale) fail('DEPTH_GROUP_BINDING', String(rec.name), `retained ${name} sheet near=${String(d.near)}, zScale=${String(d.zScale)}; declared group requires ${g.near}, ${g.zScale}; replace or explicitly clear that sheet`);
|
|
292
325
|
}
|
|
293
326
|
}
|
|
294
|
-
const report = { spec: 'rig-parts-depth-report/1', partsSha256: expected.manifest.partsSha256, recipeSha256: expected.manifest.recipeSha256, manifestSha256: hash(readFileSync(input.manifest)), rigConfigSha256: hash(readFileSync(input.rigConfig)), alpha: 128, normalization: 'median, linear p5..p95', extension: 'nearest alpha>=128, row-major ties', cleared: recipe.clear,
|
|
327
|
+
const report = { spec: 'rig-parts-depth-report/1', partsSha256: expected.manifest.partsSha256, recipeSha256: expected.manifest.recipeSha256, manifestSha256: hash(readFileSync(input.manifest)), rigConfigSha256: hash(readFileSync(input.rigConfig)), alpha: 128, normalization: 'median, linear p5..p95', extension: 'nearest alpha>=128, row-major ties', cleared: recipe.clear,
|
|
328
|
+
...(selection === undefined ? {} : { selection: { groups: selection, leftOut: file.parts.filter(p => Object.hasOwn(recipe.parts, p.name) && !applied(recipe.parts[p.name].group)).map(p => p.name) } }), parts: rows };
|
|
295
329
|
mkdirSync(join(input.out, 'parts'), { recursive: true });
|
|
296
330
|
for (const [file, bytes] of retained) {
|
|
297
331
|
if (['parts.json', 'config.json', 'depth-report.json'].includes(file)) continue;
|
package/src/editedparts.ts
CHANGED
|
@@ -38,6 +38,46 @@ export interface EditedPartProvenance {
|
|
|
38
38
|
changed_counted_px: number;
|
|
39
39
|
changed_excluded_px: number;
|
|
40
40
|
removed_opaque_px: number;
|
|
41
|
+
/**
|
|
42
|
+
* Issue #1383: where the removed opaque pixels are. One entry per
|
|
43
|
+
* 8-connected region of removed positions, as a box `[x, y, w, h]` in the
|
|
44
|
+
* part PNG's own pixels and the count of removed positions inside it; the
|
|
45
|
+
* counts sum to `removed_opaque_px`. Sorted by `y`, `x`, `h`, `w`, `px`.
|
|
46
|
+
* Written only when `removed_opaque_px > 0`, so an edit that removes
|
|
47
|
+
* nothing keeps its bytes.
|
|
48
|
+
*/
|
|
49
|
+
removed_opaque_regions?: EditedPartRemovedRegion[];
|
|
50
|
+
}
|
|
51
|
+
export interface EditedPartRemovedRegion { box: [number, number, number, number]; px: number }
|
|
52
|
+
|
|
53
|
+
/** 8-connected regions of a part-sized 0/1 mask, ordered as `removed_opaque_regions` requires. */
|
|
54
|
+
export function removedOpaqueRegions(removed: Uint8Array, width: number, height: number): EditedPartRemovedRegion[] {
|
|
55
|
+
const seen = new Uint8Array(removed.length), out: EditedPartRemovedRegion[] = [];
|
|
56
|
+
for (let start = 0; start < removed.length; start++) {
|
|
57
|
+
if (removed[start] !== 1 || seen[start] === 1) continue;
|
|
58
|
+
let left = width, top = height, right = 0, bottom = 0, px = 0;
|
|
59
|
+
const stack = [start];
|
|
60
|
+
seen[start] = 1;
|
|
61
|
+
while (stack.length > 0) {
|
|
62
|
+
const p = stack.pop()!, x = p % width, y = Math.floor(p / width);
|
|
63
|
+
px++;
|
|
64
|
+
if (x < left) left = x;
|
|
65
|
+
if (y < top) top = y;
|
|
66
|
+
if (x + 1 > right) right = x + 1;
|
|
67
|
+
if (y + 1 > bottom) bottom = y + 1;
|
|
68
|
+
for (let dy = -1; dy <= 1; dy++) for (let dx = -1; dx <= 1; dx++) {
|
|
69
|
+
const nx = x + dx, ny = y + dy, q = ny * width + nx;
|
|
70
|
+
if (nx < 0 || ny < 0 || nx >= width || ny >= height || removed[q] !== 1 || seen[q] === 1) continue;
|
|
71
|
+
seen[q] = 1;
|
|
72
|
+
stack.push(q);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
out.push({ box: [left, top, right - left, bottom - top], px });
|
|
76
|
+
}
|
|
77
|
+
return out.sort(compareRemovedRegions);
|
|
78
|
+
}
|
|
79
|
+
export function compareRemovedRegions(a: EditedPartRemovedRegion, b: EditedPartRemovedRegion): number {
|
|
80
|
+
return a.box[1] - b.box[1] || a.box[0] - b.box[0] || a.box[3] - b.box[3] || a.box[2] - b.box[2] || a.px - b.px;
|
|
41
81
|
}
|
|
42
82
|
export interface EditedPartFrontColourOwner {
|
|
43
83
|
owner: string;
|
|
@@ -156,6 +196,7 @@ export function replaceEditedParts(
|
|
|
156
196
|
const provenance: PixelProvenance = { unchanged_layer_px: 0, hand_px: 0, automatic_px: 0, edits: [], automatic: [],
|
|
157
197
|
...(record.provenance?.depth === undefined ? {} : { depth: record.provenance.depth }), edited_part: metadata };
|
|
158
198
|
const counts = new Map<number, number>();
|
|
199
|
+
const removed = new Uint8Array(old.width * old.height);
|
|
159
200
|
let opaque = 0, visible = 0, projected = 0, paintingGain = 0;
|
|
160
201
|
const partOwnerIndex = owner.names.indexOf(record.name);
|
|
161
202
|
const byOwner = new Map<number, { px: number; left: number; top: number; right: number; bottom: number }>();
|
|
@@ -169,7 +210,7 @@ export function replaceEditedParts(
|
|
|
169
210
|
metadata.changed_px++;
|
|
170
211
|
if (counted) metadata.changed_counted_px++; else metadata.changed_excluded_px++;
|
|
171
212
|
}
|
|
172
|
-
if (old.data[offset + 3] > OPAQUE_ALPHA_ABOVE && !counted) metadata.removed_opaque_px++;
|
|
213
|
+
if (old.data[offset + 3] > OPAQUE_ALPHA_ABOVE && !counted) { metadata.removed_opaque_px++; removed[p] = 1; }
|
|
173
214
|
if (!counted) { next.excluded_px++; append(next.runs, EXCLUDED_PIXEL); append(next.pre_seam_writer_runs, EXCLUDED_PIXEL); continue; }
|
|
174
215
|
opaque++;
|
|
175
216
|
const x = record.x + p % record.w, y = record.y + Math.floor(p / record.w);
|
|
@@ -216,6 +257,7 @@ export function replaceEditedParts(
|
|
|
216
257
|
else provenance.automatic_px++;
|
|
217
258
|
counts.set(writer, (counts.get(writer) ?? 0) + 1);
|
|
218
259
|
}
|
|
260
|
+
if (metadata.removed_opaque_px > 0) metadata.removed_opaque_regions = removedOpaqueRegions(removed, old.width, old.height);
|
|
219
261
|
provenance.edits = map.edits.flatMap((edit, i) => counts.has(i + 1) ? [{ edit, px: counts.get(i + 1)! }] : []);
|
|
220
262
|
provenance.automatic = (Object.keys(AUTOMATIC_WRITERS) as AutomaticWriter[]).flatMap(stage => counts.has(AUTOMATIC_WRITERS[stage]) ? [{ stage, px: counts.get(AUTOMATIC_WRITERS[stage])! }] : []);
|
|
221
263
|
record.opaque_px = opaque;
|
package/src/instruments.ts
CHANGED
|
@@ -1141,7 +1141,7 @@ export function crossingOf(art: ArtMask, stage: StageBox, frames: ReadonlyArray<
|
|
|
1141
1141
|
// Distance from a world point to the nearest pixel outside the region: rings of pixels around the one holding it.
|
|
1142
1142
|
const depthAt = (x: number, y: number): number => {
|
|
1143
1143
|
const u0 = Math.floor(x - stage.x);
|
|
1144
|
-
const v0 = Math.floor(
|
|
1144
|
+
const v0 = Math.floor(cropToSpineY(y - stage.y, H));
|
|
1145
1145
|
let best = Infinity;
|
|
1146
1146
|
for (let r = 0; r - 1 < best; r++) {
|
|
1147
1147
|
for (let v = v0 - r; v <= v0 + r; v++) {
|
|
@@ -1188,7 +1188,7 @@ export function crossingOf(art: ArtMask, stage: StageBox, frames: ReadonlyArray<
|
|
|
1188
1188
|
by1 = Math.max(by1, poly[q + 1]);
|
|
1189
1189
|
}
|
|
1190
1190
|
for (let u = Math.floor(bx0 - stage.x); u <= Math.floor(bx1 - stage.x); u++) {
|
|
1191
|
-
for (let v = Math.floor(
|
|
1191
|
+
for (let v = Math.floor(cropToSpineY(by1 - stage.y, H)); v <= Math.floor(cropToSpineY(by0 - stage.y, H)); v++) {
|
|
1192
1192
|
if (!inR(u, v)) continue;
|
|
1193
1193
|
const sx0 = stage.x + u;
|
|
1194
1194
|
const sy1 = stage.y + cropToSpineY(v, H);
|
package/src/outputpaths.ts
CHANGED
|
@@ -23,6 +23,30 @@ export function diagnosticSegment(name: string, suffix = ''): string {
|
|
|
23
23
|
return segment;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Why `dir`, a folder name another tool recorded, is not one safe path segment
|
|
28
|
+
* Parts can join under its own output as it is, or `null` when it is (issue
|
|
29
|
+
* #1367). Safe is the alphabet `diagnosticSegment` emits — `[A-Za-z0-9_@+.-]`
|
|
30
|
+
* and its escape character `~` — with no final `.` (so neither `.` nor `..`),
|
|
31
|
+
* no Windows device basename before the first dot, and 1 to 255 characters.
|
|
32
|
+
* rig-c's render records every frame-set folder in that alphabet from
|
|
33
|
+
* rig-c/core#1744 on; nothing here maps or repairs the value.
|
|
34
|
+
*/
|
|
35
|
+
export function unsafeSegmentReason(dir: unknown): string | null {
|
|
36
|
+
if (typeof dir !== 'string') return dir === undefined ? 'is absent' : `is ${dir === null ? 'null' : typeof dir}, not a string`;
|
|
37
|
+
if (dir.length === 0) return 'is empty';
|
|
38
|
+
if (/^[\\/]/.test(dir)) return 'is an absolute path';
|
|
39
|
+
if (dir === '.' || dir === '..' || /(?:^|[\\/])\.\.?(?:[\\/]|$)/.test(dir)) return 'holds a dot segment';
|
|
40
|
+
if (/[\\/]/.test(dir)) return 'holds a path separator';
|
|
41
|
+
let unit = 0;
|
|
42
|
+
while (unit < dir.length && /^[A-Za-z0-9_@+.~-]$/.test(dir[unit])) unit++;
|
|
43
|
+
if (unit < dir.length) return `holds ${JSON.stringify(dir[unit])} (U+${dir.charCodeAt(unit).toString(16).padStart(4, '0')}) outside [A-Za-z0-9_@+.~-]`;
|
|
44
|
+
if (dir.endsWith('.')) return 'ends with "."';
|
|
45
|
+
if (/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(dir)) return 'is a Windows device name before its first dot';
|
|
46
|
+
if (dir.length > 255) return `is ${dir.length} characters`;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
26
50
|
/** Validate the entire sibling scope before a caller creates any of its paths. */
|
|
27
51
|
export function diagnosticSiblings(names: readonly { name: string; suffix?: string }[], scope: string): string[] {
|
|
28
52
|
const seen = new Map<string, { name: string; folder: string }>();
|
package/src/parts.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assemblyFieldDigest, isSplitTakeMetadataField } from './assembly-reading.ts';
|
|
2
|
-
import { orderedEditedPartReceipt, type EditedPartReceipt } from './editedparts.ts';
|
|
2
|
+
import { compareRemovedRegions, orderedEditedPartReceipt, type EditedPartReceipt, type EditedPartRemovedRegion } from './editedparts.ts';
|
|
3
3
|
import { parseReceiptProducer, receiptText } from './receiptproducer.ts';
|
|
4
4
|
import { takenSourceProblems, type TakenLayerSource } from './takesource.ts';
|
|
5
5
|
import { AUTOMATIC_WRITERS, provenanceAddsUp, type PixelProvenance, type CutOwnership } from './provenance.ts';
|
|
@@ -555,6 +555,34 @@ export function tagOf(from: string): string | null {
|
|
|
555
555
|
return f === null || f.run === 'painting' ? null : f.tag;
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Issue #1383: `removed_opaque_regions`, when present, is a non-empty list of
|
|
560
|
+
* `{box: [x, y, w, h], px}` inside the part box, in the writer's order, whose
|
|
561
|
+
* `px` sum to `removed_opaque_px`. Absent is a manifest written before the
|
|
562
|
+
* field existed, or an edit that removed nothing.
|
|
563
|
+
*/
|
|
564
|
+
function editedRemovedRegions(value: unknown, removed: number, w: unknown, h: unknown, object: string, fail: (code: string, object: string, detail: string) => void): void {
|
|
565
|
+
const int = (n: unknown): n is number => Number.isSafeInteger(n);
|
|
566
|
+
const rows = Array.isArray(value) ? value as unknown[] : null;
|
|
567
|
+
const shaped = rows !== null && rows.length > 0 && int(w) && int(h) && rows.every(r => r !== null && typeof r === 'object' && !Array.isArray(r) &&
|
|
568
|
+
Object.keys(r).sort().join(',') === 'box,px' && Array.isArray((r as EditedPartRemovedRegion).box) && (r as EditedPartRemovedRegion).box.length === 4 &&
|
|
569
|
+
(r as EditedPartRemovedRegion).box.every(int) && int((r as EditedPartRemovedRegion).px));
|
|
570
|
+
if (!shaped) {
|
|
571
|
+
fail('PARTS_FIELD_TYPE', object, `is ${show(value)}; a non-empty list of {box: [x, y, w, h], px} with safe integers is required`);
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
const regions = rows as EditedPartRemovedRegion[];
|
|
575
|
+
regions.forEach((r, i) => {
|
|
576
|
+
const [x, y, bw, bh] = r.box;
|
|
577
|
+
if (x < 0 || y < 0 || bw < 1 || bh < 1 || x + bw > (w as number) || y + bh > (h as number) || r.px < 1 || r.px > bw * bh) {
|
|
578
|
+
fail('PARTS_COUNTS_ADD_UP', `${object}[${i}]`, `is box [${r.box.join(', ')}] px ${r.px}; a box of at least 1x1 inside the part's ${w as number}x${h as number} pixels and px from 1 to its area ${bw * bh} is required`);
|
|
579
|
+
}
|
|
580
|
+
if (i > 0 && compareRemovedRegions(regions[i - 1], r) > 0) fail('PARTS_FIELD_TYPE', `${object}[${i}]`, `box [${r.box.join(', ')}] follows box [${regions[i - 1].box.join(', ')}]; the order y, x, h, w, px is required`);
|
|
581
|
+
});
|
|
582
|
+
const sum = regions.reduce((n, r) => n + r.px, 0);
|
|
583
|
+
if (sum !== removed) fail('PARTS_COUNTS_ADD_UP', object, `px sum to ${sum}; removed_opaque_px ${removed} is required`);
|
|
584
|
+
}
|
|
585
|
+
|
|
558
586
|
function validEditedPartAuthor(receipt: EditedPartReceipt): boolean {
|
|
559
587
|
const keys = Object.keys(receipt).sort().join(',');
|
|
560
588
|
if (keys === 'editor,file,from_sha256,part,sha256') return receiptText(receipt.editor);
|
|
@@ -617,6 +645,9 @@ function orderedProvenance(p: PixelProvenance): PixelProvenance {
|
|
|
617
645
|
receipt: orderedEditedPartReceipt(p.edited_part.receipt),
|
|
618
646
|
changed_px: p.edited_part.changed_px, changed_counted_px: p.edited_part.changed_counted_px,
|
|
619
647
|
changed_excluded_px: p.edited_part.changed_excluded_px, removed_opaque_px: p.edited_part.removed_opaque_px,
|
|
648
|
+
...(p.edited_part.removed_opaque_regions === undefined ? {} : {
|
|
649
|
+
removed_opaque_regions: p.edited_part.removed_opaque_regions.map(r => ({ box: [r.box[0], r.box[1], r.box[2], r.box[3]] as [number, number, number, number], px: r.px })),
|
|
650
|
+
}),
|
|
620
651
|
} }) };
|
|
621
652
|
}
|
|
622
653
|
|
|
@@ -835,9 +866,10 @@ function checkProvenance(raw: unknown, opaque: unknown, object: string, fail: (c
|
|
|
835
866
|
if (v !== null && typeof v === 'object' && 'edited_part' in v) {
|
|
836
867
|
const e = v.edited_part;
|
|
837
868
|
const keys = 'changed_counted_px,changed_excluded_px,changed_px,dir,edit,receipt,removed_opaque_px';
|
|
869
|
+
const withRegions = 'changed_counted_px,changed_excluded_px,changed_px,dir,edit,receipt,removed_opaque_px,removed_opaque_regions';
|
|
838
870
|
const nonempty = (value: unknown): value is string => typeof value === 'string' && value.trim().length > 0;
|
|
839
871
|
const relativePath = (value: unknown): boolean => nonempty(value) && !/^(?:[\\/]|[A-Za-z]:[\\/])/.test(value);
|
|
840
|
-
const valid = e !== null && e !== undefined && typeof e === 'object' && !Array.isArray(e) && Object.keys(e).sort().join(',')
|
|
872
|
+
const valid = e !== null && e !== undefined && typeof e === 'object' && !Array.isArray(e) && [keys, withRegions].includes(Object.keys(e).sort().join(',')) &&
|
|
841
873
|
typeof e.edit === 'string' && /^edited_parts\[\d+\]$/.test(e.edit) && relativePath(e.dir) &&
|
|
842
874
|
[e.changed_px, e.changed_counted_px, e.changed_excluded_px, e.removed_opaque_px].every(count) &&
|
|
843
875
|
e.receipt !== null && typeof e.receipt === 'object' && !Array.isArray(e.receipt) &&
|
|
@@ -852,6 +884,7 @@ function checkProvenance(raw: unknown, opaque: unknown, object: string, fail: (c
|
|
|
852
884
|
e.removed_opaque_px > e.changed_excluded_px) {
|
|
853
885
|
fail('PARTS_COUNTS_ADD_UP', object + ' edited_part', `changed_px ${e.changed_px} must equal counted ${e.changed_counted_px} + excluded ${e.changed_excluded_px}; counted must fit opaque_px ${show(opaque)}, excluded must fit the remaining box pixels (area ${area}), and removed_opaque_px ${e.removed_opaque_px} must be at most changed_excluded_px`);
|
|
854
886
|
}
|
|
887
|
+
if ('removed_opaque_regions' in e) editedRemovedRegions(e.removed_opaque_regions, e.removed_opaque_px, identity?.w, identity?.h, object + ' edited_part.removed_opaque_regions', fail);
|
|
855
888
|
}
|
|
856
889
|
}
|
|
857
890
|
if (v !== null && typeof v === 'object' && 'depth' in v) {
|