Skip to main content

CompoundShape

Struct CompoundShape 

Source
pub struct CompoundShape {
    pub children: Vec<CompoundChild>,
    /* private fields */
}
Expand description

Compound shape: multiple child shapes combined into one body

Fields§

§children: Vec<CompoundChild>

Child shapes with their local transforms

Implementations§

Source§

impl CompoundShape

Source

pub const fn new() -> Self

Create an empty compound shape

Source

pub fn add_sphere( &mut self, sphere: Sphere, position: Vec3Fix, rotation: QuatFix, )

Add a sphere child

Source

pub fn add_capsule( &mut self, capsule: Capsule, position: Vec3Fix, rotation: QuatFix, )

Add a capsule child

Source

pub fn add_convex_hull( &mut self, hull: ConvexHull, position: Vec3Fix, rotation: QuatFix, )

Add a convex hull child

Source

pub fn from_decomposition(result: &DecompositionResult) -> Self

A compound of the convex pieces of a decomposed SDF: one hull child per piece, at the origin, so the compound is in the SDF’s own coordinates.

Together the hulls are the concave solid the SDF describes, up to the grid’s resolution (a hull is smaller than the solid by up to a cell per side), where a single convex hull would fill every dent.

Source

pub fn from_sdf( sdf: &dyn SdfField, min: Vec3Fix, max: Vec3Fix, config: &DecomposeConfig, ) -> Self

Decompose sdf inside [min, max] (crate::convex_decompose::decompose_sdf) and build the compound of its convex pieces (from_decomposition).

Source

pub fn add_box( &mut self, obox: OrientedBox, position: Vec3Fix, rotation: QuatFix, )

Add a box child

Source

pub fn len(&self) -> usize

Number of children

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn compute_aabb(&mut self) -> AABB

Compute the AABB enclosing all children (in local space)

Source

pub fn child_world_aabb( &self, child_idx: usize, body_pos: Vec3Fix, body_rot: QuatFix, ) -> AABB

Get world-space AABB for a specific child, given body transform

Source

pub fn world_aabb(&self, body_pos: Vec3Fix, body_rot: QuatFix) -> AABB

Get world-space AABB for entire compound given body transform

Source

pub fn overlapping_children( &self, target_aabb: &AABB, body_pos: Vec3Fix, body_rot: QuatFix, ) -> Vec<usize>

AABB-based closest pair pruning: 対象AABBと重なる子のみを返す。 ブロードフェーズで不要なナローフェーズ判定を除外する。

Source

pub fn support_world( &self, direction: Vec3Fix, body_pos: Vec3Fix, body_rot: QuatFix, ) -> Vec3Fix

Support function for the compound shape (selects the child with maximum support)

Source

pub fn mass_properties(&self, density: Fix128) -> MassProperties

Mass, centre of mass and the inertia about it, for the compound made of density, in the compound’s own frame.

Each child contributes its shape’s mass properties (a capsule’s along its own axis, a box’s in its own frame, a hull’s by the exact integral over its mesh), carried to where the child is, and the tensors are summed about the common centre of mass with the parallel-axis theorem (crate::mass_properties::translate_inertia). Overlapping children are counted twice where they overlap: a compound is a union of solids, not a boolean one.

MassProperties::ZERO for an empty compound, a non-positive density, or children with no volume.

Trait Implementations§

Source§

impl Clone for CompoundShape

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 CompoundShape

Source§

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

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

impl Default for CompoundShape

Source§

fn default() -> Self

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

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

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