ugly-game 0.15.42 → 0.15.43
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/dist/character.d.ts +51 -0
- package/dist/character.js +246 -17
- package/package.json +1 -1
package/dist/character.d.ts
CHANGED
|
@@ -68,8 +68,52 @@ export interface GpuCharactersBatch {
|
|
|
68
68
|
}
|
|
69
69
|
export interface GpuCharactersBackend {
|
|
70
70
|
submit(batch: GpuCharactersBatch): void;
|
|
71
|
+
/** Present when the backend applies an explicit per-frame render budget. */
|
|
72
|
+
characterBudgetReport?(): GpuCharacterBudgetReport;
|
|
71
73
|
dispose?(): void;
|
|
72
74
|
}
|
|
75
|
+
export type GpuCharacterBudgetReason = 'actor-capacity' | 'part-capacity' | 'part-cost-capacity';
|
|
76
|
+
export interface GpuCharacterBudgetLimits {
|
|
77
|
+
/** Maximum visible actors retained in one frame. Omitted means unbounded. */
|
|
78
|
+
maxActors?: number;
|
|
79
|
+
/** Maximum composed body/face/hair/garment/attachment rows. Omitted means unbounded. */
|
|
80
|
+
maxParts?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Weighted part budget. Tier 0 costs eight units and tier 7 costs one, per part. The policy
|
|
83
|
+
* deterministically raises quality tiers before it drops an optional part or whole actor.
|
|
84
|
+
*/
|
|
85
|
+
maxPartCost?: number;
|
|
86
|
+
}
|
|
87
|
+
export interface GpuCharacterBudgetRequest {
|
|
88
|
+
requestedActors: number;
|
|
89
|
+
requestedParts: number;
|
|
90
|
+
requestedPartCost: number;
|
|
91
|
+
}
|
|
92
|
+
export type GpuCharacterBudgetPolicy = GpuCharacterBudgetLimits | ((request: Readonly<GpuCharacterBudgetRequest>) => GpuCharacterBudgetLimits);
|
|
93
|
+
export interface GpuCharacterBudgetFinding {
|
|
94
|
+
code: 'gpu-characters-tier-demoted' | 'gpu-characters-part-dropped' | 'gpu-characters-actor-dropped';
|
|
95
|
+
reason: GpuCharacterBudgetReason;
|
|
96
|
+
actorSlot: number;
|
|
97
|
+
tier?: keyof Omit<GpuCharacterTiers, 'visible'>;
|
|
98
|
+
fromTier?: number;
|
|
99
|
+
toTier?: number;
|
|
100
|
+
partKind?: GpuCharacterPartKind;
|
|
101
|
+
asset?: number;
|
|
102
|
+
}
|
|
103
|
+
export interface GpuCharacterBudgetReport extends GpuCharacterBudgetRequest {
|
|
104
|
+
limits: {
|
|
105
|
+
maxActors: number | null;
|
|
106
|
+
maxParts: number | null;
|
|
107
|
+
maxPartCost: number | null;
|
|
108
|
+
};
|
|
109
|
+
renderedActors: number;
|
|
110
|
+
renderedParts: number;
|
|
111
|
+
renderedPartCost: number;
|
|
112
|
+
tierDemotions: number;
|
|
113
|
+
droppedActors: number;
|
|
114
|
+
droppedParts: number;
|
|
115
|
+
findings: readonly GpuCharacterBudgetFinding[];
|
|
116
|
+
}
|
|
73
117
|
/**
|
|
74
118
|
* The crowd renderer allocates vertex-pool offsets, while {@link GpuCharacters} allocates stable
|
|
75
119
|
* actor ordinals. A binding is the explicit bridge between those two address spaces.
|
|
@@ -236,6 +280,8 @@ export interface GpuCrowdCharactersBackendOptions {
|
|
|
236
280
|
socketCount?: number;
|
|
237
281
|
/** Explicit handoff to caller-owned hair, garment and attachment render passes. */
|
|
238
282
|
composition?: GpuCrowdCharacterCompositionBackend;
|
|
283
|
+
/** Optional deterministic pressure policy. No budget means every requested visible part renders. */
|
|
284
|
+
budget?: GpuCharacterBudgetPolicy;
|
|
239
285
|
}
|
|
240
286
|
export interface GpuCrowdCharactersPreparedFrame {
|
|
241
287
|
renderedCount: number;
|
|
@@ -245,6 +291,7 @@ export interface GpuCrowdCharactersPreparedFrame {
|
|
|
245
291
|
palettes: Float32Array;
|
|
246
292
|
buckets: readonly CrowdBucket[];
|
|
247
293
|
composition: GpuCrowdCharacterCompositionFrame;
|
|
294
|
+
budget: GpuCharacterBudgetReport;
|
|
248
295
|
}
|
|
249
296
|
export interface GpuCharactersReport {
|
|
250
297
|
capacity: number;
|
|
@@ -256,6 +303,8 @@ export interface GpuCharactersReport {
|
|
|
256
303
|
removals: number;
|
|
257
304
|
/** Counts by tier for visible actors in the most recently submitted hot frame. */
|
|
258
305
|
lastTierCounts: Record<'body' | 'face' | 'animation' | 'hair' | 'cloth', number[]>;
|
|
306
|
+
/** Backend render pressure for the last successful frame; null for backends without this seam. */
|
|
307
|
+
budget: GpuCharacterBudgetReport | null;
|
|
259
308
|
}
|
|
260
309
|
/** Validate a hot frame without allocating or converting it. */
|
|
261
310
|
export declare function validateGpuCharacterFrame(frame: GpuCharacterFrame, options: Omit<Required<GpuCharactersOptions>, 'socketCount'> & Pick<GpuCharactersOptions, 'socketCount'>): void;
|
|
@@ -296,6 +345,7 @@ export declare class GpuCrowdCharactersBackend implements GpuCharactersBackend {
|
|
|
296
345
|
private readonly faceChannels;
|
|
297
346
|
private readonly socketCount;
|
|
298
347
|
private readonly maxRiggedFaceTier;
|
|
348
|
+
private readonly budgetPolicy;
|
|
299
349
|
private readonly compositionBackend;
|
|
300
350
|
private readonly resolveBinding;
|
|
301
351
|
private readonly releaseBinding;
|
|
@@ -304,6 +354,7 @@ export declare class GpuCrowdCharactersBackend implements GpuCharactersBackend {
|
|
|
304
354
|
constructor(options: GpuCrowdCharactersBackendOptions);
|
|
305
355
|
submit(batch: GpuCharactersBatch): void;
|
|
306
356
|
lastPreparedFrame(): GpuCrowdCharactersPreparedFrame;
|
|
357
|
+
characterBudgetReport(): GpuCharacterBudgetReport;
|
|
307
358
|
dispose(): void;
|
|
308
359
|
private applyRemovals;
|
|
309
360
|
private applyIdentityUpdates;
|
package/dist/character.js
CHANGED
|
@@ -455,6 +455,7 @@ export class GpuCharacters {
|
|
|
455
455
|
coldUpdates: this.coldUpdates,
|
|
456
456
|
removals: this.removals,
|
|
457
457
|
lastTierCounts: cloneTierCounts(this.lastTierCounts),
|
|
458
|
+
budget: this.backend?.characterBudgetReport?.() ?? null,
|
|
458
459
|
};
|
|
459
460
|
}
|
|
460
461
|
dispose() {
|
|
@@ -539,6 +540,229 @@ function emptyComposition() {
|
|
|
539
540
|
bounds: new Float32Array(0),
|
|
540
541
|
};
|
|
541
542
|
}
|
|
543
|
+
function budgetParts(entry) {
|
|
544
|
+
const { identity } = entry.state;
|
|
545
|
+
const parts = [
|
|
546
|
+
{
|
|
547
|
+
key: `${entry.actorSlot}:body`,
|
|
548
|
+
kind: GPU_CHARACTER_PART_KIND.body,
|
|
549
|
+
asset: identity.bodyAsset ?? -1,
|
|
550
|
+
tier: 'body',
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
key: `${entry.actorSlot}:face`,
|
|
554
|
+
kind: GPU_CHARACTER_PART_KIND.face,
|
|
555
|
+
asset: identity.faceAsset ?? identity.bodyAsset ?? -1,
|
|
556
|
+
tier: 'face',
|
|
557
|
+
},
|
|
558
|
+
];
|
|
559
|
+
if (identity.hairAsset >= 0)
|
|
560
|
+
parts.push({
|
|
561
|
+
key: `${entry.actorSlot}:hair`,
|
|
562
|
+
kind: GPU_CHARACTER_PART_KIND.hair,
|
|
563
|
+
asset: identity.hairAsset,
|
|
564
|
+
tier: 'hair',
|
|
565
|
+
});
|
|
566
|
+
identity.garmentAssets.forEach((asset, index) => {
|
|
567
|
+
if (asset >= 0)
|
|
568
|
+
parts.push({
|
|
569
|
+
key: `${entry.actorSlot}:garment:${index}`,
|
|
570
|
+
kind: GPU_CHARACTER_PART_KIND.garment,
|
|
571
|
+
asset,
|
|
572
|
+
tier: 'cloth',
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
(identity.socketAttachments ?? []).forEach((attachment, index) => {
|
|
576
|
+
if (attachment.asset >= 0)
|
|
577
|
+
parts.push({
|
|
578
|
+
key: `${entry.actorSlot}:attachment:${index}`,
|
|
579
|
+
kind: GPU_CHARACTER_PART_KIND.socketAttachment,
|
|
580
|
+
asset: attachment.asset,
|
|
581
|
+
tier: 'body',
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
return parts;
|
|
585
|
+
}
|
|
586
|
+
function partCost(entry, part) {
|
|
587
|
+
return TIER_MASK + 1 - entry.tiers[part.tier];
|
|
588
|
+
}
|
|
589
|
+
function maxBudgetTier(entry, tier, maxRiggedFaceTier) {
|
|
590
|
+
const contiguousMax = (slots, from) => {
|
|
591
|
+
let maximum = from;
|
|
592
|
+
for (let candidate = from + 1; candidate < slots.length; candidate++) {
|
|
593
|
+
const slot = slots[candidate];
|
|
594
|
+
if (!Number.isInteger(slot) || (slot ?? -1) < 0)
|
|
595
|
+
break;
|
|
596
|
+
maximum = candidate;
|
|
597
|
+
}
|
|
598
|
+
return maximum;
|
|
599
|
+
};
|
|
600
|
+
if (tier === 'body') {
|
|
601
|
+
const attachmentLimits = (entry.state.binding.socketAttachments ?? [])
|
|
602
|
+
.filter((binding) => binding !== null)
|
|
603
|
+
.map((binding) => contiguousMax(binding.lodSlots, entry.tiers.body));
|
|
604
|
+
const faceLimit = entry.tiers.face <= maxRiggedFaceTier && entry.state.binding.facePoolSlots
|
|
605
|
+
? contiguousMax(entry.state.binding.facePoolSlots, entry.tiers.body)
|
|
606
|
+
: TIER_MASK;
|
|
607
|
+
return Math.min(TIER_MASK, entry.state.binding.poolSlots.length - 1, faceLimit, ...attachmentLimits);
|
|
608
|
+
}
|
|
609
|
+
if (tier === 'hair')
|
|
610
|
+
return Math.min(TIER_MASK, entry.state.binding.hair
|
|
611
|
+
? contiguousMax(entry.state.binding.hair.lodSlots, entry.tiers.hair)
|
|
612
|
+
: entry.tiers.hair);
|
|
613
|
+
if (tier === 'cloth') {
|
|
614
|
+
const garmentLimits = (entry.state.binding.garments ?? [])
|
|
615
|
+
.filter((binding) => binding !== null)
|
|
616
|
+
.map((binding) => contiguousMax(binding.lodSlots, entry.tiers.cloth));
|
|
617
|
+
return garmentLimits.length === 0
|
|
618
|
+
? entry.tiers.cloth
|
|
619
|
+
: Math.min(TIER_MASK, ...garmentLimits);
|
|
620
|
+
}
|
|
621
|
+
return TIER_MASK;
|
|
622
|
+
}
|
|
623
|
+
function cloneBudgetReport(report) {
|
|
624
|
+
return {
|
|
625
|
+
...report,
|
|
626
|
+
limits: { ...report.limits },
|
|
627
|
+
findings: report.findings.map((finding) => ({ ...finding })),
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
function planCharacterBudget(sourceEntries, policy, maxRiggedFaceTier = 1) {
|
|
631
|
+
const entries = sourceEntries.map((entry) => ({
|
|
632
|
+
...entry,
|
|
633
|
+
tiers: { ...entry.tiers },
|
|
634
|
+
}));
|
|
635
|
+
const budgetOrder = [...entries].sort((a, b) => a.actorSlot - b.actorSlot);
|
|
636
|
+
const requestedParts = entries.reduce((count, entry) => count + budgetParts(entry).length, 0);
|
|
637
|
+
const requestedPartCost = entries.reduce((cost, entry) => cost +
|
|
638
|
+
budgetParts(entry).reduce((actorCost, part) => actorCost + partCost(entry, part), 0), 0);
|
|
639
|
+
const request = {
|
|
640
|
+
requestedActors: entries.length,
|
|
641
|
+
requestedParts,
|
|
642
|
+
requestedPartCost,
|
|
643
|
+
};
|
|
644
|
+
const requestedLimits = typeof policy === 'function' ? policy(request) : policy;
|
|
645
|
+
const maxActors = requestedLimits?.maxActors === undefined
|
|
646
|
+
? Number.POSITIVE_INFINITY
|
|
647
|
+
: nonNegativeInt(requestedLimits.maxActors, 'budget.maxActors');
|
|
648
|
+
const maxParts = requestedLimits?.maxParts === undefined
|
|
649
|
+
? Number.POSITIVE_INFINITY
|
|
650
|
+
: nonNegativeInt(requestedLimits.maxParts, 'budget.maxParts');
|
|
651
|
+
const maxPartCost = requestedLimits?.maxPartCost === undefined
|
|
652
|
+
? Number.POSITIVE_INFINITY
|
|
653
|
+
: nonNegativeInt(requestedLimits.maxPartCost, 'budget.maxPartCost');
|
|
654
|
+
const findings = [];
|
|
655
|
+
const droppedPartKeys = new Set();
|
|
656
|
+
const droppedActorSlots = new Set();
|
|
657
|
+
const activeParts = () => entries.flatMap((entry) => droppedActorSlots.has(entry.actorSlot)
|
|
658
|
+
? []
|
|
659
|
+
: budgetParts(entry)
|
|
660
|
+
.filter((part) => !droppedPartKeys.has(part.key))
|
|
661
|
+
.map((part) => ({ entry, part })));
|
|
662
|
+
const currentCost = () => activeParts().reduce((cost, { entry, part }) => cost + partCost(entry, part), 0);
|
|
663
|
+
// Preserve lower stable actor slots and their quality. Under pressure, higher slots walk the
|
|
664
|
+
// deterministic hair → cloth → face → body ladder first; only then may anything disappear.
|
|
665
|
+
const needsPartRelief = () => activeParts().length > maxParts || currentCost() > maxPartCost;
|
|
666
|
+
while (needsPartRelief()) {
|
|
667
|
+
let changed = false;
|
|
668
|
+
for (const entry of [...budgetOrder].reverse()) {
|
|
669
|
+
for (const tier of ['hair', 'cloth', 'face', 'body']) {
|
|
670
|
+
const affected = budgetParts(entry).filter((part) => part.tier === tier);
|
|
671
|
+
const maximum = maxBudgetTier(entry, tier, maxRiggedFaceTier);
|
|
672
|
+
if (affected.length === 0 || entry.tiers[tier] >= maximum)
|
|
673
|
+
continue;
|
|
674
|
+
const reason = currentCost() > maxPartCost ? 'part-cost-capacity' : 'part-capacity';
|
|
675
|
+
const fromTier = entry.tiers[tier];
|
|
676
|
+
entry.tiers[tier]++;
|
|
677
|
+
if (tier === 'body')
|
|
678
|
+
entry.lod = entry.tiers.body;
|
|
679
|
+
findings.push({
|
|
680
|
+
code: 'gpu-characters-tier-demoted',
|
|
681
|
+
reason,
|
|
682
|
+
actorSlot: entry.actorSlot,
|
|
683
|
+
tier,
|
|
684
|
+
fromTier,
|
|
685
|
+
toTier: entry.tiers[tier],
|
|
686
|
+
});
|
|
687
|
+
changed = true;
|
|
688
|
+
if (!needsPartRelief())
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
if (!needsPartRelief())
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
if (!changed)
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
while (entries.length - droppedActorSlots.size > maxActors) {
|
|
698
|
+
const entry = [...budgetOrder]
|
|
699
|
+
.reverse()
|
|
700
|
+
.find((candidate) => !droppedActorSlots.has(candidate.actorSlot));
|
|
701
|
+
if (!entry)
|
|
702
|
+
break;
|
|
703
|
+
droppedActorSlots.add(entry.actorSlot);
|
|
704
|
+
findings.push({
|
|
705
|
+
code: 'gpu-characters-actor-dropped',
|
|
706
|
+
reason: 'actor-capacity',
|
|
707
|
+
actorSlot: entry.actorSlot,
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
const optionalParts = activeParts()
|
|
711
|
+
.filter(({ part }) => part.kind !== GPU_CHARACTER_PART_KIND.body &&
|
|
712
|
+
part.kind !== GPU_CHARACTER_PART_KIND.face)
|
|
713
|
+
.sort((a, b) => b.entry.actorSlot - a.entry.actorSlot ||
|
|
714
|
+
b.part.kind - a.part.kind ||
|
|
715
|
+
b.part.key.localeCompare(a.part.key));
|
|
716
|
+
for (const { entry, part } of optionalParts) {
|
|
717
|
+
if (!needsPartRelief())
|
|
718
|
+
break;
|
|
719
|
+
const reason = currentCost() > maxPartCost ? 'part-cost-capacity' : 'part-capacity';
|
|
720
|
+
droppedPartKeys.add(part.key);
|
|
721
|
+
findings.push({
|
|
722
|
+
code: 'gpu-characters-part-dropped',
|
|
723
|
+
reason,
|
|
724
|
+
actorSlot: entry.actorSlot,
|
|
725
|
+
partKind: part.kind,
|
|
726
|
+
asset: part.asset,
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
while (needsPartRelief()) {
|
|
730
|
+
const entry = [...budgetOrder]
|
|
731
|
+
.reverse()
|
|
732
|
+
.find((candidate) => !droppedActorSlots.has(candidate.actorSlot));
|
|
733
|
+
if (!entry)
|
|
734
|
+
break;
|
|
735
|
+
const reason = currentCost() > maxPartCost ? 'part-cost-capacity' : 'part-capacity';
|
|
736
|
+
droppedActorSlots.add(entry.actorSlot);
|
|
737
|
+
findings.push({
|
|
738
|
+
code: 'gpu-characters-actor-dropped',
|
|
739
|
+
reason,
|
|
740
|
+
actorSlot: entry.actorSlot,
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
const renderedEntries = entries.filter((entry) => !droppedActorSlots.has(entry.actorSlot));
|
|
744
|
+
const renderedParts = activeParts().length;
|
|
745
|
+
const renderedPartCost = currentCost();
|
|
746
|
+
return {
|
|
747
|
+
entries: renderedEntries,
|
|
748
|
+
droppedPartKeys,
|
|
749
|
+
report: {
|
|
750
|
+
...request,
|
|
751
|
+
limits: {
|
|
752
|
+
maxActors: Number.isFinite(maxActors) ? maxActors : null,
|
|
753
|
+
maxParts: Number.isFinite(maxParts) ? maxParts : null,
|
|
754
|
+
maxPartCost: Number.isFinite(maxPartCost) ? maxPartCost : null,
|
|
755
|
+
},
|
|
756
|
+
renderedActors: renderedEntries.length,
|
|
757
|
+
renderedParts,
|
|
758
|
+
renderedPartCost,
|
|
759
|
+
tierDemotions: findings.filter((finding) => finding.code === 'gpu-characters-tier-demoted').length,
|
|
760
|
+
droppedActors: request.requestedActors - renderedEntries.length,
|
|
761
|
+
droppedParts: request.requestedParts - renderedParts,
|
|
762
|
+
findings,
|
|
763
|
+
},
|
|
764
|
+
};
|
|
765
|
+
}
|
|
542
766
|
function validatePartBinding(binding, asset, label) {
|
|
543
767
|
if (asset < 0) {
|
|
544
768
|
if (binding)
|
|
@@ -566,6 +790,7 @@ export class GpuCrowdCharactersBackend {
|
|
|
566
790
|
faceChannels;
|
|
567
791
|
socketCount;
|
|
568
792
|
maxRiggedFaceTier;
|
|
793
|
+
budgetPolicy;
|
|
569
794
|
compositionBackend;
|
|
570
795
|
resolveBinding;
|
|
571
796
|
releaseBinding;
|
|
@@ -577,6 +802,7 @@ export class GpuCrowdCharactersBackend {
|
|
|
577
802
|
palettes: new Float32Array(0),
|
|
578
803
|
buckets: [],
|
|
579
804
|
composition: emptyComposition(),
|
|
805
|
+
budget: planCharacterBudget([], undefined).report,
|
|
580
806
|
};
|
|
581
807
|
constructor(options) {
|
|
582
808
|
this.renderer = options.renderer;
|
|
@@ -585,6 +811,7 @@ export class GpuCrowdCharactersBackend {
|
|
|
585
811
|
if (this.faceChannels !== GPU_CHARACTER_FACE_CHANNELS)
|
|
586
812
|
throw new Error(`GpuCrowdRenderer requires ${GPU_CHARACTER_FACE_CHANNELS} face channels`);
|
|
587
813
|
this.socketCount = nonNegativeInt(options.socketCount ?? 0, 'socketCount');
|
|
814
|
+
this.budgetPolicy = options.budget;
|
|
588
815
|
this.compositionBackend = options.composition;
|
|
589
816
|
this.resolveBinding = options.resolveBinding;
|
|
590
817
|
this.releaseBinding = options.releaseBinding;
|
|
@@ -600,7 +827,7 @@ export class GpuCrowdCharactersBackend {
|
|
|
600
827
|
throw new Error(`socketTransforms length ${socketValues} does not match backend requirement ${expectedSocketValues}`);
|
|
601
828
|
this.applyRemovals(batch.removedSlots);
|
|
602
829
|
this.applyIdentityUpdates(batch.identityUpdates);
|
|
603
|
-
const
|
|
830
|
+
const requestedEntries = [];
|
|
604
831
|
for (let i = 0; i < batch.frame.count; i++) {
|
|
605
832
|
const tiers = unpackGpuCharacterFlags(batch.frame.flags[i]);
|
|
606
833
|
if (!tiers.visible)
|
|
@@ -611,7 +838,7 @@ export class GpuCrowdCharactersBackend {
|
|
|
611
838
|
throw new Error(`crowd backend has no identity for actor slot ${actorSlot}`);
|
|
612
839
|
// Stable sorting below preserves actor order within a LOD, including blend ordering chosen
|
|
613
840
|
// by the caller. That makes buckets contiguous without changing same-rung draw semantics.
|
|
614
|
-
|
|
841
|
+
requestedEntries.push({
|
|
615
842
|
actorSlot,
|
|
616
843
|
sourceIndex: i,
|
|
617
844
|
lod: tiers.body,
|
|
@@ -619,20 +846,16 @@ export class GpuCrowdCharactersBackend {
|
|
|
619
846
|
state,
|
|
620
847
|
});
|
|
621
848
|
}
|
|
849
|
+
const budget = planCharacterBudget(requestedEntries, this.budgetPolicy, this.maxRiggedFaceTier);
|
|
850
|
+
const entries = budget.entries;
|
|
622
851
|
entries.sort((a, b) => a.lod - b.lod);
|
|
623
852
|
const records = new Float32Array(entries.length * CROWD_RECORD_FLOATS);
|
|
624
853
|
const palettes = new Float32Array(entries.length * this.boneCount * 16);
|
|
625
854
|
const actorSlots = new Uint32Array(entries.length);
|
|
626
855
|
const buckets = [];
|
|
627
856
|
const paletteStride = this.boneCount * 16;
|
|
628
|
-
const compositionCount = entries.reduce((count, entry) =>
|
|
629
|
-
|
|
630
|
-
return (count +
|
|
631
|
-
2 +
|
|
632
|
-
(identity.hairAsset < 0 ? 0 : 1) +
|
|
633
|
-
identity.garmentAssets.filter((asset) => asset >= 0).length +
|
|
634
|
-
(identity.socketAttachments ?? []).filter((attachment) => attachment.asset >= 0).length);
|
|
635
|
-
}, 0);
|
|
857
|
+
const compositionCount = entries.reduce((count, entry) => count +
|
|
858
|
+
budgetParts(entry).filter((part) => !budget.droppedPartKeys.has(part.key)).length, 0);
|
|
636
859
|
const composition = {
|
|
637
860
|
count: compositionCount,
|
|
638
861
|
actorSlots: new Uint32Array(compositionCount),
|
|
@@ -656,9 +879,8 @@ export class GpuCrowdCharactersBackend {
|
|
|
656
879
|
state.morphedLod = lod;
|
|
657
880
|
}
|
|
658
881
|
const wantsFace = tiers.face <= this.maxRiggedFaceTier;
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
: null;
|
|
882
|
+
const composedFacePoolSlot = bindingFaceSlot(state.binding, lod);
|
|
883
|
+
const facePoolSlot = wantsFace ? composedFacePoolSlot : null;
|
|
662
884
|
if (wantsFace && facePoolSlot === null)
|
|
663
885
|
throw new Error(`character binding has no face pool slot for rigged actor ${actorSlot} at LOD ${lod}`);
|
|
664
886
|
if (state.rigSource !== null && state.rigSource !== sourcePoolSlot) {
|
|
@@ -698,21 +920,24 @@ export class GpuCrowdCharactersBackend {
|
|
|
698
920
|
const bodyAsset = state.identity.bodyAsset ?? -1;
|
|
699
921
|
const faceAsset = state.identity.faceAsset ?? bodyAsset;
|
|
700
922
|
writePart(GPU_CHARACTER_PART_KIND.body, bodyAsset, sourcePoolSlot, lod, tiers.body, transform);
|
|
701
|
-
writePart(GPU_CHARACTER_PART_KIND.face, faceAsset,
|
|
702
|
-
if (state.identity.hairAsset >= 0
|
|
923
|
+
writePart(GPU_CHARACTER_PART_KIND.face, faceAsset, composedFacePoolSlot ?? sourcePoolSlot, lod, tiers.face, transform);
|
|
924
|
+
if (state.identity.hairAsset >= 0 &&
|
|
925
|
+
!budget.droppedPartKeys.has(`${actorSlot}:hair`)) {
|
|
703
926
|
const binding = state.binding.hair;
|
|
704
927
|
if (!binding)
|
|
705
928
|
throw new Error('hair binding is unavailable');
|
|
706
929
|
writePart(GPU_CHARACTER_PART_KIND.hair, state.identity.hairAsset, partBindingSlot(binding, tiers.hair, 'hair'), tiers.hair, tiers.hair, transform);
|
|
707
930
|
}
|
|
708
931
|
for (const [garmentIndex, asset,] of state.identity.garmentAssets.entries()) {
|
|
709
|
-
if (asset < 0
|
|
932
|
+
if (asset < 0 ||
|
|
933
|
+
budget.droppedPartKeys.has(`${actorSlot}:garment:${garmentIndex}`))
|
|
710
934
|
continue;
|
|
711
935
|
const binding = indexedPartBinding(state.binding.garments, garmentIndex, `garment ${garmentIndex}`);
|
|
712
936
|
writePart(GPU_CHARACTER_PART_KIND.garment, asset, partBindingSlot(binding, tiers.cloth, `garment ${garmentIndex}`), tiers.cloth, tiers.cloth, transform);
|
|
713
937
|
}
|
|
714
938
|
for (const [attachmentIndex, attachment] of (state.identity.socketAttachments ?? []).entries()) {
|
|
715
|
-
if (attachment.asset < 0
|
|
939
|
+
if (attachment.asset < 0 ||
|
|
940
|
+
budget.droppedPartKeys.has(`${actorSlot}:attachment:${attachmentIndex}`))
|
|
716
941
|
continue;
|
|
717
942
|
const socketTransforms = batch.frame.socketTransforms;
|
|
718
943
|
if (!socketTransforms)
|
|
@@ -740,6 +965,7 @@ export class GpuCrowdCharactersBackend {
|
|
|
740
965
|
palettes,
|
|
741
966
|
buckets: buckets.map((bucket) => ({ ...bucket })),
|
|
742
967
|
composition,
|
|
968
|
+
budget: cloneBudgetReport(budget.report),
|
|
743
969
|
};
|
|
744
970
|
this.compositionBackend?.submitComposition(composition, {
|
|
745
971
|
palettes,
|
|
@@ -749,6 +975,9 @@ export class GpuCrowdCharactersBackend {
|
|
|
749
975
|
lastPreparedFrame() {
|
|
750
976
|
return this.prepared;
|
|
751
977
|
}
|
|
978
|
+
characterBudgetReport() {
|
|
979
|
+
return cloneBudgetReport(this.prepared.budget);
|
|
980
|
+
}
|
|
752
981
|
dispose() {
|
|
753
982
|
for (const state of this.states.values())
|
|
754
983
|
this.releaseState(state);
|