Struct bevy_rapier3d::geometry::Collider
source · [−]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
sourceimpl Collider
impl Collider
sourcepub fn promote_scaled_shape(&mut self)
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
.
sourcepub fn compound(shapes: Vec<(Vect, Rot, Collider)>) -> Self
pub fn compound(shapes: Vec<(Vect, Rot, Collider)>) -> Self
Initialize a new collider with a compound shape.
sourcepub fn ball(radius: Real) -> Self
pub fn ball(radius: Real) -> Self
Initialize a new collider with a ball shape defined by its radius.
sourcepub fn halfspace(outward_normal: Vect) -> Option<Self>
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.
sourcepub fn cylinder(half_height: Real, radius: Real) -> Self
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.
sourcepub fn round_cylinder(
half_height: Real,
radius: Real,
border_radius: Real
) -> Self
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).
sourcepub fn cone(half_height: Real, radius: Real) -> Self
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.
sourcepub fn round_cone(half_height: Real, radius: Real, border_radius: Real) -> Self
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).
sourcepub fn capsule(a: Vect, b: Vect, radius: Real) -> Self
pub fn capsule(a: Vect, b: Vect, radius: Real) -> Self
Initialize a new collider with a capsule shape.
sourcepub fn capsule_x(half_height: Real, radius: Real) -> Self
pub fn capsule_x(half_height: Real, radius: Real) -> Self
Initialize a new collider with a capsule shape aligned with the x
axis.
sourcepub fn capsule_y(half_height: Real, radius: Real) -> Self
pub fn capsule_y(half_height: Real, radius: Real) -> Self
Initialize a new collider with a capsule shape aligned with the y
axis.
sourcepub fn capsule_z(half_height: Real, radius: Real) -> Self
pub fn capsule_z(half_height: Real, radius: Real) -> Self
Initialize a new collider with a capsule shape aligned with the z
axis.
sourcepub fn cuboid(hx: Real, hy: Real, hz: Real) -> Self
pub fn cuboid(hx: Real, hy: Real, hz: Real) -> Self
Initialize a new collider with a cuboid shape defined by its half-extents.
sourcepub fn round_cuboid(hx: Real, hy: Real, hz: Real, border_radius: Real) -> Self
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.
sourcepub fn triangle(a: Vect, b: Vect, c: Vect) -> Self
pub fn triangle(a: Vect, b: Vect, c: Vect) -> Self
Initializes a collider with a triangle shape.
sourcepub fn round_triangle(a: Vect, b: Vect, c: Vect, border_radius: Real) -> Self
pub fn round_triangle(a: Vect, b: Vect, c: Vect, border_radius: Real) -> Self
Initializes a collider with a triangle shape with round corners.
sourcepub fn polyline(vertices: Vec<Vect>, indices: Option<Vec<[u32; 2]>>) -> Self
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.
sourcepub fn trimesh(vertices: Vec<Vect>, indices: Vec<[u32; 3]>) -> Self
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.
sourcepub fn from_bevy_mesh(
mesh: &Mesh,
collider_shape: &ComputedColliderShape
) -> Option<Self>
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.
sourcepub fn convex_decomposition(vertices: &[Vect], indices: &[[u32; 3]]) -> Self
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.
sourcepub fn round_convex_decomposition(
vertices: &[Vect],
indices: &[[u32; 3]],
border_radius: Real
) -> Self
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.
sourcepub fn convex_decomposition_with_params(
vertices: &[Vect],
indices: &[[u32; 3]],
params: &VHACDParameters
) -> Self
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.
sourcepub fn round_convex_decomposition_with_params(
vertices: &[Vect],
indices: &[[u32; 3]],
params: &VHACDParameters,
border_radius: Real
) -> Self
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.
sourcepub fn convex_hull(points: &[Vect]) -> Option<Self>
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.
sourcepub fn round_convex_hull(points: &[Vect], border_radius: Real) -> Option<Self>
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
.
sourcepub fn convex_mesh(points: Vec<Vect>, indices: &[[u32; 3]]) -> Option<Self>
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).
sourcepub fn round_convex_mesh(
points: Vec<Vect>,
indices: &[[u32; 3]],
border_radius: Real
) -> Option<Self>
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
.
sourcepub fn heightfield(
heights: Vec<Real>,
num_rows: usize,
num_cols: usize,
scale: Vect
) -> Self
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.
sourcepub fn as_typed_shape(&self) -> ColliderView<'_>
pub fn as_typed_shape(&self) -> ColliderView<'_>
Takes a strongly typed reference of this collider.
sourcepub fn as_unscaled_typed_shape(&self) -> ColliderView<'_>
pub fn as_unscaled_typed_shape(&self) -> ColliderView<'_>
Takes a strongly typed reference of the unscaled version of this collider.
sourcepub fn as_cuboid(&self) -> Option<CuboidView<'_>>
pub fn as_cuboid(&self) -> Option<CuboidView<'_>>
Downcast this collider to a cuboid, if it is one.
sourcepub fn as_capsule(&self) -> Option<CapsuleView<'_>>
pub fn as_capsule(&self) -> Option<CapsuleView<'_>>
Downcast this collider to a capsule, if it is one.
sourcepub fn as_segment(&self) -> Option<SegmentView<'_>>
pub fn as_segment(&self) -> Option<SegmentView<'_>>
Downcast this collider to a segment, if it is one.
sourcepub fn as_triangle(&self) -> Option<TriangleView<'_>>
pub fn as_triangle(&self) -> Option<TriangleView<'_>>
Downcast this collider to a triangle, if it is one.
sourcepub fn as_trimesh(&self) -> Option<TriMeshView<'_>>
pub fn as_trimesh(&self) -> Option<TriMeshView<'_>>
Downcast this collider to a triangle mesh, if it is one.
sourcepub fn as_polyline(&self) -> Option<PolylineView<'_>>
pub fn as_polyline(&self) -> Option<PolylineView<'_>>
Downcast this collider to a polyline, if it is one.
sourcepub fn as_halfspace(&self) -> Option<HalfSpaceView<'_>>
pub fn as_halfspace(&self) -> Option<HalfSpaceView<'_>>
Downcast this collider to a half-space, if it is one.
sourcepub fn as_heightfield(&self) -> Option<HeightFieldView<'_>>
pub fn as_heightfield(&self) -> Option<HeightFieldView<'_>>
Downcast this collider to a heightfield, if it is one.
sourcepub fn as_compound(&self) -> Option<CompoundView<'_>>
pub fn as_compound(&self) -> Option<CompoundView<'_>>
Downcast this collider to a compound shape, if it is one.
sourcepub fn as_convex_polyhedron(&self) -> Option<ConvexPolyhedronView<'_>>
pub fn as_convex_polyhedron(&self) -> Option<ConvexPolyhedronView<'_>>
Downcast this collider to a convex polyhedron, if it is one.
sourcepub fn as_cylinder(&self) -> Option<CylinderView<'_>>
pub fn as_cylinder(&self) -> Option<CylinderView<'_>>
Downcast this collider to a cylinder, if it is one.
sourcepub fn as_ball_mut(&mut self) -> Option<BallViewMut<'_>>
pub fn as_ball_mut(&mut self) -> Option<BallViewMut<'_>>
Downcast this collider to a mutable ball, if it is one.
sourcepub fn as_cuboid_mut(&mut self) -> Option<CuboidViewMut<'_>>
pub fn as_cuboid_mut(&mut self) -> Option<CuboidViewMut<'_>>
Downcast this collider to a mutable cuboid, if it is one.
sourcepub fn as_capsule_mut(&mut self) -> Option<CapsuleViewMut<'_>>
pub fn as_capsule_mut(&mut self) -> Option<CapsuleViewMut<'_>>
Downcast this collider to a mutable capsule, if it is one.
sourcepub fn as_segment_mut(&mut self) -> Option<SegmentViewMut<'_>>
pub fn as_segment_mut(&mut self) -> Option<SegmentViewMut<'_>>
Downcast this collider to a mutable segment, if it is one.
sourcepub fn as_triangle_mut(&mut self) -> Option<TriangleViewMut<'_>>
pub fn as_triangle_mut(&mut self) -> Option<TriangleViewMut<'_>>
Downcast this collider to a mutable triangle, if it is one.
sourcepub fn as_trimesh_mut(&mut self) -> Option<TriMeshViewMut<'_>>
pub fn as_trimesh_mut(&mut self) -> Option<TriMeshViewMut<'_>>
Downcast this collider to a mutable triangle mesh, if it is one.
sourcepub fn as_polyline_mut(&mut self) -> Option<PolylineViewMut<'_>>
pub fn as_polyline_mut(&mut self) -> Option<PolylineViewMut<'_>>
Downcast this collider to a mutable polyline, if it is one.
sourcepub fn as_halfspace_mut(&mut self) -> Option<HalfSpaceViewMut<'_>>
pub fn as_halfspace_mut(&mut self) -> Option<HalfSpaceViewMut<'_>>
Downcast this collider to a mutable half-space, if it is one.
sourcepub fn as_heightfield_mut(&mut self) -> Option<HeightFieldViewMut<'_>>
pub fn as_heightfield_mut(&mut self) -> Option<HeightFieldViewMut<'_>>
Downcast this collider to a mutable heightfield, if it is one.
sourcepub fn as_cylinder_mut(&mut self) -> Option<CylinderViewMut<'_>>
pub fn as_cylinder_mut(&mut self) -> Option<CylinderViewMut<'_>>
Downcast this collider to a mutable cylinder, if it is one.
sourcepub fn as_cone_mut(&mut self) -> Option<ConeViewMut<'_>>
pub fn as_cone_mut(&mut self) -> Option<ConeViewMut<'_>>
Downcast this collider to a mutable cone, if it is one.
sourcepub fn set_scale(&mut self, scale: Vect, num_subdivisions: u32)
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.
sourcepub fn project_local_point_with_max_dist(
&self,
pt: Vect,
solid: bool,
max_dist: Real
) -> Option<PointProjection>
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
.
sourcepub fn project_point_with_max_dist(
&self,
translation: Vect,
rotation: Rot,
pt: Vect,
solid: bool,
max_dist: Real
) -> Option<PointProjection>
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.
sourcepub fn project_local_point(&self, pt: Vect, solid: bool) -> PointProjection
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
.
sourcepub fn project_local_point_and_get_feature(
&self,
pt: Vect
) -> (PointProjection, FeatureId)
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.
sourcepub fn distance_to_local_point(&self, pt: Vect, solid: bool) -> Real
pub fn distance_to_local_point(&self, pt: Vect, solid: bool) -> Real
Computes the minimal distance between a point and self
.
sourcepub fn contains_local_point(&self, pt: Vect) -> bool
pub fn contains_local_point(&self, pt: Vect) -> bool
Tests if the given point is inside of self
.
sourcepub fn project_point(
&self,
translation: Vect,
rotation: Rot,
pt: Vect,
solid: bool
) -> PointProjection
pub fn project_point(
&self,
translation: Vect,
rotation: Rot,
pt: Vect,
solid: bool
) -> PointProjection
Projects a point on self
transformed by m
.
sourcepub fn distance_to_point(
&self,
translation: Vect,
rotation: Rot,
pt: Vect,
solid: bool
) -> Real
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
.
sourcepub fn project_point_and_get_feature(
&self,
translation: Vect,
rotation: Rot,
pt: Vect
) -> (PointProjection, FeatureId)
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.
sourcepub fn contains_point(&self, translation: Vect, rotation: Rot, pt: Vect) -> bool
pub fn contains_point(&self, translation: Vect, rotation: Rot, pt: Vect) -> bool
Tests if the given point is inside of self
transformed by m
.
sourcepub fn cast_local_ray(
&self,
ray_origin: Vect,
ray_dir: Vect,
max_toi: Real,
solid: bool
) -> Option<Real>
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.
sourcepub fn cast_local_ray_and_get_normal(
&self,
ray_origin: Vect,
ray_dir: Vect,
max_toi: Real,
solid: bool
) -> Option<RayIntersection>
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.
sourcepub fn intersects_local_ray(
&self,
ray_origin: Vect,
ray_dir: Vect,
max_toi: Real
) -> bool
pub fn intersects_local_ray(
&self,
ray_origin: Vect,
ray_dir: Vect,
max_toi: Real
) -> bool
Tests whether a ray intersects this transformed shape.
sourcepub fn cast_ray(
&self,
translation: Vect,
rotation: Rot,
ray_origin: Vect,
ray_dir: Vect,
max_toi: Real,
solid: bool
) -> Option<Real>
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.
sourcepub fn cast_ray_and_get_normal(
&self,
translation: Vect,
rotation: Rot,
ray_origin: Vect,
ray_dir: Vect,
max_toi: Real,
solid: bool
) -> Option<RayIntersection>
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.
Trait Implementations
sourcefn from(shared_shape: SharedShape) -> Collider
fn from(shared_shape: SharedShape) -> Collider
Auto Trait Implementations
impl !RefUnwindSafe for Collider
impl Send for Collider
impl Sync for Collider
impl Unpin for Collider
impl !UnwindSafe for Collider
Blanket Implementations
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist. Read moresourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moreimpl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given [World]sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.