Skip to main content

chunk_grid

Function chunk_grid 

Source
pub fn chunk_grid(res: u32) -> (Vec<[f32; 3]>, Vec<i32>)
Expand description

Generate the triangular grid vertices and triangle indices for a chunk at resolution res.

Returns (vertices, indices) where:

  • vertices: exactly verts_per_chunk(res) entries — the interior_verts_per_chunk(res) interior grid verts in canonical (i,j) row-major order FIRST, then the 3*(res+1) perimeter skirt verts (see the module docs). Each is [wa, wb, wc] with wa+wb+wc=1; a skirt vert carries the same barycentric as the interior edge vert it mirrors.
  • indices: exactly (res*res + 6*res)*3 values — the res*res interior triangles FIRST, then the 6*res skirt triangles, all with uniform winding (outward = front) so the surface shader can use backface culling (render_mode cull_back).

§Panics

Panics if res == 0.