Table of Contents

Class AreaFloorBaker

Namespace
GrindFest
Assembly
GrindFest.dll

Keeps a NavMesh baked around each hero, because the world is generated and the mesh has to follow.

public class AreaFloorBaker : Singleton<AreaFloorBaker>
Inheritance
object
AreaFloorBaker
Inherited Members

Remarks

One platform fact shapes the scheduling: NavMeshBuilder.UpdateNavMeshDataAsync never completes in a browser (WebAssembly has no threads here), so a WebGL player bakes synchronously. Measured 2026-09-20: with the async call the mesh stayed at whatever Start() had baked, and a player reported "0 vertices, 0 area(s)".

Both variants of the bake are incremental: NavMeshBuilder hashes the sources it is given and rebuilds only the portions whose hash changed (Unity docs, NavMeshBuilder.UpdateNavMeshData). That is what makes a bake every couple of seconds affordable, and it is also what this class was breaking. The docs ask for the sources that have not changed to arrive "in the same relative order as before, because their sequence can affect the values of the hashes", and collecting them fresh from Physics.OverlapBoxNonAlloc - which promises no order at all - made every bake look like a complete change: a full rebuild instead of a partial one. The owner reported the result on 2026-09-22 as "unplayable, it stops for a second every three seconds", which is a 2 s timer plus a full rebuild. GrindFest.AreaFloorBaker.CollectSources(UnityEngine.Vector3) now sorts the colliders it collects, and that ordering is load-bearing rather than tidiness.

The timer stays the trigger, deliberately: the world changes while a hero stands still - a rock falls, an NPC walks in, a structure is placed - and the mesh has to follow that, not only the hero's position. Rebuild is for a caller that knows the world changed and will not wait for the next tick.

Three changes were needed and measurement separated them: the source order makes a bake that changes nothing free, GrindFest.AreaFloorBaker.SnapForBake(UnityEngine.Vector3) stops a walking hero from changing the box on every bake at all, and GrindFest.AreaFloorBaker.BakeSettings() stops a single changed source from rebuilding the whole box (the tiles were larger than the box, so there was only ever one tile to rebuild).

Fields

NavMeshSize
OverrideCanBakeAsync

Test hook for CanBakeAsync; null in a build and in normal play.

Rebuild
Surface

Properties

CanBakeAsync

Whether a NavMesh bake can run off the main thread on this platform.

Methods

BuildNavMesh(bool)

Rebuilds the NavMesh for every hero that needs one.