rig-parts 2.70.0 → 2.72.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 +12 -5
- package/docs/AUTHORING.md +11 -7
- package/docs/STABILITY.md +89 -21
- package/package.json +6 -5
- package/src/assemble.ts +2 -2
- package/src/build.ts +53 -29
- package/src/clipstretch.ts +0 -1
- package/src/configwrite.ts +1 -2
- package/src/depthsheets.ts +9 -2
- package/src/diagnostics.ts +1 -2
- package/src/edgesplit.ts +1 -2
- package/src/layers.ts +34 -6
- package/src/meshdraft.ts +3 -4
- package/src/paintingextension.ts +1 -2
- package/src/propose.ts +1 -2
- package/src/requirements.ts +1 -2
- package/src/rig.ts +9 -12
- package/src/runstamp.ts +96 -10
- package/src/scene.ts +1 -1
- package/src/structure.ts +1 -2
- package/src/turn.ts +1 -3
- package/src/visibility.ts +16 -11
- package/tools/build-process.ts +59 -8
package/src/depthsheets.ts
CHANGED
|
@@ -39,7 +39,12 @@ export interface DepthConfig { zScale?: number; full?: DepthRunConfig; head?: De
|
|
|
39
39
|
/** Explicit caller context; never inferred from a filename or sheet presence. */
|
|
40
40
|
export interface DepthBinding { config: DepthConfig; run: 'full' | 'head'; base: string }
|
|
41
41
|
/** Legacy metadata retained without file I/O or value validation until opt-in. */
|
|
42
|
-
export interface DeferredDepthSource {
|
|
42
|
+
export interface DeferredDepthSource {
|
|
43
|
+
filename: unknown;
|
|
44
|
+
base: string;
|
|
45
|
+
/** Bound to the original wrapper's receipt role, even if the layer is transformed. */
|
|
46
|
+
recordDecode?: (path: string, sha256: string) => void;
|
|
47
|
+
}
|
|
43
48
|
export interface DepthSource {
|
|
44
49
|
from: string;
|
|
45
50
|
image: string;
|
|
@@ -173,7 +178,9 @@ export function registerDepthRun(set: LayerSet, run: 'full' | 'head', cfg: Depth
|
|
|
173
178
|
const paths = [join(hint.base, file), join(hint.base, 'parts', `${layer.name}_depth.png`)];
|
|
174
179
|
const found = paths.filter(p => existsSync(p));
|
|
175
180
|
if (found.length === 2 && !readFileSync(found[0]).equals(readFileSync(found[1]))) throw new PartsError([{ code: 'DEPTH_SHEET_UNAMBIGUOUS', object: from, detail: `${paths.join(' and ')} differ; keep one source or identical bytes` }]);
|
|
176
|
-
|
|
181
|
+
const selected = found[0] ?? paths[0];
|
|
182
|
+
sheet = readSourceDepth(selected, layer.pixels, layer.depth);
|
|
183
|
+
hint.recordDecode?.(selected, sheet.sha256);
|
|
177
184
|
}
|
|
178
185
|
if (sheet !== undefined && supplied !== undefined) throw new PartsError([{ code: 'DEPTH_SOURCE_AMBIGUOUS', object: from, detail: 'has both depth_filename and a user declaration; the writer file is authoritative — remove the unused fallback for this layer' }]);
|
|
179
186
|
let near: DepthNear = sheet?.near ?? SEETHROUGH_DEPTH_NEAR, zScale = sheet?.zScale ?? cfg?.zScale;
|
package/src/diagnostics.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { explicitWeightRows, regionBone, type RegionSpec } from './config.ts';
|
|
1
|
+
import { type BoneEntry, explicitWeightRows, type Limb, regionBone, type RegionSpec } from './config.ts';
|
|
2
2
|
/**
|
|
3
3
|
* What `propose` looked at, said (issue #86): the coverage lines lint's
|
|
4
4
|
* per-bone record prints, and the basis file written beside the proposal.
|
|
@@ -33,7 +33,6 @@ import { explicitWeightRows, regionBone, type RegionSpec } from './config.ts';
|
|
|
33
33
|
* write the same bytes.
|
|
34
34
|
*/
|
|
35
35
|
import { type Problem, refuseIfAny } from './errors.ts';
|
|
36
|
-
import type { BoneEntry, Limb } from './config.ts';
|
|
37
36
|
import type { RigJoints } from './keypoints.ts';
|
|
38
37
|
import { BASIS_KINDS, type BasisKind, type BoneBasis, type BoneCoverage, COVERAGE_OUTCOMES, coverageOutcome, expand, FRAME_KEYS, type FrameBasis, type FrameKey, type PartSet, type Placement, type Proposal, type ProposalBasis } from './propose.ts';
|
|
39
38
|
import { BONE_ROLES, type BoneRole, compareStructure, readSkeleton } from './structure.ts';
|
package/src/edgesplit.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** Painting-edge part split on pre-projection plan rasters (#1231). */
|
|
2
|
-
import type
|
|
3
|
-
import { refuseIfAny } from './errors.ts';
|
|
2
|
+
import { type Problem, refuseIfAny } from './errors.ts';
|
|
4
3
|
import type { Raster } from './raster/types.ts';
|
|
5
4
|
import { pyRound } from './round.ts';
|
|
6
5
|
|
package/src/layers.ts
CHANGED
|
@@ -33,6 +33,7 @@ import type { TakenLayerSource } from './takesource.ts';
|
|
|
33
33
|
* role, and its place in the draw order is read like any other layer's.
|
|
34
34
|
*/
|
|
35
35
|
import { bindDepthRun, type DepthBinding, type DeferredDepthSource, type SourceDepthSheet } from './depthsheets.ts';
|
|
36
|
+
import { createHash } from 'node:crypto';
|
|
36
37
|
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
37
38
|
import { basename, dirname, join } from 'node:path';
|
|
38
39
|
import { initializeCanvas, type Layer as PsdLayer, readPsd, writePsd } from 'ag-psd';
|
|
@@ -199,6 +200,18 @@ const MANIFEST_REQUIRED = ['layers', 'width', 'height'] as const;
|
|
|
199
200
|
const LAYER_KEYS = ['name', 'filename', 'left', 'top', 'right', 'bottom', 'depth_median', 'depth_filename'] as const;
|
|
200
201
|
const LAYER_REQUIRED = ['name', 'filename', 'left', 'top', 'right', 'bottom', 'depth_median'] as const;
|
|
201
202
|
|
|
203
|
+
export interface WrapperManifestReading {
|
|
204
|
+
path: string;
|
|
205
|
+
sha256: string;
|
|
206
|
+
givenAsDirectory: boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Optional capture of consumed files for a primary assemble input. Paths retain their reader spelling. */
|
|
210
|
+
export interface WrapperReadings {
|
|
211
|
+
manifest?: WrapperManifestReading;
|
|
212
|
+
pngs: Array<{ path: string; sha256: string }>;
|
|
213
|
+
}
|
|
214
|
+
|
|
202
215
|
/**
|
|
203
216
|
* What the wrapper form's `depth_median` may be, as a refusal quotes it. A
|
|
204
217
|
* See-through run writes a number; an input with no depth — a PSD exported by
|
|
@@ -227,10 +240,15 @@ const DEPTH_RULE = 'a finite number (See-through\'s depth, larger = further back
|
|
|
227
240
|
export function readWrapperLayers(
|
|
228
241
|
path: string, binding?: DepthBinding,
|
|
229
242
|
sealedFiles?: ReadonlyMap<string, Buffer>,
|
|
243
|
+
readings?: WrapperReadings,
|
|
230
244
|
): LayerSet {
|
|
231
245
|
const bytesOf = (file: string): Buffer => sealedFiles?.get(file) ?? readFileSync(file);
|
|
232
|
-
const
|
|
246
|
+
const givenAsDirectory = existsSync(path) && statSync(path).isDirectory();
|
|
247
|
+
const manifestPath = givenAsDirectory ? join(path, 'layers.json') : path;
|
|
233
248
|
const dir = dirname(manifestPath);
|
|
249
|
+
const recordDecode = readings === undefined ? undefined : (file: string, sha256: string): void => {
|
|
250
|
+
readings.pngs.push({ path: file, sha256 });
|
|
251
|
+
};
|
|
234
252
|
const problems: Problem[] = [];
|
|
235
253
|
const refuse = (code: string, object: string, detail: string): void => {
|
|
236
254
|
problems.push({ code, object, detail });
|
|
@@ -241,7 +259,11 @@ export function readWrapperLayers(
|
|
|
241
259
|
}
|
|
242
260
|
let manifest: unknown;
|
|
243
261
|
try {
|
|
244
|
-
|
|
262
|
+
const bytes = bytesOf(manifestPath);
|
|
263
|
+
manifest = JSON.parse(bytes.toString('utf8'));
|
|
264
|
+
if (readings !== undefined) {
|
|
265
|
+
readings.manifest = { path: manifestPath, sha256: createHash('sha256').update(bytes).digest('hex'), givenAsDirectory };
|
|
266
|
+
}
|
|
245
267
|
} catch (err) {
|
|
246
268
|
refuse('LAYERS_MANIFEST_IS_JSON', manifestPath, `does not parse as JSON: ${(err as Error).message}`);
|
|
247
269
|
refuseIfAny(problems);
|
|
@@ -371,6 +393,7 @@ export function readWrapperLayers(
|
|
|
371
393
|
refuse('LAYERS_PNG_DECODES', `layer "${name}"`, (err as Error).message);
|
|
372
394
|
return;
|
|
373
395
|
}
|
|
396
|
+
recordDecode?.(present[0], createHash('sha256').update(bytes[0]).digest('hex'));
|
|
374
397
|
if (pixels.width !== right - left || pixels.height !== bottom - top) {
|
|
375
398
|
refuse(
|
|
376
399
|
'LAYERS_PNG_MATCHES_BBOX',
|
|
@@ -379,8 +402,13 @@ export function readWrapperLayers(
|
|
|
379
402
|
);
|
|
380
403
|
return;
|
|
381
404
|
}
|
|
405
|
+
const depthHint: DeferredDepthSource | undefined = !('depth_filename' in e) ? undefined : {
|
|
406
|
+
filename: e.depth_filename,
|
|
407
|
+
base: dir,
|
|
408
|
+
...(recordDecode === undefined ? {} : { recordDecode }),
|
|
409
|
+
};
|
|
382
410
|
if (hiddenOf !== null) {
|
|
383
|
-
hidden.push({ name, of: hiddenOf.of, file: present[0], pixels, left, top, right, bottom, opaquePx: opaque(pixels), ...(
|
|
411
|
+
hidden.push({ name, of: hiddenOf.of, file: present[0], pixels, left, top, right, bottom, opaquePx: opaque(pixels), ...(depthHint === undefined ? {} : { depthHint }) });
|
|
384
412
|
return;
|
|
385
413
|
}
|
|
386
414
|
read.push({
|
|
@@ -388,7 +416,7 @@ export function readWrapperLayers(
|
|
|
388
416
|
tag: tag as LayerTagReading,
|
|
389
417
|
file: present[0],
|
|
390
418
|
pixels,
|
|
391
|
-
...(
|
|
419
|
+
...(depthHint === undefined ? {} : { depthHint }),
|
|
392
420
|
left,
|
|
393
421
|
top,
|
|
394
422
|
right,
|
|
@@ -576,9 +604,9 @@ export function readPsdLayers(path: string): LayerSet {
|
|
|
576
604
|
}
|
|
577
605
|
|
|
578
606
|
/** Read whichever form `path` is: a `.psd` file, or a wrapper directory / `layers.json`. */
|
|
579
|
-
export function readLayers(path: string, binding?: DepthBinding): LayerSet {
|
|
607
|
+
export function readLayers(path: string, binding?: DepthBinding, readings?: WrapperReadings): LayerSet {
|
|
580
608
|
if (/\.psd$/i.test(path)) { const set = readPsdLayers(path); return binding === undefined ? set : bindDepthRun(set, binding.run, binding.config, binding.base); }
|
|
581
|
-
if (existsSync(path) && (statSync(path).isDirectory() || basename(path) === 'layers.json')) return readWrapperLayers(path, binding);
|
|
609
|
+
if (existsSync(path) && (statSync(path).isDirectory() || basename(path) === 'layers.json')) return readWrapperLayers(path, binding, undefined, readings);
|
|
582
610
|
refuseIfAny([
|
|
583
611
|
{
|
|
584
612
|
code: 'LAYERS_INPUT_KIND',
|
package/src/meshdraft.ts
CHANGED
|
@@ -59,11 +59,10 @@
|
|
|
59
59
|
* Pure in the sense `src/` is held to: no clock, no randomness, no network, no child process. rigc runs as a process,
|
|
60
60
|
* but the process is injected, exactly as `src/check.ts` and `src/build.ts` take it.
|
|
61
61
|
*/
|
|
62
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync,
|
|
62
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
63
63
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
64
|
-
import type
|
|
64
|
+
import { type AlphaMask, type MeasureRow, type MeshQualityReport, MeshReductionError, type MotionSchedule } from '@rig-c/core/mesh';
|
|
65
65
|
import { compareMeshesInMotion, type MotionComparisonInput } from '@rig-c/core/meshcompare';
|
|
66
|
-
import { MeshReductionError } from '@rig-c/core/mesh';
|
|
67
66
|
import { explicitFrameId, idleSchedule } from './automotion.ts';
|
|
68
67
|
import { checkStage, gateThroughRigc, type Log, RIGC_MODEL_DOCUMENT, rigStage } from './build.ts';
|
|
69
68
|
import { BARS, type CheckReport, type PackShape, type PageEdges, parsePageSize, type RigcRunner } from './check.ts';
|
|
@@ -72,7 +71,7 @@ import { relocateConfigReferences } from './configrelocation.ts';
|
|
|
72
71
|
import { PartsError, type Problem, problemLine } from './errors.ts';
|
|
73
72
|
import { IDLE_FPS } from './motion.ts';
|
|
74
73
|
import { type ContourBridges, FAINT_ALPHA } from './contour.ts';
|
|
75
|
-
import { ART_ALPHA, DUST_MAX_PX, DUST_MAX_SHARE, isDust, dustOf
|
|
74
|
+
import { ART_ALPHA, DUST_MAX_PX, DUST_MAX_SHARE, isDust, dustOf } from './mesh.ts';
|
|
76
75
|
import { partImageReference, type PartsFile, readParts } from './parts.ts';
|
|
77
76
|
import { readPng } from './raster/png.ts';
|
|
78
77
|
import type { Raster } from './raster/types.ts';
|
package/src/paintingextension.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** Explicit painting ownership, after assembly and before output cropping (#848). */
|
|
2
|
-
import type
|
|
3
|
-
import { refuseIfAny } from './errors.ts';
|
|
2
|
+
import { type Problem, refuseIfAny } from './errors.ts';
|
|
4
3
|
import { CORE_ALPHA, OPAQUE_ALPHA_ABOVE } from './layers.ts';
|
|
5
4
|
import { newMask, type Mask, type Raster } from './raster/types.ts';
|
|
6
5
|
|
package/src/propose.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ART_ALPHA, dustOf, isDust } from './mesh.ts';
|
|
2
|
-
import { explicitWeightRows, regionBone, type RegionSpec } from './config.ts';
|
|
2
|
+
import { type BoneEntry, type CharacterConfig, type ConfigConstraint, type ConfigStop, type ContourBustSpec, type ContourSpec, contourRegionsOf, deriveBustRegions, explicitWeightRows, type Limb, type MeshSpec, type PartBinding, parseConfig, type Point, regionBone, type RegionSpec, type Segment, type SkeletonSections, turnRidersByBone } from './config.ts';
|
|
3
3
|
/**
|
|
4
4
|
* The propose stage: bone origins, mesh candidate lists, regions and a default
|
|
5
5
|
* idle, read off the assembled parts — and the overlay a person or an agent
|
|
@@ -133,7 +133,6 @@ import { explicitWeightRows, regionBone, type RegionSpec } from './config.ts';
|
|
|
133
133
|
import { existsSync } from 'node:fs';
|
|
134
134
|
import { join } from 'node:path';
|
|
135
135
|
import { drawText, GLYPH_H } from '@rig-c/core/font5x7';
|
|
136
|
-
import { type BoneEntry, type CharacterConfig, type ConfigConstraint, type ConfigStop, type ContourBustSpec, type ContourSpec, contourRegionsOf, deriveBustRegions, type Limb, type MeshSpec, type PartBinding, parseConfig, type Point, type Segment, type SkeletonSections, turnRidersByBone } from './config.ts';
|
|
137
136
|
export { contourRegionsOf, deriveBustRegions };
|
|
138
137
|
import { computeExactFrameTransforms, cropToSpineY, normaliseDegrees, toWorld } from './coords.ts';
|
|
139
138
|
import { PartsError, type Problem, refuseIfAny } from './errors.ts';
|
package/src/requirements.ts
CHANGED
|
@@ -57,8 +57,7 @@ import { resolve } from 'node:path';
|
|
|
57
57
|
import { CompileError } from '@rig-c/core/errors';
|
|
58
58
|
import { splitRigSkin, type RigSkin } from '@rig-c/core/rig';
|
|
59
59
|
import { cropToSpineY } from './coords.ts';
|
|
60
|
-
import type
|
|
61
|
-
import { refuseIfAny } from './errors.ts';
|
|
60
|
+
import { type Problem, refuseIfAny } from './errors.ts';
|
|
62
61
|
import { type BoneWorld, type GeometryPose, type MeshRest, stretchFigures, stretchSeverity } from './instruments.ts';
|
|
63
62
|
import { ART_ALPHA } from './mesh.ts';
|
|
64
63
|
import { alphaAbove, type Raster } from './raster/types.ts';
|
package/src/rig.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { baseAnchorProblems, orderedBaseAnchor, baseAnchorMoves, type AnchorRegion } from './baseanchor.ts';
|
|
2
2
|
import { padDepthSheet, padTurnDepthSheet, depthSheetProblems, type PartDepthReference } from './depthsheets.ts';
|
|
3
|
-
import { explicitBoneNames, explicitSlotBones, explicitWeightRows, regionBone } from './config.ts';
|
|
3
|
+
import { type AutoSpec, type BoneEntry, type CharacterConfig, type ConfigConstraint, type ConfigStop, CONSTRAINT_FOLLOWS, constraintForRig, contourRegionsOf, type ContourSpec, DEFAULT_BUST_BONE_L, DEFAULT_BUST_BONE_R, explicitBoneNames, explicitSlotBones, explicitWeightRows, type InfluenceMeshSpec, type MeshSpec, type Point, regionBone, type RibsSpec, ROOT_BONE, stopForRig, turnRidersByBone, type WeightRule, weightsABone } from './config.ts';
|
|
4
4
|
import { explicitAttachment, type ExplicitMeshReport } from './explicitmesh.ts';
|
|
5
5
|
/**
|
|
6
6
|
* The rig stage: a character config and its assembled parts in, a rig spec
|
|
@@ -137,7 +137,6 @@ import { explicitAttachment, type ExplicitMeshReport } from './explicitmesh.ts';
|
|
|
137
137
|
* touches the disk, and the same inputs give the same bytes (key order is the
|
|
138
138
|
* order the objects are built in, and every number is rounded by `pyRound`).
|
|
139
139
|
*/
|
|
140
|
-
import { type AutoSpec, type BoneEntry, type InfluenceMeshSpec, type WeightRule, type CharacterConfig, type MeshSpec, type ConfigConstraint, type ConfigStop, CONSTRAINT_FOLLOWS, constraintForRig, contourRegionsOf, type ContourSpec, DEFAULT_BUST_BONE_L, DEFAULT_BUST_BONE_R, type Point, type RibsSpec, ROOT_BONE, stopForRig, turnRidersByBone, weightsABone } from './config.ts';
|
|
141
140
|
import { RUNTIME_PI } from '@rig-c/core/core';
|
|
142
141
|
import { type BoneTransform, computeExactFrameTransforms, computeWorldTransforms, cropToSpineY, normaliseDegrees, paintingToSetupPoint, setupToPaintingPoint, toBoneLocal, toWorld } from './coords.ts';
|
|
143
142
|
import { foldName, type Problem, refuseIfAny, PartsError } from './errors.ts';
|
|
@@ -145,8 +144,7 @@ import { recordedFocusProblems } from './setfocus.ts';
|
|
|
145
144
|
import { eyeLineDegrees } from './headframe.ts';
|
|
146
145
|
import type { RigBoneInherit, RigInvariants, RigStop } from '@rig-c/core/rig';
|
|
147
146
|
import { f32 } from '@rig-c/core/compile';
|
|
148
|
-
import type
|
|
149
|
-
import { bindWeightedVertices, buildGridMesh, buildSegmentsLattice, type EntrySegment, influenceShares, segmentDistance as rigcSegmentDistance, type SegmentsLattice, type SegmentsLatticeReport } from '@rig-c/core/mesh';
|
|
147
|
+
import { bindWeightedVertices, buildGridMesh, buildSegmentsLattice, type EntrySegment, influenceShares, type MeshCounts, type MeshQualityReport, type MeshReductionInput, type MotionAmplitude, type ReducedMesh, segmentDistance as rigcSegmentDistance, type SegmentsLattice, type SegmentsLatticeReport, type Termination } from '@rig-c/core/mesh';
|
|
150
148
|
import { type AmplitudeRow, amplitudeRow, partAmplitude, withAmplitude } from './autoamplitude.ts';
|
|
151
149
|
import { type ResidualRow, residualRow, slotEnvelope, withSkinning } from './autoenvelope.ts';
|
|
152
150
|
import { type AutoMotionCase, type AutoSearch, DEFORM_MAY_FOLD_WHY, type MotionDeformation, type StimulusPose, stimulusAnimationNames } from './automotion.ts';
|
|
@@ -181,15 +179,14 @@ import { OPAQUE_ALPHA_ABOVE } from './layers.ts';
|
|
|
181
179
|
import { bindFaceSurfaceDeform, BLINK, blinkHoldMisses, blinkSpan, blinkTimes, CONTROL_SUFFIX, controlledBones, IDLE_FPS, idleMotion, type MotionSpec, moveKeysToControls } from './motion.ts';
|
|
182
180
|
import { type PartRecord, type AlternateSetMap, FRONT_SUFFIX, PAINTING_RUN, type PartsFile, readFrom, tagOf } from './parts.ts';
|
|
183
181
|
import { waistPairs, waistBand, waistInfluences } from './waist.ts';
|
|
184
|
-
import { preserveWaistRest, refineWaistMesh, remapWaistDeforms, storedWorld, waistBottomMesh, waistBottomLayoutOf, type WaistMapping } from './waistmesh.ts';
|
|
185
|
-
import { pivotWaistMesh, sharedWaistCopy, type WaistPivotRequest } from './waistmesh.ts';
|
|
182
|
+
import { pivotWaistMesh, preserveWaistRest, refineWaistMesh, remapWaistDeforms, sharedWaistCopy, storedWorld, waistBottomMesh, waistBottomLayoutOf, type WaistMapping, type WaistPivotRequest } from './waistmesh.ts';
|
|
186
183
|
import { readTag } from './tags.ts';
|
|
187
184
|
import { EYE_GROUP_TAGS } from './propose.ts';
|
|
188
185
|
import { alphaAbove, crop, pad, type Raster } from './raster/index.ts';
|
|
189
186
|
import { pyRound } from './round.ts';
|
|
190
187
|
import { boneHeat, type HeatDust, heatInfluences, HEAT_LIMITS, heatRow, type HeatRow, latticeSilhouette, tracedSilhouette } from './heat.ts';
|
|
191
188
|
import type { PosePoints } from './skeleton.ts';
|
|
192
|
-
import { applyFaceSurfaceDeform, BODY_REAR_SHIFT_BONE, BODY_YAW_DIAL_BONE, BODYSHIFT_BONE, buildDepth25DTurn, type Depth25DTurnOptions, FACE_RATED_BAND, FACESHIFT_BONE, PITCH_DIAL_BONE, REAR_SHIFT_BONE, resolveTurnGrid, TURN_BONE, TURN_CARRIER_TAG, TURN_GRID_MAX_TRIANGLES_PER_SLOT, TURN_GRID_MAX_TRIANGLES_TOTAL, TURN_PLACES, TURN_RIDER_APART, TURN_RIDER_TAGS, turnRiderDepth, type
|
|
189
|
+
import { applyFaceSurfaceDeform, BODY_REAR_SHIFT_BONE, BODY_YAW_DIAL_BONE, BODYSHIFT_BONE, buildDepth25DTurn, type Depth25DTurnOptions, FACE_RATED_BAND, FACESHIFT_BONE, PITCH_DIAL_BONE, REAR_SHIFT_BONE, resolveTurnGrid, TURN_BONE, TURN_CARRIER_TAG, TURN_GRID_MAX_TRIANGLES_PER_SLOT, TURN_GRID_MAX_TRIANGLES_TOTAL, TURN_PLACES, TURN_RIDER_APART, TURN_RIDER_TAGS, turnRiderDepth, type TurnSpec, turnConstraintName, turnFractions, turnNearest, turnSurfaceBone, turnTwin, turnUnitBone, YAW_DIAL_BONE } from './turn.ts';
|
|
193
190
|
import type { CoupledTurnBandReport } from './turnband.ts';
|
|
194
191
|
import { DISTANCE_EXPONENT, type FloorForm, type Influence, influences, type InfluenceLimits, type MeshInfluences, meshLimits, type Segment } from './weights.ts';
|
|
195
192
|
import { turnContourBands } from './turnoverlap.ts';
|
|
@@ -1637,11 +1634,11 @@ export function buildWaistPairSource(
|
|
|
1637
1634
|
/^full:(drape|hand)-[rl]$/.test(from)
|
|
1638
1635
|
? ` — the full run's merged arm layer was split into this part (issue #490, from 1.37.0), which a config proposed before 1.37.0 does not name; see ${ARM_SPLIT_MIGRATION}, and add only its plan row and entry with: ${ARM_SPLIT_REMEDY}`
|
|
1639
1636
|
: '';
|
|
1640
|
-
const where = (
|
|
1641
|
-
for (const part of Object.keys(cfg.meshes)) if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.meshes.${part}`, `names the part "${part}", which is not in parts.json; ${where(
|
|
1637
|
+
const where = (): string => `parts.json holds ${parts.parts.length} part(s): ${parts.parts.map((p) => p.name).join(', ')}`;
|
|
1638
|
+
for (const part of Object.keys(cfg.meshes)) if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.meshes.${part}`, `names the part "${part}", which is not in parts.json; ${where()}`);
|
|
1642
1639
|
for (const [part, region] of Object.entries(cfg.regions)) {
|
|
1643
1640
|
const bone = regionBone(region);
|
|
1644
|
-
if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.regions.${part}`, `names the part "${part}", which is not in parts.json; ${where(
|
|
1641
|
+
if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.regions.${part}`, `names the part "${part}", which is not in parts.json; ${where()}`);
|
|
1645
1642
|
if (!B.has(bone)) fail('RIG_NAME_RESOLVES', `config.regions.${part}`, `names the bone "${bone}", which config.bones does not declare`);
|
|
1646
1643
|
}
|
|
1647
1644
|
if (cfg.stops !== undefined) {
|
|
@@ -1657,13 +1654,13 @@ export function buildWaistPairSource(
|
|
|
1657
1654
|
}
|
|
1658
1655
|
if (cfg.turn?.roles !== undefined) {
|
|
1659
1656
|
for (const part of Object.keys(cfg.turn.roles)) {
|
|
1660
|
-
if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.turn.roles.${part}`, `names the part "${part}", which is not in parts.json; ${where(
|
|
1657
|
+
if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.turn.roles.${part}`, `names the part "${part}", which is not in parts.json; ${where()}`);
|
|
1661
1658
|
else if (!(part in cfg.meshes) && !(part in cfg.regions)) fail('RIG_NAME_RESOLVES', `config.turn.roles.${part}`, `names "${part}", which neither config.meshes nor config.regions attaches`);
|
|
1662
1659
|
}
|
|
1663
1660
|
}
|
|
1664
1661
|
if (cfg.turn?.body !== undefined) {
|
|
1665
1662
|
for (const part of Object.keys(cfg.turn.body.roles)) {
|
|
1666
|
-
if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.turn.body.roles.${part}`, `names the part "${part}", which is not in parts.json; ${where(
|
|
1663
|
+
if (!byPart.has(part)) fail('RIG_PART_PRESENT', `config.turn.body.roles.${part}`, `names the part "${part}", which is not in parts.json; ${where()}`);
|
|
1667
1664
|
else if (!(part in cfg.meshes) && !(part in cfg.regions)) fail('RIG_NAME_RESOLVES', `config.turn.body.roles.${part}`, `names "${part}", which neither config.meshes nor config.regions attaches`);
|
|
1668
1665
|
}
|
|
1669
1666
|
}
|
package/src/runstamp.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { existsSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import nodePath, { basename, join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import nodePath, { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
4
4
|
import { type AssembleResult, FIGURE_MASK_FILE } from './assemble.ts';
|
|
5
|
-
import { BUILD_RUN_FILE, ERROR_MAP_FILE } from './build.ts';
|
|
5
|
+
import { type AssembleWrapperReadings, BUILD_RUN_FILE, type BuildWrapperRole, ERROR_MAP_FILE } from './build.ts';
|
|
6
6
|
import { CUT_MATERIAL_SOURCES } from './cutmaterial.ts';
|
|
7
7
|
import { EDGE_RESIDUAL_FILE } from './edgeresidual.ts';
|
|
8
8
|
import { PartsError } from './errors.ts';
|
|
9
|
+
import type { WrapperManifestReading, WrapperReadings } from './layers.ts';
|
|
9
10
|
import { LAYOUT_FILE } from './limblayout.ts';
|
|
10
11
|
import { argvPathFromOut, linkRuleFor, type PlatformPath, realWhereItExists, recordedConfigPath, recordedInputPath } from './outputpaths.ts';
|
|
11
12
|
import { PAINTING_ALLOCATION_FILE } from './paintingedges.ts';
|
|
@@ -68,6 +69,14 @@ export interface RunStampAssembleInputs {
|
|
|
68
69
|
head?: string | null;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
type WrapperRole = 'full' | 'head';
|
|
73
|
+
export type { BuildWrapperRole };
|
|
74
|
+
export interface BoundWrapperInputs<Role extends string = WrapperRole> {
|
|
75
|
+
manifests: Partial<Record<Role, WrapperManifestReading>>;
|
|
76
|
+
pngs: RunStampInputEntry<Role>[];
|
|
77
|
+
}
|
|
78
|
+
type AssembleWrapperInputs = BoundWrapperInputs<WrapperRole>;
|
|
79
|
+
|
|
71
80
|
export interface RunStamp {
|
|
72
81
|
spec: typeof RUN_STAMP_SPEC;
|
|
73
82
|
package: RunStampPackage;
|
|
@@ -77,6 +86,7 @@ export interface RunStamp {
|
|
|
77
86
|
config: RunStampFileEntry;
|
|
78
87
|
parts_input?: RunStampFileEntry;
|
|
79
88
|
inputs?: RunStampInputEntry[];
|
|
89
|
+
wrapper_pngs?: RunStampInputEntry<WrapperRole>[];
|
|
80
90
|
outputs: RunStampFileEntry[];
|
|
81
91
|
}
|
|
82
92
|
|
|
@@ -90,6 +100,7 @@ export interface RunStampInput {
|
|
|
90
100
|
/** The parts directory as supplied to the stage and its pre-stage digest. */
|
|
91
101
|
partsInput?: RunStampFileEntry;
|
|
92
102
|
inputs?: RunStampAssembleInputs;
|
|
103
|
+
wrapperInputs?: AssembleWrapperInputs;
|
|
93
104
|
outputPaths: readonly string[];
|
|
94
105
|
}
|
|
95
106
|
|
|
@@ -106,28 +117,87 @@ function relativeToOutRoot(outDir: string, targetPath: string): string {
|
|
|
106
117
|
type RunInputPaths<Role extends string> = Array<readonly [Role, string | null | undefined]>;
|
|
107
118
|
|
|
108
119
|
/** Name and hash the same file. A See-through directory names its manifest (issue #1554). */
|
|
109
|
-
function recordInputs<Role extends string>(paths: RunInputPaths<Role>, outDir: string, cwd: string
|
|
120
|
+
function recordInputs<Role extends string>(paths: RunInputPaths<Role>, outDir: string, cwd: string,
|
|
121
|
+
manifests?: Partial<Record<Role, WrapperManifestReading>>,
|
|
122
|
+
): RunStampInputEntry<Role>[] {
|
|
110
123
|
const entries: RunStampInputEntry<Role>[] = [];
|
|
111
124
|
for (const [role, given] of paths) {
|
|
112
125
|
if (given === undefined || given === null) continue;
|
|
113
126
|
const resolved = resolve(cwd, given);
|
|
114
|
-
const
|
|
127
|
+
const manifest = manifests?.[role];
|
|
128
|
+
const isDir = manifest?.givenAsDirectory ?? statSync(resolved).isDirectory();
|
|
115
129
|
entries.push({
|
|
116
130
|
role,
|
|
117
131
|
path: recordedInputPath(given, outDir, cwd, isDir),
|
|
118
|
-
sha256: sha256OnDisk(isDir ? join(resolved, 'layers.json') : resolved),
|
|
132
|
+
sha256: manifest?.sha256 ?? sha256OnDisk(isDir ? join(resolved, 'layers.json') : resolved),
|
|
119
133
|
});
|
|
120
134
|
}
|
|
121
135
|
return entries;
|
|
122
136
|
}
|
|
123
137
|
|
|
124
138
|
/** The ordered inputs (`source`, `full`, and `head` when given) for an `assemble` run stamp. */
|
|
125
|
-
export function buildAssembleInputs(inputs: RunStampAssembleInputs, outDir: string): RunStampInputEntry[] {
|
|
139
|
+
export function buildAssembleInputs(inputs: RunStampAssembleInputs, outDir: string, manifests?: AssembleWrapperInputs['manifests']): RunStampInputEntry[] {
|
|
126
140
|
return recordInputs<RunStampInputRole>([
|
|
127
141
|
['source', inputs.source],
|
|
128
142
|
['full', inputs.full],
|
|
129
143
|
['head', inputs.head],
|
|
130
|
-
], outDir, inputs.cwd ?? process.cwd());
|
|
144
|
+
], outDir, inputs.cwd ?? process.cwd(), manifests);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function bindWrapperRoleReadings<Role extends string>(
|
|
148
|
+
entries: ReadonlyArray<readonly [Role, WrapperReadings | undefined]>,
|
|
149
|
+
): BoundWrapperInputs<Role> | undefined {
|
|
150
|
+
const manifests: Partial<Record<Role, WrapperManifestReading>> = {};
|
|
151
|
+
const pngs: RunStampInputEntry<Role>[] = [];
|
|
152
|
+
let anyManifest = false;
|
|
153
|
+
for (const [role, reading] of entries) {
|
|
154
|
+
if (reading?.manifest === undefined) continue;
|
|
155
|
+
anyManifest = true;
|
|
156
|
+
manifests[role] = reading.manifest;
|
|
157
|
+
const dir = dirname(reading.manifest.path);
|
|
158
|
+
const hashes = new Map<string, string>();
|
|
159
|
+
for (const { path: file, sha256 } of reading.pngs) {
|
|
160
|
+
const path = relative(dir, file).split(sep).join('/');
|
|
161
|
+
if (path === '' || path === '..' || path.startsWith('../') || path.startsWith('/') || /^[a-z]:/i.test(path) || path.includes('\\') || path.includes('\0')) {
|
|
162
|
+
throw new PartsError([{
|
|
163
|
+
code: 'ASSEMBLE_WRAPPER_PNG_PATH',
|
|
164
|
+
object: `${role} wrapper PNG ${JSON.stringify(file)}`,
|
|
165
|
+
detail: `relative path ${JSON.stringify(path)} found; a canonical slash-delimited path within ${JSON.stringify(dir)} without a drive prefix, backslash or NUL is required`,
|
|
166
|
+
}]);
|
|
167
|
+
}
|
|
168
|
+
const previous = hashes.get(path);
|
|
169
|
+
if (previous !== undefined && previous !== sha256) {
|
|
170
|
+
throw new PartsError([{
|
|
171
|
+
code: 'ASSEMBLE_WRAPPER_PNG_CONFLICT',
|
|
172
|
+
object: `${role} wrapper PNG ${JSON.stringify(path)}`,
|
|
173
|
+
detail: `found SHA-256 ${previous} and ${sha256}; one digest per role and path is required`,
|
|
174
|
+
}]);
|
|
175
|
+
}
|
|
176
|
+
hashes.set(path, sha256);
|
|
177
|
+
}
|
|
178
|
+
for (const path of [...hashes.keys()].sort()) pngs.push({ role, path, sha256: hashes.get(path)! });
|
|
179
|
+
}
|
|
180
|
+
return anyManifest ? { manifests, pngs } : undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Validate the primary wrappers' consumed files before assemble can publish its outputs. */
|
|
184
|
+
export function bindAssembleWrapperInputs(readings: AssembleWrapperReadings): AssembleWrapperInputs | undefined {
|
|
185
|
+
return bindWrapperRoleReadings<WrapperRole>([
|
|
186
|
+
['full', readings.full],
|
|
187
|
+
['head', readings.head],
|
|
188
|
+
]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Validate the primary and `--alt` wrappers' consumed files before build's assemble worker publishes its outputs. */
|
|
192
|
+
export function bindBuildWrapperInputs(readings: AssembleWrapperReadings): BoundWrapperInputs<BuildWrapperRole> | undefined {
|
|
193
|
+
const entries: Array<readonly [BuildWrapperRole, WrapperReadings | undefined]> = [
|
|
194
|
+
['full', readings.full],
|
|
195
|
+
['head', readings.head],
|
|
196
|
+
];
|
|
197
|
+
readings.alts?.forEach((alt, i) => {
|
|
198
|
+
entries.push([`alt[${i}].full`, alt.full], [`alt[${i}].head`, alt.head]);
|
|
199
|
+
});
|
|
200
|
+
return bindWrapperRoleReadings(entries);
|
|
131
201
|
}
|
|
132
202
|
|
|
133
203
|
function sortCodeUnits(paths: readonly string[]): string[] {
|
|
@@ -234,7 +304,8 @@ export function buildRunStamp(input: RunStampInput): RunStamp {
|
|
|
234
304
|
path: rel,
|
|
235
305
|
sha256: sha256OnDisk(join(input.outDir, ...rel.split('/'))),
|
|
236
306
|
}));
|
|
237
|
-
const
|
|
307
|
+
const wrapperInputs = input.command === 'assemble' ? input.wrapperInputs : undefined;
|
|
308
|
+
const inputs = input.inputs === undefined ? undefined : buildAssembleInputs(input.inputs, input.outDir, wrapperInputs?.manifests);
|
|
238
309
|
return {
|
|
239
310
|
spec: RUN_STAMP_SPEC,
|
|
240
311
|
package: {
|
|
@@ -255,6 +326,7 @@ export function buildRunStamp(input: RunStampInput): RunStamp {
|
|
|
255
326
|
},
|
|
256
327
|
}),
|
|
257
328
|
...(inputs === undefined ? {} : { inputs }),
|
|
329
|
+
...(wrapperInputs === undefined ? {} : { wrapper_pngs: wrapperInputs.pngs }),
|
|
258
330
|
outputs,
|
|
259
331
|
};
|
|
260
332
|
}
|
|
@@ -294,7 +366,13 @@ export type BuildRunInputRole = RunStampInputRole | 'requirements' | 'environmen
|
|
|
294
366
|
|
|
295
367
|
export type RunRecord =
|
|
296
368
|
| (RunRecordFields & { spec: typeof RUN_RECORD_SPEC; command: 'check'; parts_input?: RunStampFileEntry })
|
|
297
|
-
| (RunRecordFields & {
|
|
369
|
+
| (RunRecordFields & {
|
|
370
|
+
spec: typeof BUILD_RUN_RECORD_SPEC;
|
|
371
|
+
command: 'build';
|
|
372
|
+
config: RunStampFileEntry;
|
|
373
|
+
inputs: RunStampInputEntry<BuildRunInputRole>[];
|
|
374
|
+
wrapper_pngs?: RunStampInputEntry<BuildRunInputRole>[];
|
|
375
|
+
});
|
|
298
376
|
|
|
299
377
|
/** One command's flags as its parser takes them: the flag-table order, which values are paths, and values that hold paths inside them. */
|
|
300
378
|
export interface ArgvTable {
|
|
@@ -415,7 +493,12 @@ interface BuildRunInputs extends RunStampAssembleInputs {
|
|
|
415
493
|
|
|
416
494
|
export type RunRecordInput = RunRecordInputFields & (
|
|
417
495
|
| { command: 'check'; partsInput?: RunStampFileEntry }
|
|
418
|
-
| {
|
|
496
|
+
| {
|
|
497
|
+
command: 'build';
|
|
498
|
+
configPath: string;
|
|
499
|
+
inputs: BuildRunInputs;
|
|
500
|
+
wrapperPngs?: readonly RunStampInputEntry<BuildRunInputRole>[];
|
|
501
|
+
}
|
|
419
502
|
);
|
|
420
503
|
|
|
421
504
|
function buildRunInputs(inputs: BuildRunInputs, outDir: string): RunStampInputEntry<BuildRunInputRole>[] {
|
|
@@ -465,6 +548,9 @@ export function buildRunRecord(input: RunRecordInput): RunRecord {
|
|
|
465
548
|
...times,
|
|
466
549
|
config: { path: recordedConfigPath(input.outDir, input.configPath), sha256: sha256OnDisk(input.configPath) },
|
|
467
550
|
inputs: buildRunInputs(input.inputs, input.outDir),
|
|
551
|
+
...(input.wrapperPngs === undefined || input.wrapperPngs.length === 0
|
|
552
|
+
? {}
|
|
553
|
+
: { wrapper_pngs: input.wrapperPngs.map(({ role, path, sha256 }) => ({ role, path, sha256 })) }),
|
|
468
554
|
...tail,
|
|
469
555
|
};
|
|
470
556
|
}
|
package/src/scene.ts
CHANGED
|
@@ -2508,7 +2508,7 @@ export function unprefixedNames(rig: RigSpec, motion: MotionSpec, ids: readonly
|
|
|
2508
2508
|
name('invariants.axes name', ax.name, false);
|
|
2509
2509
|
for (const n of [...ax.through, ...ax.bones]) name(`invariants.axes ${ax.name} bone`, n, false);
|
|
2510
2510
|
}
|
|
2511
|
-
for (const
|
|
2511
|
+
for (const k of Object.keys(motion.easings)) name('easing', k, false);
|
|
2512
2512
|
for (const [g, members] of Object.entries(motion.groups)) {
|
|
2513
2513
|
name('group', g, false);
|
|
2514
2514
|
for (const m of members) name(`group ${g} member`, m, false);
|
package/src/structure.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { explicitWeightRows, regionBone } from './config.ts';
|
|
1
|
+
import { type ConfigConstraint, CONSTRAINT_FOLLOWS, contourRegionsOf, explicitWeightRows, parseConfig, parseProposalSections, type Point, regionBone, ROOT_BONE, type SkeletonSections, weightsABone } from './config.ts';
|
|
2
2
|
/**
|
|
3
3
|
* A structural comparison of two skeletons (issue #85).
|
|
4
4
|
*
|
|
@@ -73,7 +73,6 @@ import { explicitWeightRows, regionBone } from './config.ts';
|
|
|
73
73
|
import { existsSync, readFileSync } from 'node:fs';
|
|
74
74
|
import { CompileError } from '@rig-c/core/errors';
|
|
75
75
|
import { parseRigSpec, RIG_SPEC_VERSION, type RigBone as RigcBone, type RigSpec as RigcSpec, splitRigSkin } from '@rig-c/core/rig';
|
|
76
|
-
import { type ConfigConstraint, CONSTRAINT_FOLLOWS, contourRegionsOf, parseConfig, parseProposalSections, type Point, ROOT_BONE, type SkeletonSections, weightsABone } from './config.ts';
|
|
77
76
|
import { computeExactFrameTransforms, cropToSpineY, normaliseDegrees, toWorld } from './coords.ts';
|
|
78
77
|
import { PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
79
78
|
import { edgeLength } from './length.ts';
|
package/src/turn.ts
CHANGED
|
@@ -31,13 +31,12 @@
|
|
|
31
31
|
import { boundaryDepthSamplers, type BoundaryDepths } from './boundarydepth.ts';
|
|
32
32
|
import { computeWorldTransforms, setupToPaintingPoint, toBoneLocalVector, toWorld, type BoneTransform } from './coords.ts';
|
|
33
33
|
import { extendDepthSilhouette, sampleDepthFloat, type PartDepthReference } from './depthsheets.ts';
|
|
34
|
-
import { type Problem, refuseIfAny } from './errors.ts';
|
|
34
|
+
import { PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
35
35
|
import type { Raster } from './raster/index.ts';
|
|
36
36
|
import { pyRound } from './round.ts';
|
|
37
37
|
import { turnOverlapOwners } from './turnoverlap.ts';
|
|
38
38
|
import { coupleTurnBand, type CoupledTurnBandReport, type TurnBandDial } from './turnband.ts';
|
|
39
39
|
import { sampleTurnTriangleField, turnTriangleCoordinates } from './turnfield.ts';
|
|
40
|
-
import { PartsError } from './errors.ts';
|
|
41
40
|
import { f32 } from '@rig-c/core/compile';
|
|
42
41
|
import { warnUncoveredBodyTurn } from './turncoverage.ts';
|
|
43
42
|
import { evaluateDeformTransform } from '@rig-c/core/deformgen';
|
|
@@ -1982,7 +1981,6 @@ function buildDepth25DTurnGroup(
|
|
|
1982
1981
|
const pt = opts.boneLandmarks.get(bName);
|
|
1983
1982
|
if (pt !== undefined) {
|
|
1984
1983
|
const { rec, ext, zRef } = primarySurface;
|
|
1985
|
-
const padX = Math.floor((ext.width - rec.w) / 2);
|
|
1986
1984
|
const padY = Math.floor((ext.height - rec.h) / 2);
|
|
1987
1985
|
const cheekX = pt[0] < rec.x + rec.w / 2 ? 0 : ext.width - 1;
|
|
1988
1986
|
const cheekY = Math.max(0, Math.min(ext.height - 1, Math.round(pt[1] - rec.y + padY)));
|
package/src/visibility.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { lstatSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { depthSheetProblems } from './depthsheets.ts';
|
|
6
6
|
import { foldName, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
7
|
-
import { readWrapperLayers, type Layer, type LayerSet } from './layers.ts';
|
|
7
|
+
import { readWrapperLayers, type Layer, type LayerSet, type WrapperReadings } from './layers.ts';
|
|
8
8
|
import { decodePngBytes } from './raster/png.ts';
|
|
9
9
|
import type { Raster } from './raster/types.ts';
|
|
10
10
|
import { readLayerTag } from './tags.ts';
|
|
@@ -177,9 +177,9 @@ function sourceNames(dir: string, bytes: Buffer): string[] {
|
|
|
177
177
|
return names;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
function readWrapper(dir: string, sealed: ReadonlyMap<string, Buffer
|
|
180
|
+
function readWrapper(dir: string, sealed: ReadonlyMap<string, Buffer>, readings?: WrapperReadings): ReturnType<typeof readWrapperLayers> {
|
|
181
181
|
try {
|
|
182
|
-
return readWrapperLayers(dir, undefined, sealed);
|
|
182
|
+
return readWrapperLayers(dir, undefined, sealed, readings);
|
|
183
183
|
} catch (error) {
|
|
184
184
|
if (error instanceof PartsError) {
|
|
185
185
|
throw new PartsError(error.problems.map(problem => ({ ...problem, code: 'VISIBILITY_SOURCE' })));
|
|
@@ -248,7 +248,7 @@ function score(crops: readonly Crop[], [width, height]: Pair): Uint8Array[] {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value: unknown }): RecordFiles {
|
|
251
|
+
function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value: unknown }, readings?: WrapperReadings): RecordFiles {
|
|
252
252
|
const manifestAt = join(dir, MANIFEST);
|
|
253
253
|
const { prompt_id, input_sha256, graph_sha256 } = identity;
|
|
254
254
|
const run = { spec: SPEC, prompt_id, input_sha256, graph_sha256 } as const;
|
|
@@ -277,7 +277,7 @@ function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value:
|
|
|
277
277
|
return { tag, at, row, image: image.seal };
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
-
const set = readWrapper(dir, sealed);
|
|
280
|
+
const set = readWrapper(dir, sealed, readings);
|
|
281
281
|
const canvas: Pair = [set.canvas.w, set.canvas.h];
|
|
282
282
|
if (recorded !== undefined) match(recorded.canvas, canvas, manifestAt + '.canvas');
|
|
283
283
|
if (!canvas.every(Number.isSafeInteger) || !Number.isSafeInteger(canvas[0] * canvas[1])) {
|
|
@@ -302,7 +302,12 @@ function buildRecord(dir: string, identity: VisibilityIdentity, saved?: { value:
|
|
|
302
302
|
}
|
|
303
303
|
const path = `parts/${tag}_depth.png`;
|
|
304
304
|
const sheet = readSealed(dir, path, row && { value: row.depth, at: at + '.depth' });
|
|
305
|
-
|
|
305
|
+
const file = join(dir, path);
|
|
306
|
+
const depth = decodeDepth(sheet.bytes, size, file);
|
|
307
|
+
// The producer stages the wrapper-declared sheet here for visibility,
|
|
308
|
+
// which consumes it independently of the scalar geometry opt-in.
|
|
309
|
+
layer.depthHint?.recordDecode?.(file, sheet.seal.sha256);
|
|
310
|
+
crops.push({ layer, depth, image, sheet: sheet.seal });
|
|
306
311
|
} catch (error) {
|
|
307
312
|
if (!(error instanceof PartsError)) throw error;
|
|
308
313
|
problems.push(...error.problems);
|
|
@@ -355,19 +360,19 @@ export function writeVisibilityRecord(dir: string, identity: VisibilityIdentity)
|
|
|
355
360
|
|
|
356
361
|
/** Verify the run, current source bytes, native grids and exact scored masks. */
|
|
357
362
|
export function readVisibilityRecord(dir: string, identity: VisibilityIdentity): VisibilityManifest;
|
|
358
|
-
export function readVisibilityRecord(dir: string, identity: VisibilityIdentity, includeSamples: true): RecordFiles;
|
|
363
|
+
export function readVisibilityRecord(dir: string, identity: VisibilityIdentity, includeSamples: true, readings?: WrapperReadings): RecordFiles;
|
|
359
364
|
export function readVisibilityRecord(
|
|
360
|
-
dir: string, identity: VisibilityIdentity, includeSamples = false,
|
|
365
|
+
dir: string, identity: VisibilityIdentity, includeSamples = false, readings?: WrapperReadings,
|
|
361
366
|
): VisibilityManifest | RecordFiles {
|
|
362
367
|
checkIdentity(identity);
|
|
363
368
|
const file = join(dir, MANIFEST);
|
|
364
369
|
const value = parse(readBytes(file), file, 'VISIBILITY_MANIFEST');
|
|
365
|
-
const result = buildRecord(dir, identity, { value });
|
|
370
|
+
const result = buildRecord(dir, identity, { value }, readings);
|
|
366
371
|
return includeSamples ? result : result.manifest;
|
|
367
372
|
}
|
|
368
373
|
|
|
369
374
|
/** The expected identity comes from the independent producer metadata. */
|
|
370
|
-
export function readRunVisibility(dir: string): RecordFiles | undefined {
|
|
375
|
+
export function readRunVisibility(dir: string, readings?: WrapperReadings): RecordFiles | undefined {
|
|
371
376
|
const path = join(dir, MANIFEST);
|
|
372
377
|
if (lstatSync(path, { throwIfNoEntry: false }) === undefined) return;
|
|
373
378
|
const meta = join(dir, 'meta.json');
|
|
@@ -380,5 +385,5 @@ export function readRunVisibility(dir: string): RecordFiles | undefined {
|
|
|
380
385
|
!isSha256(uploaded_image_sha256) || !isSha256(graph_sha256)) {
|
|
381
386
|
fail('VISIBILITY_SOURCE', meta, 'requires prompt_id and lowercase SHA-256 uploaded_image_sha256 and graph_sha256 from the producing run');
|
|
382
387
|
}
|
|
383
|
-
return readVisibilityRecord(dir, { prompt_id, input_sha256: uploaded_image_sha256, graph_sha256 }, true);
|
|
388
|
+
return readVisibilityRecord(dir, { prompt_id, input_sha256: uploaded_image_sha256, graph_sha256 }, true, readings);
|
|
384
389
|
}
|