CollisionShape

Struct CollisionShape 

Source
pub struct CollisionShape<P, T, B, Y = ()>
where P: Primitive,
{ pub enabled: bool, /* private fields */ }
Expand description

Collision shape describing a complete collision object in the collision world.

Can handle both convex shapes, and concave shapes, by subdividing the concave shapes into multiple convex shapes. This task is up to the user of the library to perform, no subdivision is done automatically in the library.

Contains cached information about the base bounding box containing all primitives, in model space coordinates. Also contains a cached version of the transformed bounding box, in world space coordinates.

Also have details about what collision strategy/mode to use for contact resolution with this shape.

§Type parameters:

  • P: Primitive type
  • T: Transform type
  • B: Bounding volume type
  • Y: Shape type (see Collider)

Fields§

§enabled: bool

Enable/Disable collision detection for this shape

Implementations§

Source§

impl<P, T, B, Y> CollisionShape<P, T, B, Y>
where P: Primitive + ComputeBound<B>, B: Bound<Point = P::Point> + Union<B, Output = B> + Clone, T: Transform<P::Point>, Y: Default,

Source

pub fn new_complex( strategy: CollisionStrategy, mode: CollisionMode, primitives: Vec<(P, T)>, ty: Y, ) -> Self

Create a new collision shape, with multiple collision primitives.

Will compute and cache the base bounding box that contains all the given primitives, in model space coordinates.

§Parameters
  • strategy: The collision strategy to use for this shape.
  • primitives: List of all primitives that make up this shape.
  • ty: The shape type, use () if not needed
Source

pub fn new_simple( strategy: CollisionStrategy, mode: CollisionMode, primitive: P, ) -> Self

Convenience function to create a simple collision shape with only a single given primitive, with no local-to-model transform.

§Parameters
  • strategy: The collision strategy to use for this shape.
  • primitive: The collision primitive.
Source

pub fn new_simple_with_type( strategy: CollisionStrategy, mode: CollisionMode, primitive: P, ty: Y, ) -> Self

Convenience function to create a simple collision shape with only a single given primitive, and a shape type, with no local-to-model transform.

§Parameters
  • strategy: The collision strategy to use for this shape.
  • primitive: The collision primitive.
Source

pub fn new_simple_offset( strategy: CollisionStrategy, mode: CollisionMode, primitive: P, transform: T, ) -> Self

Convenience function to create a simple collision shape with only a single given primitive, with a given local-to-model transform.

§Parameters
  • strategy: The collision strategy to use for this shape.
  • primitive: The collision primitive.
  • transform: Local-to-model transform of the primitive.
Source

pub fn update(&mut self, start: &T, end: Option<&T>)

Update the cached transformed bounding box in world space coordinates.

If the end transform is given, that will always be used. If the collision mode of the shape is Continuous, both the start and end transforms will be added to the transformed bounding box. This will make broad phase detect collisions for the whole transformation path.

§Parameters
  • start: Current model-to-world transform of the shape at the start of the frame.
  • end: Optional model-to-world transform of the shaped at the end of the frame.
Source

pub fn bound(&self) -> &B

Return the current transformed bound for the shape

Source

pub fn primitives(&self) -> &Vec<(P, T)>

Borrow the primitives of the shape

Trait Implementations§

Source§

impl<P, T: Clone, B: Clone, Y: Clone> Clone for CollisionShape<P, T, B, Y>
where P: Primitive + Clone,

Source§

fn clone(&self) -> CollisionShape<P, T, B, Y>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P, T: Debug, B: Debug, Y: Debug> Debug for CollisionShape<P, T, B, Y>
where P: Primitive + Debug,

Source§

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

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

impl<P, T, B, Y> HasBound for CollisionShape<P, T, B, Y>
where P: Primitive + ComputeBound<B>, B: Bound<Point = P::Point> + Union<B, Output = B> + Clone, T: Transform<P::Point>, Y: Default,

Source§

type Bound = B

Bounding volume type
Source§

fn bound(&self) -> &Self::Bound

Borrow the bounding volume
Source§

impl<S, P, T, B, Y> Volume<S, Matrix3<S>> for CollisionShape<P, T, B, Y>
where S: BaseFloat, P: Volume<S, Matrix3<S>> + Primitive<Point = Point3<S>> + ComputeBound<B>, B: Bound<Point = Point3<S>> + Clone + Union<B, Output = B>, T: Transform<Point3<S>>, Y: Default,

Source§

fn get_mass(&self, material: &Material) -> Mass<S, Matrix3<S>>

Compute the mass of the shape based on its material
Source§

impl<S, P, T, B, Y> Volume<S, S> for CollisionShape<P, T, B, Y>
where S: BaseFloat + Inertia, P: Volume<S, S> + Primitive<Point = Point2<S>> + ComputeBound<B>, B: Bound<Point = Point2<S>> + Clone + Union<B, Output = B>, T: Transform<Point2<S>>, Y: Default,

Source§

fn get_mass(&self, material: &Material) -> Mass<S, S>

Compute the mass of the shape based on its material

Auto Trait Implementations§

§

impl<P, T, B, Y> Freeze for CollisionShape<P, T, B, Y>
where B: Freeze, Y: Freeze,

§

impl<P, T, B, Y> RefUnwindSafe for CollisionShape<P, T, B, Y>

§

impl<P, T, B, Y> Send for CollisionShape<P, T, B, Y>
where B: Send, Y: Send, P: Send, T: Send,

§

impl<P, T, B, Y> Sync for CollisionShape<P, T, B, Y>
where B: Sync, Y: Sync, P: Sync, T: Sync,

§

impl<P, T, B, Y> Unpin for CollisionShape<P, T, B, Y>
where B: Unpin, Y: Unpin, P: Unpin, T: Unpin,

§

impl<P, T, B, Y> UnwindSafe for CollisionShape<P, T, B, Y>

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