Skip to content

Spatial Grid

Narta Xaymar Dirks edited this page Oct 28, 2026 · 2 revisions

Spatial grid

A scene with many thousands of meshes spends most of RenderWorld on finding the few that a camera can see. From 4096 meshes on, BlitzLLVM puts the meshes that stay where they are into the cells of a grid in the world, and a camera only looks at the cells it sees instead of every mesh. What is drawn does not change: the meshes are looked at in the order of their handles, so the draw order, the sorting and the picture are the same as without the grid.

A mesh goes into a cell once it has stayed as it is for a few frames. Moving it, turning it, scaling it, changing its vertices, giving it a parent or any other command that takes the entity takes it out again, and it goes back in after it has stayed still for a frame. Children of other entities, terrains, planes and entities that were part of CaptureWorld are never put in cells, and are looked at every frame as before. The grid has a cost for every mesh that is touched, so when more than 5% of the meshes are touched in one frame it is not used (every mesh is looked at, as without the grid), and it is used again when fewer than 4.5% are touched. It is also not used for a frame in which more than a tenth of the meshes are in cells that are in view, because then picking and sorting the members costs more than reading every mesh. BLITZLLVM_SPATIAL_GRID_SCAN_SHARE=<share> sets that share (the default is 0.1).

The environment variable BLITZLLVM_SPATIAL_GRID=0 turns the grid off, which is useful to compare speed or pictures. Programs built with -d also look at every mesh each frame and stop with an error if the grid left out one that is in view.

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally