pub struct BspTree { /* private fields */ }Expand description
BSP tree wrapper for efficient spatial queries
Implementations§
Source§impl BspTree
impl BspTree
Sourcepub fn new(nodes: Vec<WmoBspNode>) -> Self
pub fn new(nodes: Vec<WmoBspNode>) -> Self
Create a new BSP tree from nodes
Sourcepub fn get_node(&self, index: usize) -> Option<&WmoBspNode>
pub fn get_node(&self, index: usize) -> Option<&WmoBspNode>
Get a node by index
Sourcepub fn query_point(&self, point: &[f32; 3]) -> Vec<usize>
pub fn query_point(&self, point: &[f32; 3]) -> Vec<usize>
Query the BSP tree to find all leaf nodes that might contain the point.
Returns indices of leaf nodes that need to be checked for triangle intersection.
Sourcepub fn pick_closest_tri_neg_z(
&self,
point: &[f32; 3],
vertices: &[Vec3],
indices: &[u16],
) -> Option<usize>
pub fn pick_closest_tri_neg_z( &self, point: &[f32; 3], vertices: &[Vec3], indices: &[u16], ) -> Option<usize>
Find the closest triangle below the given point using ray-triangle intersection.
Shoots a ray in the negative Z direction from the point and finds the first triangle it intersects.
§Arguments
point- The query pointvertices- All vertices in the WMO groupindices- Triangle indices (3 per triangle)
§Returns
The index of the closest triangle (in terms of triangle count, not face index),
or None if no triangle is below the point.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BspTree
impl RefUnwindSafe for BspTree
impl Send for BspTree
impl Sync for BspTree
impl Unpin for BspTree
impl UnwindSafe for BspTree
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
Mutably borrows from an owned value. Read more