Skip to main content

Octree3D

Struct Octree3D 

Source
pub struct Octree3D { /* private fields */ }
Expand description

Adaptive 3D octree supporting dynamic insert/remove/update, AABB, sphere, and ray queries.

Implementations§

Source§

impl Octree3D

Dynamic insertion, update, removal, and AABB/sphere/ray queries for Octree3D.

Source

pub fn new(root_bounds: AxisAlignedBox3D, config: OctreeConfig) -> Self

Creates an empty Octree3D spanning root_bounds.

§Arguments
  • AxisAlignedBox3D - World-space root volume.
  • OctreeConfig - Leaf capacity and maximum depth parameters.
§Returns
  • Self - Empty adaptive 3D octree.
Source

pub fn len(&self) -> usize

Returns the number of indexed items stored in this octree.

§Returns
  • usize - Total stored item count.
Source

pub fn is_empty(&self) -> bool

Returns true when the octree contains no items.

§Returns
  • bool - Whether empty.
Source

pub fn clear(&mut self)

Removes all items and resets the octree to a single empty root node.

Source

pub fn insert(&mut self, id: u64, bounds: AxisAlignedBox3D) -> bool

Inserts or updates a 3D bounding-box item; returns false if outside root bounds.

§Arguments
  • u64 - Unique item identifier.
  • AxisAlignedBox3D - Item axis-aligned bounding box.
§Returns
  • bool - true when indexed inside root bounds.
Source

pub fn insert_point(&mut self, id: u64, position: Vec3) -> bool

Inserts a point item as a zero-volume AxisAlignedBox3D at position.

§Arguments
  • u64 - Unique item identifier.
  • Vec3 - World-space 3D position.
§Returns
  • bool - true when indexed inside root bounds.
Source

pub fn remove(&mut self, id: u64) -> bool

Removes item id from the octree.

§Arguments
  • u64 - Item identifier to remove.
§Returns
  • bool - true when present and removed.
Source

pub fn update(&mut self, id: u64, new_bounds: AxisAlignedBox3D) -> bool

Updates an existing item’s bounding box in the octree.

§Arguments
  • u64 - Existing item identifier.
  • AxisAlignedBox3D - Updated 3D bounding box.
§Returns
  • bool - true when id existed and new_bounds lies inside root bounds.
Source

pub fn query_aabb(&self, query_box: AxisAlignedBox3D, out: &mut Vec<u64>)

Queries all items overlapping query_box, writing matching IDs into out.

§Arguments
  • AxisAlignedBox3D - Query bounding box.
  • &mut Vec<u64> - Reusable output buffer (cleared first).
Source

pub fn query_sphere(&self, center: Vec3, radius: f32, out: &mut Vec<u64>)

Queries all items intersecting sphere (center, radius), writing IDs into out.

§Arguments
  • Vec3 - Query sphere center.
  • f32 - Query sphere radius.
  • &mut Vec<u64> - Reusable output buffer (cleared first).
Source

pub fn query_ray(&self, ray: Ray3D, max_distance: f32, out: &mut Vec<u64>)

Queries all items intersected by ray within [0.0, max_distance], writing IDs into out.

§Arguments
  • Ray3D - 3D ray with precomputed reciprocal direction.
  • f32 - Maximum valid ray distance.
  • &mut Vec<u64> - Reusable output buffer (cleared first).
Source§

impl Octree3D

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_root_bounds(&self) -> AxisAlignedBox3D

Source

pub fn get_mut_root_bounds(&mut self) -> &mut AxisAlignedBox3D

Source

pub fn set_root_bounds(&mut self, val: AxisAlignedBox3D) -> &mut Self

Source

pub fn get_config(&self) -> OctreeConfig

Source

pub fn get_mut_config(&mut self) -> &mut OctreeConfig

Source

pub fn set_config(&mut self, val: OctreeConfig) -> &mut Self

Trait Implementations§

Source§

impl Clone for Octree3D

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Octree3D

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Octree3D

§

impl Freeze for Octree3D
where *const u8 is !null: Freeze, PhantomData<OctreeNode3D>: Freeze, PhantomData<(u64, AxisAlignedBox3D)>: Freeze,

§

impl Move for Octree3D

§

impl RefUnwindSafe for Octree3D

§

impl Send for Octree3D
where RawVecInner: Send, RawTable<(u64, AxisAlignedBox3D)>: Send,

§

impl Sync for Octree3D
where RawVecInner: Sync, RawTable<(u64, AxisAlignedBox3D)>: Sync,

§

impl Unpin for Octree3D
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Octree3D

§

impl UnwindSafe for Octree3D

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.