performance: Apply culling to tile entities and throttle PathNavigation::updatePath to run every 8 ticks
Nightly Release / build (push) Canceled after 0s
Nightly Release / release (push) Canceled after 0s
Nightly Release / cleanup (push) Canceled after 0s
Sync branches with main / sync (push) Canceled after 0s

Cull tile entities and throttle mob pathfinding to every 8 ticks.
The players won't see the difference on the pathfinding and the culling improves the performance by a lot in zones with a lot of tile entities

in TileEntityRenderDispatcher.cpp:
Calculate if the tile entities are visible in the camera. Early return if they are so they don't get rendered while the players don't look at those tile entities so .
in PathNavigation.cpp:
Do a simple modulo operation on the current number of ticks to test if its been 8 ticks since last operation. UpdatePath(); doesn't get executed if elapsed time isn't enough
This commit is contained in:
Anaël
2026-10-04 21:02:32 +02:00
parent 1b691739e6
commit 95111a621a
2 changed files with 22 additions and 11 deletions
+8 -6
View File
@@ -149,12 +149,14 @@ Path *PathNavigation::getPath()
return path;
}
void PathNavigation::tick()
{
++_tick;
if (isDone()) return;
void PathNavigation::tick()
{
++_tick;
if (isDone()) return;
if (canUpdatePath()) updatePath();
// Instead of calculating the path every tick, do it only once every 8 ticks
// Players won't see the difference
if (_tick % 8 == 0 && canUpdatePath()) updatePath();
if (isDone()) return;
Vec3 *target = path->currentPos(mob->shared_from_this());
@@ -384,4 +386,4 @@ bool PathNavigation::canWalkAbove(int startX, int startY, int startZ, int sx, in
void PathNavigation::setLevel(Level *level)
{
this->level = level;
}
}