a
This commit is contained in:
parent
d163ceb291
commit
f6d7412744
94 changed files with 3836 additions and 1226 deletions
|
|
@ -108,6 +108,20 @@
|
|||
return Math.max(1, Number(global.TarinaiPerf?.performanceProfile?.().scheduledItemBudget || 30));
|
||||
}
|
||||
|
||||
function beginTouchedFrame(worldRef, state) {
|
||||
if (!state.touchedFrame) state.touchedFrame = [];
|
||||
else state.touchedFrame.length = 0;
|
||||
if (!state.touchedSet) state.touchedSet = new Set();
|
||||
else state.touchedSet.clear();
|
||||
worldRef._itemUpdateTouched = state.touchedFrame;
|
||||
}
|
||||
|
||||
function recordTouched(state, item) {
|
||||
if (!item || item.dead || state.touchedSet.has(item)) return;
|
||||
state.touchedSet.add(item);
|
||||
state.touchedFrame.push(item);
|
||||
}
|
||||
|
||||
function runRealtime(worldRef, state, dt) {
|
||||
let ran = 0;
|
||||
const now = worldRef.time || 0;
|
||||
|
|
@ -123,6 +137,7 @@
|
|||
}
|
||||
if (interval <= 0) {
|
||||
global.TarinaiItemRuntime.updateOne(item, dt, worldRef);
|
||||
recordTouched(state, item);
|
||||
item._schedulerLastAt = now;
|
||||
ran += 1;
|
||||
const nextInterval = itemUpdateInterval(item);
|
||||
|
|
@ -155,6 +170,7 @@
|
|||
}
|
||||
const elapsed = Math.min(10, Math.max(0.001, now - (item._schedulerLastAt ?? entry.time - interval)));
|
||||
global.TarinaiItemRuntime.updateOne(item, elapsed, worldRef);
|
||||
recordTouched(state, item);
|
||||
item._schedulerLastAt = now;
|
||||
ran += 1;
|
||||
dueRuns += 1;
|
||||
|
|
@ -197,6 +213,7 @@
|
|||
const end = global.TarinaiPerf.begin("update.items");
|
||||
try {
|
||||
const state = ensure(worldRef);
|
||||
beginTouchedFrame(worldRef, state);
|
||||
const realtimeEnd = global.TarinaiPerf.begin("update.items.realtime");
|
||||
let realtimeRan = runRealtime(worldRef, state, dt);
|
||||
let ran = realtimeRan;
|
||||
|
|
@ -207,9 +224,11 @@
|
|||
ran += dueRan;
|
||||
if (dueEnd) dueEnd();
|
||||
global.TarinaiSignalSystem?.updateWorld?.(worldRef, dt);
|
||||
global.TarinaiItemEnvironmentHazardSystem?.updatePoweredHazards?.(worldRef, dt);
|
||||
const physicsEnd = global.TarinaiPerf.begin("update.physicsWorld");
|
||||
const physicsBudget = physicsBudgetFor(worldRef);
|
||||
const physicsWorld = global.TarinaiPhysicsWorldSystem.updateWorld(worldRef, dt, physicsBudget);
|
||||
const trapHeld = global.TarinaiItemEnvironmentHazardSystem?.enforceTrapHolds?.(worldRef) || 0;
|
||||
const mechanicalWorld = physicsWorld.mechanical || null;
|
||||
const constraintWorld = physicsWorld.constraintRan || 0;
|
||||
const postConstraintPairs = physicsWorld.postConstraintPairs || 0;
|
||||
|
|
@ -232,6 +251,7 @@
|
|||
physicsBudget,
|
||||
poisonContactBudget,
|
||||
poisonContactRemoved,
|
||||
trapHeld,
|
||||
physics: physicsWorld || mechanicalWorld,
|
||||
constraints: constraintWorld,
|
||||
postConstraintPairs,
|
||||
|
|
@ -245,7 +265,7 @@
|
|||
}
|
||||
|
||||
function trackedDynamicItems(worldRef) {
|
||||
return worldRef?._itemUpdateRealtime || [];
|
||||
return worldRef?._itemUpdateTouched || [];
|
||||
}
|
||||
|
||||
global.TarinaiItemUpdateScheduler = Object.freeze({ run, trackedDynamicItems, wakeItem });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue