pub struct BspNode { /* private fields */ }Expand description
A node in the BSP tree.
Each node partitions space using a splitting plane and stores polygons that are coplanar with that plane. Polygons on the front or back of the plane are stored in the respective child subtrees.
§Coplanar Polygon Storage
Coplanar polygons are separated by their facing direction relative to the splitting plane’s normal:
coplanar_front: polygons whose normal points the same direction as the plane normalcoplanar_back: polygons whose normal points opposite to the plane normal
This distinction is important for future CSG operations where polygon facing determines inside/outside classification.
Implementations§
Source§impl BspNode
impl BspNode
Sourcepub fn new(plane: Plane3D) -> Self
pub fn new(plane: Plane3D) -> Self
Creates a new BSP node with the given splitting plane.
The node starts with no coplanar polygons and no children.
Sourcepub fn with_coplanar(
plane: Plane3D,
coplanar_front: Vec<Polygon>,
coplanar_back: Vec<Polygon>,
) -> Self
pub fn with_coplanar( plane: Plane3D, coplanar_front: Vec<Polygon>, coplanar_back: Vec<Polygon>, ) -> Self
Creates a new BSP node with a splitting plane and initial coplanar polygons.
Sourcepub fn coplanar_front(&self) -> &[Polygon]
pub fn coplanar_front(&self) -> &[Polygon]
Returns coplanar polygons facing the same direction as the plane normal.
Sourcepub fn coplanar_back(&self) -> &[Polygon]
pub fn coplanar_back(&self) -> &[Polygon]
Returns coplanar polygons facing opposite to the plane normal.
Sourcepub fn all_coplanar(&self) -> impl Iterator<Item = &Polygon>
pub fn all_coplanar(&self) -> impl Iterator<Item = &Polygon>
Returns all coplanar polygons at this node (both front and back facing).
Sourcepub fn coplanar_count(&self) -> usize
pub fn coplanar_count(&self) -> usize
Returns the number of coplanar polygons at this node.
Sourcepub fn front_mut(&mut self) -> Option<&mut BspNode>
pub fn front_mut(&mut self) -> Option<&mut BspNode>
Returns a mutable reference to the front child subtree.
Sourcepub fn back_mut(&mut self) -> Option<&mut BspNode>
pub fn back_mut(&mut self) -> Option<&mut BspNode>
Returns a mutable reference to the back child subtree.
Sourcepub fn add_coplanar_front(&mut self, polygon: Polygon)
pub fn add_coplanar_front(&mut self, polygon: Polygon)
Adds a polygon to the coplanar front list.
Sourcepub fn add_coplanar_back(&mut self, polygon: Polygon)
pub fn add_coplanar_back(&mut self, polygon: Polygon)
Adds a polygon to the coplanar back list.
Sourcepub fn polygon_count(&self) -> usize
pub fn polygon_count(&self) -> usize
Returns the total number of polygons in this subtree (including all descendants).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BspNode
impl RefUnwindSafe for BspNode
impl Send for BspNode
impl Sync for BspNode
impl Unpin for BspNode
impl UnwindSafe for BspNode
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.