Expand description
offline BSP tree and PVS compiler for Lunar levels.
call from your crate’s build.rs to compile a level mesh into a binary blob
that BspLevel can load at runtime with zero
parsing cost.
§build.rs example
ⓘ
fn main() {
let blob = lunar_bsp_build::compile_bsp_file("assets/levels/level1.glb").unwrap();
let out = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
std::fs::write(out.join("level1.bsp"), blob).unwrap();
println!("cargo:rerun-if-changed=assets/levels/level1.glb");
}then in your game:
ⓘ
let level = BspLevel::from_binary(include_bytes!(concat!(env!("OUT_DIR"), "/level1.bsp")))
.expect("level bsp corrupt");
app.insert_resource(level);§area ids
name your GLTF meshes with an areaN_ prefix (e.g. area0_floor, area1_corridor)
to automatically assign area ids. meshes without this prefix are untagged and
treated as always-visible geometry.
portal hints let you override the auto-detected portals or add portals where the geometry auto-detection misses connections.
Re-exports§
pub use portal::BspPortalHint;
Modules§
- gltf
- GLTF/GLB level mesh loader.
- partition
- SAH k-d tree construction for offline BSP compilation.
- portal
- portal extraction for BSP compilation.
- pvs
- ray-sampling PVS (potentially-visible set) computation.
Structs§
- BspCompile
Config - configuration for the BSP compiler.
- BspInput
Mesh - a mesh to include in the BSP compilation.
Functions§
- compile_
bsp - compile a set of meshes into a BSP blob.
- compile_
bsp_ file - compile a GLTF/GLB level file into a BSP blob using default settings.
- compile_
bsp_ file_ with_ config - compile a GLTF/GLB level file with explicit portal hints and compile config.