@rig-c/parts 2.46.0 → 2.47.1
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 +3 -1
- package/docs/AUTHORING.md +37 -15
- package/docs/STABILITY.md +29 -3
- package/package.json +1 -1
- package/src/alternatelayers.ts +2 -1
- package/src/assemble.ts +48 -48
- package/src/assembly-reading.ts +320 -94
- package/src/authoredunit.ts +2 -2
- package/src/behindseams.ts +67 -2
- package/src/build.ts +21 -10
- package/src/check.ts +9 -6
- package/src/config.ts +48 -14
- package/src/depthworkflow.ts +4 -2
- package/src/editedparts.ts +6 -1
- package/src/inputs.ts +1 -1
- package/src/parts.ts +2 -2
- package/src/partsource.ts +4 -1
- package/src/takelayers.ts +4 -1
- package/src/takeregion.ts +4 -1
package/src/build.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { changedAssemblyFields, effectiveAssemblyRules,
|
|
1
|
+
import { changedAssemblyFields, effectiveAssemblyRules, projectAssemblyConfig, readProjectedAssemblyConfig, type AssemblyLimb, refuseStaleAssembly, type AssemblyRules } from './assembly-reading.ts';
|
|
2
2
|
import { editedPartFrontColourLines, readEditedParts } from './editedparts.ts';
|
|
3
3
|
import { SOURCE_COVER_FILE, sourceCoverReport, type SourceCoverSet } from './sourcecover.ts';
|
|
4
4
|
import { STAGE_MAP_FILE } from './provenance.ts';
|
|
@@ -70,7 +70,7 @@ import { createHash } from 'node:crypto';
|
|
|
70
70
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
71
71
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
72
72
|
import { type AnimFrame, EncodeError, encodeApng, encodeIndexedApng, INDEXED_DEFAULTS } from './apng.ts';
|
|
73
|
-
import { assemble, type AssembleResult, boxOf, cutLines, edgeSplitLines, ERROR_LIMIT, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, softOcclusionLine, driftLine, limbLines, FIGURE_MASK_FILE, figureMaskLines, figuresLine, groundWarning, holeKindsLine, holeLines, measurePinholes, measureRecomposite, pinholeProblems, pinholesLine, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, stageFields, uncoveredLine, underBox } from './assemble.ts';
|
|
73
|
+
import { assemble, type AssembleResult, boxOf, cutLines, edgeSplitLines, ERROR_LIMIT, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, softOcclusionLine, driftLine, limbLines, FIGURE_MASK_FILE, figureMaskLines, figuresLine, groundWarning, holeKindsLine, holeLines, measurePinholes, measureRecomposite, pinholeProblems, pinholesLine, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, projectedStageFields, stageFields, uncoveredLine, underBox } from './assemble.ts';
|
|
74
74
|
import { allocationClause, type Reducer, stageBClause, unboundedClause } from './automesh.ts';
|
|
75
75
|
import { residualClause } from './autoenvelope.ts';
|
|
76
76
|
import { type AutoMotionCase, failingRows, idleSchedule, localRow, motionClause, motionDeformation, motionDocument, motionInput, motionRowText, motionStimulus, motionVerdict, noStimulusProblem, prepareComparison, type ReplayCandidate, runComparison, runPreparedComparison, sourceSelfFailure, stimulusMotion, withStimulus } from './automotion.ts';
|
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
untestedIntervals,
|
|
99
99
|
} from './autoreplay.ts';
|
|
100
100
|
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
|
-
import { type CharacterConfig, type Cut, type Extend,
|
|
101
|
+
import { type CharacterConfig, type Cut, type Extend, loadConfigAndAnimations, loadConfigWithBytes, loadEarlyConfig, type Patch, type PlanEntry } from './config.ts';
|
|
102
102
|
import { coreCompileGuideLine, failLine, foldName, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
103
103
|
import { editedConfigImages, editedRunImages, missingReceipts, readEditorReceipts } from './editreceipt.ts';
|
|
104
104
|
import { untracedPartSources } from './partsource.ts';
|
|
@@ -237,6 +237,7 @@ export interface AssembleOutputs {
|
|
|
237
237
|
|
|
238
238
|
/** The error map's file name beside a recomposite: `recomposite_rig.png` -> `recomposite_error_rig.png`. */
|
|
239
239
|
export const ERROR_MAP_FILE = 'recomposite_error_rig.png';
|
|
240
|
+
const ASSEMBLE_YIELD_NOTHING = 'ASSEMBLE_YIELD_NOTHING';
|
|
240
241
|
|
|
241
242
|
/**
|
|
242
243
|
* One line per part whose fringe `pushBackFringe` cleared (issue #119), in
|
|
@@ -439,7 +440,7 @@ export function emitFillMasksStage(input: EmitFillMasksInput, log: Log): Array<{
|
|
|
439
440
|
* (`ASSEMBLE_LIMB_CAP_PRESENT`), or a file that does not decode as a PNG
|
|
440
441
|
* (`ASSEMBLE_LIMB_CAP_DECODES`). The stage holds the image to the cap's box.
|
|
441
442
|
*/
|
|
442
|
-
export function readCaps(configPath: string, limbs: Readonly<Record<string,
|
|
443
|
+
export function readCaps(configPath: string, limbs: Readonly<Record<string, AssemblyLimb>>): Map<string, Raster> {
|
|
443
444
|
const problems: Problem[] = [];
|
|
444
445
|
const out = new Map<string, Raster>();
|
|
445
446
|
for (const [l, limb] of Object.entries(limbs)) {
|
|
@@ -503,13 +504,17 @@ function sourceCoverSet(result: AssembleResult, set: string | null, painting: st
|
|
|
503
504
|
|
|
504
505
|
/** Read, assemble, and write only after every refusal has had its chance. Throws a PartsError on a refusal, having written nothing. */
|
|
505
506
|
export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs, log: Log): AssembleResult {
|
|
507
|
+
// Flag-only figure masks and the region-take tolerance are effective
|
|
508
|
+
// inputs outside the legacy config reading.
|
|
506
509
|
const requirementsFile = input.requirements === undefined ? null : readRequirements(input.requirements);
|
|
507
510
|
const materialAsked = requirementsFile?.cut_material !== undefined;
|
|
508
511
|
// Issue #944: the pinhole bar is measured only when the requirements file declares it required.
|
|
509
512
|
const pinholesAsked = requirementsFile !== null && pinholesRequired(requirementsFile);
|
|
510
513
|
// The early door: assemble runs before propose has drafted bones, meshes,
|
|
511
514
|
// regions and motion, so it requires only what it reads (issue #20).
|
|
512
|
-
const
|
|
515
|
+
const projection = projectAssemblyConfig(loadEarlyConfig(input.config, 'assemble', input.project));
|
|
516
|
+
// The assemble loader requires seethrough before projection.
|
|
517
|
+
const cfg = { ...projection.config, seethrough: projection.config.seethrough! };
|
|
513
518
|
const supportDeclarations = JSON.stringify(cfg.assemble.cuts ?? []);
|
|
514
519
|
const { seam, project } = effectiveAssemblyRules(cfg.assemble, input);
|
|
515
520
|
const requirements = cfg.assemble.ground === 'busy' && project === 'visible'
|
|
@@ -524,7 +529,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
524
529
|
const takenRuns = applyTakenLayers(read, src, cfg, input.config);
|
|
525
530
|
const runs = applyTakenRegions(takenRuns, src, cfg, input.config, requirementsFile?.setup_painting, receipts, input.source);
|
|
526
531
|
for (const note of runs.notes) log(note.startsWith('WARN ') ? note : `note: ${note}`);
|
|
527
|
-
const fields =
|
|
532
|
+
const fields = projectedStageFields(cfg, runs.single ? { w: src.width, h: src.height } : null);
|
|
528
533
|
const setupPainting = requirements === null || fields.ground !== 'busy' || project !== 'visible' ? undefined
|
|
529
534
|
: readRequirements(requirements.read).setup_painting;
|
|
530
535
|
const figureSupport = setupPainting === undefined ? undefined
|
|
@@ -607,6 +612,8 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
607
612
|
});
|
|
608
613
|
}
|
|
609
614
|
|
|
615
|
+
const scopedYield = typeof fields.yieldRefused === 'object' ? fields.yieldRefused : [];
|
|
616
|
+
const yieldedParts = new Set(result.yieldReadings?.filter(row => row.yielded > 0).map(row => row.part));
|
|
610
617
|
const altProblems: Problem[] = [];
|
|
611
618
|
const allocationReports: Array<{ file: string; report: { set: string; coverageTransfers: PaintingAllocationReading['coverageTransfers'] } & Record<string, unknown> }> = [];
|
|
612
619
|
const altBuilt: Array<{ record: AlternatePartsRecord; images: Array<{ name: string; image: Raster }>; excluded: ExcludedCount[]; islands: IslandCount[]; splits: SplitCount[]; capSplits: SplitCount[]; depthClamps: AssembleResult['depthClamps'] }> = [];
|
|
@@ -713,7 +720,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
713
720
|
for (const sg of limb.segments) if (sg.hybrid !== undefined) { coveredSet.add(sg.hybrid.part); generatedBands.push(sg.hybrid.part); }
|
|
714
721
|
}
|
|
715
722
|
let rawCuts = alt.cuts !== undefined ? alt.cuts : fields.cuts.filter((c) => coveredSet.has(c.into) && coveredSet.has(c.from)).map((c) => ({ ...c, under: undefined }));
|
|
716
|
-
let altLimbs: Record<string,
|
|
723
|
+
let altLimbs: Record<string, AssemblyLimb> = {};
|
|
717
724
|
if (fields.limbs !== undefined) {
|
|
718
725
|
for (const [ln, limb] of Object.entries(fields.limbs)) {
|
|
719
726
|
if (limb.segments.every((sg) => coveredSet.has(sg.part))) {
|
|
@@ -780,7 +787,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
780
787
|
const originalIslands = alt.parts === undefined || input.setIslands === 'all' ? [] : setIslandSources(fields.limbs ?? {}, originalAltLimbs);
|
|
781
788
|
const altIslands = alternateLayerIslands(originalIslands, selectedLayers.groups);
|
|
782
789
|
// Issue #609: the limbs of those layers the set does not carry — the other leg of a two-leg layer.
|
|
783
|
-
const otherLimbs: Record<string,
|
|
790
|
+
const otherLimbs: Record<string, AssemblyLimb> =
|
|
784
791
|
input.setSplit === 'connectivity'
|
|
785
792
|
? {}
|
|
786
793
|
: Object.fromEntries(Object.entries(fields.limbs ?? {}).filter(([ln, l]) => !(ln in altLimbs) && l.segments.some((sg) => originalIslands.includes(sg.from))));
|
|
@@ -935,6 +942,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
935
942
|
}
|
|
936
943
|
throw err;
|
|
937
944
|
}
|
|
945
|
+
for (const row of altRes.yieldReadings ?? []) if (row.yielded > 0) yieldedParts.add(row.part);
|
|
938
946
|
const altMaskProblems = verifyUnderPlateMasks(altRes, altCuts, altUnderPlates, `${alt.at}.cuts`);
|
|
939
947
|
if (altMaskProblems.length > 0) {
|
|
940
948
|
altProblems.push(...altMaskProblems);
|
|
@@ -1069,7 +1077,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1069
1077
|
result.parts.alternates = altBuilt.map((b) => b.record);
|
|
1070
1078
|
}
|
|
1071
1079
|
|
|
1072
|
-
const reading =
|
|
1080
|
+
const reading = readProjectedAssemblyConfig(projection, result.parts, input.config, { seam, project });
|
|
1073
1081
|
let previousAssembly = undefined;
|
|
1074
1082
|
if (existsSync(outs.partsJson)) {
|
|
1075
1083
|
try { previousAssembly = readPartsManifest(outs.partsJson).assembly_config; }
|
|
@@ -1224,6 +1232,9 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1224
1232
|
if (result.figureMask !== undefined) for (const l of figureMaskLines(result.figureMask, scene)) log(l);
|
|
1225
1233
|
log(pinholesLine(pinholes, altBuilt.map((b) => b.record.name)));
|
|
1226
1234
|
for (const d of result.drift) log(driftLine(d));
|
|
1235
|
+
for (const part of scopedYield) {
|
|
1236
|
+
if (!yieldedParts.has(part)) log(`${ASSEMBLE_YIELD_NOTHING}: part ${JSON.stringify(part)} — no eligible projection refusal to yield in the base or alternate sets`);
|
|
1237
|
+
}
|
|
1227
1238
|
for (const d of result.softOcclusion ?? []) log(softOcclusionLine(d));
|
|
1228
1239
|
for (const line of result.cropClipped ?? []) log(line);
|
|
1229
1240
|
// Issue #588: per subset set, one line per limb part cut from a layer of more than one island, then (issue #587) one
|
|
@@ -1242,7 +1253,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1242
1253
|
* base parts at alpha above `OPAQUE_ALPHA_ABOVE`, at their `parts.json` x, y.
|
|
1243
1254
|
*/
|
|
1244
1255
|
function otherLimbsOf(
|
|
1245
|
-
limbs: Readonly<Record<string,
|
|
1256
|
+
limbs: Readonly<Record<string, AssemblyLimb>>,
|
|
1246
1257
|
setPlaced: ReadonlySet<string>,
|
|
1247
1258
|
bones: readonly BoneEntry[],
|
|
1248
1259
|
base: ReadonlyArray<{ record: PartRecord; image: Raster }>,
|
package/src/check.ts
CHANGED
|
@@ -43,7 +43,7 @@ import { baseAnchorMoves, type AnchorRegion } from './baseanchor.ts';
|
|
|
43
43
|
*
|
|
44
44
|
* | output | what |
|
|
45
45
|
* | --- | --- |
|
|
46
|
-
* | `build
|
|
46
|
+
* | `build/`, `build-report.json` | `rigc build --profile rig-play --pack --page-edges free --pack-shape polygon` (or `pot`, `rect`, when the caller names them; {@link PAGE_EDGES}, {@link PACK_SHAPES}) — the packed atlas is the final artifact, and `build-report.json` beside `build/` holds rigc's own `build-report/1` (`--report`) for that primary packed compile on a failing compile as on a green one (issue #1394) |
|
|
47
47
|
* | `gate_spine-html.txt` | that build's gate lines, verbatim — the one gate: rigc's `build` runs it once over the compile and once over the packed pages on disk, and `rig-play` holds every rule `spine` measures (selftest `CH09`) |
|
|
48
48
|
* | `idle_frames/` | `rigc render --animation idle --fps 12 --max 640 --geometry`: `frames.json` + `idle/f*.png` + `idle/geometry.json` (each mesh's skinned vertices, which `TEXTURE_STRETCH` reads, every attachment's posed triangles, which `TIP_OVER_ROOT` and both halves of `STILL_REGIONS_DARK` read since issues #118 and #123, and every bone's world transform, which the face half reads its head bone from) |
|
|
49
49
|
* | `contact.png` | rigc's own contact sheet of that render, copied out |
|
|
@@ -6898,7 +6898,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6898
6898
|
const out = resolve(outDir);
|
|
6899
6899
|
const outExisted = existsSync(out);
|
|
6900
6900
|
mkdirSync(out, { recursive: true });
|
|
6901
|
-
const buildDir = join(out, 'build');
|
|
6901
|
+
const buildDir = join(out, 'build'), buildReportPath = join(out, BUILD_REPORT_FILE);
|
|
6902
6902
|
const idleDir = join(out, 'idle_frames');
|
|
6903
6903
|
const stillDir = join(out, '_still');
|
|
6904
6904
|
const isoDir = join(out, '_isolated');
|
|
@@ -6908,7 +6908,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6908
6908
|
const foldDir = join(out, FOLD_SCRATCH);
|
|
6909
6909
|
const seamMotionDir = join(out, MOTION_SEAM_SCRATCH);
|
|
6910
6910
|
const windBandDir = join(out, WIND_BAND_SCRATCH);
|
|
6911
|
-
for (const d of [join(out, 'extremes'), join(out, '_extremes'), buildDir, idleDir, stillDir, isoDir, loopDir, seamDir, keptDir, join(out, 'setup_still_auto'), foldDir, seamMotionDir, windBandDir]) rmSync(d, { recursive: true, force: true });
|
|
6911
|
+
for (const d of [join(out, 'extremes'), join(out, '_extremes'), buildDir, buildReportPath, idleDir, stillDir, isoDir, loopDir, seamDir, keptDir, join(out, 'setup_still_auto'), foldDir, seamMotionDir, windBandDir]) rmSync(d, { recursive: true, force: true });
|
|
6912
6912
|
const written: string[] = [];
|
|
6913
6913
|
const write = (name: string, data: string): void => {
|
|
6914
6914
|
writeFileSync(join(out, name), data);
|
|
@@ -6917,9 +6917,9 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6917
6917
|
|
|
6918
6918
|
try {
|
|
6919
6919
|
// 1. build, packed, under the policy profile
|
|
6920
|
-
const build = rigc(['build', '--rig', inp.rigPath, '--motion', inp.motionPath, '--out', buildDir, ...packedBuildArgs(mode)]);
|
|
6920
|
+
const build = rigc(['build', '--rig', inp.rigPath, '--motion', inp.motionPath, '--out', buildDir, '--report', buildReportPath, ...packedBuildArgs(mode)]);
|
|
6921
6921
|
const gateHtml = buildGateLines(build.out);
|
|
6922
|
-
write('gate_spine-html.txt', `${gateHtml.join('\n')}\n`);
|
|
6922
|
+
write('gate_spine-html.txt', `${gateHtml.join('\n')}\n`); if (existsSync(buildReportPath)) written.push(BUILD_REPORT_FILE);
|
|
6923
6923
|
if (build.status !== 0) refuseIfAny(rigcFailed(packedBuildLabel(mode), build, gateHtml));
|
|
6924
6924
|
const pack = parsePackLines(gateHtml);
|
|
6925
6925
|
refuseIfAny(packEdgeProblems(pack, mode));
|
|
@@ -6971,7 +6971,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6971
6971
|
windBandRead = measureWindBand(wb, buildDir, windBandDir, animationNames, rigc);
|
|
6972
6972
|
} catch (err) {
|
|
6973
6973
|
rmSync(windBandDir, { recursive: true, force: true });
|
|
6974
|
-
|
|
6974
|
+
for (const p of [join(out, 'gate_spine-html.txt'), buildReportPath]) rmSync(p, { force: true });
|
|
6975
6975
|
rmSync(buildDir, { recursive: true, force: true });
|
|
6976
6976
|
if (!outExisted) rmSync(out, { recursive: true, force: true });
|
|
6977
6977
|
throw err;
|
|
@@ -9968,3 +9968,6 @@ export function stretchLine(geo: IdleGeometry | null, path: string, problems: Pr
|
|
|
9968
9968
|
per_mesh: rows,
|
|
9969
9969
|
};
|
|
9970
9970
|
}
|
|
9971
|
+
|
|
9972
|
+
/** The compiler's `build-report/1` (`--report`) written beside `build/` on the primary packed compile (issue #1394). */
|
|
9973
|
+
export const BUILD_REPORT_FILE = 'build-report.json';
|
package/src/config.ts
CHANGED
|
@@ -349,7 +349,7 @@ export interface Assemble {
|
|
|
349
349
|
/** Issue #492: composite full:face under head:face on the head canvas to fill transparent holes inside the face silhouette. */
|
|
350
350
|
head_face_underfill?: boolean;
|
|
351
351
|
/** Opt-in: yield original drift-refused front cores and connected non-core rims to an opaque behind holder matching the painting. */
|
|
352
|
-
yield_refused?: boolean;
|
|
352
|
+
yield_refused?: boolean | string[];
|
|
353
353
|
/** Emit the report-only last-writer sidecar; absent or false is off. */
|
|
354
354
|
stage_map?: boolean;
|
|
355
355
|
/** Named plan parts retain their own pixels beneath a drawn-in-front soft occluder. */
|
|
@@ -940,15 +940,15 @@ export function partBoundBones(b: PartBinding): Map<string, string[]> {
|
|
|
940
940
|
* Returns null when `config.turn` is absent, so a rig without a turn block is
|
|
941
941
|
* untouched.
|
|
942
942
|
*/
|
|
943
|
-
export function turnMovingPartPair(
|
|
943
|
+
export function turnMovingPartPair<C extends Pick<ConfigConstraint, 'type'> & { bone?: unknown }>(
|
|
944
944
|
cfg: {
|
|
945
945
|
assemble?: CharacterConfig['assemble'];
|
|
946
946
|
turn?: TurnSpec;
|
|
947
947
|
bones?: BoneEntry[];
|
|
948
948
|
meshes?: Record<string, MeshSpec>;
|
|
949
949
|
regions?: Record<string, RegionSpec>;
|
|
950
|
-
limbs?: Record<string, Limb
|
|
951
|
-
constraints?:
|
|
950
|
+
limbs?: Record<string, Pick<Limb, 'segments'>>;
|
|
951
|
+
constraints?: C[];
|
|
952
952
|
},
|
|
953
953
|
): ((a: string, b: string) => boolean) | null {
|
|
954
954
|
const turn = cfg.turn;
|
|
@@ -1794,7 +1794,7 @@ export interface EarlyConfig {
|
|
|
1794
1794
|
depth?: DepthConfig;
|
|
1795
1795
|
key: string;
|
|
1796
1796
|
seethrough: SeeThrough;
|
|
1797
|
-
assemble: { rig_scale: number; seam?: SeamRule; project?: ProjectRule; ground?: Ground; take?: TakeDeclaration[]; editor_receipts?: EditorReceipts; edited_parts?: EditedParts; head_face_underfill?: boolean; yield_refused?: boolean; stage_map?: boolean; keep_under_occluders?: string[]; require_hidden_extent?: HiddenExtentDeclaration[]; extend_painting?: PaintingExtension[]; occluders?: OccluderDeclaration[]; edge_splits?: EdgeSplit[] };
|
|
1797
|
+
assemble: { rig_scale: number; seam?: SeamRule; project?: ProjectRule; ground?: Ground; take?: TakeDeclaration[]; editor_receipts?: EditorReceipts; edited_parts?: EditedParts; head_face_underfill?: boolean; yield_refused?: boolean | string[]; stage_map?: boolean; keep_under_occluders?: string[]; require_hidden_extent?: HiddenExtentDeclaration[]; extend_painting?: PaintingExtension[]; occluders?: OccluderDeclaration[]; edge_splits?: EdgeSplit[] };
|
|
1798
1798
|
}
|
|
1799
1799
|
|
|
1800
1800
|
/** What plain `assemble` reads: the early config plus the plan `--propose-plan` printed. */
|
|
@@ -1890,9 +1890,7 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null, p
|
|
|
1890
1890
|
if ('take' in a) checkTakeLayers(c, a.take, null, a);
|
|
1891
1891
|
if ('editor_receipts' in a) checkEditorReceipts(c, a.editor_receipts);
|
|
1892
1892
|
if ('edited_parts' in a) checkEditedParts(c, a.edited_parts, a.plan);
|
|
1893
|
-
|
|
1894
|
-
c.fail('CONFIG_FIELD_TYPE', 'config.assemble.yield_refused', `is ${show(a.yield_refused)}; true or false is required`);
|
|
1895
|
-
}
|
|
1893
|
+
checkYieldRefused(c, a);
|
|
1896
1894
|
}
|
|
1897
1895
|
}
|
|
1898
1896
|
}
|
|
@@ -1920,6 +1918,7 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null, p
|
|
|
1920
1918
|
checkAlternates(c, t.assemble.alternates, made, limbs, names?.bones ?? null, names?.chains ?? null, t.regions, t.meshes);
|
|
1921
1919
|
}
|
|
1922
1920
|
const output = new Set([...made.parts.filter(n => !limbs?.consumed.has(n)), ...made.patches, ...made.cuts, ...(limbs?.parts.keys() ?? [])]);
|
|
1921
|
+
if (isPlainObject(t.assemble)) checkYieldRefused(c, t.assemble, new Set([...finalLayerPartNames(made.parts, made.cuts, limbs), ...made.patches]), limbs);
|
|
1923
1922
|
if (isPlainObject(t.assemble) && 'extend_painting' in t.assemble) checkPaintingExtensions(c, t.assemble.extend_painting, new Set([...output].filter(n => !made.patches.includes(n) && !limbs?.consumed.has(n))));
|
|
1924
1923
|
if ('motion_seams' in t) {
|
|
1925
1924
|
c.problems.push(...motionSeamProblems(t.motion_seams, output, 'config.motion_seams', 'CONFIG_MOTION_SEAM'));
|
|
@@ -2141,9 +2140,10 @@ function parseConfigFrom(raw: Json, base: string | null): { config: CharacterCon
|
|
|
2141
2140
|
if (isPlainObject(t.assemble) && 'alternates' in t.assemble) {
|
|
2142
2141
|
checkAlternates(c, t.assemble.alternates, { parts, patches, cuts }, limbs, names.bones, names.chains, t.regions, t.meshes);
|
|
2143
2142
|
}
|
|
2144
|
-
if (isPlainObject(t.assemble)
|
|
2145
|
-
const output =
|
|
2146
|
-
|
|
2143
|
+
if (isPlainObject(t.assemble)) {
|
|
2144
|
+
const output = finalLayerPartNames(parts, cuts, limbs);
|
|
2145
|
+
checkYieldRefused(c, t.assemble, new Set([...output, ...patches]), limbs);
|
|
2146
|
+
if ('extend_painting' in t.assemble) checkPaintingExtensions(c, t.assemble.extend_painting, output);
|
|
2147
2147
|
}
|
|
2148
2148
|
if ('meshes' in t) checkMeshes(c, t.meshes, names.bones, names.chains, t.stops);
|
|
2149
2149
|
if ('regions' in t) checkRegions(c, t.regions, names.bones);
|
|
@@ -2722,6 +2722,43 @@ function checkOccluderFiles(c: Check, assemble: Json, base: string | null): void
|
|
|
2722
2722
|
c.problems.push(...occluderFileProblems(declarations, base));
|
|
2723
2723
|
}
|
|
2724
2724
|
|
|
2725
|
+
function finalLayerPartNames(parts: readonly string[], cuts: readonly string[], limbs: LimbNames | null): Set<string> {
|
|
2726
|
+
return new Set([...parts, ...cuts].filter(name => !limbs?.consumed.has(name)).concat([...(limbs?.parts.keys() ?? [])]));
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
function checkYieldRefused(c: Check, assemble: Record<string, Json>, outputs?: Set<string>, limbs?: LimbNames | null): void {
|
|
2730
|
+
const value = assemble.yield_refused;
|
|
2731
|
+
if (!('yield_refused' in assemble) || typeof value === 'boolean') return;
|
|
2732
|
+
const at = 'config.assemble.yield_refused';
|
|
2733
|
+
if (!Array.isArray(value)) {
|
|
2734
|
+
c.fail('CONFIG_FIELD_TYPE', at, `is ${show(value)}; true, false or a list of final yielding part names is required`);
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
if (value.length === 0) c.fail('CONFIG_FIELD_TYPE', at, 'is []; use false or omit the key to disable yield');
|
|
2738
|
+
const names = outputs === undefined ? undefined : new Set(outputs);
|
|
2739
|
+
if (names !== undefined && Array.isArray(assemble.alternates)) {
|
|
2740
|
+
for (const alternate of assemble.alternates.filter(isPlainObject)) {
|
|
2741
|
+
if (!Array.isArray(alternate.cuts)) continue;
|
|
2742
|
+
for (const cut of alternate.cuts.filter(isPlainObject)) if (typeof cut.into === 'string') names.add(cut.into);
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
const seen = new Set<string>();
|
|
2746
|
+
for (const [i, name] of value.entries()) {
|
|
2747
|
+
const entry = `${at}[${i}]`;
|
|
2748
|
+
if (!c.string(entry, name)) continue;
|
|
2749
|
+
if (seen.has(name)) c.fail('CONFIG_PART_UNIQUE', entry, `names ${show(name)} again; each yielding part is named once`);
|
|
2750
|
+
seen.add(name);
|
|
2751
|
+
if (names !== undefined && !names.has(name)) {
|
|
2752
|
+
const limb = limbs?.consumed.get(name);
|
|
2753
|
+
const segments = limb === undefined ? [] : limbs?.chains.get(limb)?.parts ?? [];
|
|
2754
|
+
const detail = limb === undefined
|
|
2755
|
+
? 'a final output part name is required (source tags and aliases are not accepted)'
|
|
2756
|
+
: `config.limbs.${limb} consumes it; list its final segment parts instead (${segments.map(part => show(part)).join(', ')})`;
|
|
2757
|
+
c.fail('CONFIG_NAME_RESOLVES', entry, `names ${show(name)}; ${detail}`);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2725
2762
|
function checkKeepUnderOccluders(c: Check, a: Record<string, Json>, plan: readonly string[] | null): void {
|
|
2726
2763
|
if (!('keep_under_occluders' in a)) return;
|
|
2727
2764
|
const at = 'config.assemble.keep_under_occluders';
|
|
@@ -2924,9 +2961,6 @@ function checkAssemble(c: Check, v: Json, door: 'assemble' | 'full'): { parts: s
|
|
|
2924
2961
|
if ('head_face_underfill' in a && typeof a.head_face_underfill !== 'boolean') {
|
|
2925
2962
|
c.fail('CONFIG_FIELD_TYPE', `${p}.head_face_underfill`, `is ${show(a.head_face_underfill)}; true or false is required`);
|
|
2926
2963
|
}
|
|
2927
|
-
if ('yield_refused' in a && typeof a.yield_refused !== 'boolean') {
|
|
2928
|
-
c.fail('CONFIG_FIELD_TYPE', `${p}.yield_refused`, `is ${show(a.yield_refused)}; true or false is required`);
|
|
2929
|
-
}
|
|
2930
2964
|
if ('stage_map' in a && typeof a.stage_map !== 'boolean') {
|
|
2931
2965
|
c.fail('CONFIG_FIELD_TYPE', `${p}.stage_map`, `is ${show(a.stage_map)}; true or false is required`);
|
|
2932
2966
|
}
|
package/src/depthworkflow.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { createHash } from 'node:crypto';
|
|
6
6
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
8
|
+
import { refuseStaleAssembly } from './assembly-reading.ts';
|
|
8
9
|
import { loadConfigAndAnimations, parseConfig } from './config.ts';
|
|
9
10
|
import { relocateConfigReferences } from './configrelocation.ts';
|
|
10
11
|
import { depthReading, readSourceDepth } from './depthsheets.ts';
|
|
@@ -223,7 +224,8 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
223
224
|
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']; })]);
|
|
224
225
|
const rawParts = object(readJson(join(input.parts, 'parts.json')), 'parts.json'), file = readParts(join(input.parts, 'parts.json'));
|
|
225
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');
|
|
226
|
-
loadConfigAndAnimations(input.rigConfig);
|
|
227
|
+
const { config } = loadConfigAndAnimations(input.rigConfig);
|
|
228
|
+
refuseStaleAssembly(input.rigConfig, file, config);
|
|
227
229
|
const raw = object(readJson(input.rigConfig), 'rig config'), turn = object(raw.turn, 'config.turn');
|
|
228
230
|
for (const [name, group] of Object.entries(recipe.groups)) {
|
|
229
231
|
const target = name === 'head' ? turn : object(turn.body, 'config.turn.body'); target.pivot = group.pivot;
|
|
@@ -231,7 +233,7 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
231
233
|
}
|
|
232
234
|
// Keep relative paths portable when relocating the output directory with its inputs.
|
|
233
235
|
relocateConfigReferences(raw, dirname(input.rigConfig), input.out, 'relative');
|
|
234
|
-
parseConfig(raw);
|
|
236
|
+
refuseStaleAssembly(join(input.out, 'config.json'), file, parseConfig(raw));
|
|
235
237
|
const warnings: string[] = [];
|
|
236
238
|
const writes = new Map<string, Uint8Array>(), rows: Obj[] = [], recs = rawParts.parts as Obj[];
|
|
237
239
|
// Retain auxiliary art (including alternate sets) and diagnostics byte-for-byte.
|
package/src/editedparts.ts
CHANGED
|
@@ -128,7 +128,12 @@ export function replaceEditedParts(
|
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
130
|
const found = sha(encodePngBytes(part.image));
|
|
131
|
-
if (found !== receipt.from_sha256) problems.push({
|
|
131
|
+
if (found !== receipt.from_sha256) problems.push({
|
|
132
|
+
code: 'ASSEMBLE_EDITED_PART_BASELINE', object,
|
|
133
|
+
detail: `the current assembled PNG sha256 is ${found}; receipt from_sha256 ${receipt.from_sha256} is required. ` +
|
|
134
|
+
'The assembled PNG changed since the baseline, typically because an assembly input changed. ' +
|
|
135
|
+
'Use edited-part --parts with the prior manifest and current config to check for ASSEMBLY_CONFIG_STALE and see which assembly fields changed',
|
|
136
|
+
});
|
|
132
137
|
if (image.width !== part.record.w || image.height !== part.record.h) problems.push({ code: 'ASSEMBLE_EDITED_PART_SIZE', object, detail: `edited PNG is ${image.width}x${image.height}; assembled box ${part.record.w}x${part.record.h} is required` });
|
|
133
138
|
const actual = sha(edit.bytes);
|
|
134
139
|
if (actual !== receipt.sha256) problems.push({ code: 'ASSEMBLE_EDITED_PART_SHA256', object, detail: `edited bytes sha256 is ${actual}; receipt sha256 ${receipt.sha256} is required` });
|
package/src/inputs.ts
CHANGED
|
@@ -73,7 +73,7 @@ export function padToSquare(w: number, h: number, side: number): SquarePad {
|
|
|
73
73
|
return { side, left: Math.floor((side - w) / 2), top: Math.floor((side - h) / 2) };
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export function makeInputs(painting: Raster, cfg: Pick<CharacterConfig
|
|
76
|
+
export function makeInputs(painting: Raster, cfg: { seethrough?: Partial<Pick<NonNullable<CharacterConfig['seethrough']>, 'head_box' | 'resolution'>> }, label: string): SeeThroughInputs {
|
|
77
77
|
const problems: Problem[] = [];
|
|
78
78
|
const { width: w, height: h } = painting;
|
|
79
79
|
let translucent = 0;
|
package/src/parts.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assemblyFieldDigest } from './assembly-reading.ts';
|
|
1
|
+
import { assemblyFieldDigest, isSplitTakeMetadataField } from './assembly-reading.ts';
|
|
2
2
|
import { orderedEditedPartReceipt, type EditedPartReceipt } from './editedparts.ts';
|
|
3
3
|
import { parseReceiptProducer, receiptText } from './receiptproducer.ts';
|
|
4
4
|
import { takenSourceProblems, type TakenLayerSource } from './takesource.ts';
|
|
@@ -886,7 +886,7 @@ function checkParts(raw: unknown, path: string): PartsFile {
|
|
|
886
886
|
if (value === null || typeof value !== 'object' || Object.keys(value).some(key => key !== 'sha256' && key !== 'fields') ||
|
|
887
887
|
!digest(value.sha256) || !Array.isArray(value.fields) || value.fields.length === 0 ||
|
|
888
888
|
!value.fields.every((row, i) => row !== null && typeof row === 'object' && Object.keys(row).length === 2 &&
|
|
889
|
-
typeof row.name === 'string' && /^[a-z_]+(?:\.[a-z_]+)*$/.test(row.name) &&
|
|
889
|
+
typeof row.name === 'string' && (/^[a-z_]+(?:\.[a-z_]+)*$/.test(row.name) || isSplitTakeMetadataField(row.name)) &&
|
|
890
890
|
digest(row.sha256) && (i === 0 || value.fields![i - 1].name < row.name)) ||
|
|
891
891
|
assemblyFieldDigest(value.fields) !== value.sha256) {
|
|
892
892
|
fail('PARTS_FIELD_TYPE', `${path} field "assembly_config"`, 'requires sorted distinct field names with lowercase SHA-256 digests and their matching aggregate digest');
|
package/src/partsource.ts
CHANGED
|
@@ -54,7 +54,10 @@ export function tracePartsDeclared(cfg: Pick<AssembleConfig, 'assemble'>): boole
|
|
|
54
54
|
* Order is the config's: cuts, each alternate set's cuts, patches, painting
|
|
55
55
|
* extensions, the arm split, limb splits in key order.
|
|
56
56
|
*/
|
|
57
|
-
export function untracedPartSources(cfg: Pick<AssembleConfig, 'assemble'
|
|
57
|
+
export function untracedPartSources(cfg: Pick<AssembleConfig, 'assemble'> & {
|
|
58
|
+
seethrough: Pick<AssembleConfig['seethrough'], 'arm_split'>;
|
|
59
|
+
limbs?: Record<string, Pick<NonNullable<AssembleConfig['limbs']>[string], 'segments' | 'split'>>;
|
|
60
|
+
}): Problem[] {
|
|
58
61
|
if (!tracePartsDeclared(cfg)) return [];
|
|
59
62
|
const out: Problem[] = [];
|
|
60
63
|
const refuse = (object: string, found: string): void => {
|
package/src/takelayers.ts
CHANGED
|
@@ -161,7 +161,10 @@ function supportOverlap(a: Layer, b: Layer): number {
|
|
|
161
161
|
return px;
|
|
162
162
|
}
|
|
163
163
|
/** Apply every declaration together, so replacing all tied layers from one run can retain its known order. */
|
|
164
|
-
export function applyTakenLayers
|
|
164
|
+
export function applyTakenLayers<T extends Pick<EarlyConfig, 'depth'> & {
|
|
165
|
+
seethrough: Pick<EarlyConfig['seethrough'], 'resolution' | 'head_box'>;
|
|
166
|
+
assemble: { take?: TakeDeclaration[]; plan?: PlanEntry[]; occluders?: OccluderDeclaration[] };
|
|
167
|
+
}>(runs: { full: LayerSet; head: LayerSet; single: boolean }, painting: Raster, cfg: T, configPath: string): { full: LayerSet; head: LayerSet; single: boolean; notes: string[] } {
|
|
165
168
|
const wholeDeclarations = (cfg.assemble.take ?? []).filter((item): item is TakeLayers => 'tags' in item);
|
|
166
169
|
const declarations = (cfg.assemble.take ?? []).filter((item): item is TakeLayers | TakeOccluderSplit => 'tags' in item || 'occluder' in item);
|
|
167
170
|
const occluders = cfg.assemble.occluders ?? [];
|
package/src/takeregion.ts
CHANGED
|
@@ -118,7 +118,10 @@ export function deriveTakenRegion(base: Layer, donor: Layer, painting: Raster, s
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/** Called beside whole-layer take, before assembly or any output emission. */
|
|
121
|
-
export function applyTakenRegions(runs: Runs, painting: Raster, cfg: AssembleConfig,
|
|
121
|
+
export function applyTakenRegions(runs: Runs, painting: Raster, cfg: Pick<AssembleConfig, 'depth'> & {
|
|
122
|
+
seethrough: Pick<AssembleConfig['seethrough'], 'head_box'> | undefined;
|
|
123
|
+
assemble: Pick<AssembleConfig['assemble'], 'take' | 'plan'>;
|
|
124
|
+
}, configPath: string, setup: SetupPainting | undefined, receipts: ReceiptLedger, sourcePath?: string): Runs {
|
|
122
125
|
const declarations = (cfg.assemble.take ?? []).filter((item): item is TakeRegion => 'seed' in item);
|
|
123
126
|
if (declarations.length === 0) return runs;
|
|
124
127
|
const tolerance = setup?.rgb_tolerance;
|