rig-parts 2.60.0 → 2.61.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 +1 -0
- package/docs/AUTHORING.md +84 -40
- package/docs/STABILITY.md +19 -1
- package/package.json +2 -2
- package/src/build.ts +11 -1
- package/src/check.ts +16 -2
- package/src/rig.ts +56 -26
- package/src/scene.ts +33 -4
- package/src/turn.ts +103 -14
- package/src/turnband.ts +418 -0
package/src/scene.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* (its name and every bone or slot it names), `stops` entry (its `chain`,
|
|
20
20
|
* its `links` and its `against`; issue #431), `invariants.detached` bone,
|
|
21
21
|
* `invariants.axes` entry (its name, its `through` and its `bones`; issue #239),
|
|
22
|
+
* `invariants.deformSliderCombinations` slider constraint reference,
|
|
22
23
|
* track (its `bone`, `group` or `physics` constraint target; issue #1485),
|
|
23
24
|
* group and easing of character `<id>` is renamed `<id>:<name>`
|
|
24
25
|
* ({@link prefixed}); `root` is the one shared root. A name resolves to
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
import { createHash } from 'node:crypto';
|
|
105
106
|
import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
106
107
|
import { dirname, join, resolve } from 'node:path';
|
|
107
|
-
import type
|
|
108
|
+
import { deformSliderCombinationProblem, type RigStop } from '@rig-c/core/rig';
|
|
108
109
|
import { checkStage, gateThroughRigc, type Log } from './build.ts';
|
|
109
110
|
import { ACCEPTABLE_BARS, barsNotMet, CHECK_SPEC, type CheckReport, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, type PackMode, parsePageSize, requirementsNotPass, type RigcRunner } from './check.ts';
|
|
110
111
|
import { CONSTRAINT_BONE_FIELDS, editorReceiptProblems, ROOT_BONE } from './config.ts';
|
|
@@ -513,7 +514,7 @@ const ATTACHMENT_KEYS = ['type', 'path', 'image', 'width', 'height', 'uvs', 'tri
|
|
|
513
514
|
const RIG_KEYS = ['spec', 'name', 'images', 'skeleton', 'bones', 'slots', 'skins', 'constraints', 'stops', 'invariants'];
|
|
514
515
|
const STOP_KEYS = ['chain', 'links', 'against', 'at', 'inward', 'outward', 'lower'];
|
|
515
516
|
const STOP_LOWER_KEYS = ['inward', 'outward'];
|
|
516
|
-
const INVARIANT_KEYS = ['idleDrivesMeshes', 'detached', 'axes', 'meshSlots', 'meshTriangles', 'deformMayFold'];
|
|
517
|
+
const INVARIANT_KEYS = ['idleDrivesMeshes', 'detached', 'axes', 'meshSlots', 'meshTriangles', 'deformMayFold', 'deformSliderCombinations'];
|
|
517
518
|
const MOTION_KEYS = ['spec', 'archetype', 'cut', 'easings', 'groups', 'animations'];
|
|
518
519
|
const IDLE_KEYS = ['duration', 'loop', 'note', 'tracks', 'deform'];
|
|
519
520
|
const TRACK_KEYS = ['bone', 'group', 'physics', 'property', 'keys'];
|
|
@@ -731,6 +732,10 @@ export function readCharacterBuild(c: SceneCharacter, problems: Problem[], accep
|
|
|
731
732
|
if (!Array.isArray(r.invariants.deformMayFold)) unknown('rig.json invariants.deformMayFold', r.invariants.deformMayFold, []);
|
|
732
733
|
else r.invariants.deformMayFold.forEach((entry, i) => unknown(`rig.json invariants.deformMayFold[${i}]`, entry, ['slot', 'why']));
|
|
733
734
|
}
|
|
735
|
+
const combinationProblem = deformSliderCombinationProblem(r.invariants.deformSliderCombinations, 'rig.json invariants.deformSliderCombinations');
|
|
736
|
+
if (combinationProblem !== undefined) {
|
|
737
|
+
problems.push({ code: 'SCENE_BUILD_FIELD_KNOWN', object: who, detail: combinationProblem });
|
|
738
|
+
}
|
|
734
739
|
}
|
|
735
740
|
const skins = isRecord(r.skins) ? r.skins : {};
|
|
736
741
|
unknown('rig.json skins', skins, ['default']);
|
|
@@ -1063,7 +1068,7 @@ export function scaledConstraint(con: Record<string, unknown>, s: number): Recor
|
|
|
1063
1068
|
out.limit = scaledBy(typeof con.limit === 'number' ? con.limit : SPINE_PHYSICS_LIMIT_DEFAULT, s);
|
|
1064
1069
|
break;
|
|
1065
1070
|
case 'slider':
|
|
1066
|
-
if (
|
|
1071
|
+
if (sliderInputIsLength(con)) {
|
|
1067
1072
|
len('from');
|
|
1068
1073
|
out.scale = scaledBy(typeof con.scale === 'number' ? con.scale : SPINE_SLIDER_SCALE_DEFAULT, 1 / s);
|
|
1069
1074
|
}
|
|
@@ -1072,6 +1077,11 @@ export function scaledConstraint(con: Record<string, unknown>, s: number): Recor
|
|
|
1072
1077
|
return out;
|
|
1073
1078
|
}
|
|
1074
1079
|
|
|
1080
|
+
/** A bone-driven slider's input may be a length, just like its mapping's `from`. */
|
|
1081
|
+
function sliderInputIsLength(con: Record<string, unknown> | undefined): boolean {
|
|
1082
|
+
return typeof con?.bone === 'string' && typeof con.property === 'string' && lengthProperty(con.property);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1075
1085
|
/** A stop of a character at scale `s` (issue #431): its `at` offset in `against`'s local frame scaled by `s`, its degree bounds unchanged; `s` 1 returns `stop` as given. */
|
|
1076
1086
|
export function scaledStop(stop: RigStop, s: number): RigStop {
|
|
1077
1087
|
if (s === 1) return stop;
|
|
@@ -1520,6 +1530,13 @@ export function composeScene(
|
|
|
1520
1530
|
for (const [i, entry] of (b.rig.invariants?.deformMayFold ?? []).entries()) {
|
|
1521
1531
|
if (!(slotsOf.get(b.id) ?? []).includes(entry.slot)) missing(`rig.json invariants.deformMayFold[${i}].slot`, `names ${show(entry.slot)}, which this character does not declare`);
|
|
1522
1532
|
}
|
|
1533
|
+
for (const [i, combination] of (b.rig.invariants?.deformSliderCombinations ?? []).entries()) {
|
|
1534
|
+
for (const [j, { slider }] of combination.inputs.entries()) {
|
|
1535
|
+
if (!(b.rig.constraints ?? []).some(con => con.type === 'slider' && con.name === slider)) {
|
|
1536
|
+
missing(`rig.json invariants.deformSliderCombinations[${i}].inputs[${j}].slider`, `names ${show(slider)}; this character must declare a slider constraint with that name`);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1523
1540
|
for (const [i, con] of (b.rig.constraints ?? []).entries()) if (con.type === 'slider') {
|
|
1524
1541
|
if (typeof con.animation !== 'string' || !(con.animation in anims)) missing(`rig.json constraints[${i}].animation`, `names ${show(con.animation)}, which this character's motion does not declare; an animation of its own is required`);
|
|
1525
1542
|
}
|
|
@@ -1603,6 +1620,7 @@ export function composeScene(
|
|
|
1603
1620
|
const stops: RigStop[] = [];
|
|
1604
1621
|
const detached: NonNullable<NonNullable<RigSpec['invariants']>['detached']> = [];
|
|
1605
1622
|
const axes: NonNullable<NonNullable<RigSpec['invariants']>['axes']> = [];
|
|
1623
|
+
const combinations: NonNullable<NonNullable<RigSpec['invariants']>['deformSliderCombinations']> = [];
|
|
1606
1624
|
scene.characters.forEach((c) => {
|
|
1607
1625
|
const b = byId.get(c.id) as CharacterBuild;
|
|
1608
1626
|
const id = c.id;
|
|
@@ -1693,6 +1711,12 @@ export function composeScene(
|
|
|
1693
1711
|
for (const d of b.rig.invariants?.detached ?? []) detached.push({ ...d, bone: P(id, d.bone), notUnder: P(id, d.notUnder) });
|
|
1694
1712
|
// An axis entry's name is unique within one rig, and two characters each carry a "face": the name is prefixed too.
|
|
1695
1713
|
for (const ax of b.rig.invariants?.axes ?? []) axes.push({ name: prefixed(id, ax.name), through: [P(id, ax.through[0]), P(id, ax.through[1])], bones: ax.bones.map((n) => P(id, n)), tolerance: ax.tolerance });
|
|
1714
|
+
for (const { inputs } of b.rig.invariants?.deformSliderCombinations ?? []) {
|
|
1715
|
+
combinations.push({ inputs: inputs.map(({ slider, value }) => {
|
|
1716
|
+
const constraint = b.rig.constraints?.find(con => con.type === 'slider' && con.name === slider);
|
|
1717
|
+
return { slider: prefixed(id, slider), value: sliderInputIsLength(constraint) ? scaledBy(value, s) : value };
|
|
1718
|
+
}) });
|
|
1719
|
+
}
|
|
1696
1720
|
});
|
|
1697
1721
|
const slots: RigSpec['slots'] = [];
|
|
1698
1722
|
if (scene.plate !== null && plate !== null) slots.push({ name: PLATE, bone: PLATE, attachment: PLATE });
|
|
@@ -1708,6 +1732,7 @@ export function composeScene(
|
|
|
1708
1732
|
if (axes.length > 0) invariants.axes = axes;
|
|
1709
1733
|
const mayFold = ready.flatMap(b => (b.rig.invariants?.deformMayFold ?? []).map(e => ({ ...e, slot: prefixed(b.id, e.slot) })));
|
|
1710
1734
|
if (mayFold.length > 0) invariants.deformMayFold = mayFold;
|
|
1735
|
+
if (combinations.length > 0) invariants.deformSliderCombinations = combinations;
|
|
1711
1736
|
const meshCounts = (b: CharacterBuild): { meshSlots: number; meshTriangles: number } => {
|
|
1712
1737
|
let meshSlots = 0, meshTriangles = 0;
|
|
1713
1738
|
for (const atts of Object.values(b.rig.skins.default)) {
|
|
@@ -1886,7 +1911,8 @@ export function requirementPrefixProblems(file: RequirementsFile, builds: readon
|
|
|
1886
1911
|
*/
|
|
1887
1912
|
export function unprefixedNames(rig: RigSpec, motion: MotionSpec, ids: readonly string[], plate: boolean, plates: readonly string[] = [], sceneAnimations: readonly string[] = []): string[] {
|
|
1888
1913
|
const bad: string[] = [];
|
|
1889
|
-
const
|
|
1914
|
+
const hasPrefix = (n: unknown): boolean => typeof n === 'string' && ids.some((id) => n.startsWith(`${id}${PREFIX_SEP}`) && n.length > id.length + 1);
|
|
1915
|
+
const ok = (n: string, allowPlate: boolean): boolean => n === ROOT_BONE || (allowPlate && ((plate && n === PLATE) || plates.includes(n))) || hasPrefix(n);
|
|
1890
1916
|
const name = (where: string, n: unknown, allowPlate = true): void => {
|
|
1891
1917
|
if (typeof n !== 'string' || !ok(n, allowPlate)) bad.push(`${where} ${show(n)}`);
|
|
1892
1918
|
};
|
|
@@ -1931,6 +1957,9 @@ export function unprefixedNames(rig: RigSpec, motion: MotionSpec, ids: readonly
|
|
|
1931
1957
|
name(`stop ${s.chain} against`, s.against, false);
|
|
1932
1958
|
}
|
|
1933
1959
|
for (const entry of rig.invariants?.deformMayFold ?? []) name('invariants.deformMayFold slot', entry.slot, false);
|
|
1960
|
+
for (const { inputs } of rig.invariants?.deformSliderCombinations ?? []) {
|
|
1961
|
+
for (const { slider } of inputs) if (!hasPrefix(slider)) bad.push(`invariants.deformSliderCombinations slider ${show(slider)}`);
|
|
1962
|
+
}
|
|
1934
1963
|
for (const d of rig.invariants?.detached ?? []) {
|
|
1935
1964
|
name('invariants.detached bone', d.bone, false);
|
|
1936
1965
|
name('invariants.detached notUnder', d.notUnder, false);
|
package/src/turn.ts
CHANGED
|
@@ -35,11 +35,13 @@ import { type Problem, refuseIfAny } from './errors.ts';
|
|
|
35
35
|
import type { Raster } from './raster/index.ts';
|
|
36
36
|
import { pyRound } from './round.ts';
|
|
37
37
|
import { turnOverlapOwners } from './turnoverlap.ts';
|
|
38
|
+
import { coupleTurnBand, type CoupledTurnBandReport, type TurnBandDial } from './turnband.ts';
|
|
38
39
|
import { sampleTurnTriangleField, turnTriangleCoordinates } from './turnfield.ts';
|
|
39
40
|
import { PartsError } from './errors.ts';
|
|
40
41
|
import { f32 } from '@rig-c/core/compile';
|
|
41
42
|
import { warnUncoveredBodyTurn } from './turncoverage.ts';
|
|
42
43
|
import { evaluateDeformTransform } from '@rig-c/core/deformgen';
|
|
44
|
+
import type { RigInvariants } from '@rig-c/core/rig';
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* The layers that ride on the face (issue #271): See-through makes no depth
|
|
@@ -1504,6 +1506,7 @@ export function sampleUnitPartDepth(scalar: Raster, art: Raster, ref: PartDepthR
|
|
|
1504
1506
|
export interface Depth25DTurnOptions {
|
|
1505
1507
|
/** Report-only diagnostics; never serialized into the rig or motion. */
|
|
1506
1508
|
warnings?: Problem[];
|
|
1509
|
+
coupledTurnBands?: Map<string, CoupledTurnBandReport[]>;
|
|
1507
1510
|
turn: TurnSpec;
|
|
1508
1511
|
parts: ReadonlyArray<{ name: string; x: number; y: number; w: number; h: number; depth?: PartDepthReference }>;
|
|
1509
1512
|
images: ReadonlyMap<string, Raster>;
|
|
@@ -1528,6 +1531,8 @@ export interface Depth25DTurnOptions {
|
|
|
1528
1531
|
overlapOwners?: ReadonlyArray<{ group: 'head' | 'body'; neighbours: readonly string[] } | undefined>;
|
|
1529
1532
|
/** Every attachment of a part containing a blended mesh carries its own group mask. */
|
|
1530
1533
|
groups?: ReadonlyMap<string, 'head' | 'body'>;
|
|
1534
|
+
/** The declared region index that supplied each contour vertex's band. */
|
|
1535
|
+
contourBandVertices?: ReadonlyArray<number | undefined>;
|
|
1531
1536
|
/** Declared contour regions on this part, to refuse an other-group band that weights no vertex (#1543, #1548). */
|
|
1532
1537
|
contourRegions?: ReadonlyArray<{
|
|
1533
1538
|
index: number;
|
|
@@ -1570,6 +1575,20 @@ interface Depth25DTurnRig {
|
|
|
1570
1575
|
slots: Array<{ name: string; bone: string; attachment: string | null }>;
|
|
1571
1576
|
constraints?: Array<Record<string, unknown>>;
|
|
1572
1577
|
stops?: ReadonlyArray<{ links: readonly string[] }>;
|
|
1578
|
+
invariants?: Pick<RigInvariants, 'deformSliderCombinations'>;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
type GeneratedTurnDial = TurnBandDial & { dialBone: string; animatedBones: readonly string[] };
|
|
1582
|
+
|
|
1583
|
+
/** All endpoint tuples, plus each endpoint pair with the third dial at neutral. */
|
|
1584
|
+
function turnDialCombinations(dials: readonly GeneratedTurnDial[]) {
|
|
1585
|
+
if (dials.length < 2) return [];
|
|
1586
|
+
const tuples = dials.reduce<Array<Array<{ slider: string; value: number }>>>(
|
|
1587
|
+
(combinations, { slider, maxDeg }) => combinations.flatMap(inputs =>
|
|
1588
|
+
[-maxDeg, 0, maxDeg].map(value => [...inputs, { slider, value }])),
|
|
1589
|
+
[[]],
|
|
1590
|
+
);
|
|
1591
|
+
return tuples.filter(inputs => inputs.filter(({ value }) => value !== 0).length >= 2).map(inputs => ({ inputs }));
|
|
1573
1592
|
}
|
|
1574
1593
|
|
|
1575
1594
|
interface TurnBandCover {
|
|
@@ -1592,6 +1611,61 @@ function surfaceSetupGraph(rig: Pick<Depth25DTurnRig, 'bones' | 'stops'>) {
|
|
|
1592
1611
|
return { bones, resolve };
|
|
1593
1612
|
}
|
|
1594
1613
|
|
|
1614
|
+
function repairSharedTurnBands(
|
|
1615
|
+
rig: Depth25DTurnRig,
|
|
1616
|
+
opts: Depth25DTurnOptions,
|
|
1617
|
+
authored: TurnSpec,
|
|
1618
|
+
dials: readonly GeneratedTurnDial[],
|
|
1619
|
+
combinations: ReturnType<typeof turnDialCombinations>,
|
|
1620
|
+
): void {
|
|
1621
|
+
if (dials.length !== 3 || new Set(dials.map(dial => dial.dialBone)).size !== 3) return;
|
|
1622
|
+
const supported = new Set(dials.map(dial => dial.slider));
|
|
1623
|
+
for (const constraint of rig.constraints ?? []) {
|
|
1624
|
+
// Other sliders can apply arbitrary motion during the combination pose.
|
|
1625
|
+
if (constraint.type === 'slider' &&
|
|
1626
|
+
(typeof constraint.name !== 'string' || !supported.has(constraint.name) || constraint.loop === true || constraint.skin === true)) return;
|
|
1627
|
+
}
|
|
1628
|
+
const setup = surfaceSetupGraph(rig);
|
|
1629
|
+
const parents = new Map(setup.bones.map(b => [b.name, b.parent]));
|
|
1630
|
+
const shown = new Map(rig.slots.map(slot => [slot.name, slot.attachment]));
|
|
1631
|
+
const moving = new Set(dials.flatMap(dial => [dial.dialBone, ...dial.animatedBones]).map(setup.resolve));
|
|
1632
|
+
for (const stop of rig.stops ?? []) for (const link of stop.links) moving.add(link);
|
|
1633
|
+
for (const constraint of rig.constraints ?? []) {
|
|
1634
|
+
// The Core combination survey poses with physics reset.
|
|
1635
|
+
if (constraint.type === 'physics' || constraint.type === 'slider') continue;
|
|
1636
|
+
if (Array.isArray(constraint.bones)) for (const bone of constraint.bones) {
|
|
1637
|
+
if (typeof bone === 'string') moving.add(setup.resolve(bone));
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
let world: ReturnType<typeof computeWorldTransforms> | undefined;
|
|
1641
|
+
for (const mesh of opts.surfaceMeshes ?? []) {
|
|
1642
|
+
const bands = opts.contourBands?.[mesh.part] ?? mesh.contourRegions;
|
|
1643
|
+
if (!bands?.length || mesh.groups === undefined || new Set(mesh.groups.values()).size !== 2 ||
|
|
1644
|
+
shown.get(mesh.slot) !== mesh.attachment) continue;
|
|
1645
|
+
const headOwns = authored.roles?.[mesh.part] === 'surface';
|
|
1646
|
+
const bodyOwns = authored.body?.roles[mesh.part] === 'surface';
|
|
1647
|
+
if (headOwns === bodyOwns) continue;
|
|
1648
|
+
const frames = new Map<string, BoneTransform>();
|
|
1649
|
+
world ??= computeWorldTransforms(setup.bones);
|
|
1650
|
+
for (const { bone } of mesh.weights.flat()) {
|
|
1651
|
+
if (frames.has(bone)) continue;
|
|
1652
|
+
const resolved = setup.resolve(bone);
|
|
1653
|
+
const frame = world.get(resolved);
|
|
1654
|
+
if (frame === undefined) break;
|
|
1655
|
+
let ancestor: string | undefined = resolved;
|
|
1656
|
+
while (ancestor !== undefined && !moving.has(ancestor)) ancestor = parents.get(ancestor);
|
|
1657
|
+
if (ancestor !== undefined) break;
|
|
1658
|
+
frames.set(bone, frame);
|
|
1659
|
+
}
|
|
1660
|
+
const reports = coupleTurnBand(mesh, bands, headOwns ? 'body' : 'head', mesh.groups, frames, dials, combinations);
|
|
1661
|
+
if (reports.length > 0 && opts.coupledTurnBands !== undefined) {
|
|
1662
|
+
const part = opts.coupledTurnBands.get(mesh.part) ?? [];
|
|
1663
|
+
part.push(...reports);
|
|
1664
|
+
opts.coupledTurnBands.set(mesh.part, part);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1595
1669
|
function buildDepth25DTurnGroup(
|
|
1596
1670
|
rig: Depth25DTurnRig,
|
|
1597
1671
|
motion: {
|
|
@@ -1602,7 +1676,7 @@ function buildDepth25DTurnGroup(
|
|
|
1602
1676
|
group: Depth25DGroupSpec,
|
|
1603
1677
|
bandCovers: readonly TurnBandCover[],
|
|
1604
1678
|
problems: Problem[],
|
|
1605
|
-
):
|
|
1679
|
+
): GeneratedTurnDial[] {
|
|
1606
1680
|
const { roles } = group;
|
|
1607
1681
|
const partMap = new Map(opts.parts.map((p) => [p.name, p]));
|
|
1608
1682
|
const startProblems = problems.length;
|
|
@@ -1667,7 +1741,7 @@ function buildDepth25DTurnGroup(
|
|
|
1667
1741
|
}
|
|
1668
1742
|
surfaceSheets.set(part, { rec: rec as { name: string; x: number; y: number; w: number; h: number; depth: PartDepthReference }, ext, zRef });
|
|
1669
1743
|
}
|
|
1670
|
-
if (problems.length > startProblems) return;
|
|
1744
|
+
if (problems.length > startProblems) return [];
|
|
1671
1745
|
|
|
1672
1746
|
const primarySurface = (group.useEyeLandmarksForZRef ? surfaceSheets.get('face') : undefined) ?? [...surfaceSheets.values()][0];
|
|
1673
1747
|
// Units already use this anchor. Surfaces must share it too: subtracting
|
|
@@ -1678,7 +1752,7 @@ function buildDepth25DTurnGroup(
|
|
|
1678
1752
|
// Resolve on original sheets AFTER choosing the original shared anchor.
|
|
1679
1753
|
const boundary = boundaryDepthSamplers(group.boundaryDepths, opts.parts, opts.images, group.roles, group.fieldPrefix);
|
|
1680
1754
|
problems.push(...boundary.problems);
|
|
1681
|
-
if (problems.length > startProblems) return;
|
|
1755
|
+
if (problems.length > startProblems) return [];
|
|
1682
1756
|
const boundarySamples = boundary.samplers;
|
|
1683
1757
|
const pivot = pyRound(group.pivot, 4);
|
|
1684
1758
|
const counter = group.counter;
|
|
@@ -1756,7 +1830,7 @@ function buildDepth25DTurnGroup(
|
|
|
1756
1830
|
}
|
|
1757
1831
|
boneDepths.set(reg.bone, pivot + zCover - cZRef);
|
|
1758
1832
|
}
|
|
1759
|
-
if (problems.length > startProblems) return;
|
|
1833
|
+
if (problems.length > startProblems) return [];
|
|
1760
1834
|
}
|
|
1761
1835
|
// Key one scalar depth per direct carrier child. A region can bind a
|
|
1762
1836
|
// descendant of that child or a generated carrier instead of its authored bone.
|
|
@@ -1935,7 +2009,7 @@ function buildDepth25DTurnGroup(
|
|
|
1935
2009
|
addUnitBone(carrier, resolved);
|
|
1936
2010
|
}
|
|
1937
2011
|
}
|
|
1938
|
-
if (problems.length > startProblems) return;
|
|
2012
|
+
if (problems.length > startProblems) return [];
|
|
1939
2013
|
|
|
1940
2014
|
// Order unitBones in rig.bones declaration order for determinism.
|
|
1941
2015
|
const boneIndex = new Map(rig.bones.map((b, i) => [b.name, i]));
|
|
@@ -1948,7 +2022,7 @@ function buildDepth25DTurnGroup(
|
|
|
1948
2022
|
motion.groups[group.unitGroupName] = unitBones;
|
|
1949
2023
|
}
|
|
1950
2024
|
|
|
1951
|
-
const buildAxisAnim = (kind: 'yaw' | 'pitch', animName: string, maxDeg: number)
|
|
2025
|
+
const buildAxisAnim = (kind: 'yaw' | 'pitch', animName: string, maxDeg: number) => {
|
|
1952
2026
|
const prop = kind === 'yaw' ? 'translatex' : 'translatey';
|
|
1953
2027
|
const duration = pyRound(2 * maxDeg * TURN_DIAL_SCALE, 6);
|
|
1954
2028
|
const step = maxDeg / 2;
|
|
@@ -2240,10 +2314,12 @@ function buildDepth25DTurnGroup(
|
|
|
2240
2314
|
tracks,
|
|
2241
2315
|
...(deform.length > 0 ? { deform } : {}),
|
|
2242
2316
|
};
|
|
2317
|
+
const animatedBones = tracks.flatMap(track => track.bone === undefined ? motion.groups?.[track.group!] ?? [] : [track.bone]);
|
|
2318
|
+
return { deform, animatedBones };
|
|
2243
2319
|
};
|
|
2244
2320
|
|
|
2245
2321
|
rig.constraints ??= [];
|
|
2246
|
-
const upsertSlider = (name: string, animName: string, dialBone: string, maxDeg: number):
|
|
2322
|
+
const upsertSlider = (name: string, animName: string, dialBone: string, maxDeg: number): string | undefined => {
|
|
2247
2323
|
const colliding = rig.constraints?.find((c) => c.type === 'slider' && c.name === name && c.animation !== animName);
|
|
2248
2324
|
if (colliding !== undefined) {
|
|
2249
2325
|
problems.push({
|
|
@@ -2254,7 +2330,7 @@ function buildDepth25DTurnGroup(
|
|
|
2254
2330
|
return;
|
|
2255
2331
|
}
|
|
2256
2332
|
const existing = rig.constraints?.find((c) => c.type === 'slider' && c.animation === animName);
|
|
2257
|
-
if (existing !== undefined) {
|
|
2333
|
+
if (existing !== undefined && typeof existing.name === 'string') {
|
|
2258
2334
|
existing.bone = dialBone;
|
|
2259
2335
|
existing.property = 'rotate';
|
|
2260
2336
|
existing.from = -maxDeg;
|
|
@@ -2264,6 +2340,7 @@ function buildDepth25DTurnGroup(
|
|
|
2264
2340
|
existing.local = true;
|
|
2265
2341
|
existing.additive = true;
|
|
2266
2342
|
existing.mix = 1;
|
|
2343
|
+
return existing.name;
|
|
2267
2344
|
} else {
|
|
2268
2345
|
rig.constraints?.push({
|
|
2269
2346
|
name,
|
|
@@ -2279,13 +2356,20 @@ function buildDepth25DTurnGroup(
|
|
|
2279
2356
|
additive: true,
|
|
2280
2357
|
mix: 1,
|
|
2281
2358
|
});
|
|
2359
|
+
return name;
|
|
2282
2360
|
}
|
|
2283
2361
|
};
|
|
2284
2362
|
|
|
2363
|
+
const dials: GeneratedTurnDial[] = [];
|
|
2285
2364
|
for (const axis of group.axes) {
|
|
2286
|
-
buildAxisAnim(axis.kind, axis.animName, axis.maxDeg);
|
|
2287
|
-
upsertSlider(axis.sliderName, axis.animName, axis.dialBone, axis.maxDeg);
|
|
2365
|
+
const { deform, animatedBones } = buildAxisAnim(axis.kind, axis.animName, axis.maxDeg);
|
|
2366
|
+
const slider = upsertSlider(axis.sliderName, axis.animName, axis.dialBone, axis.maxDeg);
|
|
2367
|
+
if (slider !== undefined) dials.push({
|
|
2368
|
+
slider, maxDeg: axis.maxDeg, scale: TURN_DIAL_SCALE, dialBone: axis.dialBone, deform, animatedBones,
|
|
2369
|
+
group: group.fieldPrefix === 'config.turn' ? 'head' : 'body',
|
|
2370
|
+
});
|
|
2288
2371
|
}
|
|
2372
|
+
return dials;
|
|
2289
2373
|
}
|
|
2290
2374
|
|
|
2291
2375
|
/**
|
|
@@ -2302,6 +2386,7 @@ export function buildDepth25DTurn(
|
|
|
2302
2386
|
opts: Depth25DTurnOptions,
|
|
2303
2387
|
): void {
|
|
2304
2388
|
const problems: Problem[] = [];
|
|
2389
|
+
const authored = opts.turn;
|
|
2305
2390
|
const { yaw: yawMax, pitch: pitchMax } = resolveTurnBands(opts.turn);
|
|
2306
2391
|
// Ownership is derived here, never accepted as an authored producer switch.
|
|
2307
2392
|
opts = { ...opts, surfaceMeshes: opts.surfaceMeshes?.map(({ overlapOwners: _owners, groups: _groups, ...mesh }) => mesh) };
|
|
@@ -2532,8 +2617,9 @@ export function buildDepth25DTurn(
|
|
|
2532
2617
|
} };
|
|
2533
2618
|
}
|
|
2534
2619
|
|
|
2620
|
+
const dials: GeneratedTurnDial[] = [];
|
|
2535
2621
|
if (opts.turn.roles !== undefined) {
|
|
2536
|
-
buildDepth25DTurnGroup(
|
|
2622
|
+
dials.push(...buildDepth25DTurnGroup(
|
|
2537
2623
|
rig,
|
|
2538
2624
|
motion,
|
|
2539
2625
|
opts,
|
|
@@ -2556,13 +2642,13 @@ export function buildDepth25DTurn(
|
|
|
2556
2642
|
},
|
|
2557
2643
|
bandCovers,
|
|
2558
2644
|
problems,
|
|
2559
|
-
);
|
|
2645
|
+
));
|
|
2560
2646
|
}
|
|
2561
2647
|
|
|
2562
2648
|
if (opts.turn.body !== undefined) {
|
|
2563
2649
|
const body = opts.turn.body;
|
|
2564
2650
|
const bodySlider = typeof body.slider === 'string' && body.slider.trim().length > 0 ? body.slider : BODY_YAW_DIAL_BONE;
|
|
2565
|
-
buildDepth25DTurnGroup(
|
|
2651
|
+
dials.push(...buildDepth25DTurnGroup(
|
|
2566
2652
|
rig,
|
|
2567
2653
|
motion,
|
|
2568
2654
|
opts,
|
|
@@ -2584,9 +2670,12 @@ export function buildDepth25DTurn(
|
|
|
2584
2670
|
},
|
|
2585
2671
|
bandCovers,
|
|
2586
2672
|
problems,
|
|
2587
|
-
);
|
|
2673
|
+
));
|
|
2588
2674
|
}
|
|
2589
2675
|
|
|
2590
2676
|
refuseIfAny(problems);
|
|
2677
|
+
const combinations = turnDialCombinations(dials);
|
|
2678
|
+
if (combinations.length > 0) rig.invariants = { ...rig.invariants, deformSliderCombinations: combinations };
|
|
2679
|
+
if (blended.size > 0) repairSharedTurnBands(rig, opts, authored, dials, combinations);
|
|
2591
2680
|
if (opts.warnings !== undefined) warnUncoveredBodyTurn(rig, motion, opts);
|
|
2592
2681
|
}
|