rig-parts 2.55.0 → 2.57.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 +83 -196
- package/cli.ts +55 -9
- package/docs/AUTHORING.md +221 -25
- package/docs/MIGRATION.md +2 -2
- package/docs/PAINTING.md +1 -1
- package/docs/STABILITY.md +76 -15
- package/package.json +1 -1
- package/src/build.ts +27 -8
- package/src/bustlandmarks.ts +118 -22
- package/src/check.ts +9 -9
- package/src/config.ts +134 -3
- package/src/configrelocation.ts +3 -0
- package/src/depthworkflow.ts +7 -1
- package/src/outputpaths.ts +107 -0
- package/src/rig.ts +56 -5
- package/src/runstamp.ts +176 -19
- package/src/scene.ts +112 -25
- package/src/sceneclips.ts +83 -2
- package/src/scenerepeat.ts +111 -0
- package/src/turn.ts +225 -2
- package/src/turnoverlap.ts +23 -0
package/src/check.ts
CHANGED
|
@@ -99,7 +99,7 @@ import { createRequire } from 'node:module';
|
|
|
99
99
|
import type { Candidate, Piece, Viewport as RootCoverageViewport } from '@rig-c/core/render-shared';
|
|
100
100
|
import { fillHoles } from './raster/morph.ts';
|
|
101
101
|
import { closeSync, copyFileSync, cpSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs';
|
|
102
|
-
import { diagnosticSegment, diagnosticSiblings, unsafeSegmentReason } from './outputpaths.ts';
|
|
102
|
+
import { argvPathFromOut, diagnosticSegment, diagnosticSiblings, unsafeSegmentReason } from './outputpaths.ts';
|
|
103
103
|
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
104
104
|
import { measureRecomposite, type RecompositeFigures, recompositeRecord, scenePhrase, sourceInRig, figureSilhouette } from './assemble.ts';
|
|
105
105
|
import { type BoneTransform, computeExactFrameTransforms, cropToSpineY, normaliseDegrees, toBoneLocal } from './coords.ts';
|
|
@@ -6828,7 +6828,7 @@ function renderExtremes(build: string, out: string, animations: readonly string[
|
|
|
6828
6828
|
* MEASURABLE is a problem. Without it nothing here reads, writes or prints
|
|
6829
6829
|
* anything it did not before.
|
|
6830
6830
|
*/
|
|
6831
|
-
export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string,
|
|
6831
|
+
export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string, _requirementsAs: string | undefined = requirements, config?: InputFileRecord, windBand?: string, noExtremes = false, supportSource?: string, supportFigure?: Mask, assemblyRules?: AssemblyRules): CheckReport {
|
|
6832
6832
|
const pageSize = parsePageSize(mode.pageSize);
|
|
6833
6833
|
let inp: CheckInputs;
|
|
6834
6834
|
let reqFile: RequirementsFile | null = null;
|
|
@@ -6868,7 +6868,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
6868
6868
|
if (got !== null && wb !== null) take(() => resolveWindBand(wb, got));
|
|
6869
6869
|
refuseIfAny(refused);
|
|
6870
6870
|
}
|
|
6871
|
-
reqRecord = requirementsFileRecord(requirements,
|
|
6871
|
+
reqRecord = requirementsFileRecord(requirements, argvPathFromOut(requirements, outDir, process.cwd()));
|
|
6872
6872
|
inp = got as CheckInputs;
|
|
6873
6873
|
const file = reqFile as RequirementsFile;
|
|
6874
6874
|
const ready = inp;
|
|
@@ -7006,7 +7006,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
7006
7006
|
let windBandRead: WindBandLine | null = null;
|
|
7007
7007
|
if (wb !== null) {
|
|
7008
7008
|
try {
|
|
7009
|
-
windBandRead = measureWindBand(wb, buildDir, windBandDir, animationNames, rigc);
|
|
7009
|
+
windBandRead = { ...measureWindBand(wb, buildDir, windBandDir, animationNames, rigc), path: argvPathFromOut(wb.path, outDir, process.cwd()) };
|
|
7010
7010
|
} catch (err) {
|
|
7011
7011
|
rmSync(windBandDir, { recursive: true, force: true });
|
|
7012
7012
|
for (const p of [join(out, 'gate_spine-html.txt'), buildReportPath]) rmSync(p, { force: true });
|
|
@@ -7755,11 +7755,12 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
7755
7755
|
const skipped: { loop?: string; seam?: string } = {};
|
|
7756
7756
|
if (inp.noIdle !== null) skipped.loop = inp.noIdle;
|
|
7757
7757
|
if (inp.noParts !== null) skipped.seam = inp.noParts;
|
|
7758
|
+
const recordedEnv: CheckEnvironment | null = env === null ? null : { ...env, path: argvPathFromOut(env.path, outDir, process.cwd()) };
|
|
7758
7759
|
const readings: Omit<CheckFigures, 'spec' | 'bar_outcomes' | 'build' | 'PASS'> = {
|
|
7759
7760
|
gate_spine_html_green: htmlGreen,
|
|
7760
7761
|
rigc_entry: rigcEntry,
|
|
7761
7762
|
pack_mode: { page_edges: mode.pageEdges, pack_shape: mode.packShape, ...(pageSize === undefined ? {} : { page_size: pageSize }) },
|
|
7762
|
-
...(
|
|
7763
|
+
...(recordedEnv === null ? {} : { environment: recordedEnv }),
|
|
7763
7764
|
loop_max_diff: loop === null ? null : loop.max,
|
|
7764
7765
|
...(loopPhysics === null ? {} : { loop_physics: loopPhysics.map(row => ({ ...row, ...checkRow('loop_physics', 'rig', false, []) })) }),
|
|
7765
7766
|
seam_mean: seam === null ? null : round3(seam.mean),
|
|
@@ -7921,10 +7922,9 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
|
|
|
7921
7922
|
export const REQUIREMENTS_DIR = 'requirements';
|
|
7922
7923
|
|
|
7923
7924
|
/**
|
|
7924
|
-
* Issue #556: the requirements file a check read, first in `check.json`'s
|
|
7925
|
-
* `requirements` block —
|
|
7926
|
-
*
|
|
7927
|
-
* bytes do not move with the directory the build ran in), the sha256 of the
|
|
7925
|
+
* Issue #556, #1554: the requirements file a check read, first in `check.json`'s
|
|
7926
|
+
* `requirements` block — `path` relative to `check`'s `--out` directory by
|
|
7927
|
+
* {@link argvPathFromOut} (`<out>/check` under `build`), the sha256 of the
|
|
7928
7928
|
* bytes read, and the file's top-level keys in its order, so a reader sees
|
|
7929
7929
|
* what the file asked (a `not_swinging`, a `may_fold`) without opening it.
|
|
7930
7930
|
*/
|
package/src/config.ts
CHANGED
|
@@ -633,8 +633,8 @@ export function contourRegionsOf(spec: ContourSpec): ContourRegionSpec[] {
|
|
|
633
633
|
* are decided exactly on that grid.
|
|
634
634
|
*/
|
|
635
635
|
export type ContourRegionSpec =
|
|
636
|
-
| { name: string; shape: 'circle'; cx: number; cy: number; r: number; spacing: number; band: number; bone: string }
|
|
637
|
-
| { name: string; shape: 'polygon'; points: Point[]; spacing: number; band: number; bone: string };
|
|
636
|
+
| { name: string; shape: 'circle'; cx: number; cy: number; r: number; spacing: number; band: number; bone: string; cover?: string }
|
|
637
|
+
| { name: string; shape: 'polygon'; points: Point[]; spacing: number; band: number; bone: string; cover?: string };
|
|
638
638
|
|
|
639
639
|
/**
|
|
640
640
|
* One mesh in the automatic mode (issue #126, item 2): the contour mesh over
|
|
@@ -2169,6 +2169,7 @@ function parseConfigFrom(raw: Json, base: string | null): { config: CharacterCon
|
|
|
2169
2169
|
}
|
|
2170
2170
|
const meshParts = isPlainObject(t.meshes) ? new Set(Object.keys(t.meshes).filter((k) => !isRecordKey(k))) : new Set<string>();
|
|
2171
2171
|
if ('turn' in t) checkTurn(c, t.turn, attached, names.bones, hasAltFace, parts, declaredSliders, meshParts, t.meshes, names.chains, names.parents);
|
|
2172
|
+
checkContourBandCovers(c, t.meshes, t.turn, attached, names.bones, names.chains, names.parents);
|
|
2172
2173
|
if ('scene' in t) checkScene(c, t.scene);
|
|
2173
2174
|
if ('cloth' in t) checkCloth(c, t.cloth);
|
|
2174
2175
|
if ('requirements' in t && c.string('config.requirements', t.requirements) && base !== null) checkRequirementsFile(c, configFilePath('requirements', base, t.requirements) as string);
|
|
@@ -3874,7 +3875,7 @@ function checkContour(c: Check, at: string, v: Json, bones: Set<string>): void {
|
|
|
3874
3875
|
const rat = `${at}.regions[${i}]`;
|
|
3875
3876
|
const shape = typeof rv === 'object' && rv !== null && !Array.isArray(rv) ? (rv as Record<string, Json>).shape : undefined;
|
|
3876
3877
|
const own = shape === 'circle' ? ['cx', 'cy', 'r'] : shape === 'polygon' ? ['points'] : [];
|
|
3877
|
-
const r = c.object(rat, rv, ['name', 'shape', 'bone', 'spacing', 'band', ...own], []);
|
|
3878
|
+
const r = c.object(rat, rv, ['name', 'shape', 'bone', 'spacing', 'band', ...own], ['cover']);
|
|
3878
3879
|
if (r === null) return;
|
|
3879
3880
|
if ('shape' in r && own.length === 0) c.fail('CONFIG_FIELD_TYPE', `${rat}.shape`, `is ${show(r.shape)}; "circle" (with cx, cy, r) or "polygon" (with points) is required`);
|
|
3880
3881
|
if ('name' in r && c.string(`${rat}.name`, r.name)) {
|
|
@@ -3884,6 +3885,9 @@ function checkContour(c: Check, at: string, v: Json, bones: Set<string>): void {
|
|
|
3884
3885
|
if ('bone' in r && (typeof r.bone !== 'string' || !bones.has(r.bone))) {
|
|
3885
3886
|
c.fail('CONFIG_NAME_RESOLVES', `${rat}.bone`, `is ${show(r.bone)}; a bone config.bones declares is required — the region's control bone`);
|
|
3886
3887
|
}
|
|
3888
|
+
if ('cover' in r && (typeof r.cover !== 'string' || r.cover.length === 0)) {
|
|
3889
|
+
c.fail('CONFIG_FIELD_TYPE', `${rat}.cover`, `is ${show(r.cover)}; a non-empty part name is required`);
|
|
3890
|
+
}
|
|
3887
3891
|
if ('spacing' in r) c.number(`${rat}.spacing`, r.spacing, 'positive');
|
|
3888
3892
|
if ('band' in r) onGrid(`${rat}.band`, r.band, 'non-negative');
|
|
3889
3893
|
if (shape === 'circle') {
|
|
@@ -5786,6 +5790,133 @@ function checkTurn(
|
|
|
5786
5790
|
}
|
|
5787
5791
|
}
|
|
5788
5792
|
|
|
5793
|
+
/**
|
|
5794
|
+
* Issue #1548: `meshes.<part>.contour.regions[i].cover` names the `"surface"` part in the
|
|
5795
|
+
* other 2.5D turn group whose extended depth sheet supplies the region's other-group depth.
|
|
5796
|
+
* Refuses (`CONFIG_TURN_BAND_COVER`) when `part` is not a 2.5D turn surface, when the region's
|
|
5797
|
+
* bone is not in the other turn group (where `cover` would read nothing), when `cover` is not
|
|
5798
|
+
* an attached part, when `cover` lacks role `"surface"` in that other group, or when two regions
|
|
5799
|
+
* on one mesh share a bone with disagreeing `cover` declarations.
|
|
5800
|
+
*/
|
|
5801
|
+
function checkContourBandCovers(
|
|
5802
|
+
c: Check,
|
|
5803
|
+
rawMeshes: Json,
|
|
5804
|
+
rawTurn: Json,
|
|
5805
|
+
attached: ReadonlySet<string>,
|
|
5806
|
+
bones: ReadonlySet<string>,
|
|
5807
|
+
chains: ReadonlyMap<string, number>,
|
|
5808
|
+
parents: ReadonlyMap<string, string>,
|
|
5809
|
+
): void {
|
|
5810
|
+
if (!isPlainObject(rawMeshes)) return;
|
|
5811
|
+
const turnObj = isPlainObject(rawTurn) ? rawTurn : null;
|
|
5812
|
+
const headRoles = turnObj !== null && isPlainObject(turnObj.roles) ? turnObj.roles : null;
|
|
5813
|
+
const bodyObj = turnObj !== null && isPlainObject(turnObj.body) ? turnObj.body : null;
|
|
5814
|
+
const bodyRoles = bodyObj !== null && isPlainObject(bodyObj.roles) ? bodyObj.roles : null;
|
|
5815
|
+
const bodyRoot =
|
|
5816
|
+
bodyObj !== null && typeof bodyObj.bone === 'string' && bones.has(bodyObj.bone)
|
|
5817
|
+
? bodyObj.bone
|
|
5818
|
+
: bones.has('chest')
|
|
5819
|
+
? 'chest'
|
|
5820
|
+
: 'hip';
|
|
5821
|
+
const descends = (bone: string, root: string): boolean => {
|
|
5822
|
+
if (!bones.has(bone) || !bones.has(root)) return false;
|
|
5823
|
+
const seen = new Set<string>();
|
|
5824
|
+
for (let cur: string | undefined = bone; cur !== undefined && !seen.has(cur); cur = parents.get(cur)) {
|
|
5825
|
+
if (cur === root) return true;
|
|
5826
|
+
seen.add(cur);
|
|
5827
|
+
}
|
|
5828
|
+
return false;
|
|
5829
|
+
};
|
|
5830
|
+
const groupOf = (bone: string): 'head' | 'body' | null =>
|
|
5831
|
+
descends(bone, 'head') ? 'head' : !descends(bodyRoot, 'head') && descends(bone, bodyRoot) ? 'body' : null;
|
|
5832
|
+
|
|
5833
|
+
for (const [part, spec] of Object.entries(rawMeshes)) {
|
|
5834
|
+
if (isRecordKey(part) || !isPlainObject(spec) || !isPlainObject(spec.contour) || !Array.isArray(spec.contour.regions)) continue;
|
|
5835
|
+
const headSurface = headRoles?.[part] === 'surface';
|
|
5836
|
+
const bodySurface = bodyRoles?.[part] === 'surface';
|
|
5837
|
+
const segGroups = new Set<'head' | 'body'>();
|
|
5838
|
+
if (Array.isArray(spec.segments)) {
|
|
5839
|
+
for (const s of spec.segments) {
|
|
5840
|
+
if (typeof s === 'string') {
|
|
5841
|
+
const count = chains.get(s);
|
|
5842
|
+
const list = count !== undefined ? Array.from({ length: count }, (_, k) => `${s}${k}`) : [s];
|
|
5843
|
+
for (const b of list) {
|
|
5844
|
+
const g = groupOf(b);
|
|
5845
|
+
if (g !== null) segGroups.add(g);
|
|
5846
|
+
}
|
|
5847
|
+
} else if (Array.isArray(s) && typeof s[0] === 'string') {
|
|
5848
|
+
const g = groupOf(s[0]);
|
|
5849
|
+
if (g !== null) segGroups.add(g);
|
|
5850
|
+
}
|
|
5851
|
+
}
|
|
5852
|
+
}
|
|
5853
|
+
const coverByBone = new Map<string, string | null>();
|
|
5854
|
+
spec.contour.regions.forEach((rv, i) => {
|
|
5855
|
+
if (!isPlainObject(rv)) return;
|
|
5856
|
+
const bone = typeof rv.bone === 'string' ? rv.bone : null;
|
|
5857
|
+
const hasCover = 'cover' in rv;
|
|
5858
|
+
if (bone !== null && bones.has(bone)) {
|
|
5859
|
+
const curCover = hasCover && typeof rv.cover === 'string' && rv.cover.length > 0 ? rv.cover : null;
|
|
5860
|
+
const prev = coverByBone.get(bone);
|
|
5861
|
+
if (prev !== undefined && prev !== curCover) {
|
|
5862
|
+
c.fail(
|
|
5863
|
+
'CONFIG_TURN_BAND_COVER',
|
|
5864
|
+
`config.meshes.${part}.contour.regions[${i}].cover`,
|
|
5865
|
+
`disagrees with an earlier contour region on bone "${bone}" (${prev === null ? 'absent' : `"${prev}"`} vs ${curCover === null ? 'absent' : `"${curCover}"`}); regions sharing a control bone on one mesh must agree on cover`,
|
|
5866
|
+
);
|
|
5867
|
+
} else if (prev === undefined) {
|
|
5868
|
+
coverByBone.set(bone, curCover);
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
if (!hasCover || typeof rv.cover !== 'string' || rv.cover.length === 0) return;
|
|
5872
|
+
const cover = rv.cover;
|
|
5873
|
+
const at = `config.meshes.${part}.contour.regions[${i}].cover`;
|
|
5874
|
+
const regName = typeof rv.name === 'string' ? rv.name : String(i);
|
|
5875
|
+
if (!headSurface && !bodySurface) {
|
|
5876
|
+
c.fail(
|
|
5877
|
+
'CONFIG_TURN_BAND_COVER',
|
|
5878
|
+
at,
|
|
5879
|
+
`is "${cover}" on region "${regName}" of "${part}", which has no 2.5D turn "surface" role; cover reads a depth sheet only on a turn "surface" part`,
|
|
5880
|
+
);
|
|
5881
|
+
return;
|
|
5882
|
+
}
|
|
5883
|
+
if (bone === null || !bones.has(bone)) return;
|
|
5884
|
+
const regGroup = groupOf(bone);
|
|
5885
|
+
const inOtherGroup =
|
|
5886
|
+
headSurface && !bodySurface
|
|
5887
|
+
? regGroup === 'body'
|
|
5888
|
+
: bodySurface && !headSurface
|
|
5889
|
+
? regGroup === 'head'
|
|
5890
|
+
: regGroup !== null && segGroups.size === 1 && !segGroups.has(regGroup);
|
|
5891
|
+
if (!inOtherGroup || regGroup === null) {
|
|
5892
|
+
c.fail(
|
|
5893
|
+
'CONFIG_TURN_BAND_COVER',
|
|
5894
|
+
at,
|
|
5895
|
+
`is "${cover}" on region "${regName}" (bone "${bone}"), which is ${regGroup === null ? 'outside both 2.5D turn subtrees' : `in "${part}"'s own ${regGroup} turn group`}, so cover would read nothing; bind the region to a bone in the other turn group or remove cover`,
|
|
5896
|
+
);
|
|
5897
|
+
return;
|
|
5898
|
+
}
|
|
5899
|
+
const otherRoles = regGroup === 'head' ? headRoles : bodyRoles;
|
|
5900
|
+
const otherPath = regGroup === 'head' ? 'config.turn.roles' : 'config.turn.body.roles';
|
|
5901
|
+
if (!attached.has(cover)) {
|
|
5902
|
+
c.fail(
|
|
5903
|
+
'CONFIG_TURN_BAND_COVER',
|
|
5904
|
+
at,
|
|
5905
|
+
`names "${cover}", which config.meshes and config.regions do not attach; a declared part with role "surface" in ${otherPath} is required`,
|
|
5906
|
+
);
|
|
5907
|
+
return;
|
|
5908
|
+
}
|
|
5909
|
+
if (otherRoles?.[cover] !== 'surface') {
|
|
5910
|
+
c.fail(
|
|
5911
|
+
'CONFIG_TURN_BAND_COVER',
|
|
5912
|
+
at,
|
|
5913
|
+
`names "${cover}", which has role ${otherRoles === null || !(cover in otherRoles) ? 'none' : show(otherRoles[cover])} in ${otherPath}; role "surface" in the ${regGroup} turn group is required`,
|
|
5914
|
+
);
|
|
5915
|
+
}
|
|
5916
|
+
});
|
|
5917
|
+
}
|
|
5918
|
+
}
|
|
5919
|
+
|
|
5789
5920
|
/** #773: all scalar units and user polarity are authored, never inferred. */
|
|
5790
5921
|
function checkDepthConfig(c: Check, raw: Json): void {
|
|
5791
5922
|
const d = c.object('config.depth', raw, [], ['zScale', 'full', 'head']);
|
package/src/configrelocation.ts
CHANGED
|
@@ -34,6 +34,9 @@ function relocateAssemblyFiles(raw: unknown, relocate: (value: string) => string
|
|
|
34
34
|
fields(take, ['run_dir', 'st_input']);
|
|
35
35
|
fields(take.reference, ['painting']);
|
|
36
36
|
}
|
|
37
|
+
if (object(raw.assemble.editor_receipts)) {
|
|
38
|
+
for (const receipt of entries(raw.assemble.editor_receipts.receipts)) fields(receipt, ['file']);
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
if (object(raw.limbs)) {
|
|
39
42
|
for (const limb of Object.values(raw.limbs).filter(object)) {
|
package/src/depthworkflow.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { PartsError, type Problem } from './errors.ts';
|
|
|
10
10
|
import { loadConfigAndAnimations, parseConfig } from './config.ts';
|
|
11
11
|
import { relocateConfigReferences } from './configrelocation.ts';
|
|
12
12
|
import { depthReading, readSourceDepth } from './depthsheets.ts';
|
|
13
|
+
import { readEditorReceipts } from './editreceipt.ts';
|
|
13
14
|
import { alphaSupport, depthMapFail as fail, floatBox, integrateNormals, mapToSheet, readNumericMap, type NumericMap } from './depthmaps.ts';
|
|
14
15
|
import { depthImageReference, partImageReference, readParts } from './parts.ts';
|
|
15
16
|
import { readPartSet } from './propose.ts';
|
|
@@ -243,6 +244,8 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
243
244
|
const rawParts = object(readJson(join(input.parts, 'parts.json')), 'parts.json'), file = readParts(join(input.parts, 'parts.json'));
|
|
244
245
|
for (const p of file.parts) if (Object.hasOwn(recipe.parts, p.name) && applied(recipe.parts[p.name].group) && p.provenance?.depth?.kind === 'authored-unit') fail('DEPTH_AUTHORED_UNIT_CONFLICT', `part "${p.name}"`, 'has provenance.depth.kind "authored-unit"; a transported scalar reference cannot coexist with authored unit depth — retain the unit declaration or supply an explicitly reassembled scalar-compatible input; no automatic transition is made');
|
|
245
246
|
const { config } = loadConfigAndAnimations(input.rigConfig);
|
|
247
|
+
const receiptProblems = readEditorReceipts(config.assemble.editor_receipts, input.rigConfig).problems;
|
|
248
|
+
if (receiptProblems.length) throw new PartsError(receiptProblems);
|
|
246
249
|
refuseStaleAssembly(input.rigConfig, file, config);
|
|
247
250
|
const raw = object(readJson(input.rigConfig), 'rig config'), turn = object(raw.turn, 'config.turn');
|
|
248
251
|
// A group left out must not turn: the rig builds a group's turn from its config block, not from its sheets.
|
|
@@ -263,7 +266,10 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
|
|
|
263
266
|
}
|
|
264
267
|
// Keep relative paths portable when relocating the output directory with its inputs.
|
|
265
268
|
relocateConfigReferences(raw, dirname(input.rigConfig), input.out, 'relative');
|
|
266
|
-
|
|
269
|
+
const relocatedConfig = parseConfig(raw), outConfig = join(input.out, 'config.json');
|
|
270
|
+
const relocatedReceiptProblems = readEditorReceipts(relocatedConfig.assemble.editor_receipts, outConfig).problems;
|
|
271
|
+
if (relocatedReceiptProblems.length) throw new PartsError(relocatedReceiptProblems);
|
|
272
|
+
refuseStaleAssembly(outConfig, file, relocatedConfig);
|
|
267
273
|
const warnings: string[] = [];
|
|
268
274
|
const writes = new Map<string, Uint8Array>(), rows: Obj[] = [], recs = rawParts.parts as Obj[];
|
|
269
275
|
// Retain auxiliary art (including alternate sets) and diagnostics byte-for-byte.
|
package/src/outputpaths.ts
CHANGED
|
@@ -1,5 +1,112 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, realpathSync } from 'node:fs';
|
|
2
|
+
import nodePath, { resolve } from 'node:path';
|
|
1
3
|
import { PartsError } from './errors.ts';
|
|
2
4
|
|
|
5
|
+
/** `node:path`, or its `win32`/`posix` twin a control passes in. */
|
|
6
|
+
export type PlatformPath = typeof nodePath.posix;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A directory through its links when it or an ancestor exists: the deepest existing prefix is resolved by
|
|
10
|
+
* `realpathSync` and any not-yet-created trailing segments are appended, so rebasing before `mkdirSync` agrees with
|
|
11
|
+
* rebasing after it. As given when only the filesystem root exists (nothing on disk to resolve).
|
|
12
|
+
*/
|
|
13
|
+
export function realWhereItExists(path: string): string {
|
|
14
|
+
if (nodePath.sep === '\\' && path.startsWith('/')) return path;
|
|
15
|
+
if (nodePath.dirname(path) === path) return path;
|
|
16
|
+
if (existsSync(path)) return realpathSync(path);
|
|
17
|
+
const missing: string[] = [];
|
|
18
|
+
let cur = path;
|
|
19
|
+
for (;;) {
|
|
20
|
+
const parent = nodePath.dirname(cur);
|
|
21
|
+
if (parent === cur) return path;
|
|
22
|
+
missing.push(nodePath.basename(cur));
|
|
23
|
+
cur = parent;
|
|
24
|
+
if (nodePath.dirname(cur) === cur) return path;
|
|
25
|
+
if (existsSync(cur)) {
|
|
26
|
+
let resolved = realpathSync(cur);
|
|
27
|
+
for (let i = missing.length - 1; i >= 0; i--) resolved = nodePath.join(resolved, missing[i]);
|
|
28
|
+
return resolved;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A path as spelled: no link resolved. */
|
|
34
|
+
function asSpelled(path: string): string {
|
|
35
|
+
return path;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The link rule a path is rebased to `--out` by, chosen by `api`'s platform: the rule its `..` follows when a replay
|
|
40
|
+
* runs from the `--out` directory. On POSIX `..` is the physical parent, and the working directory is reported by its
|
|
41
|
+
* real path, so both ends are resolved through their links ({@link realWhereItExists}). On Windows `..` is textual:
|
|
42
|
+
* measured (issue #1551, Bun 1.4.4 on Windows build 26100), a process started in a directory spelled through a
|
|
43
|
+
* junction reports that spelling as `process.cwd()` and resolves `..` against it, while `realpathSync` and
|
|
44
|
+
* `realpathSync.native` both resolve the junction; resolving the ends there climbed one level too many from the
|
|
45
|
+
* `--out` the run was given. So on Windows a path is rebased as spelled, from `--out` as the run was given it.
|
|
46
|
+
*/
|
|
47
|
+
export function linkRuleFor(api: PlatformPath): (path: string) => string {
|
|
48
|
+
return api.sep === '\\' ? asSpelled : realWhereItExists;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `path` relative to `outDir` in `api`'s separators, with `outDir` and `path`'s directory resolved through their
|
|
53
|
+
* links by `real` and `path`'s own last segment kept: the rule {@link recordedConfigPath}, {@link argvPathFromOut}
|
|
54
|
+
* and {@link recordedInputPath} share, rig-c core's `relativeToOut` (core issue #1770).
|
|
55
|
+
*/
|
|
56
|
+
export function relativeKeepingName(outDir: string, path: string, real: (path: string) => string, api: PlatformPath): string {
|
|
57
|
+
const absolute = api.resolve(path);
|
|
58
|
+
return api.relative(real(api.resolve(outDir)), api.join(real(api.dirname(absolute)), api.basename(absolute)));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* `config.path` in a `rig-run/2` record: relative to the real `--out` directory, the config's directory resolved through
|
|
63
|
+
* its links and the file's own name kept, `/`-separated. A config given through a link is recorded by the link's name,
|
|
64
|
+
* as rig-c core's render-run.json records an input (core issue #1770), so a replay reads what the link names then.
|
|
65
|
+
* `rig-run/1`'s `config.path` still resolves the file itself and is unchanged.
|
|
66
|
+
* The links are resolved by {@link linkRuleFor}'s rule, so on Windows the path is relative to `--out` as spelled.
|
|
67
|
+
* `real` and `api` are the resolution and path rules used, for the control.
|
|
68
|
+
*/
|
|
69
|
+
export function recordedConfigPath(outDir: string, configPath: string, real?: (path: string) => string, api: PlatformPath = nodePath): string {
|
|
70
|
+
return relativeKeepingName(outDir, configPath, real ?? linkRuleFor(api), api).split(api.sep).join('/');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* One path argument written relative to the `--out` directory, with `/` separators: both taken from `cwd`, the
|
|
75
|
+
* `--out` directory and the argument's directory resolved through their links, the argument's own last segment kept
|
|
76
|
+
* (a linked file keeps its own name), as {@link recordedConfigPath} records `config.path`. `.` when it is the directory
|
|
77
|
+
* itself. Written as given when it cannot be expressed relative to `--out` (another Windows drive).
|
|
78
|
+
*
|
|
79
|
+
* Measured (issue #1544): with `--out` given through a linked directory (`/var` -> `/private/var` on macOS) and the
|
|
80
|
+
* argument relative to a working directory the process reports by its real path, plain path arithmetic climbed out
|
|
81
|
+
* through the link and named a path that, replayed from the `--out` directory, did not exist. `real` is the link
|
|
82
|
+
* resolution used, {@link linkRuleFor} the platform's by default (on Windows, as spelled: issue #1551); the control
|
|
83
|
+
* passes the other platform's rule to plant the wrong arithmetic.
|
|
84
|
+
*/
|
|
85
|
+
export function argvPathFromOut(given: string, out: string, cwd: string, api: PlatformPath = nodePath, real: (path: string) => string = linkRuleFor(api)): string {
|
|
86
|
+
const rel = relativeKeepingName(api.resolve(cwd, out), api.resolve(cwd, given), real, api);
|
|
87
|
+
if (api.isAbsolute(rel)) return given;
|
|
88
|
+
return rel === '' ? '.' : rel.split(api.sep).join('/');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* One `assemble` input (`source`, `full`, `head`) recorded relative to `--out` by {@link argvPathFromOut} (issue
|
|
93
|
+
* #1554): when `isDirectory` is true (a See-through directory run), records the hashed manifest `<given>/layers.json`
|
|
94
|
+
* rather than the directory itself so the recorded `path` names the exact file `sha256` digests.
|
|
95
|
+
*/
|
|
96
|
+
export function recordedInputPath(given: string, out: string, cwd: string, isDirectory = false, api: PlatformPath = nodePath, real: (path: string) => string = linkRuleFor(api)): string {
|
|
97
|
+
return argvPathFromOut(isDirectory ? api.join(given, 'layers.json') : given, out, cwd, api, real);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Make an output directory and its parents, from its resolved path. Bun on Windows refuses
|
|
102
|
+
* `mkdirSync('.', { recursive: true })` with EEXIST when `.` exists (windows-latest, Bun 1.4.5, issue #1541), so an
|
|
103
|
+
* `--out .` given from the directory it names reached that refusal; the resolved path is made on every platform.
|
|
104
|
+
* `mkdir` is the call made, for the control that plants the unresolved one.
|
|
105
|
+
*/
|
|
106
|
+
export function makeOutDir(dir: string, mkdir: (path: string, options: { recursive: true }) => unknown = mkdirSync): void {
|
|
107
|
+
mkdir(resolve(dir), { recursive: true });
|
|
108
|
+
}
|
|
109
|
+
|
|
3
110
|
/**
|
|
4
111
|
* Filesystem spelling for a diagnostic name. See STABILITY's "Diagnostic path
|
|
5
112
|
* segments" for the single public definition. Encode code units, not UTF-8:
|
package/src/rig.ts
CHANGED
|
@@ -189,8 +189,9 @@ import { alphaAbove, crop, pad, type Raster } from './raster/index.ts';
|
|
|
189
189
|
import { pyRound } from './round.ts';
|
|
190
190
|
import { boneHeat, type HeatDust, heatInfluences, HEAT_LIMITS, heatRow, type HeatRow, latticeSilhouette, tracedSilhouette } from './heat.ts';
|
|
191
191
|
import type { PosePoints } from './skeleton.ts';
|
|
192
|
-
import { applyFaceSurfaceDeform, BODY_REAR_SHIFT_BONE, BODY_YAW_DIAL_BONE, BODYSHIFT_BONE, buildDepth25DTurn, 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 TurnRole, type TurnSpec, turnConstraintName, turnFractions, turnNearest, turnSurfaceBone, turnTwin, turnUnitBone, YAW_DIAL_BONE } from './turn.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 TurnRole, type TurnSpec, turnConstraintName, turnFractions, turnNearest, turnSurfaceBone, turnTwin, turnUnitBone, YAW_DIAL_BONE } from './turn.ts';
|
|
193
193
|
import { DISTANCE_EXPONENT, type FloorForm, type Influence, influences, type InfluenceLimits, type MeshInfluences, meshLimits, type Segment } from './weights.ts';
|
|
194
|
+
import { turnContourBands } from './turnoverlap.ts';
|
|
194
195
|
|
|
195
196
|
/** Transparent pixels added round every part image — the reference's `PAD`. */
|
|
196
197
|
export const PAD = 4;
|
|
@@ -2009,6 +2010,7 @@ export function buildWaistPairSource(
|
|
|
2009
2010
|
};
|
|
2010
2011
|
const skin: RigSpec['skins']['default'] = {};
|
|
2011
2012
|
const meshReport: MeshReport[] = [];
|
|
2013
|
+
const contourRegionSummaries = new Map<string, NonNullable<NonNullable<Depth25DTurnOptions['surfaceMeshes']>[number]['contourRegions']>>();
|
|
2012
2014
|
const outImages: Array<[string, Raster]> = [];
|
|
2013
2015
|
const depthReferences: NonNullable<RigOutput['depthReferences']> = [];
|
|
2014
2016
|
const emitDepth = (part: string, reference: PartDepthReference, scalar: Raster): void => {
|
|
@@ -2135,6 +2137,7 @@ export function buildWaistPairSource(
|
|
|
2135
2137
|
const weights: WeightEntry[][] = [];
|
|
2136
2138
|
const reached = regions.map(() => 0);
|
|
2137
2139
|
const whole = regions.map(() => 0);
|
|
2140
|
+
const weighted = regions.map(() => 0);
|
|
2138
2141
|
let infl = 0;
|
|
2139
2142
|
let maxInfl = 0;
|
|
2140
2143
|
let overlapped = false;
|
|
@@ -2182,6 +2185,9 @@ export function buildWaistPairSource(
|
|
|
2182
2185
|
if (li.g >= 1) whole[li.region]++;
|
|
2183
2186
|
}
|
|
2184
2187
|
const shares = writtenShares(li, limits.floor);
|
|
2188
|
+
if (li.region >= 0 && shares.some((s) => s.bone === regions[li.region].bone && s.weight > 0)) {
|
|
2189
|
+
weighted[li.region]++;
|
|
2190
|
+
}
|
|
2185
2191
|
const ent: WeightEntry[] = shares.map(({ bone, weight }) => {
|
|
2186
2192
|
const [x, y] = toBoneLocal(world.get(bone) as BoneTransform, spineX(wx), spineY(wy));
|
|
2187
2193
|
return { bone, x: places(x), y: places(y), weight };
|
|
@@ -2199,6 +2205,20 @@ export function buildWaistPairSource(
|
|
|
2199
2205
|
for (const [x, y] of cm.vertices) uvs.push(pyRound(x / w, 6), pyRound(y / h, 6));
|
|
2200
2206
|
const bones = new Set(segs.map((s) => s.bone));
|
|
2201
2207
|
for (const rg of regions) bones.add(rg.bone);
|
|
2208
|
+
const explicitRegions = spec.regions?.length ?? 0;
|
|
2209
|
+
if (explicitRegions > 0) {
|
|
2210
|
+
contourRegionSummaries.set(
|
|
2211
|
+
p.name,
|
|
2212
|
+
regions.slice(0, explicitRegions).map((rg, index) => ({
|
|
2213
|
+
index,
|
|
2214
|
+
name: rg.name,
|
|
2215
|
+
shape: rg.shape,
|
|
2216
|
+
bone: rg.bone,
|
|
2217
|
+
weightedVertices: weighted[index],
|
|
2218
|
+
...(rg.cover === undefined ? {} : { cover: rg.cover }),
|
|
2219
|
+
})),
|
|
2220
|
+
);
|
|
2221
|
+
}
|
|
2202
2222
|
const rep = cm.report;
|
|
2203
2223
|
return {
|
|
2204
2224
|
attachment: { type: 'mesh', image: file, width: w, height: h, uvs, triangles: cm.triangles, hull: cm.hull, weights },
|
|
@@ -2573,6 +2593,19 @@ export function buildWaistPairSource(
|
|
|
2573
2593
|
roleField,
|
|
2574
2594
|
`declares role "surface" for "${p.name}", which requires a depth sheet in parts.json; run assemble with config.depth or provide "${p.name}_depth.png"`,
|
|
2575
2595
|
);
|
|
2596
|
+
for (const [mPart, mSpec] of Object.entries(cfg.meshes)) {
|
|
2597
|
+
if ('contour' in mSpec && mSpec.contour.regions !== undefined) {
|
|
2598
|
+
mSpec.contour.regions.forEach((rg, ri) => {
|
|
2599
|
+
if (rg.cover === p.name) {
|
|
2600
|
+
fail(
|
|
2601
|
+
'CONFIG_TURN_BAND_COVER',
|
|
2602
|
+
`config.meshes.${mPart}.contour.regions[${ri}].cover`,
|
|
2603
|
+
`names "${p.name}", which carries no depth sheet in parts.json; run assemble with config.depth or provide "${p.name}_depth.png"`,
|
|
2604
|
+
);
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2576
2609
|
continue;
|
|
2577
2610
|
}
|
|
2578
2611
|
}
|
|
@@ -3800,11 +3833,12 @@ export function buildWaistPairSource(
|
|
|
3800
3833
|
turn: cfg.turn,
|
|
3801
3834
|
parts: parts.parts,
|
|
3802
3835
|
images,
|
|
3836
|
+
contourBands: turnContourBands(cfg.meshes),
|
|
3803
3837
|
regions: cfg.regions,
|
|
3804
3838
|
stills,
|
|
3805
3839
|
boneLandmarks,
|
|
3806
3840
|
hasAlternateFaceSet,
|
|
3807
|
-
surfaceMeshes: turnSurfaceMeshes(cfg, rig, parts.rig_size),
|
|
3841
|
+
surfaceMeshes: turnSurfaceMeshes(cfg, rig, parts.rig_size, contourRegionSummaries),
|
|
3808
3842
|
neighbourMeshes: turnNeighbourMeshes(cfg, rig, parts, new Map(outImages)),
|
|
3809
3843
|
coverageMeshes: cfg.turn.body === undefined ? undefined : turnNeighbourMeshes(cfg, rig, parts, new Map(outImages), true),
|
|
3810
3844
|
});
|
|
@@ -3818,11 +3852,12 @@ export function buildWaistPairSource(
|
|
|
3818
3852
|
turn: cfg.turn,
|
|
3819
3853
|
parts: parts.parts,
|
|
3820
3854
|
images,
|
|
3855
|
+
contourBands: turnContourBands(cfg.meshes),
|
|
3821
3856
|
regions: cfg.regions,
|
|
3822
3857
|
stills,
|
|
3823
3858
|
boneLandmarks,
|
|
3824
3859
|
hasAlternateFaceSet,
|
|
3825
|
-
surfaceMeshes: turnSurfaceMeshes(cfg, rig, parts.rig_size),
|
|
3860
|
+
surfaceMeshes: turnSurfaceMeshes(cfg, rig, parts.rig_size, contourRegionSummaries),
|
|
3826
3861
|
neighbourMeshes: turnNeighbourMeshes(cfg, rig, parts, new Map(outImages)),
|
|
3827
3862
|
});
|
|
3828
3863
|
}
|
|
@@ -4324,10 +4359,16 @@ function refuseSharedWaistMotion(motion: MotionSpec, top: string, bone: string):
|
|
|
4324
4359
|
}
|
|
4325
4360
|
|
|
4326
4361
|
/** Final named bindings, including explicit islands; grid surfaces keep their Core path. */
|
|
4327
|
-
function turnSurfaceMeshes(
|
|
4362
|
+
function turnSurfaceMeshes(
|
|
4363
|
+
cfg: CharacterConfig,
|
|
4364
|
+
rig: RigSpec,
|
|
4365
|
+
canvas: readonly [number, number],
|
|
4366
|
+
contourRegions?: ReadonlyMap<string, NonNullable<NonNullable<Depth25DTurnOptions['surfaceMeshes']>[number]['contourRegions']>>,
|
|
4367
|
+
) {
|
|
4328
4368
|
const meshes = [];
|
|
4329
4369
|
for (const part of Object.keys(cfg.meshes)) {
|
|
4330
4370
|
if (cfg.turn?.roles?.[part] !== 'surface' && cfg.turn?.body?.roles?.[part] !== 'surface') continue;
|
|
4371
|
+
let firstForPart = true;
|
|
4331
4372
|
for (const slot of rig.slots) {
|
|
4332
4373
|
if (slot.name !== part && !slot.name.startsWith(`${part}__island`)) continue;
|
|
4333
4374
|
for (const [attachment, att] of Object.entries(rig.skins.default[slot.name] ?? {})) {
|
|
@@ -4337,7 +4378,17 @@ function turnSurfaceMeshes(cfg: CharacterConfig, rig: RigSpec, canvas: readonly
|
|
|
4337
4378
|
if (attachment !== part && !slot.name.startsWith(`${part}__island`)) {
|
|
4338
4379
|
throw new PartsError([{ code: 'RIG_TURN_SURFACE_MESH_ATTACHMENT', object: `surface mesh "${slot.name}/${attachment}"`, detail: `requires the base drawing "${part}"; alternate drawings need their own registered depth sampling frame` }]);
|
|
4339
4380
|
}
|
|
4340
|
-
|
|
4381
|
+
const regionsForPart = firstForPart ? contourRegions?.get(part) : undefined;
|
|
4382
|
+
firstForPart = false;
|
|
4383
|
+
meshes.push({
|
|
4384
|
+
part,
|
|
4385
|
+
slot: slot.name,
|
|
4386
|
+
attachment,
|
|
4387
|
+
weights: att.weights,
|
|
4388
|
+
triangles: att.triangles,
|
|
4389
|
+
canvas,
|
|
4390
|
+
...(regionsForPart === undefined ? {} : { contourRegions: regionsForPart }),
|
|
4391
|
+
});
|
|
4341
4392
|
}
|
|
4342
4393
|
}
|
|
4343
4394
|
}
|