@rig-c/parts 1.66.0 → 1.68.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/README.md +22 -3
- package/cli.ts +10 -1
- package/docs/AUTHORING.md +128 -14
- package/docs/MIGRATION.md +30 -1
- package/docs/STABILITY.md +95 -4
- package/package.json +2 -2
- package/skills/rig-parts/SKILL.md +1 -1
- package/src/assemble.ts +63 -13
- package/src/automotion.ts +21 -1
- package/src/build.ts +40 -6
- package/src/check.ts +104 -2
- package/src/comfy/seethrough.ts +7 -2
- package/src/config.ts +143 -12
- package/src/depthsheets.ts +418 -0
- package/src/layers.ts +24 -12
- package/src/limblayout.ts +2 -2
- package/src/limbslots.ts +1 -1
- package/src/motion.ts +4 -1
- package/src/motionseampose.ts +117 -0
- package/src/motionseams.ts +91 -0
- package/src/parts.ts +17 -4
- package/src/propose.ts +14 -8
- package/src/rig.ts +290 -26
- package/src/turn.ts +444 -6
package/docs/STABILITY.md
CHANGED
|
@@ -53,7 +53,7 @@ defaults are the help's too, and none is guessed from the art.
|
|
|
53
53
|
| `sheet` | `--source`, `--layers` (repeatable), `--out`; optional `--cell`, `--cols` |
|
|
54
54
|
| `inputs` | `--source`, `--config`, `--out` |
|
|
55
55
|
| `comfy` | `paint`: `--config`, `--out`; optional `--seeds`, `--seed0`, `--host`, `--wait`, `--timeout`, `--poll` |
|
|
56
|
-
| `comfy` | `seethrough`: `--image`, `--out`; optional `--resolution`, `--steps`, `--seed`, `--prefix`, `--offload`, `--lama`, `--nf4`, `--host`, `--wait`, `--timeout`, `--poll` |
|
|
56
|
+
| `comfy` | `seethrough`: `--image`, `--out`; optional `--resolution`, `--steps`, `--seed`, `--prefix`, `--offload`, `--lama`, `--nf4`, `--host`, `--wait`, `--timeout`, `--poll`, `--config` (optional depth block), `--depth-run` (`full` or `head`, required with the block) |
|
|
57
57
|
| `assemble` | `--propose-plan` with `--source`, `--full`, `--config`, optional `--head`, `--write-config` (must name `--config` itself, issue #356); or `--source`, `--full`, `--config`, `--out`, optional `--head` (without it, one run: issue #359), `--seam` (near-white, silhouette), `--project` (core, visible), `--alt` (repeatable `<name>=<source>:<full>[:<head>]`, issue #454) |
|
|
58
58
|
| `propose` | `--head-box` with `--full`, `--canvas`; optional `--no-back-hair`, `--write-config` (existing config, issue #356) |
|
|
59
59
|
| `propose` | `--parts`, `--source`, `--out`; optional `--compare` or `--from-config` (one of them), `--keypoints`, `--person` and `--wrist-snap` (each with `--keypoints`), `--full`, `--head` (the turn control's depths; not with `--from-config`), `--grid-rule` (`figure` or `part`, the drafted lattice's spacing; not with `--from-config`), `--cloth` (a config whose `cloth` block is the recipe, issue #364; not with `--from-config`), `--write-config` (existing config for an ordinary proposal, issue #356; a new file with `--cloth`, issue #537; not with `--from-config` — additive: without it nothing `propose` writes changes), `--from` (the config the recipe is changed from, only with `--write-config`, issue #571 — additive: without it nothing `--write-config` writes changes), `--only-missing` (only with `--parts` and `--write-config`, not with `--cloth` or `--from-config`, issue #671 — additive: without it nothing `--write-config` writes changes) |
|
|
@@ -118,7 +118,7 @@ The fields, object by object (a bold path is where the object sits; `<part>` is
|
|
|
118
118
|
part name, `[i]` an entry of a list):
|
|
119
119
|
|
|
120
120
|
<!-- stable:config -->
|
|
121
|
-
- **config** — required by the full loader, in front of rig and build: `key`, `assemble`, `bones`, `meshes`, `regions`, `motion`; optional: `generation`, `seethrough`, `limbs`, `constraints`, `stops`, `turn`, `scene`, `cloth`, `proposed_rig_scale`, `requirements` (issue #556, additive: a path beside the config that build reads in place of its requirements flag, whose behaviour is unchanged)
|
|
121
|
+
- **config** — required by the full loader, in front of rig and build: `key`, `assemble`, `bones`, `meshes`, `regions`, `motion`; optional: `generation`, `seethrough`, `limbs`, `constraints`, `stops`, `turn`, `scene`, `cloth`, `proposed_rig_scale`, `requirements` (issue #556, additive: a path beside the config that build reads in place of its requirements flag, whose behaviour is unchanged), `motion_seams`, `depth`
|
|
122
122
|
- **generation** — required: `checkpoint`, `loras`, `trigger`, `identity`, `sampler`, `costume`, `negative_extra`, `style`, `negative_pose`, `latent`, `seed`; optional: `pose`, `control`
|
|
123
123
|
- **generation.loras[i]** — required: `name`, `strength`; optional: `strength_clip`
|
|
124
124
|
- **generation.sampler** — required: `steps`, `cfg`, `sampler`, `scheduler`
|
|
@@ -176,14 +176,19 @@ part name, `[i]` an entry of a list):
|
|
|
176
176
|
- **motion.blink** — required: `t`, `eyes`, `squash`; optional: `brows`, `brow_drop`, `still`
|
|
177
177
|
- **motion.blink.still.<part>** — required: `row`, `bone`
|
|
178
178
|
- **motion.animations_from**, the file it names — required: `spec`, `animations`
|
|
179
|
-
- **turn** — required: `pivot`, `depths
|
|
179
|
+
- **turn** — required: `pivot`, `depths` (or `roles`, issue #763); optional: `deform`, `band`, `radius`, `surface`, `head`, `roles`, `counter`, `grid`, `unitDepths`
|
|
180
180
|
- **turn.depths.<part>** — a See-through depth
|
|
181
|
+
- **turn.roles.<part>** — `"surface"`, `"unit"` or `"rear"` (issue #763)
|
|
182
|
+
- **turn.unitDepths.<part>** — a calibrated world depth in rig pixels (issue #763)
|
|
181
183
|
- **turn.deform.<key>** — a per-degree fraction or coupling share (FACE_DEFORM_FRACTIONS, issue #436)
|
|
182
184
|
- **turn.band**, when an object — optional: `yaw`, `pitch` (issue #472)
|
|
183
185
|
- **turn.surface**, when an object — optional: `radius` (issue #479)
|
|
184
186
|
- **turn.head**, when an object — optional: `pivot`, `radius` (issues #478, #479)
|
|
185
187
|
- **scene** — no field (`{}`; a record or an annotation only)
|
|
186
188
|
- **proposal.json**, the file propose writes — `bones`, `meshes`, `regions`, `limbs` under `--keypoints` where an arm or a leg is drafted from its joints (issue #349), `stops` when supplied, `motion` under the rules above, `turn` with `--full`/`--head`, `proposed_rig_scale` (issue #354), and `notes`
|
|
189
|
+
- **depth** — optional: `zScale`, `full`, `head` (#773)
|
|
190
|
+
- **depth.full**, **depth.head** — optional: `layers`, `atlas` (one fallback route)
|
|
191
|
+
- **depth.full.layers.<layer>**, **depth.head.layers.<layer>**, **depth.full.atlas**, **depth.head.atlas** — required: `image`, `near`, `zScale`
|
|
187
192
|
<!-- /stable:config -->
|
|
188
193
|
|
|
189
194
|
`TY14` holds the set of field names in backticks above to the set of names the
|
|
@@ -291,7 +296,7 @@ in the package.
|
|
|
291
296
|
|
|
292
297
|
## rig-c
|
|
293
298
|
|
|
294
|
-
`dependencies` takes `rig-c` `^2.
|
|
299
|
+
`dependencies` takes `rig-c` `^2.72.0`: 2.72.0 or any later 2.x. Bun 1.4 or later
|
|
295
300
|
is the declared floor (`engines.bun` `>=1.4.0`; older 1.4 releases are not tested in
|
|
296
301
|
CI, which runs `latest`, and compatibility with an older 1.4 release is handled when
|
|
297
302
|
reported as an issue). What this package relies on in rig-c, every import
|
|
@@ -351,6 +356,22 @@ documents). On CI (`ubuntu-latest`), the last two green runs on `main` took 4 mi
|
|
|
351
356
|
`22b2c5a` respectively. None of these figures is a promise: they are what the named
|
|
352
357
|
runs measured.
|
|
353
358
|
|
|
359
|
+
The following measurement used the unreleased [core#1595](https://github.com/rig-c/core/issues/1595)
|
|
360
|
+
prepared-reference implementation, packaged locally with `rig-c` metadata version
|
|
361
|
+
`2.70.0` (tarball SHA-256 `dac8c10631e9c0fbd30b9361155b26cba5526ece618c623e87e8dd20cc3dd92c`).
|
|
362
|
+
Its grid-selection replays bind one exact reference and schedule, then compare each
|
|
363
|
+
fresh gated candidate.
|
|
364
|
+
The number of candidate probes, gated builds and packed-page checks is
|
|
365
|
+
unchanged; a changed bound or reference input is refused. In one exclusive Nova
|
|
366
|
+
WSL ABBA invocation, using the same rig-c tarball in both arms and two runs per
|
|
367
|
+
arm, the strict switched `bottomwear` input derived from public `reference-demo` took 56.00–56.28 s
|
|
368
|
+
with one-shot comparison and 50.55–51.40 s with preparation included; the similarly switched public
|
|
369
|
+
`reference-sample` input took 18.96–20.41 s and 16.39–18.71 s respectively.
|
|
370
|
+
The paired differences were 4.59–5.74 s and 1.70–2.57 s. These are observed
|
|
371
|
+
wall times for those inputs, not an execution limit or a machine-wide idle
|
|
372
|
+
measurement; load outside the Nova pool was not measured. The prior count
|
|
373
|
+
bounds remain the termination guarantee.
|
|
374
|
+
|
|
354
375
|
## Determinism
|
|
355
376
|
|
|
356
377
|
The same inputs, with the same version of this package and the same installed
|
|
@@ -381,3 +402,73 @@ carrier and measured geometry must agree; the lower rigid piece alone carries
|
|
|
381
402
|
existing `LIMB_ONE_BONE` line checks ordinary segments as before; the band
|
|
382
403
|
requires exactly its two adjacent carriers. `SEAM_OVER_RANGE` uses the stored
|
|
383
404
|
radius and existing rest-art comparison, without changing its bar.
|
|
405
|
+
|
|
406
|
+
## Explicit motion seam observations (issue #750)
|
|
407
|
+
|
|
408
|
+
`motion_seams: [{part, neighbour}]` is optional in proposal/config/parts.json.
|
|
409
|
+
Absent leaves the existing declaration path unchanged. Readers refuse unknown
|
|
410
|
+
parts, self-pairs, unordered duplicates, malformed entries and unknown entry
|
|
411
|
+
fields by name. Empty declares no additional pair. Proposal turn/copy/write and
|
|
412
|
+
assemble preserve it; check never infers a removed declaration. A declared pair
|
|
413
|
+
uses the existing non-root WARN floor and unchanged exits, unless independently
|
|
414
|
+
selected by the existing proven body-root FAIL contract.
|
|
415
|
+
|
|
416
|
+
All played non-root WARN rows may add `worst` and `pose_at_worst`, including
|
|
417
|
+
existing limb rows. Worst is the maximum above-floor raw hit, earliest frame
|
|
418
|
+
on a tie, gap before ghost on a remaining tie. Pose evidence binds the same
|
|
419
|
+
seam geometry's actual setup, frame index, animation, viewport and raw time.
|
|
420
|
+
It records carrier-path world axes, parent-relative setup-axis deltas modulo
|
|
421
|
+
360, unchanged static ranges and explicit unavailable comparison reasons;
|
|
422
|
+
frame0 and source key endpoints are not setup or measured pose substitutes.
|
|
423
|
+
No angle bar or new threshold is added. Missing/mismatched data refuses.
|
|
424
|
+
Without a declaration only optional WARN evidence changes existing check bytes.
|
|
425
|
+
For the declared no-chest control at identical paths, the exact byte projection
|
|
426
|
+
of an existing seam container excludes only its selection, rows, derived status
|
|
427
|
+
and reason. The historical optional-container bar required exactly seven keys,
|
|
428
|
+
`CLEAR` and zero warnings across every animation. Its measured raw exit 1 stays
|
|
429
|
+
red: the added greeting keys only the head, but the original idle also keys the
|
|
430
|
+
chest and reports an above-floor opening at frames 8–12. The source type also
|
|
431
|
+
permits informational `worlds`; neither finding changes the product contract.
|
|
432
|
+
|
|
433
|
+
[HQ's post-verdict restatement](https://github.com/rig-c/parts/issues/750#issuecomment-6398631279)
|
|
434
|
+
corrects that premise. When the baseline omits `SEAM_OVER_MOTION` entirely, audit
|
|
435
|
+
the new container against the complete `MotionSeamLine` source type, including
|
|
436
|
+
its required and optional fields and referenced types, rather than a hand-kept
|
|
437
|
+
key list. Independently verify fps 12, the exact source floor, compiled animation
|
|
438
|
+
roster, generated selection and every row against the raw readings. All added
|
|
439
|
+
greeting rows must be readable and clean. Any WARN must name an animation that
|
|
440
|
+
actually keys a joint on the pair's carrier ancestry, witnessed by the original
|
|
441
|
+
authored motion, compiled tracks and actual drawing carriers. The original idle
|
|
442
|
+
WARN remains reported with the unchanged floor and exit behavior. Only after
|
|
443
|
+
those audits may lossless removal of the new container establish exact equality
|
|
444
|
+
of every outside byte. An existing baseline container keeps the narrower field
|
|
445
|
+
exclusions above. The original red and the separate post-verdict re-evaluation
|
|
446
|
+
are retained together; no input, animation selector or threshold is changed.
|
|
447
|
+
|
|
448
|
+
The WARN pose reader also requires the published stock coordinate header and
|
|
449
|
+
the required source bone/parent roster. It binds the complete geometry frame
|
|
450
|
+
cohort to the actual PNG frame set through `readFrameSet` and `boneTrackOf`,
|
|
451
|
+
including unselected frames, before reading the worst pose. Identical static
|
|
452
|
+
ranges on a bone deduplicate; conflicting ranges are explicitly ambiguous,
|
|
453
|
+
never described as no declared range.
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
## Optional depth sheets (#773)
|
|
457
|
+
|
|
458
|
+
A wrapper `depth_filename` is a legacy hint. Without explicit `config.depth`,
|
|
459
|
+
no depth file is read, validated, fetched or emitted, even when files or
|
|
460
|
+
in-memory sheets exist; art/order and legacy output stay unchanged. With the
|
|
461
|
+
block, a drawn layer source must be opaque grayscale on its exact grid.
|
|
462
|
+
Reader/export APIs take explicit config/run/base context; raw export defaults
|
|
463
|
+
to art only. Comfy CLI adds `--config` and `--depth-run full|head`; the block
|
|
464
|
+
requires a named run and a named run requires the block. Active download and
|
|
465
|
+
source errors remain refusals, never missing-file fallback.
|
|
466
|
+
Assembly's optional part `depth` reference holds `image`, `near`, `zScale` and
|
|
467
|
+
`sources` (each original `from`, `image`, `sha256`, `crop`, and `reading` with
|
|
468
|
+
`orderingMedian`, `sheetMedian`, `relation`). These fields are omitted without
|
|
469
|
+
active binding. Persisted authored part references remain active for standalone
|
|
470
|
+
rig reading regardless of config opt-in. `rig` adds padded measurement PNGs and the `rig-parts-depth-sheets/1`
|
|
471
|
+
`depth_sheets.json` companion only with references (each output `part`, actual
|
|
472
|
+
padded `size`, and `depth`; a still split names both slices). Current weighted meshes do
|
|
473
|
+
not acquire a Core field or change geometry; #763 owns the generator consumer.
|
|
474
|
+
The separate ordering scalar is unchanged. No-image outputs retain legacy bytes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/parts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.68.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
|
"bin": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"ag-psd": "^31.0.2",
|
|
67
|
-
"rig-c": "^2.
|
|
67
|
+
"rig-c": "^2.72.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@esotericsoftware/spine-core": "4.3.13",
|
|
@@ -85,7 +85,7 @@ under that.
|
|
|
85
85
|
gap See-through left (a skirt split into two legs), fixed in the plan or the layers,
|
|
86
86
|
not in the rig. Then `rig-parts propose --parts work/rig
|
|
87
87
|
--source <painting> --out work` → copy `bones`, `meshes`, `regions`, `limbs`,
|
|
88
|
-
`motion`, `constraints`, `turn`, `proposed_rig_scale` from `proposal.json` into the config, each it
|
|
88
|
+
`motion`, `constraints`, `turn`, `motion_seams`, `proposed_rig_scale` from `proposal.json` into the config, each it
|
|
89
89
|
wrote (`limbs` only with `--keypoints`, `constraints` only with `--cloth`, `turn`
|
|
90
90
|
only with `--full`/`--head`; a `limbs` block left out is refused at the next step). `assemble` needs the plan and none of
|
|
91
91
|
those sections; do not stub them to get past it (AUTHORING §4 says what each step
|
package/src/assemble.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bindDepthRun, copyDepthMaterial, registerDepthRun, transportPartDepth, type DepthConfig, type RegisteredDepth } from './depthsheets.ts';
|
|
1
2
|
/**
|
|
2
3
|
* The assemble stage: two See-through runs over one painting — a FULL-body run
|
|
3
4
|
* and a HEAD-crop run — merged into one set of rig-space parts, each part one
|
|
@@ -101,9 +102,10 @@
|
|
|
101
102
|
*/
|
|
102
103
|
import { sourceLimbTarget, nearestTargetPart } from './limbownership.ts';
|
|
103
104
|
import { type ArmSplit, type BoneEntry, type CharacterConfig, type ControlSkeleton, controlSkeletonOf, type Cut, type EarlyConfig, type Extend, type Limb, type Patch, type PlanEntry, type Run, type SeeThrough } from './config.ts';
|
|
104
|
-
import { type Problem, refuseIfAny } from './errors.ts';
|
|
105
|
+
import { PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
105
106
|
import { CORE_ALPHA, figuresPhrase, implausibleRules, type Layer, type LayerFigures, layerFigures, type LayerSet, NEAR_WHITE_MIN, OPAQUE_ALPHA_ABOVE, ruleSummary } from './layers.ts';
|
|
106
107
|
import { padToSquare, squarePad } from './inputs.ts';
|
|
108
|
+
import type { MotionSeamDeclaration } from './motionseams.ts';
|
|
107
109
|
import { type CapRecord, type LimbRecord, PAINTING_RUN, type PartRecord, type PartsFile, type RecompositeRecord, type SceneRecord, type SingleRunPad } from './parts.ts';
|
|
108
110
|
import { assignCrossedLimbs, assignOverlappingHands, type BonePlace, bonePlaces, capBox, coveredRadius, type CutPlacement, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, luma601, nearestLimb, nearestOnLine, offLineFigure, pastJoint, placeCut, polylineDist2, segmentOf } from './limbs.ts';
|
|
109
111
|
import {
|
|
@@ -307,6 +309,9 @@ export function singleRunPadRecord(single: boolean, sourceW: number, sourceH: nu
|
|
|
307
309
|
}
|
|
308
310
|
|
|
309
311
|
export interface AssembleInput {
|
|
312
|
+
depth?: DepthConfig;
|
|
313
|
+
/** Config-relative user sheet paths; caller supplies its actual base. */
|
|
314
|
+
depthBase?: string;
|
|
310
315
|
/** The painting. Its alpha is ignored, as the reference's `convert("RGB")` drops it. */
|
|
311
316
|
source: Raster;
|
|
312
317
|
full: LayerSet;
|
|
@@ -320,6 +325,7 @@ export interface AssembleInput {
|
|
|
320
325
|
patches: Patch[];
|
|
321
326
|
/** `assemble.cuts`: plan parts' pixels taken into new parts by polygon (`cutPart`), placed per their `draw`. */
|
|
322
327
|
cuts: Cut[];
|
|
328
|
+
motion_seams?: MotionSeamDeclaration[];
|
|
323
329
|
/** Internal alternate selection: piece layer by cut output; polygon subtraction and under stay on from. */
|
|
324
330
|
cutLayers?: ReadonlyMap<string, string>;
|
|
325
331
|
/**
|
|
@@ -1358,10 +1364,11 @@ export function applyArmSplit(set: LayerSet, resolution: number, armSplit: ArmSp
|
|
|
1358
1364
|
]);
|
|
1359
1365
|
}
|
|
1360
1366
|
const combinedRaw = newRaster(resolution, resolution);
|
|
1361
|
-
|
|
1367
|
+
const scalarOwners = handLayers.some(l => l.depthSheet !== undefined) ? new Int32Array(resolution * resolution).fill(-1) : null;
|
|
1368
|
+
for (const [layerIndex, l] of handLayers.entries()) {
|
|
1362
1369
|
const { canvas } = cleanGhosts(placeLayer(l, resolution));
|
|
1363
1370
|
for (let p = 0; p < resolution * resolution; p++) {
|
|
1364
|
-
if (canvas.data[p * 4 + 3] > 0) combinedRaw.data.set(canvas.data.subarray(p * 4, p * 4 + 4), p * 4);
|
|
1371
|
+
if (canvas.data[p * 4 + 3] > 0) { combinedRaw.data.set(canvas.data.subarray(p * 4, p * 4 + 4), p * 4); if (scalarOwners !== null) scalarOwners[p] = layerIndex; }
|
|
1365
1372
|
}
|
|
1366
1373
|
}
|
|
1367
1374
|
const { canvas: combined } = cleanGhosts(combinedRaw);
|
|
@@ -1468,7 +1475,7 @@ export function applyArmSplit(set: LayerSet, resolution: number, armSplit: ArmSp
|
|
|
1468
1475
|
}
|
|
1469
1476
|
}
|
|
1470
1477
|
const refLayer = handLayers.reduce((best, l) => (l.opaquePx > best.opaquePx ? l : best), handLayers[0]);
|
|
1471
|
-
const makeLayer = (name: 'handwear-r' | 'handwear-l', canvas: Raster, m: ReturnType<typeof maskOf>): Layer => ({
|
|
1478
|
+
const makeLayer = (name: 'handwear-r' | 'handwear-l', canvas: Raster, m: ReturnType<typeof maskOf>): Layer => copyDepthMaterial({
|
|
1472
1479
|
name,
|
|
1473
1480
|
tag: readLayerTag(name) as LayerTagReading,
|
|
1474
1481
|
file: refLayer.file,
|
|
@@ -1480,7 +1487,7 @@ export function applyArmSplit(set: LayerSet, resolution: number, armSplit: ArmSp
|
|
|
1480
1487
|
depth: refLayer.depth,
|
|
1481
1488
|
drawOrder: 0,
|
|
1482
1489
|
opaquePx: m.opaque,
|
|
1483
|
-
});
|
|
1490
|
+
}, handLayers, (x, y) => { const owner = scalarOwners?.[Math.floor(y) * resolution + Math.floor(x)] ?? -1; return owner < 0 ? [] : [{ layer: handLayers[owner], x, y, weight: 1 }]; });
|
|
1484
1491
|
const byTag = {
|
|
1485
1492
|
'handwear-r': makeLayer('handwear-r', rightCanvas, mr),
|
|
1486
1493
|
'handwear-l': makeLayer('handwear-l', leftCanvas, ml),
|
|
@@ -1777,7 +1784,7 @@ export function splitMergedArmRunsWithNotes(
|
|
|
1777
1784
|
}
|
|
1778
1785
|
}
|
|
1779
1786
|
if (opaque === 0 || x1 < x0) return null;
|
|
1780
|
-
return {
|
|
1787
|
+
return copyDepthMaterial({
|
|
1781
1788
|
name,
|
|
1782
1789
|
tag: readLayerTag(name) as LayerTagReading,
|
|
1783
1790
|
file: hwLayer.file,
|
|
@@ -1789,7 +1796,7 @@ export function splitMergedArmRunsWithNotes(
|
|
|
1789
1796
|
depth: hwLayer.depth,
|
|
1790
1797
|
drawOrder: 0,
|
|
1791
1798
|
opaquePx: opaque,
|
|
1792
|
-
};
|
|
1799
|
+
}, [hwLayer], (x, y) => [{ layer: hwLayer, x, y, weight: 1 }]);
|
|
1793
1800
|
};
|
|
1794
1801
|
const drapeLayer = buildSplitLayer(`drape-${s}`, drapeCanvas);
|
|
1795
1802
|
const sleeveLayer = buildSplitLayer(tag, sleeveCanvas);
|
|
@@ -2083,9 +2090,14 @@ function prepareHeadFace(
|
|
|
2083
2090
|
bottom: y1 + 1,
|
|
2084
2091
|
opaquePx: compOpaquePx,
|
|
2085
2092
|
};
|
|
2093
|
+
const copiedLayer = copyDepthMaterial(replacedLayer, [headFaceLayer, fullFaceLayer], (x, y) => {
|
|
2094
|
+
const ta = cleanedHead.canvas.data[(Math.floor(y) * resolution + Math.floor(x)) * 4 + 3] / 255;
|
|
2095
|
+
const sx = f32(frame.fullK / frame.headK), tx = f32(-(frame.headBox[0] + frame.fullPad) / frame.headK), ty = frame.fullPadTop === 0 && frame.headBox[1] === 0 ? 0 : f32(-(frame.headBox[1] + frame.fullPadTop) / frame.headK);
|
|
2096
|
+
return [{ layer: headFaceLayer, x, y, weight: ta }, { layer: fullFaceLayer, x: (x - 0.5 - tx) / sx + 0.5, y: (y - 0.5 - ty) / sx + 0.5, weight: 1 - ta }];
|
|
2097
|
+
});
|
|
2086
2098
|
activeHead = {
|
|
2087
2099
|
...head,
|
|
2088
|
-
layers: head.layers.map((l) => (l.name === 'face' ?
|
|
2100
|
+
layers: head.layers.map((l) => (l.name === 'face' ? copiedLayer : l)),
|
|
2089
2101
|
};
|
|
2090
2102
|
if (underfillPx > 0) {
|
|
2091
2103
|
underfillNote = `face: head_face_underfill composited full:face under head:face on the head canvas, filling ${underfillPx} transparent px (${rawStats.headOv} / ${fullPx} px, ${(rawStats.cov * 100).toFixed(1)}% -> ${postStats.headOv} / ${fullPx} px, ${(postStats.cov * 100).toFixed(1)}%)`;
|
|
@@ -2557,6 +2569,7 @@ export function figureSilhouette(srcr: Raster): Mask {
|
|
|
2557
2569
|
}
|
|
2558
2570
|
|
|
2559
2571
|
export interface PlacedPart {
|
|
2572
|
+
depthImage?: Raster;
|
|
2560
2573
|
record: PartRecord;
|
|
2561
2574
|
image: Raster;
|
|
2562
2575
|
}
|
|
@@ -4311,6 +4324,7 @@ export interface AssembleResult {
|
|
|
4311
4324
|
hidden: HiddenArtUse[];
|
|
4312
4325
|
seamRule: SeamRule;
|
|
4313
4326
|
projectRule: ProjectRule;
|
|
4327
|
+
depthReadings?: Array<{ from: string; reading: import('./depthsheets.ts').DepthReading }>;
|
|
4314
4328
|
/** Issue #492: head-canvas pixels filled by `config.assemble.head_face_underfill: true` when > 0. */
|
|
4315
4329
|
headFaceUnderfillPx?: number;
|
|
4316
4330
|
/** Issue #587: what each `exclude` entry took, in entry order; empty without one. */
|
|
@@ -4473,8 +4487,17 @@ export function assemble(input: AssembleInput): AssembleResult {
|
|
|
4473
4487
|
{ sourceW: source.width, sourceH: source.height, resolution: input.resolution, headBox: input.headBox, rigScale: input.rigScale, ...(single ? { single: true } : {}) },
|
|
4474
4488
|
{ full: input.full, head: input.head },
|
|
4475
4489
|
);
|
|
4490
|
+
if (input.depthBase === undefined && (input.depth?.full !== undefined || input.depth?.head !== undefined)) refuseIfAny([{ code: 'DEPTH_SOURCE_BASE', object: 'assemble depthBase', detail: 'user sheet paths require the actual config-directory base; no process-cwd guess is made' }]);
|
|
4491
|
+
const depthInputProblems: Problem[] = [];
|
|
4492
|
+
const bind = (set: LayerSet, run: 'full' | 'head'): LayerSet => {
|
|
4493
|
+
try { return bindDepthRun(set, run, input.depth, input.depthBase ?? ''); }
|
|
4494
|
+
catch (error) { if (error instanceof PartsError) { depthInputProblems.push(...error.problems); return set; } throw error; }
|
|
4495
|
+
};
|
|
4496
|
+
const depthFullInput = bind(input.full, 'full');
|
|
4497
|
+
const depthHeadInput = single ? depthFullInput : bind(input.head, 'head');
|
|
4498
|
+
refuseIfAny(depthInputProblems);
|
|
4476
4499
|
// Issue #366: one run's file, padded to the resolution square; read as both runs, as before.
|
|
4477
|
-
const fullPadded = single ? padSingleRun(
|
|
4500
|
+
const fullPadded = single ? padSingleRun(depthFullInput, frame, input.resolution) : depthFullInput;
|
|
4478
4501
|
// Issue #439: when seethrough.arm_split is declared, split the full run's overlapping handwear into handwear-r and handwear-l.
|
|
4479
4502
|
const fullArmSplit = input.armSplit === undefined ? fullPadded : applyArmSplit(fullPadded, input.resolution, input.armSplit);
|
|
4480
4503
|
// Issue #490: when generation.control.skeleton is present, split merged arm layers (or refuse when sleeve and drape share one colour).
|
|
@@ -4492,10 +4515,13 @@ export function assemble(input: AssembleInput): AssembleResult {
|
|
|
4492
4515
|
!single &&
|
|
4493
4516
|
(plan.some(([, r, t]) => r === 'head' && t === 'face') || (plan.some(([, r]) => r === 'full') && plan.some(([, r]) => r === 'head')));
|
|
4494
4517
|
const headFacePrep = checkHeadFace
|
|
4495
|
-
? prepareHeadFace(full,
|
|
4496
|
-
: { head: single ? full :
|
|
4518
|
+
? prepareHeadFace(full, depthHeadInput, frame, input.resolution, input.headFaceUnderfill === true)
|
|
4519
|
+
: { head: single ? full : depthHeadInput, underfillPx: 0, underfillNote: null };
|
|
4497
4520
|
const head = headFacePrep.head;
|
|
4498
4521
|
const padRecord = singleRunPadRecord(single, source.width, source.height, input.resolution, frame);
|
|
4522
|
+
const depthFull = registerDepthRun(full, 'full', input.depth, input.depthBase ?? '');
|
|
4523
|
+
const depthHead = single ? new Map<string, RegisteredDepth>() : registerDepthRun(head, 'head', input.depth, input.depthBase ?? '');
|
|
4524
|
+
const registeredDepth = new Map([...depthFull, ...depthHead]);
|
|
4499
4525
|
if (single) checkSingleRun(full, plan, extend);
|
|
4500
4526
|
checkPlanAgainstRuns(sourcePlan, extend, full, head);
|
|
4501
4527
|
const { W, H } = frame;
|
|
@@ -5072,10 +5098,30 @@ export function assemble(input: AssembleInput): AssembleResult {
|
|
|
5072
5098
|
};
|
|
5073
5099
|
if (pushedHere.length > 0) record.fringe_pushed_back = pushedHere;
|
|
5074
5100
|
if (limb !== undefined) record.limb = limb;
|
|
5075
|
-
|
|
5101
|
+
const image = crop(r, x0, y0, record.w, record.h);
|
|
5102
|
+
const limbIndex = limb === undefined ? -1 : lim.parts.findIndex(q => q.record.name === limb.name && q.record.segment === limb.segment);
|
|
5103
|
+
const upperIndex = limb === undefined ? -1 : lim.parts.findIndex(q => q.record.name === limb.name && q.record.segment === limb.segment - 1);
|
|
5104
|
+
const capSource = limbIndex < 0 ? null : lim.capFrom[limbIndex];
|
|
5105
|
+
const scalar = transportPartDepth(record, image, registeredDepth, {
|
|
5106
|
+
map: run => runMap(frame, run), width: W, extend: extendKeys, owner: trace.from,
|
|
5107
|
+
ring: trace.ring.data, region: region?.data ?? null,
|
|
5108
|
+
copiedSource: (x, y) => {
|
|
5109
|
+
if (capSource === null || upperIndex < 0) return null;
|
|
5110
|
+
const [bx, by, bw, bh] = capSource.box;
|
|
5111
|
+
if (x < bx || y < by || x >= bx + bw || y >= by + bh || capSource.codes[(y - by) * bw + x - bx] !== CAP_FROM_UPPER) return null;
|
|
5112
|
+
const upper = limbPieces[upperIndex], p = y * W + x, e = upper.trace.from[p];
|
|
5113
|
+
return { key: e < 0 ? upper.key : upper.extendKeys[e], ring: upper.trace.ring.data[p] !== 0 };
|
|
5114
|
+
},
|
|
5115
|
+
...((limb?.cap?.image_px ?? 0) > 0 || (limb?.cap?.lower_px ?? 0) > 0 ? { unsupported: `cap copies ${(limb?.cap?.image_px ?? 0) + (limb?.cap?.lower_px ?? 0)} pixels from a separate cap image whose scalar grid is undeclared` } : {}),
|
|
5116
|
+
});
|
|
5117
|
+
if (scalar !== undefined) record.depth = scalar.reference;
|
|
5118
|
+
set({ record, image, ...(scalar === undefined ? {} : { depthImage: scalar.image }) });
|
|
5076
5119
|
});
|
|
5077
5120
|
refuseIfAny(empty);
|
|
5078
5121
|
const placed: PlacedPart[] = order.map((d) => ('plan' in d ? planned[d.plan] : 'cut' in d ? cutPlaced[d.cut] : 'limb' in d ? limbPlaced[d.limb] : cut[d.patch]) as PlacedPart);
|
|
5122
|
+
const artFiles = new Set(placed.map(p => `${p.record.name}.png`));
|
|
5123
|
+
for (const p of placed) if (p.record.depth !== undefined && artFiles.has(p.record.depth.image)) refuseIfAny([{ code: 'DEPTH_SHEET_UNAMBIGUOUS', object: p.record.depth.image, detail: 'collides with a part artwork filename; choose noncolliding part names before sheet emission' }]);
|
|
5124
|
+
|
|
5079
5125
|
|
|
5080
5126
|
seamOverride(placed, srcr, seamRule, seamRule === 'silhouette' ? silhouette : null, keepInOrder);
|
|
5081
5127
|
const can = recomposite(placed, W, H);
|
|
@@ -5105,6 +5151,7 @@ export function assemble(input: AssembleInput): AssembleResult {
|
|
|
5105
5151
|
parts: {
|
|
5106
5152
|
rig_size: [W, H],
|
|
5107
5153
|
scale_rig_per_source: frame.S,
|
|
5154
|
+
...(input.motion_seams === undefined ? {} : { motion_seams: input.motion_seams.map(({ part, neighbour }) => ({ part, neighbour })) }),
|
|
5108
5155
|
parts: placed.map((p) => p.record),
|
|
5109
5156
|
ghost_px: ghost,
|
|
5110
5157
|
recomposite: recompositeRecord(figures),
|
|
@@ -5112,6 +5159,7 @@ export function assemble(input: AssembleInput): AssembleResult {
|
|
|
5112
5159
|
...(padRecord === null ? {} : { single_run_pad: padRecord }),
|
|
5113
5160
|
},
|
|
5114
5161
|
images: placed,
|
|
5162
|
+
...(registeredDepth.size === 0 ? {} : { depthReadings: ([['full', depthFullInput], ...(single ? [] : [['head', depthHeadInput]])] as Array<['full' | 'head', LayerSet]>).flatMap(([run, set]) => set.layers.flatMap(layer => layer.depthSheet === undefined ? [] : [{ from: `${run}:${layer.name}`, reading: layer.depthSheet.reading }])) }),
|
|
5115
5163
|
recomposite: can,
|
|
5116
5164
|
errorMap: recompositeErrorMap(can, srcr, placed, inside),
|
|
5117
5165
|
figure: inside === null ? null : figureImage(inside, W, H),
|
|
@@ -5875,7 +5923,7 @@ function unplannedNotes(
|
|
|
5875
5923
|
* full-loader config, where it is optional.
|
|
5876
5924
|
*/
|
|
5877
5925
|
export function stageFields(
|
|
5878
|
-
cfg: Pick<CharacterConfig, 'seethrough' | 'assemble' | 'scene'> & { limbs?: Record<string, Limb>; bones?: BoneEntry[] },
|
|
5926
|
+
cfg: Pick<CharacterConfig, 'seethrough' | 'assemble' | 'scene' | 'motion_seams'> & { limbs?: Record<string, Limb>; bones?: BoneEntry[] },
|
|
5879
5927
|
single: { w: number; h: number } | null = null,
|
|
5880
5928
|
): {
|
|
5881
5929
|
resolution: number;
|
|
@@ -5885,6 +5933,7 @@ export function stageFields(
|
|
|
5885
5933
|
extend: Extend[];
|
|
5886
5934
|
patches: Patch[];
|
|
5887
5935
|
cuts: Cut[];
|
|
5936
|
+
motion_seams?: MotionSeamDeclaration[];
|
|
5888
5937
|
scene?: boolean;
|
|
5889
5938
|
limbs?: Record<string, Limb>;
|
|
5890
5939
|
bones?: BoneEntry[];
|
|
@@ -5915,6 +5964,7 @@ export function stageFields(
|
|
|
5915
5964
|
extend: cfg.assemble.extend_below_crop ?? [],
|
|
5916
5965
|
patches: cfg.assemble.patches ?? [],
|
|
5917
5966
|
cuts: cfg.assemble.cuts ?? [],
|
|
5967
|
+
...(cfg.motion_seams === undefined ? {} : { motion_seams: cfg.motion_seams }),
|
|
5918
5968
|
...(cfg.scene === undefined ? {} : { scene: true }),
|
|
5919
5969
|
...(cfg.limbs === undefined ? {} : { limbs: cfg.limbs, bones: cfg.bones ?? [] }),
|
|
5920
5970
|
};
|
package/src/automotion.ts
CHANGED
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
* Pure: no clock, no randomness, nothing read or written.
|
|
85
85
|
*/
|
|
86
86
|
import { type AcceptedOperation, MeshReductionError, type AlphaMask, type ArtFitBounds, type MeasureRow, type MeshQualityReport, type MotionAmplitude, type MotionBounds, type MotionSchedule, writeMeshQualityReport } from 'rig-c/mesh';
|
|
87
|
-
import { compareMeshesInMotion, type MotionComparisonInput } from 'rig-c/meshcompare';
|
|
87
|
+
import { compareMeshesInMotion, comparePreparedMotion, prepareMotionReference, type MotionComparisonInput, type MotionReferenceInput, type PreparedMotionReference } from 'rig-c/meshcompare';
|
|
88
88
|
import type { AutoMotionSpec } from './config.ts';
|
|
89
89
|
import type { Problem } from './errors.ts';
|
|
90
90
|
import { IDLE_FPS, type MotionSpec, type MotionTrack } from './motion.ts';
|
|
@@ -334,6 +334,26 @@ export function runComparison(object: string, input: MotionComparisonInput): Mes
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
/** Bind the exact reference-side input for the sequential replay candidates. */
|
|
338
|
+
export function prepareComparison(object: string, input: MotionReferenceInput): PreparedMotionReference | Problem {
|
|
339
|
+
try {
|
|
340
|
+
return prepareMotionReference(input);
|
|
341
|
+
} catch (err) {
|
|
342
|
+
if (!(err instanceof MeshReductionError)) throw err;
|
|
343
|
+
return { code: 'AUTO_MESH_MOTION_INPUT', object, detail: `rig-c's compareMeshesInMotion refused the comparison's input (${err.code}): ${err.message}; nothing is built in the part's place` };
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** Compare a fresh gated candidate under the prepared reference and its bound schedule/art/options. */
|
|
348
|
+
export function runPreparedComparison(object: string, handle: PreparedMotionReference, input: MotionComparisonInput): MeshQualityReport | Problem {
|
|
349
|
+
try {
|
|
350
|
+
return comparePreparedMotion(handle, input);
|
|
351
|
+
} catch (err) {
|
|
352
|
+
if (!(err instanceof MeshReductionError)) throw err;
|
|
353
|
+
return { code: 'AUTO_MESH_MOTION_INPUT', object, detail: `rig-c's compareMeshesInMotion refused the comparison's input (${err.code}): ${err.message}; nothing is built in the part's place` };
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
337
357
|
/** A gated row in one phrase: code, region, state, value against its bound, the worst frame. */
|
|
338
358
|
export function motionRowText(r: MeasureRow): string {
|
|
339
359
|
const region = r.object.region === null ? '' : ` [region "${r.object.region}"]`;
|
package/src/build.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readSourceDepth } from './depthsheets.ts';
|
|
1
2
|
import { alternateLayerSources, alternateLayerIslands, alternateLayerOthers } from './alternatelayers.ts';
|
|
2
3
|
import { setFocusProblems } from './setfocus.ts';
|
|
3
4
|
/**
|
|
@@ -49,7 +50,7 @@ import { type AnimFrame, EncodeError, encodeApng, encodeIndexedApng, INDEXED_DEF
|
|
|
49
50
|
import { assemble, type AssembleResult, cutLines, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, driftLine, limbLines, FIGURE_MASK_FILE, figuresLine, holeKindsLine, holeLines, measureRecomposite, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, stageFields, uncoveredLine } from './assemble.ts';
|
|
50
51
|
import { allocationClause, type Reducer, stageBClause, unboundedClause } from './automesh.ts';
|
|
51
52
|
import { residualClause } from './autoenvelope.ts';
|
|
52
|
-
import { type AutoMotionCase, failingRows, idleSchedule, localRow, motionClause, motionDeformation, motionDocument, motionInput, motionRowText, motionStimulus, motionVerdict, noStimulusProblem, type ReplayCandidate, runComparison, sourceSelfFailure, stimulusMotion, withStimulus } from './automotion.ts';
|
|
53
|
+
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';
|
|
53
54
|
import {
|
|
54
55
|
bisectAccepted,
|
|
55
56
|
budgetProblem,
|
|
@@ -321,7 +322,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
321
322
|
const fields = stageFields(cfg, runs.single ? { w: src.width, h: src.height } : null);
|
|
322
323
|
const under = readUnders(input.config, fields.cuts);
|
|
323
324
|
const caps = fields.limbs === undefined ? undefined : readCaps(input.config, fields.limbs);
|
|
324
|
-
const result = assemble({ source: src, full: runs.full, head: runs.head, ...fields, under, ...(caps === undefined ? {} : { caps }), seamRule: input.seam, projectRule: input.project });
|
|
325
|
+
const result = assemble({ source: src, full: runs.full, head: runs.head, depth: cfg.depth, depthBase: dirname(resolve(input.config)), ...fields, under, ...(caps === undefined ? {} : { caps }), seamRule: input.seam, projectRule: input.project });
|
|
325
326
|
|
|
326
327
|
// Issue #454: alternate painting sets, assembled before any file is written.
|
|
327
328
|
const configDir = dirname(resolve(input.config));
|
|
@@ -635,6 +636,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
635
636
|
try {
|
|
636
637
|
altRes = assemble({
|
|
637
638
|
source: altSrc,
|
|
639
|
+
depth: cfg.depth, depthBase: configDir,
|
|
638
640
|
limbUnderCover: alt.parts !== undefined && input.setCover !== 'painting',
|
|
639
641
|
...(altTips === undefined ? {} : { boneTips: altTips }),
|
|
640
642
|
capOwnership: input.setCapOwnership ?? 'target',
|
|
@@ -674,8 +676,8 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
674
676
|
}
|
|
675
677
|
const keptImages = altRes.images
|
|
676
678
|
.filter(({ record }) => coveredSet.has(record.name))
|
|
677
|
-
.
|
|
678
|
-
const keptRecords = altRes.parts.parts.filter((p) => coveredSet.has(p.name));
|
|
679
|
+
.flatMap(({ record, image, depthImage }) => [{ name: `${alt.name}_${record.name}`, image }, ...(depthImage === undefined || record.depth === undefined ? [] : [{ name: `${alt.name}_${record.depth.image.slice(0, -4)}`, image: depthImage }])]);
|
|
680
|
+
const keptRecords = altRes.parts.parts.filter((p) => coveredSet.has(p.name)).map(p => p.depth === undefined ? p : { ...p, depth: { ...p.depth, image: `${alt.name}_${p.depth.image}` } });
|
|
679
681
|
const slots: Record<string, string> = {};
|
|
680
682
|
for (const r of keptRecords) slots[altFront.has(r.name) ? `${r.name}${FRONT_SUFFIX}` : r.name] = `${alt.name}_${r.name}`;
|
|
681
683
|
let altRecomposite = altRes.parts.recomposite as RecompositeRecord;
|
|
@@ -715,6 +717,26 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
715
717
|
capSplits: altRes.capSplits,
|
|
716
718
|
});
|
|
717
719
|
}
|
|
720
|
+
const emittedAssets = [
|
|
721
|
+
...result.images.flatMap(({ record, depthImage }) => [
|
|
722
|
+
`${record.name}.png`,
|
|
723
|
+
...(depthImage !== undefined && record.depth !== undefined ? [record.depth.image] : []),
|
|
724
|
+
]),
|
|
725
|
+
...altBuilt.flatMap((b) => b.images.map(({ name }) => `${name}.png`)),
|
|
726
|
+
];
|
|
727
|
+
const assetIndices = new Map<string, number>();
|
|
728
|
+
emittedAssets.forEach((file, index) => {
|
|
729
|
+
const previous = assetIndices.get(file);
|
|
730
|
+
if (previous !== undefined) {
|
|
731
|
+
altProblems.push({
|
|
732
|
+
code: 'DEPTH_SHEET_UNAMBIGUOUS',
|
|
733
|
+
object: file,
|
|
734
|
+
detail: `output assets[${previous}] and [${index}] require the same filename; choose distinct base, alternate and sheet names`,
|
|
735
|
+
});
|
|
736
|
+
} else {
|
|
737
|
+
assetIndices.set(file, index);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
718
740
|
refuseIfAny(altProblems);
|
|
719
741
|
if (altBuilt.length > 0) {
|
|
720
742
|
result.parts.alternates = altBuilt.map((b) => b.record);
|
|
@@ -726,7 +748,11 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
726
748
|
mkdirSync(dirname(outs.recomposite), { recursive: true });
|
|
727
749
|
mkdirSync(dirname(outs.errorMap), { recursive: true });
|
|
728
750
|
writeParts(outs.partsJson, result.parts);
|
|
729
|
-
for (const { record, image } of result.images)
|
|
751
|
+
for (const { record, image, depthImage } of result.images) {
|
|
752
|
+
writePng(join(outs.partsDir, `${record.name}.png`), image);
|
|
753
|
+
if (depthImage !== undefined && record.depth !== undefined) writePng(join(outs.partsDir, record.depth.image), depthImage);
|
|
754
|
+
}
|
|
755
|
+
for (const row of result.depthReadings ?? []) log(` depth reading ${row.from}: ${row.reading.relation}; ordering median ${row.reading.orderingMedian}, source-sheet median ${row.reading.sheetMedian} (half-level quantization; reading only, polarity declared)`);
|
|
730
756
|
for (const b of altBuilt) {
|
|
731
757
|
for (const { name, image } of b.images) writePng(join(outs.partsDir, `${name}.png`), image);
|
|
732
758
|
}
|
|
@@ -1206,6 +1232,9 @@ export function replaySearch(
|
|
|
1206
1232
|
}
|
|
1207
1233
|
const selection = motion.selection;
|
|
1208
1234
|
if (selection !== undefined && selection.maxProbes < maxReplays(N, I)) return refuse(budgetProblem(c.object, selection.maxProbes, N, I));
|
|
1235
|
+
const { candidates: _unused, ...referenceInput } = motionInput(c, motion, refModel, refModel, probeSchedule);
|
|
1236
|
+
const prepared = prepareComparison(c.object, referenceInput);
|
|
1237
|
+
if ('code' in prepared) return refuse(prepared);
|
|
1209
1238
|
const kept = new Map<number, ReplayCandidate>();
|
|
1210
1239
|
const probeFrames: string[] = [];
|
|
1211
1240
|
let fatal: Problem | null = null;
|
|
@@ -1234,7 +1263,7 @@ export function replaySearch(
|
|
|
1234
1263
|
};
|
|
1235
1264
|
return refused(`rigc exit ${gate.status}`);
|
|
1236
1265
|
}
|
|
1237
|
-
const cmp =
|
|
1266
|
+
const cmp = runPreparedComparison(c.object, prepared, motionInput(c, motion, refModel, model, probeSchedule));
|
|
1238
1267
|
if ('code' in cmp) {
|
|
1239
1268
|
fatal = cmp;
|
|
1240
1269
|
return refused(cmp.code);
|
|
@@ -1358,17 +1387,21 @@ export function readRigInputs(config: string, partsDir: string): RigInputs {
|
|
|
1358
1387
|
const { config: cfg, animations: from } = loadConfigAndAnimations(config);
|
|
1359
1388
|
const parts = readParts(join(partsDir, 'parts.json'));
|
|
1360
1389
|
const images = new Map<string, Raster>();
|
|
1390
|
+
const depthProblems: Problem[] = [];
|
|
1361
1391
|
for (const p of parts.parts) {
|
|
1362
1392
|
const png = join(partsDir, 'parts', `${p.name}.png`);
|
|
1363
1393
|
if (existsSync(png)) images.set(p.name, readPng(png));
|
|
1394
|
+
if (p.depth !== undefined && images.has(p.name)) { try { images.set(p.depth.image, readSourceDepth(join(partsDir, 'parts', p.depth.image), images.get(p.name) as Raster, null).pixels); } catch (error) { if (error instanceof PartsError) depthProblems.push(...error.problems); else throw error; } }
|
|
1364
1395
|
}
|
|
1365
1396
|
for (const alt of parts.alternates ?? []) {
|
|
1366
1397
|
for (const p of alt.records) {
|
|
1367
1398
|
const attName = `${alt.name}_${p.name}`;
|
|
1368
1399
|
const png = join(partsDir, 'parts', `${attName}.png`);
|
|
1369
1400
|
if (existsSync(png)) images.set(attName, readPng(png));
|
|
1401
|
+
if (p.depth !== undefined && images.has(attName)) { try { images.set(p.depth.image, readSourceDepth(join(partsDir, 'parts', p.depth.image), images.get(attName) as Raster, null).pixels); } catch (error) { if (error instanceof PartsError) depthProblems.push(...error.problems); else throw error; } }
|
|
1370
1402
|
}
|
|
1371
1403
|
}
|
|
1404
|
+
refuseIfAny(depthProblems);
|
|
1372
1405
|
return { cfg, from, parts, images };
|
|
1373
1406
|
}
|
|
1374
1407
|
|
|
@@ -1380,6 +1413,7 @@ export function rigOutputTexts(r: RigOutput, animations: Parameters<typeof withA
|
|
|
1380
1413
|
['rig.json', rigJsonText(r.rig)],
|
|
1381
1414
|
['motion.json', rigJsonText(mergedMotion)],
|
|
1382
1415
|
['mesh_report.json', rigJsonText(r.meshReport)],
|
|
1416
|
+
...(r.depthReferences === undefined ? [] : [['depth_sheets.json', rigJsonText({ spec: 'rig-parts-depth-sheets/1', parts: r.depthReferences })] as [string, string]]),
|
|
1383
1417
|
...(r.sets === undefined ? [] : [[SETS_FILE, rigJsonText(r.sets)] as [string, string]]),
|
|
1384
1418
|
];
|
|
1385
1419
|
}
|