Skip to main content

Module spatial

Module spatial 

Source

Structs§

SpatialGrid
In-memory spatial grid mapping cell coordinates to entity ID lists.
SpatialHashGrid
Dense spatial grid for O(1) entity lookup by position. Grid cells are cell_size x cell_size world units. Uses u64 entity handles — zero-copy, no per-entity String allocation.

Constants§

CELL_SIZE
Cell size in world units.

Functions§

action_horizon_cells
Return 3x3 neighbor cell coordinates for AOI queries.
astar
Bounded A* pathfinding. Returns path as Vec<(i32, i32)> excluding start. cost_fn returns movement cost (999 = impassable) for a given (x, y). Bounded by max_steps to prevent unbounded work.
cell_coord
Compute cell coordinate from world position (floor division).
compute_cell_id
Compute deterministic cell ID from world/region/position.
compute_fov
Compute field-of-view positions from (ox, oy) with given radius. Uses 8-octant recursive shadowcasting.
compute_observer_visibility_mask
Compute observer visibility mask: 1 for visible meshlets, 0 for culled. fov_cells is the output of compute_fov. meshlet_coords are the (x, y) cell positions of each meshlet.
distance_squared
Compute squared distance between two points. Integer-only, no sqrt.
fill_observer_visibility_mask
Zero-allocation version: writes into caller-provided output slice. out must be at least meshlet_coords.len() long.