pub struct Collider {
    pub raw: SharedShape,
    /* private fields */
}
Expand description

A geometric entity that can be attached to a body so it can be affected by contacts and intersection queries.

Fields§

§raw: SharedShape

The raw shape from Rapier.

Implementations§

source§

impl Collider

source

pub fn scale(&self) -> Vect

The scaling factor that was applied to this collider.

source

pub fn promote_scaled_shape(&mut self)

This replaces the unscaled version of this collider by its scaled version, and resets self.scale() to 1.0.

source

pub fn compound(shapes: Vec<(Vect, Rot, Collider)>) -> Self

Initialize a new collider with a compound shape.

source

pub fn ball(radius: Real) -> Self

Initialize a new collider with a ball shape defined by its radius.

source

pub fn halfspace(outward_normal: Vect) -> Option<Self>

Initialize a new collider build with a half-space shape defined by the outward normal of its planar boundary.

source

pub fn cylinder(half_height: Real, radius: Real) -> Self

Initialize a new collider with a cylindrical shape defined by its half-height (along along the y axis) and its radius.

source

pub fn round_cylinder( half_height: Real, radius: Real, border_radius: Real ) -> Self

Initialize a new collider with a rounded cylindrical shape defined by its half-height (along along the y axis), its radius, and its roundedness (the radius of the sphere used for dilating the cylinder).

source

pub fn cone(half_height: Real, radius: Real) -> Self

Initialize a new collider with a cone shape defined by its half-height (along along the y axis) and its basis radius.

source

pub fn round_cone(half_height: Real, radius: Real, border_radius: Real) -> Self

Initialize a new collider with a rounded cone shape defined by its half-height (along along the y axis), its radius, and its roundedness (the radius of the sphere used for dilating the cylinder).

source

pub fn capsule(a: Vect, b: Vect, radius: Real) -> Self

Initialize a new collider with a capsule shape.

source

pub fn capsule_x(half_height: Real, radius: Real) -> Self

Initialize a new collider with a capsule shape aligned with the x axis.

source

pub fn capsule_y(half_height: Real, radius: Real) -> Self

Initialize a new collider with a capsule shape aligned with the y axis.

source

pub fn capsule_z(half_height: Real, radius: Real) -> Self

Initialize a new collider with a capsule shape aligned with the z axis.

source

pub fn cuboid(hx: Real, hy: Real, hz: Real) -> Self

Initialize a new collider with a cuboid shape defined by its half-extents.

source

pub fn round_cuboid(hx: Real, hy: Real, hz: Real, border_radius: Real) -> Self

Initialize a new collider with a round cuboid shape defined by its half-extents and border radius.

source

pub fn segment(a: Vect, b: Vect) -> Self

Initializes a collider with a segment shape.

source

pub fn triangle(a: Vect, b: Vect, c: Vect) -> Self

Initializes a collider with a triangle shape.

source

pub fn round_triangle(a: Vect, b: Vect, c: Vect, border_radius: Real) -> Self

Initializes a collider with a triangle shape with round corners.

source

pub fn polyline(vertices: Vec<Vect>, indices: Option<Vec<[u32; 2]>>) -> Self

Initializes a collider with a polyline shape defined by its vertex and index buffers.

source

pub fn trimesh(vertices: Vec<Vect>, indices: Vec<[u32; 3]>) -> Self

Initializes a collider with a triangle mesh shape defined by its vertex and index buffers.

source

pub fn trimesh_with_flags( vertices: Vec<Vect>, indices: Vec<[u32; 3]>, flags: TriMeshFlags ) -> Self

Initializes a collider with a triangle mesh shape defined by its vertex and index buffers, and flags controlling its pre-processing.

source

pub fn from_bevy_mesh( mesh: &Mesh, collider_shape: &ComputedColliderShape ) -> Option<Self>

Initializes a collider with a Bevy Mesh.

Returns None if the index buffer or vertex buffer of the mesh are in an incompatible format.

source

pub fn convex_decomposition(vertices: &[Vect], indices: &[[u32; 3]]) -> Self

Initializes a collider with a compound shape obtained from the decomposition of the given trimesh (in 3D) or polyline (in 2D) into convex parts.

source

pub fn round_convex_decomposition( vertices: &[Vect], indices: &[[u32; 3]], border_radius: Real ) -> Self

Initializes a collider with a compound shape obtained from the decomposition of the given trimesh (in 3D) or polyline (in 2D) into convex parts dilated with round corners.

source

pub fn convex_decomposition_with_params( vertices: &[Vect], indices: &[[u32; 3]], params: &VHACDParameters ) -> Self

Initializes a collider with a compound shape obtained from the decomposition of the given trimesh (in 3D) or polyline (in 2D) into convex parts.

source

pub fn round_convex_decomposition_with_params( vertices: &[Vect], indices: &[[u32; 3]], params: &VHACDParameters, border_radius: Real ) -> Self

Initializes a collider with a compound shape obtained from the decomposition of the given trimesh (in 3D) or polyline (in 2D) into convex parts dilated with round corners.

source

pub fn convex_hull(points: &[Vect]) -> Option<Self>

Initializes a new collider with a 2D convex polygon or 3D convex polyhedron obtained after computing the convex-hull of the given points.

source

pub fn round_convex_hull(points: &[Vect], border_radius: Real) -> Option<Self>

Initializes a new collider with a round 2D convex polygon or 3D convex polyhedron obtained after computing the convex-hull of the given points. The shape is dilated by a sphere of radius border_radius.

source

pub fn convex_mesh(points: Vec<Vect>, indices: &[[u32; 3]]) -> Option<Self>

Creates a new collider that is a convex polyhedron formed by the given triangle-mesh assumed to be convex (no convex-hull will be automatically computed).

source

pub fn round_convex_mesh( points: Vec<Vect>, indices: &[[u32; 3]], border_radius: Real ) -> Option<Self>

Creates a new collider that is a round convex polyhedron formed by the given triangle-mesh assumed to be convex (no convex-hull will be automatically computed). The triangle mesh shape is dilated by a sphere of radius border_radius.

source

pub fn heightfield( heights: Vec<Real>, num_rows: usize, num_cols: usize, scale: Vect ) -> Self

Initializes a collider with a heightfield shape defined by its set of height (in column-major format) and a scale factor along each coordinate axis.

source

pub fn as_typed_shape(&self) -> ColliderView<'_>

Takes a strongly typed reference of this collider.

source

pub fn as_unscaled_typed_shape(&self) -> ColliderView<'_>

Takes a strongly typed reference of the unscaled version of this collider.

source

pub fn as_ball(&self) -> Option<BallView<'_>>

Downcast this collider to a ball, if it is one.

source

pub fn as_cuboid(&self) -> Option<CuboidView<'_>>

Downcast this collider to a cuboid, if it is one.

source

pub fn as_capsule(&self) -> Option<CapsuleView<'_>>

Downcast this collider to a capsule, if it is one.

source

pub fn as_segment(&self) -> Option<SegmentView<'_>>

Downcast this collider to a segment, if it is one.

source

pub fn as_triangle(&self) -> Option<TriangleView<'_>>

Downcast this collider to a triangle, if it is one.

source

pub fn as_trimesh(&self) -> Option<TriMeshView<'_>>

Downcast this collider to a triangle mesh, if it is one.

source

pub fn as_polyline(&self) -> Option<PolylineView<'_>>

Downcast this collider to a polyline, if it is one.

source

pub fn as_halfspace(&self) -> Option<HalfSpaceView<'_>>

Downcast this collider to a half-space, if it is one.

source

pub fn as_heightfield(&self) -> Option<HeightFieldView<'_>>

Downcast this collider to a heightfield, if it is one.

source

pub fn as_compound(&self) -> Option<CompoundView<'_>>

Downcast this collider to a compound shape, if it is one.

source

pub fn as_convex_polyhedron(&self) -> Option<ConvexPolyhedronView<'_>>

Downcast this collider to a convex polyhedron, if it is one.

source

pub fn as_cylinder(&self) -> Option<CylinderView<'_>>

Downcast this collider to a cylinder, if it is one.

source

pub fn as_cone(&self) -> Option<ConeView<'_>>

Downcast this collider to a cone, if it is one.

source

pub fn as_ball_mut(&mut self) -> Option<BallViewMut<'_>>

Downcast this collider to a mutable ball, if it is one.

source

pub fn as_cuboid_mut(&mut self) -> Option<CuboidViewMut<'_>>

Downcast this collider to a mutable cuboid, if it is one.

source

pub fn as_capsule_mut(&mut self) -> Option<CapsuleViewMut<'_>>

Downcast this collider to a mutable capsule, if it is one.

source

pub fn as_segment_mut(&mut self) -> Option<SegmentViewMut<'_>>

Downcast this collider to a mutable segment, if it is one.

source

pub fn as_triangle_mut(&mut self) -> Option<TriangleViewMut<'_>>

Downcast this collider to a mutable triangle, if it is one.

source

pub fn as_trimesh_mut(&mut self) -> Option<TriMeshViewMut<'_>>

Downcast this collider to a mutable triangle mesh, if it is one.

source

pub fn as_polyline_mut(&mut self) -> Option<PolylineViewMut<'_>>

Downcast this collider to a mutable polyline, if it is one.

source

pub fn as_halfspace_mut(&mut self) -> Option<HalfSpaceViewMut<'_>>

Downcast this collider to a mutable half-space, if it is one.

source

pub fn as_heightfield_mut(&mut self) -> Option<HeightFieldViewMut<'_>>

Downcast this collider to a mutable heightfield, if it is one.

source

pub fn as_cylinder_mut(&mut self) -> Option<CylinderViewMut<'_>>

Downcast this collider to a mutable cylinder, if it is one.

source

pub fn as_cone_mut(&mut self) -> Option<ConeViewMut<'_>>

Downcast this collider to a mutable cone, if it is one.

source

pub fn set_scale(&mut self, scale: Vect, num_subdivisions: u32)

Set the scaling factor of this shape.

If the scaling factor is non-uniform, and the scaled shape can’t be represented as a supported smooth shape (for example scalling a Ball with a non-uniform scale results in an ellipse which isn’t supported), the shape is approximated by a convex polygon/convex polyhedron using num_subdivisions subdivisions.

source

pub fn project_local_point_with_max_dist( &self, pt: Vect, solid: bool, max_dist: Real ) -> Option<PointProjection>

Projects a point on self, unless the projection lies further than the given max distance.

The point is assumed to be expressed in the local-space of self.

source

pub fn project_point_with_max_dist( &self, translation: Vect, rotation: Rot, pt: Vect, solid: bool, max_dist: Real ) -> Option<PointProjection>

Projects a point on self transformed by m, unless the projection lies further than the given max distance.

source

pub fn project_local_point(&self, pt: Vect, solid: bool) -> PointProjection

Projects a point on self.

The point is assumed to be expressed in the local-space of self.

source

pub fn project_local_point_and_get_feature( &self, pt: Vect ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self and returns the id of the feature the point was projected on.

source

pub fn distance_to_local_point(&self, pt: Vect, solid: bool) -> Real

Computes the minimal distance between a point and self.

source

pub fn contains_local_point(&self, pt: Vect) -> bool

Tests if the given point is inside of self.

source

pub fn project_point( &self, translation: Vect, rotation: Rot, pt: Vect, solid: bool ) -> PointProjection

Projects a point on self transformed by m.

source

pub fn distance_to_point( &self, translation: Vect, rotation: Rot, pt: Vect, solid: bool ) -> Real

Computes the minimal distance between a point and self transformed by m.

source

pub fn project_point_and_get_feature( &self, translation: Vect, rotation: Rot, pt: Vect ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self transformed by m and returns the id of the feature the point was projected on.

source

pub fn contains_point(&self, translation: Vect, rotation: Rot, pt: Vect) -> bool

Tests if the given point is inside of self transformed by m.

source

pub fn cast_local_ray( &self, ray_origin: Vect, ray_dir: Vect, max_toi: Real, solid: bool ) -> Option<Real>

Computes the time of impact between this transform shape and a ray.

source

pub fn cast_local_ray_and_get_normal( &self, ray_origin: Vect, ray_dir: Vect, max_toi: Real, solid: bool ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.

source

pub fn intersects_local_ray( &self, ray_origin: Vect, ray_dir: Vect, max_toi: Real ) -> bool

Tests whether a ray intersects this transformed shape.

source

pub fn cast_ray( &self, translation: Vect, rotation: Rot, ray_origin: Vect, ray_dir: Vect, max_toi: Real, solid: bool ) -> Option<Real>

Computes the time of impact between this transform shape and a ray.

source

pub fn cast_ray_and_get_normal( &self, translation: Vect, rotation: Rot, ray_origin: Vect, ray_dir: Vect, max_toi: Real, solid: bool ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.

source

pub fn intersects_ray( &self, translation: Vect, rotation: Rot, ray_origin: Vect, ray_dir: Vect, max_toi: Real ) -> bool

Tests whether a ray intersects this transformed shape.

Trait Implementations§

source§

impl Clone for Collider

source§

fn clone(&self) -> Collider

Returns a copy 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 Component for Colliderwhere Self: Send + Sync + 'static,

§

type Storage = TableStorage

source§

impl Debug for Collider

source§

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

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

impl Default for Collider

source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Collider

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a> From<&'a Collider> for &'a dyn Shape

source§

fn from(collider: &'a Collider) -> &'a dyn Shape

Converts to this type from the input type.
source§

impl From<SharedShape> for Collider

source§

fn from(shared_shape: SharedShape) -> Collider

Converts to this type from the input type.
source§

impl Serialize for Collider

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,

§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U

Return the T [ShaderType] for self. When used in [AsBindGroup] derives, it is safe to assume that all images in self exist.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<C> Bundle for Cwhere C: Component,

§

fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )

§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a, Aligned>,

§

fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_, Aligned>) )

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromWorld for Twhere T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given [World]
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> TypeData for Twhere T: 'static + Send + Sync + Clone,

§

fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>

§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

§

impl<T> Event for Twhere T: Send + Sync + 'static,