aaa
This commit is contained in:
parent
f1c3af2b89
commit
2636d580a8
75 changed files with 3890 additions and 1084 deletions
|
|
@ -12,6 +12,15 @@
|
|||
map[k] = (map[k] || 0) + n;
|
||||
}
|
||||
|
||||
function backgroundFullBudgetFor() {
|
||||
return Math.max(1, Number(global.TarinaiPerf?.performanceProfile?.().creatureBackgroundBudget || 36));
|
||||
}
|
||||
|
||||
function consumesBackgroundBudget(cadence) {
|
||||
if (!cadence || cadence.urgent || cadence.visible) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateCreatures(worldRef, dt) {
|
||||
const h = helpers;
|
||||
const end = global.TarinaiPerf.begin("update.tarinai.individual") || null;
|
||||
|
|
@ -35,6 +44,10 @@
|
|||
skippedStates: {},
|
||||
sleepPhysical: 0,
|
||||
passivePhysical: 0,
|
||||
fullBudget: backgroundFullBudgetFor(worldRef),
|
||||
fullBudgetUsed: 0,
|
||||
fullBudgetSkips: 0,
|
||||
offscreenSkipped: 0,
|
||||
};
|
||||
const prevSpatialDeferMode = worldRef.deferSpatialRebuildMode || "";
|
||||
worldRef.deferSpatialRebuildDepth = (worldRef.deferSpatialRebuildDepth || 0) + 1;
|
||||
|
|
@ -60,6 +73,7 @@
|
|||
else if (interval < 0.75) stats.near += 1;
|
||||
else stats.far += 1;
|
||||
if (!Number.isFinite(interval)) continue;
|
||||
const usesBackgroundBudget = consumesBackgroundBudget(cadence);
|
||||
|
||||
const context = { cadence, motionDt: dt };
|
||||
if (interval <= 0) {
|
||||
|
|
@ -77,11 +91,21 @@
|
|||
t._nextLowFreqUpdateAt = now + interval * (0.65 + jitter * 0.70);
|
||||
}
|
||||
if (now >= t._nextLowFreqUpdateAt) {
|
||||
if (usesBackgroundBudget && stats.fullBudgetUsed >= stats.fullBudget) {
|
||||
const jitter = stableUnit(t.id || t.familyKey || Math.random(), `creature-budget:${Math.floor(now * 4)}`);
|
||||
t._nextLowFreqUpdateAt = now + Math.max(dt, interval * (0.18 + jitter * 0.18));
|
||||
stats.fullBudgetSkips += 1;
|
||||
stats.offscreenSkipped += cadence.visible ? 0 : 1;
|
||||
stats.skipped += 1;
|
||||
inc(stats.skippedStates, behaviorId);
|
||||
continue;
|
||||
}
|
||||
const runDt = Math.max(dt, t._updateAccum || dt);
|
||||
const jitter = stableUnit(t.id || t.familyKey || Math.random(), `creature-cadence:${Math.floor(now * 2)}`);
|
||||
t._updateAccum = 0;
|
||||
t._nextLowFreqUpdateAt = now + interval * (0.92 + jitter * 0.22);
|
||||
stats.full += 1;
|
||||
if (usesBackgroundBudget) stats.fullBudgetUsed += 1;
|
||||
global.TarinaiCreatureRuntime.updateOne(t, runDt, { context });
|
||||
} else if (cadence.smoothMotion) {
|
||||
if (global.TarinaiCreatureRuntime.updateMotionOnly(t, dt, { context })) {
|
||||
|
|
@ -128,14 +152,10 @@
|
|||
fastTarinai.push(t);
|
||||
}
|
||||
if (fastTarinai?.length) {
|
||||
worldRef.nextTarinaiCollisionCheckAt = now;
|
||||
worldRef.workStats && (worldRef.workStats.collisionRuns = (worldRef.workStats.collisionRuns || 0) + 1);
|
||||
const endCollision = global.TarinaiPerf.begin("update.tarinai.collisions") || null;
|
||||
try { worldRef.resolveTarinaiHighSpeedCollisions(dt, { fastSources: fastTarinai, threshold: collisionSpeedThreshold }); }
|
||||
finally { if (endCollision) endCollision(); }
|
||||
} else if (now >= (worldRef.nextTarinaiCollisionCheckAt || 0)) {
|
||||
worldRef.nextTarinaiCollisionCheckAt = now + 0.55;
|
||||
worldRef.workStats && (worldRef.workStats.collisionSkips = (worldRef.workStats.collisionSkips || 0) + 1);
|
||||
} else {
|
||||
worldRef.workStats && (worldRef.workStats.collisionSkips = (worldRef.workStats.collisionSkips || 0) + 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue