Skip to main content

CompoundShape

Struct CompoundShape 

Source
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>

Source

pub fn new() -> Self

Create an empty compound shape.

Source

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.

Source

pub fn child_count(&self) -> usize

Number of child shapes.

Trait Implementations§

Source§

impl<const D: usize> Default for CompoundShape<D>

Source§

fn default() -> Self

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

impl<const D: usize> Shape<D> for CompoundShape<D>

Source§

fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>

Support function: furthest point on any child in the given direction.

For each child:

  1. Rotate direction into child’s local frame (inverse rotation).
  2. Query child’s support in that local direction.
  3. Transform the result back to compound-local frame.
  4. Return the child whose result has the maximum dot with direction.
Source§

fn bounding_sphere(&self) -> (Point<D>, f64)

Bounding sphere: (center, radius).
Source§

fn as_any(&self) -> &dyn Any

Downcast to concrete type for specialized collision dispatch. Read more

Auto Trait Implementations§

§

impl<const D: usize> Freeze for CompoundShape<D>

§

impl<const D: usize> !RefUnwindSafe 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>

§

impl<const D: usize> !UnwindSafe for CompoundShape<D>

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> 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> Same for T

Source§

type Output = T

Should always be Self
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, 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.