Skip to main content

BvhNodeIndex

Struct BvhNodeIndex 

Source
pub struct BvhNodeIndex(pub usize);
Expand description

An index identifying a single BVH tree node.

The BVH stores nodes in pairs (BvhNodeWide), where each pair contains a left and right child. This index encodes both which pair and which side (left or right) in a single usize value for efficient storage and manipulation.

§Encoding

The index is encoded as: (wide_node_index << 1) | is_right

  • The upper bits identify the BvhNodeWide (pair of nodes)
  • The lowest bit indicates left (0) or right (1)

§Example

use parry3d::partitioning::BvhNodeIndex;

// Create indices for the left and right children of node pair 5
let left = BvhNodeIndex::left(5);
let right = BvhNodeIndex::right(5);

assert_eq!(left.sibling(), right);
assert_eq!(right.sibling(), left);

// Decompose to get the pair index and side
let (pair_idx, is_right) = left.decompose();
assert_eq!(pair_idx, 5);
assert_eq!(is_right, false);

§See Also

  • BvhNodeWide - The pair of nodes this index points into
  • Bvh - The main BVH structure

Tuple Fields§

§0: usize

Implementations§

Source§

impl BvhNodeIndex

Source

pub fn decompose(self) -> (usize, bool)

Decomposes this index into its components.

Returns a tuple of (wide_node_index, is_right) where:

  • wide_node_index is the index into the BVH’s array of BvhNodeWide pairs
  • is_right is false for left child, true for right child
§Returns

A tuple (usize, bool) containing the pair index and side flag.

§Example
use parry3d::partitioning::BvhNodeIndex;

let left = BvhNodeIndex::left(10);
let (pair_idx, is_right) = left.decompose();

assert_eq!(pair_idx, 10);
assert_eq!(is_right, false);
§See Also
  • new - Construct from components
Source

pub fn sibling(self) -> Self

Returns the sibling of this node.

If this index points to the left child of a pair, returns the right child. If this index points to the right child, returns the left child.

§Returns

The BvhNodeIndex of the sibling node.

§Example
use parry3d::partitioning::BvhNodeIndex;

let left = BvhNodeIndex::left(5);
let right = BvhNodeIndex::right(5);

assert_eq!(left.sibling(), right);
assert_eq!(right.sibling(), left);
Source

pub fn left(id: u32) -> Self

Creates an index for the left child of a node pair.

§Arguments
  • id - The index of the BvhNodeWide pair in the BVH’s node array
§Returns

A BvhNodeIndex pointing to the left child of the specified pair.

§Example
use parry3d::partitioning::BvhNodeIndex;

let left_child = BvhNodeIndex::left(0);
let (pair_idx, is_right) = left_child.decompose();

assert_eq!(pair_idx, 0);
assert_eq!(is_right, false);
§See Also
  • right - Create index for right child
  • new - Create index with explicit side
Source

pub fn right(id: u32) -> Self

Creates an index for the right child of a node pair.

§Arguments
  • id - The index of the BvhNodeWide pair in the BVH’s node array
§Returns

A BvhNodeIndex pointing to the right child of the specified pair.

§Example
use parry3d::partitioning::BvhNodeIndex;

let right_child = BvhNodeIndex::right(0);
let (pair_idx, is_right) = right_child.decompose();

assert_eq!(pair_idx, 0);
assert_eq!(is_right, true);
§See Also
  • left - Create index for left child
  • new - Create index with explicit side
Source

pub fn new(id: u32, is_right: bool) -> Self

Creates a new node index from a pair ID and side flag.

§Arguments
  • id - The index of the BvhNodeWide pair in the BVH’s node array
  • is_right - false for left child, true for right child
§Returns

A BvhNodeIndex encoding both the pair and the side.

§Example
use parry3d::partitioning::BvhNodeIndex;

let left = BvhNodeIndex::new(3, false);
let right = BvhNodeIndex::new(3, true);

assert_eq!(left, BvhNodeIndex::left(3));
assert_eq!(right, BvhNodeIndex::right(3));
§See Also
  • left - Convenience method for left child
  • right - Convenience method for right child

Trait Implementations§

Source§

impl Clone for BvhNodeIndex

Source§

fn clone(&self) -> BvhNodeIndex

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 Copy for BvhNodeIndex

Source§

impl Debug for BvhNodeIndex

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for BvhNodeIndex

Source§

fn default() -> BvhNodeIndex

Returns the “default value” for a type. Read more
Source§

impl Eq for BvhNodeIndex

Source§

impl PartialEq for BvhNodeIndex

Source§

fn eq(&self, other: &BvhNodeIndex) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BvhNodeIndex

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

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.