@rig-c/parts 2.44.0 → 2.45.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 +2 -0
- package/cli.ts +130 -33
- package/docs/AUTHORING.md +365 -79
- package/docs/DEPTH.md +33 -6
- package/docs/MIGRATION.md +2 -0
- package/docs/STABILITY.md +353 -39
- package/package.json +1 -1
- package/src/boundarydepth.ts +113 -0
- package/src/check.ts +296 -78
- package/src/cloth.ts +14 -3
- package/src/config.ts +78 -11
- package/src/configwrite.ts +3 -3
- package/src/diffdrafts.ts +593 -0
- package/src/editedparts.ts +11 -2
- package/src/externalreceipt.ts +130 -0
- package/src/maskvalues.ts +21 -0
- package/src/outputpaths.ts +40 -0
- package/src/parts.ts +14 -5
- package/src/plate.ts +2 -6
- package/src/propose.ts +165 -8
- package/src/receiptproducer.ts +41 -0
- package/src/remesh-api.ts +33 -0
- package/src/remesh.ts +197 -19
- package/src/remeshdelta.ts +143 -30
- package/src/rig.ts +95 -21
- package/src/scene.ts +45 -9
- package/src/sceneclips.ts +60 -1
- package/src/turn.ts +24 -3
- package/tools/edited-part-cli.ts +12 -3
package/src/cloth.ts
CHANGED
|
@@ -72,8 +72,13 @@ import { pyRound } from './round.ts';
|
|
|
72
72
|
import { segmentDistance } from './weights.ts';
|
|
73
73
|
|
|
74
74
|
/** The tags a `cloth` recipe may name: the parts the proposer drafts chains on that hang. */
|
|
75
|
-
export const CLOTH_TARGETS = ['bottomwear', 'back hair', 'front hair'] as const;
|
|
75
|
+
export const CLOTH_TARGETS = ['bottomwear', 'back hair', 'front hair', 'handwear-r', 'handwear-l'] as const;
|
|
76
76
|
export type ClothTarget = (typeof CLOTH_TARGETS)[number];
|
|
77
|
+
export type SleeveClothTarget = Extract<ClothTarget, `handwear-${string}`>;
|
|
78
|
+
|
|
79
|
+
export function isSleeveCloth(target: ClothTarget): target is SleeveClothTarget {
|
|
80
|
+
return target === 'handwear-r' || target === 'handwear-l';
|
|
81
|
+
}
|
|
77
82
|
|
|
78
83
|
/** The per-branch stiffness of a tree. */
|
|
79
84
|
export interface ClothStrength {
|
|
@@ -88,6 +93,7 @@ export interface ClothRecipe {
|
|
|
88
93
|
links: number;
|
|
89
94
|
split?: { at: number; into: number; hold_tip?: boolean };
|
|
90
95
|
length_ratio?: number;
|
|
96
|
+
extent?: number;
|
|
91
97
|
strength?: ClothStrength;
|
|
92
98
|
damping?: number;
|
|
93
99
|
alternate_damping?: number;
|
|
@@ -315,7 +321,12 @@ export function draftTrees(input: TreeInput, r: ClothRecipe): TreeChain[] {
|
|
|
315
321
|
: branchCols.length > 0
|
|
316
322
|
? Math.min(trunkCol.tipY, ...branchCols.map((bc) => bc?.tipY ?? trunkCol.tipY))
|
|
317
323
|
: trunkCol.tipY;
|
|
318
|
-
const
|
|
324
|
+
const rootY = r.extent === undefined ? input.rootY : trunkTipY - r.extent * (trunkTipY - input.rootY);
|
|
325
|
+
const rows = mass !== undefined
|
|
326
|
+
? linkRows(mass.rootY, mass.tipY, r.links, ratio)
|
|
327
|
+
: r.extent === undefined && trunkTipY === input.tipY
|
|
328
|
+
? baseRows
|
|
329
|
+
: linkRows(rootY, trunkTipY, r.links, ratio);
|
|
319
330
|
const frame = mass === undefined ? input.frame : mass.frame;
|
|
320
331
|
const xWith = (col: TreeColumnTip | null, y: number, f: number): number =>
|
|
321
332
|
mass !== undefined ? (mass.xAt(y, f) ?? mass.fallbackX(f)) : ((col?.xAt ?? input.xAt)(y, f) ?? input.fallbackX(f));
|
|
@@ -349,7 +360,7 @@ export function draftTrees(input: TreeInput, r: ClothRecipe): TreeChain[] {
|
|
|
349
360
|
const fb = mass === undefined ? (k + (b + 0.5) / into) / n : (tInMass + (b + 0.5) / into) / nInMass;
|
|
350
361
|
const bCol = branchCols[b] ?? trunkCol;
|
|
351
362
|
const bTipY = bCol?.tipY ?? trunkTipY;
|
|
352
|
-
const bRows = bTipY === trunkTipY ? rows : linkRows(
|
|
363
|
+
const bRows = bTipY === trunkTipY ? rows : linkRows(rootY, bTipY, r.links, ratio);
|
|
353
364
|
const ch: TreeChain = {
|
|
354
365
|
chain: `${input.prefix}${k}${LETTERS[b]}_`,
|
|
355
366
|
parent: `${trunk.chain}${trunkLinks - 1}`,
|
package/src/config.ts
CHANGED
|
@@ -101,11 +101,12 @@ import { pyRound } from './round.ts';
|
|
|
101
101
|
import { motionSeamProblems, type MotionSeamDeclaration } from './motionseams.ts';
|
|
102
102
|
import { REQUIREMENTS_SPEC, type RequirementsFile } from './requirements.ts';
|
|
103
103
|
import { setupPaintingFilePath } from './setuppainting.ts';
|
|
104
|
-
import { CLOTH_TARGETS, type ClothRecipes, RECIPE_STRENGTH, RIGC_DEFAULT_DAMPING, springStable } from './cloth.ts';
|
|
104
|
+
import { CLOTH_TARGETS, type ClothRecipes, isSleeveCloth, RECIPE_STRENGTH, RIGC_DEFAULT_DAMPING, springStable } from './cloth.ts';
|
|
105
105
|
import { GRID, MAX_SIDE } from './contour.ts';
|
|
106
|
-
import { foldName, type Problem, refuseIfAny } from './errors.ts';
|
|
106
|
+
import { foldName, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
107
107
|
import { edgeLength } from './length.ts';
|
|
108
108
|
import { setFocusProblems } from './setfocus.ts';
|
|
109
|
+
import { parseReceiptProducer } from './receiptproducer.ts';
|
|
109
110
|
import { type EditorReceipts, SHA256_PATTERN, SHA256_RULE } from './editreceipt.ts';
|
|
110
111
|
import { isSkeletonName, KEYPOINT_NAMES, type KeypointName, type PosePoints, scaledPoints, SKELETON_NAMES, type SkeletonName } from './skeleton.ts';
|
|
111
112
|
import { acceptedTagNames, AUTHOR_LABEL_RULE, AUTHOR_PREFIX, readLayerTag } from './tags.ts';
|
|
@@ -405,7 +406,13 @@ export type Segment = string | [string, Point, Point];
|
|
|
405
406
|
* locally refined by rig-c's `reduceMesh` under the author's declared
|
|
406
407
|
* bounds (`src/automesh.ts`).
|
|
407
408
|
*/
|
|
408
|
-
export type MeshSpec = (LatticeMeshSpec | ContourMeshSpec | AutoMeshSpec | InfluenceMeshSpec | ExplicitMeshSpec) & { gather?: false };
|
|
409
|
+
export type MeshSpec = (LatticeMeshSpec | ContourMeshSpec | AutoMeshSpec | InfluenceMeshSpec | ExplicitMeshSpec) & { gather?: false; fixed_above?: FixedAbove };
|
|
410
|
+
|
|
411
|
+
/** Candidate bones for vertices at or above the cloth root, in rig pixels. */
|
|
412
|
+
export interface FixedAbove {
|
|
413
|
+
row: number;
|
|
414
|
+
bones: string[];
|
|
415
|
+
}
|
|
409
416
|
|
|
410
417
|
/**
|
|
411
418
|
* One mesh in the influence mode (issue #378): rig-c's `segments` lattice over the part at `cell` px, every vertex
|
|
@@ -2842,8 +2849,17 @@ function checkEditedParts(c: Check, value: Json, plan: Json | undefined): void {
|
|
|
2842
2849
|
const seen = new Map<string, number>();
|
|
2843
2850
|
(o.receipts as Json[]).forEach((value, i) => {
|
|
2844
2851
|
const p = at + '.receipts[' + i + ']';
|
|
2845
|
-
const r = c.object(p, value, ['part', 'file', 'sha256', 'from_sha256', 'editor'
|
|
2852
|
+
const r = c.object(p, value, ['part', 'file', 'sha256', 'from_sha256'], ['editor', 'producer']);
|
|
2846
2853
|
if (r === null) return;
|
|
2854
|
+
if (!('editor' in r) && !('producer' in r)) c.fail('CONFIG_FIELD_PRESENT', p, 'requires either editor or producer');
|
|
2855
|
+
if ('editor' in r && 'producer' in r) c.fail('CONFIG_KEY_KNOWN', p + '.producer', 'cannot accompany editor; one producer declaration is required');
|
|
2856
|
+
if ('producer' in r) {
|
|
2857
|
+
try { parseReceiptProducer(r.producer, p + '.producer'); }
|
|
2858
|
+
catch (error) {
|
|
2859
|
+
if (!(error instanceof PartsError)) throw error;
|
|
2860
|
+
c.problems.push(...error.problems);
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2847
2863
|
if ('part' in r && c.string(p + '.part', r.part)) {
|
|
2848
2864
|
const part = r.part as string;
|
|
2849
2865
|
if (seen.has(part)) c.fail('ASSEMBLE_EDITED_PART_DUPLICATE', p + '.part', `names "${part}" again (first at receipts[${seen.get(part)}]); one receipt per part is required`);
|
|
@@ -3450,9 +3466,27 @@ function checkMeshes(c: Check, v: Json, bones: Set<string>, chains: Map<string,
|
|
|
3450
3466
|
const at = `config.meshes.${part}`;
|
|
3451
3467
|
// The known keys keep their old order (grid, r, segments) with contour after them, and `r` and `segments` are
|
|
3452
3468
|
// required in the place and words the object check uses, so a lattice mesh's refusals read as they did.
|
|
3453
|
-
const m = c.object(at, spec, [], ['grid', 'r', 'segments', 'contour', 'auto', 'exponent', 'rule', 'ribs', 'influences', 'stray', 'influence', 'gather', 'explicit']);
|
|
3469
|
+
const m = c.object(at, spec, [], ['grid', 'r', 'segments', 'contour', 'auto', 'exponent', 'rule', 'ribs', 'influences', 'stray', 'influence', 'gather', 'explicit', 'fixed_above']);
|
|
3454
3470
|
if (m === null) continue;
|
|
3455
3471
|
checkGather(c, at, m);
|
|
3472
|
+
if ('fixed_above' in m) {
|
|
3473
|
+
const path = `${at}.fixed_above`;
|
|
3474
|
+
const hold = c.object(path, m.fixed_above, ['row', 'bones'], []);
|
|
3475
|
+
if ('auto' in m || 'explicit' in m || m.rule === 'heat') {
|
|
3476
|
+
c.fail('CONFIG_FIELD_TYPE', path, 'requires a distance lattice, distance contour, or influence mesh');
|
|
3477
|
+
}
|
|
3478
|
+
if (hold !== null) {
|
|
3479
|
+
if ('row' in hold) c.number(`${path}.row`, hold.row);
|
|
3480
|
+
if ('bones' in hold && c.array(`${path}.bones`, hold.bones, true)) {
|
|
3481
|
+
const segments = Array.isArray(m.segments) ? m.segments : [];
|
|
3482
|
+
for (const bone of hold.bones as Json[]) {
|
|
3483
|
+
if (typeof bone !== 'string' || !bones.has(bone) || !segments.some((segment) => segment === bone || (Array.isArray(segment) && segment[0] === bone))) {
|
|
3484
|
+
c.fail('CONFIG_NAME_RESOLVES', `${path}.bones`, `names ${show(bone)}, which must be a fixed bone in this mesh's segments`);
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3456
3490
|
if ('explicit' in m) {
|
|
3457
3491
|
checkExplicit(c, at, m, explicitBoneNames(bones, chains, stops), part);
|
|
3458
3492
|
continue;
|
|
@@ -4843,8 +4877,12 @@ function checkCloth(c: Check, v: Json): void {
|
|
|
4843
4877
|
for (const tag of CLOTH_TARGETS) {
|
|
4844
4878
|
if (!(tag in v)) continue;
|
|
4845
4879
|
const path = `${at}.${JSON.stringify(tag)}`;
|
|
4846
|
-
const r = c.object(path, v[tag], ['links', 'wind', 'gravity'], ['chains', 'split', 'length_ratio', 'strength', 'damping', 'alternate_damping', 'translate', 'swing', 'part', 'parts', 'influence']);
|
|
4880
|
+
const r = c.object(path, v[tag], ['links', 'wind', 'gravity'], ['chains', 'split', 'length_ratio', 'strength', 'damping', 'alternate_damping', 'translate', 'swing', 'part', 'parts', 'influence', 'extent']);
|
|
4847
4881
|
if (r === null) continue;
|
|
4882
|
+
const sleeve = isSleeveCloth(tag);
|
|
4883
|
+
if (sleeve && (!('part' in r) || Array.isArray(r.part) || 'parts' in r)) {
|
|
4884
|
+
c.fail('CONFIG_CLOTH_SLEEVE_PART', `${path}.part`, 'one sleeve carrier name is required in part; leave parts out');
|
|
4885
|
+
}
|
|
4848
4886
|
if (tag !== 'back hair' && !('chains' in r)) c.fail('CONFIG_FIELD_PRESENT', `${path}.chains`, 'is absent and required');
|
|
4849
4887
|
const chains = 'chains' in r && c.int(`${path}.chains`, r.chains, 1) ? (r.chains as number) : null;
|
|
4850
4888
|
const links = 'links' in r && c.int(`${path}.links`, r.links, 1) ? (r.links as number) : null;
|
|
@@ -4860,6 +4898,14 @@ function checkCloth(c: Check, v: Json): void {
|
|
|
4860
4898
|
}
|
|
4861
4899
|
}
|
|
4862
4900
|
if ('length_ratio' in r) c.number(`${path}.length_ratio`, r.length_ratio, 'positive');
|
|
4901
|
+
if ('extent' in r) {
|
|
4902
|
+
const extent = `${path}.extent`;
|
|
4903
|
+
if ((tag !== 'bottomwear' && !sleeve) || 'parts' in r || Array.isArray(r.part)) {
|
|
4904
|
+
c.fail('CONFIG_CLOTH_EXTENT', extent, 'is supported on a single bottomwear or sleeve carrier only');
|
|
4905
|
+
} else if (typeof r.extent !== 'number' || !Number.isFinite(r.extent) || r.extent <= 0 || r.extent > 1) {
|
|
4906
|
+
c.fail('CONFIG_CLOTH_EXTENT', extent, `is ${show(r.extent)}; a finite fraction above 0 and at most 1 is required`);
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4863
4909
|
// Issue #518: the influence mode for the parts this recipe meshes; the three fields #513 did not vary are the
|
|
4864
4910
|
// author's, each required, and radius, when stated, is kept as stated (the rig stage holds it to the reach).
|
|
4865
4911
|
if ('influence' in r) {
|
|
@@ -4928,7 +4974,7 @@ function checkCloth(c: Check, v: Json): void {
|
|
|
4928
4974
|
if ('part' in r) {
|
|
4929
4975
|
if (Array.isArray(r.part)) {
|
|
4930
4976
|
checkPartList(`${path}.part`, r.part);
|
|
4931
|
-
} else if (tag !== 'bottomwear') {
|
|
4977
|
+
} else if (tag !== 'bottomwear' && !sleeve) {
|
|
4932
4978
|
c.fail('CONFIG_CLOTH_PART_ON_BOTTOMWEAR', `${path}.part`, `is declared on "${tag}"; part hands the skirt's recipe (bottomwear) to a topwear part or its cut skirt piece (a dress) — leave it out here`);
|
|
4933
4979
|
} else c.string(`${path}.part`, r.part);
|
|
4934
4980
|
}
|
|
@@ -5310,10 +5356,10 @@ function checkTurn(
|
|
|
5310
5356
|
const hasBody = isPlainObject(v) && 'body' in v;
|
|
5311
5357
|
const hasDepths = isPlainObject(v) && 'depths' in v;
|
|
5312
5358
|
const o = hasRoles
|
|
5313
|
-
? c.object(at, v, ['roles'], ['pivot', 'depths', 'counter', 'grid', 'unitDepths', 'head', 'deform', 'band', 'radius', 'surface', 'body'])
|
|
5359
|
+
? c.object(at, v, ['roles'], ['pivot', 'depths', 'counter', 'grid', 'unitDepths', 'boundaryDepths', 'head', 'deform', 'band', 'radius', 'surface', 'body'])
|
|
5314
5360
|
: hasBody && !hasDepths
|
|
5315
|
-
? c.object(at, v, ['body'], ['pivot', 'depths', 'roles', 'counter', 'grid', 'unitDepths', 'head', 'deform', 'band', 'radius', 'surface'])
|
|
5316
|
-
: c.object(at, v, ['pivot', 'depths'], ['roles', 'counter', 'grid', 'unitDepths', 'head', 'deform', 'band', 'radius', 'surface', 'body']);
|
|
5361
|
+
? c.object(at, v, ['body'], ['pivot', 'depths', 'roles', 'counter', 'grid', 'unitDepths', 'boundaryDepths', 'head', 'deform', 'band', 'radius', 'surface'])
|
|
5362
|
+
: c.object(at, v, ['pivot', 'depths'], ['roles', 'counter', 'grid', 'unitDepths', 'boundaryDepths', 'head', 'deform', 'band', 'radius', 'surface', 'body']);
|
|
5317
5363
|
if (o === null) return;
|
|
5318
5364
|
const pivot = 'pivot' in o && c.number(`${at}.pivot`, o.pivot) ? (o.pivot as number) : null;
|
|
5319
5365
|
const checkGridField = (gAt: string, gv: Json): void => {
|
|
@@ -5349,6 +5395,26 @@ function checkTurn(
|
|
|
5349
5395
|
}
|
|
5350
5396
|
}
|
|
5351
5397
|
};
|
|
5398
|
+
const checkBoundaryDepths = (bAt: string, value: Json, roles: Json | undefined): void => {
|
|
5399
|
+
if (!isPlainObject(value)) { c.fail('CONFIG_FIELD_TYPE', bAt, 'requires an object of target part -> {neighbour, band}'); return; }
|
|
5400
|
+
for (const [target, raw] of Object.entries(value)) {
|
|
5401
|
+
const field = `${bAt}.${target}`;
|
|
5402
|
+
const declaration = c.object(field, raw, ['neighbour', 'band'], []);
|
|
5403
|
+
if (!attached.has(target)) c.fail('CONFIG_NAME_RESOLVES', field, `names "${target}"; an exact attached part name is required`);
|
|
5404
|
+
if (!isPlainObject(roles) || roles[target] !== 'surface') c.fail('CONFIG_FIELD_TYPE', field, `target "${target}" requires role "surface" in this turn group`);
|
|
5405
|
+
if (declaration === null) continue;
|
|
5406
|
+
for (const key of ['neighbour', 'band']) {
|
|
5407
|
+
if (!(key in declaration)) continue;
|
|
5408
|
+
const name = declaration[key];
|
|
5409
|
+
if (typeof name !== 'string' || name.length === 0) c.fail('CONFIG_FIELD_TYPE', `${field}.${key}`, 'requires an exact nonempty part name');
|
|
5410
|
+
else if (!attached.has(name)) c.fail('CONFIG_NAME_RESOLVES', `${field}.${key}`, `names "${name}"; an exact attached part name is required`);
|
|
5411
|
+
}
|
|
5412
|
+
if (typeof declaration.neighbour === 'string' && (!isPlainObject(roles) || roles[declaration.neighbour] !== 'surface' || declaration.neighbour === target)) {
|
|
5413
|
+
c.fail('CONFIG_FIELD_TYPE', `${field}.neighbour`, `requires a different surface in the same turn group as "${target}"`);
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
};
|
|
5417
|
+
if ('boundaryDepths' in o) checkBoundaryDepths(`${at}.boundaryDepths`, o.boundaryDepths, o.roles);
|
|
5352
5418
|
if ('counter' in o && c.number(`${at}.counter`, o.counter)) {
|
|
5353
5419
|
const cnt = o.counter as number;
|
|
5354
5420
|
if (cnt < 0 || cnt > 1) {
|
|
@@ -5448,7 +5514,8 @@ function checkTurn(
|
|
|
5448
5514
|
}
|
|
5449
5515
|
if ('body' in o) {
|
|
5450
5516
|
const bAt = `${at}.body`;
|
|
5451
|
-
const bo = c.object(bAt, o.body, ['roles'], ['pivot', 'bone', 'slider', 'counter', 'grid', 'unitDepths']);
|
|
5517
|
+
const bo = c.object(bAt, o.body, ['roles'], ['pivot', 'bone', 'slider', 'counter', 'grid', 'unitDepths', 'boundaryDepths']);
|
|
5518
|
+
if (bo !== null && 'boundaryDepths' in bo) checkBoundaryDepths(`${bAt}.boundaryDepths`, bo.boundaryDepths, bo.roles);
|
|
5452
5519
|
if (bo !== null) {
|
|
5453
5520
|
if ('pivot' in bo) {
|
|
5454
5521
|
c.number(`${bAt}.pivot`, bo.pivot);
|
package/src/configwrite.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import type { PlanProposal } from './assemble.ts';
|
|
12
12
|
import type { HeadBoxProposal } from './headbox.ts';
|
|
13
13
|
import type { CharacterConfig } from './config.ts';
|
|
14
|
-
import type
|
|
14
|
+
import { orderedEditedPartReceipt, type EditedPartReceipt } from './editedparts.ts';
|
|
15
15
|
import type { Proposal, PROPOSAL_CONFIG_SECTIONS } from './propose.ts';
|
|
16
16
|
import { PartsError } from './errors.ts';
|
|
17
17
|
import { parseConfig, parseProposalSections } from './config.ts';
|
|
@@ -99,11 +99,11 @@ export function mergeConfigProposal(raw: unknown, patch: ConfigWritePatch): Conf
|
|
|
99
99
|
const checked = parseConfig(before);
|
|
100
100
|
const spec = checked.assemble.edited_parts;
|
|
101
101
|
if (spec === undefined) throw new PartsError([{ code: 'EDITED_PART_BLOCK', object: 'config.assemble.edited_parts', detail: 'has no assemble.edited_parts; declare {dir, receipts: []} before recording an edited part' }]);
|
|
102
|
-
const { part
|
|
102
|
+
const { part } = patch.receipt;
|
|
103
103
|
if (!checked.assemble.plan.some(([name]) => name === part)) throw new PartsError([{ code: 'ASSEMBLE_EDITED_PART_UNKNOWN', object: part, detail: 'is not in assemble.plan; an existing plan part is required' }]);
|
|
104
104
|
const found = spec.receipts.findIndex(row => row.part === part);
|
|
105
105
|
const index = found === -1 ? spec.receipts.length : found;
|
|
106
|
-
const value = clone(
|
|
106
|
+
const value = clone(orderedEditedPartReceipt(patch.receipt), 'receipt');
|
|
107
107
|
const receipts = ((config.assemble as ConfigObject).edited_parts as ConfigObject).receipts as ConfigJson[];
|
|
108
108
|
if (found !== -1 && equal(receipts[index], value)) return { config, changes: [], edits: [] };
|
|
109
109
|
receipts[index] = value;
|