Struct rhusics_core::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 typeT
: Transform typeB
: Bounding volume typeY
: Shape type (seeCollider
)
Fields
enabled: bool
Enable/Disable collision detection for this shape
Implementations
sourceimpl<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,
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,
sourcepub fn new_complex(
strategy: CollisionStrategy,
mode: CollisionMode,
primitives: Vec<(P, T)>,
ty: Y
) -> Self
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
sourcepub fn new_simple(
strategy: CollisionStrategy,
mode: CollisionMode,
primitive: P
) -> Self
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.
sourcepub fn new_simple_with_type(
strategy: CollisionStrategy,
mode: CollisionMode,
primitive: P,
ty: Y
) -> Self
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.
sourcepub fn new_simple_offset(
strategy: CollisionStrategy,
mode: CollisionMode,
primitive: P,
transform: T
) -> Self
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.
sourcepub fn update(&mut self, start: &T, end: Option<&T>)
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.
sourcepub fn primitives(&self) -> &Vec<(P, T)>
pub fn primitives(&self) -> &Vec<(P, T)>
Borrow the primitives of the shape
Trait Implementations
sourceimpl<P: Clone, T: Clone, B: Clone, Y: Clone> Clone for CollisionShape<P, T, B, Y>where
P: Primitive,
impl<P: Clone, T: Clone, B: Clone, Y: Clone> Clone for CollisionShape<P, T, B, Y>where
P: Primitive,
sourcefn clone(&self) -> CollisionShape<P, T, B, Y>
fn clone(&self) -> CollisionShape<P, T, B, Y>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more