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][lunar_bsp::level::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.