public sealed class ProximityGridA flat spatial hash over the XZ plane, rebuilt every frame, for "which agents are near this one".
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Avoidance is the only thing that asks, and it asks once per agent per frame about a circle a few radii wide. Comparing every agent to every other is fine at ten agents and quadratic at two hundred; a grid whose cell is the query range turns it into a walk over nine cells.
Rebuilt rather than maintained, because every agent moves every frame and an incremental structure would be re-inserting all of them anyway. The buckets keep their capacity across frames, so a steady-state crowd allocates nothing.
Fields and properties (1)
public float CellSizeHow wide a cell is.
Methods (4)
public ProximityGrid(float cellSize)Creates a grid.
public void Clear()Empties the grid, keeping the buckets for the next frame.
public void Add(int item, Vector3 position)Puts an item in the grid.
public int Query(Vector3 position, float range, Span<int> results)Finds everything within a range of a point.
Used by (1)
- CrowdVixen.Navigation