pub struct Octree<D>where
D: Default,{ /* private fields */ }
Expand description
A barebones octree offering just the methods required for accessing and modifying its contents. Other management structures/functions will be needed to make this more useful, especially for the purpose of querying contents.
Implementations§
Source§impl<D, S, T> Octree<ManagedOctreeData<D, S>>
impl<D, S, T> Octree<ManagedOctreeData<D, S>>
pub fn new_managed(centre: (S, S, S), half_length: S) -> Self
Sourcepub fn with_max_size(self, max_size: usize) -> Self
pub fn with_max_size(self, max_size: usize) -> Self
Set max_size
Sourcepub fn with_drop_below_size(self, drop_below_size: usize) -> Self
pub fn with_drop_below_size(self, drop_below_size: usize) -> Self
Set drop_below_size
Panics when set to 0
Sourcepub fn clear_data(&mut self)
pub fn clear_data(&mut self)
Clears data from the node (not the whole tree)
pub fn rebalance(&mut self)
Source§impl<D> Octree<D>where
D: Default,
impl<D> Octree<D>where
D: Default,
pub fn new() -> Self
pub fn new_with_data(data: D) -> Self
Sourcepub fn add_child(
&mut self,
idx: usize,
child: Self,
) -> Result<&mut Self, AddChildError>
pub fn add_child( &mut self, idx: usize, child: Self, ) -> Result<&mut Self, AddChildError>
Adds and returns a reference to a child at a particular index.
§Errors
Returns an error if the idx is out of range (i.e. idx >= 8) or if the child is already added.
Sourcepub fn add_child_at_pos(
&mut self,
pos_x: bool,
pos_y: bool,
pos_z: bool,
child: Self,
) -> Result<&mut Self, AddChildError>
pub fn add_child_at_pos( &mut self, pos_x: bool, pos_y: bool, pos_z: bool, child: Self, ) -> Result<&mut Self, AddChildError>
Adds and returns a reference to a child at an index based on whether the child is at the positive or negative side of each axis.
§Arguments
pos_x
- positive x axis if true, negative if false.pos_y
- positive y axis if true, negative if false.pos_z
- positive z axis if true, negative if false.
§Errors
Returns an error if the child is already added.
Sourcepub fn remove_child(&mut self, idx: usize) -> Option<Self>
pub fn remove_child(&mut self, idx: usize) -> Option<Self>
Removes a child and returns the owned value, if it exists.
Sourcepub fn remove_child_at_pos(
&mut self,
pos_x: bool,
pos_y: bool,
pos_z: bool,
) -> Option<Self>
pub fn remove_child_at_pos( &mut self, pos_x: bool, pos_y: bool, pos_z: bool, ) -> Option<Self>
Removes a child at an index based on whether the child is at the positive or negative side of each access and returns the owned value, if it exists.
§Arguments
pos_x
- positive x axis if true, negative if false.pos_y
- positive y axis if true, negative if false.pos_z
- positive z axis if true, negative if false.
Sourcepub fn get_child(&self, idx: usize) -> Option<&Self>
pub fn get_child(&self, idx: usize) -> Option<&Self>
Gets a reference to a child given an index.
Sourcepub fn get_child_mut(&mut self, idx: usize) -> Option<&mut Self>
pub fn get_child_mut(&mut self, idx: usize) -> Option<&mut Self>
Gets a mutable reference to a child given an index.
Sourcepub fn get_child_at_pos(
&self,
pos_x: bool,
pos_y: bool,
pos_z: bool,
) -> Option<&Self>
pub fn get_child_at_pos( &self, pos_x: bool, pos_y: bool, pos_z: bool, ) -> Option<&Self>
Gets a reference to a child given whether the child is at the positive or negative side of an axis.
§Arguments
pos_x
- positive x axis if true, negative if false.pos_y
- positive y axis if true, negative if false.pos_z
- positive z axis if true, negative if false.
Sourcepub fn get_child_mut_at_pos(
&mut self,
pos_x: bool,
pos_y: bool,
pos_z: bool,
) -> Option<&mut Self>
pub fn get_child_mut_at_pos( &mut self, pos_x: bool, pos_y: bool, pos_z: bool, ) -> Option<&mut Self>
Gets a mutable reference to a child given whether the child is at the positive or negative side of an axis.
§Arguments
pos_x
- positive x axis if true, negative if false.pos_y
- positive y axis if true, negative if false.pos_z
- positive z axis if true, negative if false.
Sourcepub fn get_data_mut(&mut self) -> &mut D
pub fn get_data_mut(&mut self) -> &mut D
Gets a mutable reference to the underlying data in the node.