Skip to main content

Module geometry

Module geometry 

Source
Expand description

The geometry the engine can build without any source file: voxel-chunk streaming (build_chunk_mesh / build_chunk_impostor_mesh regenerate a chunk’s mesh as it streams in), the glass/water quad generators the GPU backends call, the procedural mesh generators (room, box, cylinder, plane, sphere, terrain, skybox, extrude, heightfield-from-pixels), and the shared low-level mesh math (per-vertex tangents, face normals, the vertex tuple type).

The generators produce (Vec<Vert>, Vec<u16>); packing that into a payload is crate::bake::mesh. The cook crate’s JSON compile front end parses world.jsonl args and calls down into both.

Modules§

glass_quad
src/geometry/glass_quad.rs: flat rectangular quad for a GlassPanel.
water_grid
src/geometry/water_grid.rs: flat tessellated quad for a WaterSurface.

Structs§

ChunkBlockType
One palette entry for the chunk mesher: solidity plus per-face atlas UVs.
ChunkGenerator
Deterministic terrain generator for one VoxelWorld.
HeightfieldField
The field a heightmap image displaces: grid extents, resolution, and the elevation range the red channel maps into.
PaletteSlot
One entry resolved from a VoxelChunk palette. None slots are non-solid (air) and emit no geometry; their neighbours treat them as empty. Public so the cook crate’s compile_voxel_chunk_payload (build-time mesher) can build the palette this crate’s runtime build_chunk_mesh also consumes.

Functions§

build_box
Build an axis-aligned box from half-extents [x, y, z].
build_chunk_impostor_mesh
Build a coarse “impostor” mesh for one distant chunk from its terrain surface heights.
build_chunk_mesh
Build a renderable mesh for one procedurally generated chunk.
build_cylinder
Build an upright cylinder from radius, height, and segment count.
build_extrude
Extrude profile (an [x, z] polygon of at least 3 points, either winding) by height along Y, optionally rounding convex corners with corner_radius sampled at corner_segments arc points per corner.
build_heightfield_from_pixels
Build a heightfield grid from decoded RGBA pixels: bilinear-sample the image’s red channel across the field’s grid and map it through the elevation range.
build_plane
Build a flat horizontal plane from half-width and half-depth.
build_room_geometry
Build room geometry from explicit extents.
build_skybox
Build an inside-facing skybox cube with half-extent size on all axes. Keep size below the camera’s far plane so the sky is not clipped.
build_sphere
Build a UV sphere from radius, ring count, and segment count.
build_terrain
Build a displaced terrain grid. subdivisions is the grid resolution per axis (clamped to 4..=255); amplitude is the peak height above the base plane in metres.
build_voxel_mesh
Generate hidden-face-culled geometry for a voxel chunk.
compute_tangents
Compute a per-vertex tangent vector for every vertex in the mesh.
payload_joints_to_defs
Convert a payload-joint vec to the args-form vec the runtime build_skeleton_from_joint_defs consumes. Public so the client runtime init path can call it without re-implementing the field mapping.

Type Aliases§

Vert
Interleaved CPU vertex tuple the geometry generators produce before packing into the GPU Vertex: position, normal, color, uv. Public so the cook crate’s generators and payload compilers can name the same shape the runtime tangent pass consumes.