pub struct BspWorld<'a> {
pub planes: &'a [Plane],
pub nodes: &'a [Node],
pub leaves: &'a [Leaf],
pub faces: &'a [Face],
pub marksurfaces: &'a [u16],
pub vertices: &'a [[f32; 3]],
pub uvs: &'a [[f32; 2]],
pub lm_uvs: &'a [[f32; 2]],
pub vis: &'a [u8],
pub vis_offsets: &'a [u32],
pub num_clusters: u16,
}Expand description
The complete borrowed BSP world.
Construct with BspWorld::new from your static lumps, then pass a
&BspWorld into K3dengine::record_bsp every frame. No allocator needed.
Fields§
§planes: &'a [Plane]§nodes: &'a [Node]§leaves: &'a [Leaf]§faces: &'a [Face]§marksurfaces: &'a [u16]Indirection table: leaves[i].first_marksurface indexes into this.
vertices: &'a [[f32; 3]]§uvs: &'a [[f32; 2]]Per-vertex surface UV coordinates (parallel to vertices).
lm_uvs: &'a [[f32; 2]]Per-vertex lightmap UV coordinates (parallel to vertices).
May be empty when lightmaps are unused.
vis: &'a [u8]Quake-style RLE-compressed PVS blob. Empty = always visible.
vis_offsets: &'a [u32]vis_offsets[cluster_id] = byte offset into vis for that cluster.
num_clusters: u16Implementations§
Source§impl<'a> BspWorld<'a>
impl<'a> BspWorld<'a>
Sourcepub fn leaf_for_point(&self, p: [f32; 3]) -> usize
pub fn leaf_for_point(&self, p: [f32; 3]) -> usize
Walk the BSP tree to find which leaf contains world-space point p.
Iterative — zero stack usage beyond the function call frame. Handles degenerate trees (0 nodes) by returning leaf 0.
Sourcepub fn cluster_visible(&self, from_cluster: i16, test_cluster: i16) -> bool
pub fn cluster_visible(&self, from_cluster: i16, test_cluster: i16) -> bool
Test whether test_cluster is potentially visible from from_cluster.
Returns true unconditionally when:
from_cluster < 0(leaf with no PVS — Quake convention: always visible), or- The PVS blob is empty (no vis data compiled — developer/test use), or
test_cluster == from_cluster(every cluster sees itself).
Otherwise decodes Quake-style RLE: the vis row for from_cluster
is a stream of non-zero bytes (each byte is 8 cluster bits) and zero
runs encoded as [0x00, count] (skips count * 8 clusters).
Auto Trait Implementations§
impl<'a> Freeze for BspWorld<'a>
impl<'a> RefUnwindSafe for BspWorld<'a>
impl<'a> Send for BspWorld<'a>
impl<'a> Sync for BspWorld<'a>
impl<'a> Unpin for BspWorld<'a>
impl<'a> UnsafeUnpin for BspWorld<'a>
impl<'a> UnwindSafe for BspWorld<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.