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 intoBvh- The main BVH structure
Tuple Fields§
§0: usizeImplementations§
Source§impl BvhNodeIndex
impl BvhNodeIndex
Sourcepub fn decompose(self) -> (usize, bool)
pub fn decompose(self) -> (usize, bool)
Decomposes this index into its components.
Returns a tuple of (wide_node_index, is_right) where:
wide_node_indexis the index into the BVH’s array ofBvhNodeWidepairsis_rightisfalsefor left child,truefor 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
Sourcepub fn sibling(self) -> Self
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);Sourcepub fn left(id: u32) -> Self
pub fn left(id: u32) -> Self
Creates an index for the left child of a node pair.
§Arguments
id- The index of theBvhNodeWidepair 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
Sourcepub fn right(id: u32) -> Self
pub fn right(id: u32) -> Self
Creates an index for the right child of a node pair.
§Arguments
id- The index of theBvhNodeWidepair 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
Sourcepub fn new(id: u32, is_right: bool) -> Self
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 theBvhNodeWidepair in the BVH’s node arrayis_right-falsefor left child,truefor 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
Trait Implementations§
Source§impl Clone for BvhNodeIndex
impl Clone for BvhNodeIndex
Source§fn clone(&self) -> BvhNodeIndex
fn clone(&self) -> BvhNodeIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BvhNodeIndex
impl Debug for BvhNodeIndex
Source§impl Default for BvhNodeIndex
impl Default for BvhNodeIndex
Source§fn default() -> BvhNodeIndex
fn default() -> BvhNodeIndex
Source§impl PartialEq for BvhNodeIndex
impl PartialEq for BvhNodeIndex
impl Copy for BvhNodeIndex
impl Eq for BvhNodeIndex
impl StructuralPartialEq for BvhNodeIndex
Auto Trait Implementations§
impl Freeze for BvhNodeIndex
impl RefUnwindSafe for BvhNodeIndex
impl Send for BvhNodeIndex
impl Sync for BvhNodeIndex
impl Unpin for BvhNodeIndex
impl UnwindSafe for BvhNodeIndex
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§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.