stable
This commit is contained in:
parent
0f1cb2fe6c
commit
129c07183a
51 changed files with 5711 additions and 1122 deletions
|
|
@ -153,12 +153,43 @@
|
|||
return ran;
|
||||
}
|
||||
|
||||
function physicsBudgetFor(worldRef) {
|
||||
const tier = global.TarinaiPerf?.renderQualityTier?.() || "high";
|
||||
const itemCount = (worldRef?.items || []).length || 0;
|
||||
const activeHint = worldRef?._itemUpdateRealtime?.length || 0;
|
||||
if (tier === "low") return { maxPairs: 140, maxLinks: 90, postMaxPairs: 36, maxSubsteps: 2 };
|
||||
if (tier === "medium" || tier === "mid") {
|
||||
const crowded = itemCount > 64 && activeHint <= 2;
|
||||
return crowded
|
||||
? { maxPairs: 150, maxLinks: 105, postMaxPairs: 44, maxSubsteps: 2 }
|
||||
: { maxPairs: 190, maxLinks: 130, postMaxPairs: 60, maxSubsteps: 3 };
|
||||
}
|
||||
return itemCount > 80
|
||||
? { maxPairs: 240, maxLinks: 170, postMaxPairs: 78, maxSubsteps: 4 }
|
||||
: { maxPairs: 300, maxLinks: 210, postMaxPairs: 100, maxSubsteps: 5 };
|
||||
}
|
||||
|
||||
function run(worldRef, dt) {
|
||||
const end = global.TarinaiPerf?.begin?.("update.items") || null;
|
||||
try {
|
||||
const state = ensure(worldRef);
|
||||
let ran = runRealtime(worldRef, state, dt);
|
||||
ran += runDue(worldRef, state);
|
||||
const realtimeEnd = global.TarinaiPerf?.begin?.("update.items.realtime") || null;
|
||||
let realtimeRan = runRealtime(worldRef, state, dt);
|
||||
let ran = realtimeRan;
|
||||
if (realtimeEnd) realtimeEnd();
|
||||
const dueEnd = global.TarinaiPerf?.begin?.("update.items.scheduled") || null;
|
||||
const dueRan = runDue(worldRef, state);
|
||||
ran += dueRan;
|
||||
if (dueEnd) dueEnd();
|
||||
const physicsEnd = global.TarinaiPerf?.begin?.("update.physicsWorld") || null;
|
||||
const physicsBudget = physicsBudgetFor(worldRef);
|
||||
const physicsWorld = global.TarinaiPhysicsWorldSystem?.updateWorld
|
||||
? global.TarinaiPhysicsWorldSystem.updateWorld(worldRef, dt, physicsBudget)
|
||||
: null;
|
||||
const mechanicalWorld = physicsWorld?.mechanical || (global.TarinaiMechanicalSystem?.updateWorld?.(worldRef, dt, { maxPairs: physicsBudget.maxPairs, maxLinks: 0, skipLinks: true, maxSubsteps: physicsBudget.maxSubsteps }) || null);
|
||||
const constraintWorld = physicsWorld ? physicsWorld.constraintRan : (global.TarinaiConstraintSystem?.updateWorld?.(worldRef, dt, { maxLinks: Math.min(180, physicsBudget.maxLinks) }) || 0);
|
||||
const postConstraintPairs = physicsWorld ? physicsWorld.postConstraintPairs : (constraintWorld ? (global.TarinaiMechanicalSystem?.resolveMechanicalPairs?.(worldRef, dt, { maxPairs: Math.min(80, physicsBudget.postMaxPairs) }) || 0) : 0);
|
||||
if (physicsEnd) physicsEnd();
|
||||
state.signature = schedulerSignature(worldRef);
|
||||
worldRef._itemUpdateSchedulerStats = {
|
||||
heap: state.heap.length,
|
||||
|
|
@ -166,8 +197,18 @@
|
|||
rebuilds: state.rebuilds,
|
||||
lastReason: state.reason,
|
||||
lastRan: ran,
|
||||
realtimeRan,
|
||||
dueRan,
|
||||
sleeping: state.heap.length,
|
||||
activeRealtime: state.realtime.length,
|
||||
physicsBudget,
|
||||
physics: physicsWorld || mechanicalWorld,
|
||||
constraints: constraintWorld,
|
||||
postConstraintPairs,
|
||||
mechanicalStats: worldRef._mechanicalWorldStats || null,
|
||||
constraintStats: worldRef._constraintWorldStats || null,
|
||||
};
|
||||
return ran;
|
||||
return ran + (physicsWorld?.ran || mechanicalWorld?.ran || 0) + constraintWorld;
|
||||
} finally {
|
||||
if (end) end();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue