BspNode

Struct BspNode 

Source
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 normal
  • coplanar_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

Source

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.

Source

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.

Source

pub fn plane(&self) -> &Plane3D

Returns a reference to the splitting plane.

Source

pub fn coplanar_front(&self) -> &[Polygon]

Returns coplanar polygons facing the same direction as the plane normal.

Source

pub fn coplanar_back(&self) -> &[Polygon]

Returns coplanar polygons facing opposite to the plane normal.

Source

pub fn all_coplanar(&self) -> impl Iterator<Item = &Polygon>

Returns all coplanar polygons at this node (both front and back facing).

Source

pub fn coplanar_count(&self) -> usize

Returns the number of coplanar polygons at this node.

Source

pub fn front(&self) -> Option<&BspNode>

Returns a reference to the front child subtree.

Source

pub fn back(&self) -> Option<&BspNode>

Returns a reference to the back child subtree.

Source

pub fn front_mut(&mut self) -> Option<&mut BspNode>

Returns a mutable reference to the front child subtree.

Source

pub fn back_mut(&mut self) -> Option<&mut BspNode>

Returns a mutable reference to the back child subtree.

Source

pub fn set_front(&mut self, node: Option<BspNode>)

Sets the front child subtree.

Source

pub fn set_back(&mut self, node: Option<BspNode>)

Sets the back child subtree.

Source

pub fn add_coplanar_front(&mut self, polygon: Polygon)

Adds a polygon to the coplanar front list.

Source

pub fn add_coplanar_back(&mut self, polygon: Polygon)

Adds a polygon to the coplanar back list.

Source

pub fn is_leaf(&self) -> bool

Checks if this node has any children.

Source

pub fn polygon_count(&self) -> usize

Returns the total number of polygons in this subtree (including all descendants).

Source

pub fn depth(&self) -> usize

Returns the depth of this subtree (1 for a leaf node).

Trait Implementations§

Source§

impl Clone for BspNode

Source§

fn clone(&self) -> BspNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BspNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.