pub struct CompoundShape<const D: usize> { /* private fields */ }Expand description
A convex rigid body composed of multiple child shapes.
The overall support function is the argmax of all children’s support
points transformed into the compound’s local frame. This makes compound
shapes first-class Shape<D> objects compatible with GJK.
Implementations§
Source§impl<const D: usize> CompoundShape<D>
impl<const D: usize> CompoundShape<D>
Sourcepub fn from_shape(shape: Box<dyn Shape<D>>) -> Self
pub fn from_shape(shape: Box<dyn Shape<D>>) -> Self
Create a compound shape from a single shape.
Sourcepub fn add_child(&mut self, transform: Transform<D>, shape: Box<dyn Shape<D>>)
pub fn add_child(&mut self, transform: Transform<D>, shape: Box<dyn Shape<D>>)
Add a child shape at the given local-frame transform.
Recomputes the cached bounding sphere after each addition.
Sourcepub fn children(&self) -> &[(Transform<D>, Box<dyn Shape<D>>)]
pub fn children(&self) -> &[(Transform<D>, Box<dyn Shape<D>>)]
Access the child shapes and their local transforms.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Number of child shapes.
Trait Implementations§
Source§impl<const D: usize> Clone for CompoundShape<D>
impl<const D: usize> Clone for CompoundShape<D>
Source§impl<const D: usize> Default for CompoundShape<D>
impl<const D: usize> Default for CompoundShape<D>
Source§impl<const D: usize> Shape<D> for CompoundShape<D>
impl<const D: usize> Shape<D> for CompoundShape<D>
Source§fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>
fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>
Support function: furthest point on any child in the given direction.
For each child:
- Rotate
directioninto child’s local frame (inverse rotation). - Query child’s support in that local direction.
- Transform the result back to compound-local frame.
- Return the child whose result has the maximum dot with
direction.
Source§fn bounding_sphere(&self) -> (Point<D>, f64)
fn bounding_sphere(&self) -> (Point<D>, f64)
Bounding sphere: (center, radius).
Auto Trait Implementations§
impl<const D: usize> !RefUnwindSafe for CompoundShape<D>
impl<const D: usize> !UnwindSafe for CompoundShape<D>
impl<const D: usize> Freeze for CompoundShape<D>
impl<const D: usize> Send for CompoundShape<D>
impl<const D: usize> Sync for CompoundShape<D>
impl<const D: usize> Unpin for CompoundShape<D>
impl<const D: usize> UnsafeUnpin for CompoundShape<D>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.