@rig-c/parts 2.50.0 → 2.51.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 +122 -11
- package/docs/AUTHORING.md +112 -55
- package/docs/STABILITY.md +60 -16
- 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/instruments.ts +2 -2
- package/src/outputpaths.ts +24 -0
- package/src/physicscontrib.ts +311 -0
- package/src/propose.ts +30 -22
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.51.0",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./assembly-reading": "./src/assembly-reading.ts",
|
|
8
|
+
"./cloth-targets.json": "./src/cloth-targets.json",
|
|
8
9
|
"./*": "./*"
|
|
9
10
|
},
|
|
10
11
|
"bin": {
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
77
|
"ag-psd": "^31.0.2",
|
|
77
|
-
"@rig-c/core": "3.8.
|
|
78
|
+
"@rig-c/core": "3.8.1"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@esotericsoftware/spine-core": "4.3.13",
|
package/src/build.ts
CHANGED
|
@@ -97,6 +97,7 @@ import {
|
|
|
97
97
|
splitSchedule,
|
|
98
98
|
untestedIntervals,
|
|
99
99
|
} from './autoreplay.ts';
|
|
100
|
+
import { physicsLines } from './physicscontrib.ts';
|
|
100
101
|
import { besideIdleLine, checkSummaryLine, inputFileRecord, type InputFileRecord, CLOTH_LINE, type ClothLine, clothWarnText, figureOpeningLines, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamRequiredLine, motionSeamWarnText, motionJointContactLines, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, parsePageSize, readCheckEnvironment, readWindBand, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR, WIND_BAND_LINE, windBandLines } from './check.ts';
|
|
101
102
|
import { type CharacterConfig, type Cut, type Extend, loadConfigAndAnimations, loadConfigWithBytes, loadEarlyConfig, type Patch, type PlanEntry } from './config.ts';
|
|
102
103
|
import { coreCompileGuideLine, failLine, foldName, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
@@ -2446,6 +2447,7 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
|
|
|
2446
2447
|
if (r.motionSeam.required !== undefined) log(` ${motionSeamRequiredLine(r.motionSeam.required)}`);
|
|
2447
2448
|
for (const [i, l] of figureOpeningLines(r.figureOpenings).entries()) log(` ${i === 0 ? '' : ' '}${l}`);
|
|
2448
2449
|
for (const [i, l] of clothLines(r.cloth).entries()) log(` ${i === 0 ? '' : ' '}${l}`);
|
|
2450
|
+
if (r.physics !== undefined) for (const [i, l] of physicsLines(r.physics).entries()) log(` ${i === 0 ? '' : ' '}${l}`);
|
|
2449
2451
|
for (const name of REPORTED_LINES) log(` ${judgementLine(name, fig[name])}`);
|
|
2450
2452
|
if (fig.sets !== undefined) {
|
|
2451
2453
|
for (const [setName, setFig] of Object.entries(fig.sets)) {
|
package/src/bustlandmarks.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { accessSync, constants, existsSync, lstatSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { basename, dirname, join, resolve, sep } from 'node:path';
|
|
4
|
-
import { type CharacterConfig, DEFAULT_BUST_ALPHA, DEFAULT_BUST_BONE_L, DEFAULT_BUST_BONE_R, DEFAULT_BUST_CLEARANCE, DEFAULT_BUST_SPACING, loadConfig } from './config.ts';
|
|
4
|
+
import { bustClearanceDetail, type CharacterConfig, DEFAULT_BUST_ALPHA, DEFAULT_BUST_BONE_L, DEFAULT_BUST_BONE_R, DEFAULT_BUST_CLEARANCE, DEFAULT_BUST_SPACING, loadConfig } from './config.ts';
|
|
5
5
|
import { BUST_SHAPE_FIELDS, type BustShapeKey, type ConfigWritePatch, type PendingBustShape } from './configwrite.ts';
|
|
6
6
|
import { SHA256_PATTERN } from './editreceipt.ts';
|
|
7
7
|
import { PartsError, type Problem } from './errors.ts';
|
|
@@ -228,6 +228,32 @@ function oneRow(rows: readonly ChestRow[], problems: Problem[]): ChestRow | null
|
|
|
228
228
|
return null;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
/** Where one field of the shape the points are checked with came from (issue #1441). */
|
|
232
|
+
export type BustShapeSource = 'the config' | 'the pending record' | 'the default';
|
|
233
|
+
/** The shape the three points are checked with: each field's value and where it came from. */
|
|
234
|
+
export type EffectiveBustShape = { readonly [K in BustShapeKey]: { readonly value: unknown; readonly source: BustShapeSource } };
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Issue #1441: the shape the points are checked with, the one the config write will hold. Each field is the pending
|
|
238
|
+
* record's where it names one, else the config's declared `contour.bust` field, else the default. The one rule, read
|
|
239
|
+
* by `propose --bust-landmarks` on both routes and by `bust-landmarks` before it writes the landmarks file.
|
|
240
|
+
*/
|
|
241
|
+
export function effectiveBustShape(declared: Readonly<Record<string, unknown>> | undefined, pending: Readonly<Partial<Record<BustShapeKey, unknown>>> | undefined): EffectiveBustShape {
|
|
242
|
+
const pick = (key: BustShapeKey): { value: unknown; source: BustShapeSource } =>
|
|
243
|
+
pending !== undefined && Object.hasOwn(pending, key) && pending[key] !== undefined ? { value: pending[key], source: 'the pending record' }
|
|
244
|
+
: declared !== undefined && Object.hasOwn(declared, key) && declared[key] !== undefined ? { value: declared[key], source: 'the config' }
|
|
245
|
+
: { value: SHAPE_DEFAULTS[key], source: 'the default' };
|
|
246
|
+
return { alpha: pick('alpha'), clearance: pick('clearance'), bone_r: pick('bone_r'), bone_l: pick('bone_l'), spacing: pick('spacing') };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** The two fields the clearance rule reads (`bustClearanceDetail`): the ones a refusal of the points names. */
|
|
250
|
+
export const BUST_POINT_SHAPE_FIELDS = ['alpha', 'clearance'] as const;
|
|
251
|
+
|
|
252
|
+
/** The clause a refusal of the points carries: the two fields the clearance rule reads, each with its source. */
|
|
253
|
+
export function bustShapeClause(shape: EffectiveBustShape): string {
|
|
254
|
+
return `the shape checked: alpha ${show(shape.alpha.value)} (${shape.alpha.source}), clearance ${show(shape.clearance.value)} (${shape.clearance.source})`;
|
|
255
|
+
}
|
|
256
|
+
|
|
231
257
|
/** The five shape fields after defaults, from a partial spec. */
|
|
232
258
|
const effective = (spec: Partial<Shape>): Shape => ({ ...SHAPE_DEFAULTS, ...spec });
|
|
233
259
|
|
|
@@ -240,7 +266,18 @@ type ShapeField = { key: ShapeKey; value?: number | string };
|
|
|
240
266
|
* field to write: the act's value where the act spells it out, the key's removal where the act omits it. With no
|
|
241
267
|
* `contour.bust`, a field that differs from the default is returned as pending, for the sidecar.
|
|
242
268
|
*/
|
|
243
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Issue #1443: the act moves the points when apex_r or apex_l differs from the declared one in either coordinate, or
|
|
271
|
+
* when its cleavage differs from the declared one. An act with no cleavage moves the points too: propose derives one
|
|
272
|
+
* from a midline this command does not have, so it cannot be held equal, and the pending path loses nothing (propose
|
|
273
|
+
* writes the points and the shape in one staged write).
|
|
274
|
+
*/
|
|
275
|
+
export function bustPointsMoved(act: { apex_r: readonly number[]; apex_l: readonly number[]; cleavage?: readonly number[] }, declared: { apex_r: readonly number[]; apex_l: readonly number[]; cleavage: readonly number[] }): boolean {
|
|
276
|
+
const same = (a: readonly number[], b: readonly number[]): boolean => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
277
|
+
return !same(act.apex_r, declared.apex_r) || !same(act.apex_l, declared.apex_l) || act.cleavage === undefined || !same(act.cleavage, declared.cleavage);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function checkRow(row: ChestRow, parts: PartsFile | null, config: CharacterConfig | null, writeConfig: boolean, problems: Problem[]): { fields: ShapeField[]; pending: PendingBustShape['fields']; moved: boolean } {
|
|
244
281
|
const at = `value.chestLandmarks[${row.index}]`;
|
|
245
282
|
if (parts !== null) {
|
|
246
283
|
const [width, height] = parts.rig_size;
|
|
@@ -257,12 +294,12 @@ function checkRow(row: ChestRow, parts: PartsFile | null, config: CharacterConfi
|
|
|
257
294
|
if (row.skin !== 'default') {
|
|
258
295
|
problems.push({ code: 'BUST_LANDMARKS_SLOT', object: `${at}.edit.skin`, detail: `is "${row.skin}"; "default" is required: this package writes every mesh into the default skin` });
|
|
259
296
|
}
|
|
260
|
-
if (config === null) return { fields: [], pending: {} };
|
|
297
|
+
if (config === null) return { fields: [], pending: {}, moved: false };
|
|
261
298
|
const mesh = Object.hasOwn(config.meshes, row.slot) ? config.meshes[row.slot] : undefined;
|
|
262
299
|
if (mesh === undefined || !('contour' in mesh)) {
|
|
263
300
|
const found = mesh === undefined ? 'no mesh in config.meshes' : `a ${['grid', 'auto', 'influence', 'explicit'].find(m => m in mesh) ?? 'non-contour'} mesh`;
|
|
264
301
|
problems.push({ code: 'BUST_LANDMARKS_SLOT', object: `${at}.edit.slot`, detail: `"${row.slot}" has ${found}; a part whose config.meshes entry is a contour mesh is required (the chest carrier propose drafts)` });
|
|
265
|
-
return { fields: [], pending: {} };
|
|
302
|
+
return { fields: [], pending: {}, moved: false };
|
|
266
303
|
}
|
|
267
304
|
// No contour.bust yet (a first draft made with --no-bust) reads as the defaults: propose drafts contour.bust from the
|
|
268
305
|
// three points alone, so the defaults are the values the redraft builds with.
|
|
@@ -275,6 +312,9 @@ function checkRow(row: ChestRow, parts: PartsFile | null, config: CharacterConfi
|
|
|
275
312
|
...(declared.bone_l === undefined ? {} : { bone_l: declared.bone_l }),
|
|
276
313
|
});
|
|
277
314
|
const actShape = effective(row.shape);
|
|
315
|
+
// Issue #1443: with the points moved, the shape is not written against the config's old points: it waits in the
|
|
316
|
+
// sidecar like a first draft's, and propose writes it with the new points.
|
|
317
|
+
const moved = declared !== undefined && bustPointsMoved(row.landmarks, declared);
|
|
278
318
|
const fields: ShapeField[] = [];
|
|
279
319
|
const pending: PendingBustShape['fields'] = {};
|
|
280
320
|
for (const key of SHAPE_KEYS) {
|
|
@@ -282,8 +322,10 @@ function checkRow(row: ChestRow, parts: PartsFile | null, config: CharacterConfi
|
|
|
282
322
|
const spelled = row.shape[key];
|
|
283
323
|
// No contour.bust yet: the field differs from the default, so the act spells it. It is left pending in the
|
|
284
324
|
// sidecar for propose --write-config to write with the three points (shape fields alone make no contour.bust).
|
|
285
|
-
|
|
286
|
-
|
|
325
|
+
// Points moved (issue #1443): the same, and a field the act leaves out where the config declares another value
|
|
326
|
+
// is pending as the default's value, since the record holds values and the act's shape is the default there.
|
|
327
|
+
if (declared === undefined || moved) {
|
|
328
|
+
pending[key] = spelled ?? SHAPE_DEFAULTS[key];
|
|
287
329
|
continue;
|
|
288
330
|
}
|
|
289
331
|
if (writeConfig) {
|
|
@@ -296,7 +338,17 @@ function checkRow(row: ChestRow, parts: PartsFile | null, config: CharacterConfi
|
|
|
296
338
|
detail: `is ${show(actShape[key])}${spelled === undefined ? ' (absent, the default)' : ''}; meshes.${row.slot}.contour.bust.${key} ${show(configShape[key])}, ${from}, is required: the landmarks file carries no such field; run again with --write-config to take the act's value into the config; propose --write-config keeps the config's shape fields on the redraft (#1428)`,
|
|
297
339
|
});
|
|
298
340
|
}
|
|
299
|
-
|
|
341
|
+
// Issue #1441: the points against the shape propose will check them with, so this command refuses what propose
|
|
342
|
+
// refuses. The config after this command: the act's fields with --write-config, else the declared ones. A cleavage
|
|
343
|
+
// the act leaves out is derived by propose from a midline this command does not have, so it is checked there.
|
|
344
|
+
const after = declared === undefined ? undefined : writeConfig && !moved ? { ...row.shape } : { ...declared };
|
|
345
|
+
const shape = effectiveBustShape(after, pending);
|
|
346
|
+
const { apex_r, apex_l, cleavage } = row.landmarks;
|
|
347
|
+
if (cleavage !== undefined && typeof shape.alpha.value === 'number' && typeof shape.clearance.value === 'number') {
|
|
348
|
+
const detail = bustClearanceDetail({ apex_r, apex_l, cleavage }, shape.alpha.value, shape.clearance.value);
|
|
349
|
+
if (detail !== null) problems.push({ code: 'CONFIG_BUST_CLEARANCE', object: `${at}.edit.bust`, detail: `${detail}; ${bustShapeClause(shape)}` });
|
|
350
|
+
}
|
|
351
|
+
return { fields, pending, moved };
|
|
300
352
|
}
|
|
301
353
|
|
|
302
354
|
/** A path's device and inode, or null when nothing is there. */
|
|
@@ -382,6 +434,9 @@ export interface BustLandmarksPlan {
|
|
|
382
434
|
texts: readonly [string, string];
|
|
383
435
|
/** With `writeConfig`: the act's shape fields that differ from the config's `contour.bust`; null when none differs. */
|
|
384
436
|
configPatch: ConfigWritePatch | null;
|
|
437
|
+
/** Issue #1443: the config declares `contour.bust` and the act moves its points ({@link bustPointsMoved}), so a
|
|
438
|
+
* differing shape is pending in the record and the config is not written. */
|
|
439
|
+
moved: boolean;
|
|
385
440
|
}
|
|
386
441
|
|
|
387
442
|
/**
|
|
@@ -398,7 +453,7 @@ export function planBustLandmarks(input: { act: string; parts: string; config: s
|
|
|
398
453
|
const parts = collect(() => readParts(join(partsDir, 'parts.json')), problems);
|
|
399
454
|
const config = collect(() => loadConfig(configPath), problems);
|
|
400
455
|
const row = act === null ? null : oneRow(act.rows, problems);
|
|
401
|
-
const { fields, pending } = row === null ? { fields: [], pending: {} } : checkRow(row, parts, config, input.writeConfig === true, problems);
|
|
456
|
+
const { fields, pending, moved } = row === null ? { fields: [], pending: {}, moved: false } : checkRow(row, parts, config, input.writeConfig === true, problems);
|
|
402
457
|
if (problems.length > 0 || act === null || row === null || typeof actBytes === 'string') throw new PartsError(problems);
|
|
403
458
|
const text = bustLandmarksText(row.landmarks);
|
|
404
459
|
const provenance: BustLandmarksProvenance = {
|
|
@@ -414,6 +469,7 @@ export function planBustLandmarks(input: { act: string; parts: string; config: s
|
|
|
414
469
|
landmarks: row.landmarks, provenance, out, provenancePath: out + BUST_LANDMARKS_PROVENANCE_SUFFIX,
|
|
415
470
|
texts: [text, JSON.stringify(provenance, null, 2) + '\n'],
|
|
416
471
|
configPatch: fields.length === 0 ? null : { kind: 'bust-shape', part: row.slot, fields },
|
|
472
|
+
moved,
|
|
417
473
|
};
|
|
418
474
|
}
|
|
419
475
|
|
package/src/check.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { ART_JOINT_LINE, artJointLine, type ArtJointLine } from './artjoints.ts'
|
|
|
11
11
|
import { BOUNDARY_COLOUR_LINE, BOUNDARY_COLOUR_UNMEASURED_CODE, BOUNDARY_COLOUR_UNMEASURED_SUFFIX, measureBoundaryColour, type BoundaryColourMeasured } from './boundarycolour.ts';
|
|
12
12
|
import { BEHIND_SEAM_LINE, behindTurnAnimations, measureBehindSeams, type BehindSeamsMeasured } from './behindseams.ts';
|
|
13
13
|
import { baseAnchorMoves, type AnchorRegion } from './baseanchor.ts';
|
|
14
|
+
import { PHYSICS_CONTRIBUTES_LINE, measurePhysicsContribution, physicsLine, type PhysicsContributionLine } from './physicscontrib.ts';
|
|
14
15
|
/**
|
|
15
16
|
* The check stage: build a rig through rig-c, gate it under both
|
|
16
17
|
* profiles, render its idle, and measure the two things the gate cannot see —
|
|
@@ -97,7 +98,7 @@ import { createRequire } from 'node:module';
|
|
|
97
98
|
import type { Candidate, Piece, Viewport as RootCoverageViewport } from '@rig-c/core/render-shared';
|
|
98
99
|
import { fillHoles } from './raster/morph.ts';
|
|
99
100
|
import { closeSync, copyFileSync, cpSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs';
|
|
100
|
-
import { diagnosticSegment, diagnosticSiblings } from './outputpaths.ts';
|
|
101
|
+
import { diagnosticSegment, diagnosticSiblings, unsafeSegmentReason } from './outputpaths.ts';
|
|
101
102
|
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
102
103
|
import { measureRecomposite, type RecompositeFigures, recompositeRecord, scenePhrase, sourceInRig, figureSilhouette } from './assemble.ts';
|
|
103
104
|
import { type BoneTransform, computeExactFrameTransforms, cropToSpineY, normaliseDegrees, toBoneLocal } from './coords.ts';
|
|
@@ -1070,36 +1071,45 @@ function retainedCheckRenderPlan(source: string) {
|
|
|
1070
1071
|
const bytes = readFileSync(index, 'utf8');
|
|
1071
1072
|
const raw: unknown = JSON.parse(bytes);
|
|
1072
1073
|
if (!isRecord(raw) || !Array.isArray(raw.sets)) return sidecarProblem(index, 'requires a frames.json sets array to retain a render');
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
const
|
|
1082
|
-
if (
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1074
|
+
// Issue #1367: rig-c's render names each frame-set folder (rig-c/core#1744)
|
|
1075
|
+
// and records it under sets[].dir. That value is copied as it is, never
|
|
1076
|
+
// rebuilt from the animation's name; it is joined under the output only once
|
|
1077
|
+
// it is one safe path segment, and two that one case-insensitive
|
|
1078
|
+
// filesystem would make one folder are refused before anything is copied.
|
|
1079
|
+
const problems: Problem[] = [];
|
|
1080
|
+
const folded = new Map<string, { at: number; dir: string }>();
|
|
1081
|
+
const dirs = raw.sets.map((set: unknown, i: number): string => {
|
|
1082
|
+
const which = `${index} sets[${i}]` + (isRecord(set) && typeof set.animation === 'string' ? ` (animation ${JSON.stringify(set.animation)})` : '');
|
|
1083
|
+
if (!isRecord(set)) {
|
|
1084
|
+
problems.push({ code: 'FRAMES_SIDECAR', object: which, detail: 'is not an object; a set record with a "dir" is required to retain a render' });
|
|
1085
|
+
return '';
|
|
1086
|
+
}
|
|
1087
|
+
const why = unsafeSegmentReason(set.dir);
|
|
1088
|
+
if (why !== null) {
|
|
1089
|
+
problems.push({ code: 'FRAMES_SIDECAR', object: which, detail: `"dir" ${set.dir === undefined ? '' : JSON.stringify(set.dir) + ' '}${why}; one path segment of [A-Za-z0-9_@+.~-], not ending in ".", not a Windows device name and at most 255 characters is required to retain a render, as rigc render records it from rig-c/core#1744 on — Parts copies "dir" as it is and maps nothing` });
|
|
1090
|
+
return '';
|
|
1091
|
+
}
|
|
1092
|
+
const dir = set.dir as string;
|
|
1093
|
+
const previous = folded.get(dir.toLowerCase());
|
|
1094
|
+
if (previous !== undefined) {
|
|
1095
|
+
problems.push({ code: 'FRAMES_SIDECAR', object: which, detail: `"dir" ${JSON.stringify(dir)} and sets[${previous.at}] "dir" ${JSON.stringify(previous.dir)} are one folder ${JSON.stringify(dir.toLowerCase())} on a case-insensitive filesystem; distinct case-folded set directories are required to retain a render` });
|
|
1096
|
+
} else folded.set(dir.toLowerCase(), { at: i, dir });
|
|
1097
|
+
return dir;
|
|
1087
1098
|
});
|
|
1088
|
-
|
|
1089
|
-
return { bytes,
|
|
1099
|
+
refuseIfAny(problems);
|
|
1100
|
+
return { bytes, dirs };
|
|
1090
1101
|
}
|
|
1091
1102
|
|
|
1092
|
-
/** Copy a retained render and
|
|
1103
|
+
/** Copy a retained render: each set's folder and `frames.json` as rigc wrote them (issue #1367). */
|
|
1093
1104
|
export function retainCheckRender(source: string, target: string): void {
|
|
1094
|
-
const { bytes,
|
|
1105
|
+
const { bytes, dirs } = retainedCheckRenderPlan(source);
|
|
1095
1106
|
mkdirSync(target, { recursive: true });
|
|
1096
1107
|
// Root sidecars and set-local filenames are fixed renderer protocol names.
|
|
1097
1108
|
for (const entry of readdirSync(source, { withFileTypes: true })) {
|
|
1098
1109
|
if (entry.isFile() && entry.name !== 'frames.json') copyFileSync(join(source, entry.name), join(target, entry.name));
|
|
1099
1110
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
writeFileSync(join(target, 'frames.json'), changed ? JSON.stringify({ ...raw, sets }, null, 2) + '\n' : bytes);
|
|
1111
|
+
for (const dir of dirs) cpSync(join(source, dir), join(target, dir), { recursive: true });
|
|
1112
|
+
writeFileSync(join(target, 'frames.json'), bytes);
|
|
1103
1113
|
}
|
|
1104
1114
|
|
|
1105
1115
|
/**
|
|
@@ -2834,6 +2844,8 @@ export interface CheckFigures {
|
|
|
2834
2844
|
[MOTION_SEAM_LINE]?: MotionSeamLine;
|
|
2835
2845
|
/** Written only when the rig declares a physics constraint and has an idle (issue #501): {@link ClothLine}, a warning, never a bar. */
|
|
2836
2846
|
[CLOTH_LINE]?: ClothLine;
|
|
2847
|
+
/** Written only when it reads a part under physics (issue #1320): {@link PhysicsContributionLine}, a warning, never a bar. */
|
|
2848
|
+
[PHYSICS_CONTRIBUTES_LINE]?: PhysicsContributionLine;
|
|
2837
2849
|
[COINCIDE_LINE]?: SupportReport;
|
|
2838
2850
|
RECOMPOSITE_HOLES: ReportedLine;
|
|
2839
2851
|
/** Issue #933: openings inside the figure over motion across undeclared setup-overlapping layer pairs; omitted when SKIP. */
|
|
@@ -3268,6 +3280,8 @@ export interface CheckReport {
|
|
|
3268
3280
|
behindSeams: BehindSeamsMeasured | null;
|
|
3269
3281
|
/** `CLOTH_SETTLES` (issue #501): a warning, never a bar — in `check.json` only when the rig declares a physics constraint and has an idle; its SKIP is printed either way. */
|
|
3270
3282
|
cloth: ClothLine;
|
|
3283
|
+
/** `PHYSICS_CONTRIBUTES` (issue #1320): a warning, never a bar — in `check.json` only when it reads a part under physics; its SKIP is printed either way. */
|
|
3284
|
+
physics?: PhysicsContributionLine;
|
|
3271
3285
|
/** `WIND_BAND` (issue #590): the steady-wind band each declared seam pair holds, written under `--wind-band` only. */
|
|
3272
3286
|
windBand?: WindBandLine;
|
|
3273
3287
|
/**
|
|
@@ -3289,9 +3303,9 @@ export function barsSummary(r: Pick<CheckReport, 'bars'>): string {
|
|
|
3289
3303
|
return `${measured.length} of ${measured.length + skipped.length} bar(s) measured, ${skipped.length} skipped${skipped.length === 0 ? '' : ` (${skipped.map((s) => s.bar).join(', ')})`}`;
|
|
3290
3304
|
}
|
|
3291
3305
|
|
|
3292
|
-
/** The summary's warning clause: each warning line that read something, named, with the warnings they printed together, and `SETUP_PAINTING_MOSTLY_UNCOVERED` only when
|
|
3306
|
+
/** The summary's warning clause: each warning line that read something, named, with the warnings they printed together, and `PHYSICS_CONTRIBUTES` (issue #1320) and `SETUP_PAINTING_MOSTLY_UNCOVERED` only when they printed one (issue #1421); empty when none read. */
|
|
3293
3307
|
export function warningsClause(r: Pick<CheckReport, 'motionSeam' | 'cloth' | 'figures'>): string {
|
|
3294
|
-
const read = [...(r.motionSeam.status === 'SKIP' || (r.motionSeam.roots !== undefined && r.motionSeam.pairs.every(p => p.root !== undefined)) ? [] : [{ name: MOTION_SEAM_LINE, n: r.motionSeam.warnings }]), ...(r.cloth.status === 'SKIP' ? [] : [{ name: CLOTH_LINE, n: r.cloth.warnings }]), ...(setupPaintingWarningCount(r.figures[SETUP_PAINTING_LINE]) === 0 ? [] : [{ name: SETUP_PAINTING_UNCOVERED_WARNING, n: setupPaintingWarningCount(r.figures[SETUP_PAINTING_LINE]) }])];
|
|
3308
|
+
const read = [...(r.motionSeam.status === 'SKIP' || (r.motionSeam.roots !== undefined && r.motionSeam.pairs.every(p => p.root !== undefined)) ? [] : [{ name: MOTION_SEAM_LINE, n: r.motionSeam.warnings }]), ...(r.cloth.status === 'SKIP' ? [] : [{ name: CLOTH_LINE, n: r.cloth.warnings }]), ...((r.figures[PHYSICS_CONTRIBUTES_LINE]?.warnings ?? 0) === 0 ? [] : [{ name: PHYSICS_CONTRIBUTES_LINE, n: r.figures[PHYSICS_CONTRIBUTES_LINE]?.warnings ?? 0 }]), ...(setupPaintingWarningCount(r.figures[SETUP_PAINTING_LINE]) === 0 ? [] : [{ name: SETUP_PAINTING_UNCOVERED_WARNING, n: setupPaintingWarningCount(r.figures[SETUP_PAINTING_LINE]) }])];
|
|
3295
3309
|
if (read.length === 0) return '';
|
|
3296
3310
|
return `; ${read.reduce((a, x) => a + x.n, 0)} warning(s) (${read.map((x) => x.name).join(', ')}, not a bar)`;
|
|
3297
3311
|
}
|
|
@@ -3318,7 +3332,7 @@ export type CheckStatus = 'PASS' | 'FAIL' | 'SKIP' | 'WARN' | 'CLEAR' | 'REPORTE
|
|
|
3318
3332
|
* never skipped); `loop` SKIP when `loop_max_diff` is null, `seam` SKIP when `seam_mean` is null, otherwise FAIL when
|
|
3319
3333
|
* {@link barsNotMet} names it and PASS when it does not. Every other block carries its own `status` key and is copied:
|
|
3320
3334
|
* the judgement lines, then {@link FOLD_LINE}, {@link LEVEL_LINE}, {@link STRESS_LINE}, {@link LIMB_LINE},
|
|
3321
|
-
* {@link SWEEP_LINE}, {@link MOTION_SEAM_LINE}, {@link CLOTH_LINE}, the reported lines, {@link SOURCE_LINE} and
|
|
3335
|
+
* {@link SWEEP_LINE}, {@link MOTION_SEAM_LINE}, {@link CLOTH_LINE}, {@link PHYSICS_CONTRIBUTES_LINE}, the reported lines, {@link SOURCE_LINE} and
|
|
3322
3336
|
* {@link WIND_BAND_LINE}, each where the file writes it. The `requirements` block's lines are not bars and are not read here.
|
|
3323
3337
|
*/
|
|
3324
3338
|
export function checkStatuses(fig: Omit<CheckFigures, 'spec' | 'bar_outcomes' | 'build'>): Record<string, CheckStatus> {
|
|
@@ -3326,7 +3340,7 @@ export function checkStatuses(fig: Omit<CheckFigures, 'spec' | 'bar_outcomes' |
|
|
|
3326
3340
|
const bar = (id: 'gate' | 'loop' | 'seam', measured: boolean): CheckStatus => (!measured ? 'SKIP' : checkBarStatus(raw, id) === 'FAIL' ? 'FAIL' : 'PASS');
|
|
3327
3341
|
const out: Record<string, CheckStatus> = { gate: bar('gate', true), loop: bar('loop', fig.loop_max_diff !== null), seam: bar('seam', fig.seam_mean !== null) };
|
|
3328
3342
|
for (const n of JUDGEMENT_LINES) out[n] = fig[n].status;
|
|
3329
|
-
for (const n of [FOLD_LINE, LEVEL_LINE, STRESS_LINE, LIMB_LINE, SWEEP_LINE, MOTION_SEAM_LINE, CLOTH_LINE, ...REPORTED_LINES, 'figure_openings', SOURCE_LINE, WIND_BAND_LINE, ART_JOINT_LINE, CUT_MATERIAL_LINE, SETUP_PAINTING_LINE, BOUNDARY_COLOUR_LINE, BEHIND_SEAM_LINE, COINCIDE_LINE] as const) {
|
|
3343
|
+
for (const n of [FOLD_LINE, LEVEL_LINE, STRESS_LINE, LIMB_LINE, SWEEP_LINE, MOTION_SEAM_LINE, CLOTH_LINE, PHYSICS_CONTRIBUTES_LINE, ...REPORTED_LINES, 'figure_openings', SOURCE_LINE, WIND_BAND_LINE, ART_JOINT_LINE, CUT_MATERIAL_LINE, SETUP_PAINTING_LINE, BOUNDARY_COLOUR_LINE, BEHIND_SEAM_LINE, COINCIDE_LINE] as const) {
|
|
3330
3344
|
const l = fig[n];
|
|
3331
3345
|
if (l !== undefined) out[n] = l.status;
|
|
3332
3346
|
}
|
|
@@ -7426,6 +7440,19 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
7426
7440
|
cloth = unread === undefined ? clothLine(rows, idle.fps, idle.frames.length, idle.duration) : clothLine([], idle.fps, idle.frames.length, idle.duration, unread);
|
|
7427
7441
|
}
|
|
7428
7442
|
|
|
7443
|
+
// 3g. every part under physics, the same compile posed with physics on and off over the idle (issue #1320): a
|
|
7444
|
+
// warning, never a bar; SKIP, named, with no idle, no parts or no physics constraint
|
|
7445
|
+
let physics: PhysicsContributionLine;
|
|
7446
|
+
if (idle === null) physics = physicsLine([], IDLE_FPS, 0, 'none', "rig-c's default environment", inp.noIdle ?? 'no idle');
|
|
7447
|
+
else if (full === null) physics = physicsLine([], IDLE_FPS, 0, 'none', "rig-c's default environment", inp.noParts ?? 'no parts.json');
|
|
7448
|
+
else {
|
|
7449
|
+
const rest = attachmentPoses(join(idle.dir, GEOMETRY_FILE), idle.written)[0] ?? new Map<string, PosedAttachment>();
|
|
7450
|
+
physics = measurePhysicsContribution(officialRenderer(), buildDir, inp.rig, inp.motion, full.parts.parts.map((p) => ({
|
|
7451
|
+
name: p.name, w: p.w, h: p.h, bound: boundBones(inp.rig, p.name), rest: rest.get(p.name) === undefined ? undefined : { vertices: (rest.get(p.name) as PosedAttachment).rest, triangles: (rest.get(p.name) as PosedAttachment).triangles },
|
|
7452
|
+
art: () => placedArt(p.x, p.y, readPng(join(dirname(inp.partsDir), partImageReference(p).path))),
|
|
7453
|
+
})), inp.stage, idle.fps);
|
|
7454
|
+
}
|
|
7455
|
+
|
|
7429
7456
|
// 4. the setup pose as a one-key throwaway animation — the seam reads it against the parts, the source line against
|
|
7430
7457
|
// the painting — and, beside it, the same pose with the eyes shut
|
|
7431
7458
|
let seam: SeamFigures | null = null;
|
|
@@ -7722,6 +7749,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
7722
7749
|
...(sweep === null ? {} : { [SWEEP_LINE]: sweep }),
|
|
7723
7750
|
...(motionSeam.pairs.length === 0 && motionSeam.roots === undefined && motionSeam.required === undefined ? {} : { [MOTION_SEAM_LINE]: motionSeam }),
|
|
7724
7751
|
...(stripped === null || idle === null ? {} : { [CLOTH_LINE]: cloth }),
|
|
7752
|
+
...(physics.status === 'SKIP' ? {} : { [PHYSICS_CONTRIBUTES_LINE]: physics }),
|
|
7725
7753
|
RECOMPOSITE_HOLES: inp.parts === null ? { status: 'SKIP', reason: inp.noParts ?? '' } : holesLine(inp.parts),
|
|
7726
7754
|
...(figureOpenings.status === 'SKIP' ? {} : { figure_openings: figureOpenings }),
|
|
7727
7755
|
...(sourceRead === null ? {} : { [SOURCE_LINE]: sourceRead }),
|
|
@@ -7839,6 +7867,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
7839
7867
|
motionSeam,
|
|
7840
7868
|
figureOpenings,
|
|
7841
7869
|
cloth,
|
|
7870
|
+
physics,
|
|
7842
7871
|
boundaryColour,
|
|
7843
7872
|
behindSeams,
|
|
7844
7873
|
...(sweepSteps.size === 0 ? {} : { sweepSteps }),
|
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/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);
|