Struct rapier3d::geometry::ColliderBuilder
source · [−]pub struct ColliderBuilder {Show 15 fields
pub shape: SharedShape,
pub density: Option<Real>,
pub mass_properties: Option<MassProperties>,
pub friction: Real,
pub friction_combine_rule: CoefficientCombineRule,
pub restitution: Real,
pub restitution_combine_rule: CoefficientCombineRule,
pub position: Isometry<Real>,
pub is_sensor: bool,
pub active_collision_types: ActiveCollisionTypes,
pub active_hooks: ActiveHooks,
pub active_events: ActiveEvents,
pub user_data: u128,
pub collision_groups: InteractionGroups,
pub solver_groups: InteractionGroups,
}
Expand description
A structure responsible for building a new collider.
Fields
shape: SharedShape
The shape of the collider to be built.
density: Option<Real>
The uniform density of the collider to be built.
mass_properties: Option<MassProperties>
Overrides automatic computation of MassProperties
.
If None, it will be computed based on shape and density.
friction: Real
The friction coefficient of the collider to be built.
friction_combine_rule: CoefficientCombineRule
The rule used to combine two friction coefficients.
restitution: Real
The restitution coefficient of the collider to be built.
restitution_combine_rule: CoefficientCombineRule
The rule used to combine two restitution coefficients.
position: Isometry<Real>
The position of this collider.
is_sensor: bool
Is this collider a sensor?
active_collision_types: ActiveCollisionTypes
Contact pairs enabled for this collider.
active_hooks: ActiveHooks
Physics hooks enabled for this collider.
active_events: ActiveEvents
Events enabled for this collider.
user_data: u128
The user-data of the collider being built.
collision_groups: InteractionGroups
The collision groups for the collider being built.
solver_groups: InteractionGroups
The solver groups for the collider being built.
Implementations
sourceimpl ColliderBuilder
impl ColliderBuilder
sourcepub fn new(shape: SharedShape) -> Self
pub fn new(shape: SharedShape) -> Self
Initialize a new collider builder with the given shape.
sourcepub fn compound(shapes: Vec<(Isometry<Real>, SharedShape)>) -> Self
pub fn compound(shapes: Vec<(Isometry<Real>, SharedShape)>) -> Self
Initialize a new collider builder with a compound shape.
sourcepub fn ball(radius: Real) -> Self
pub fn ball(radius: Real) -> Self
Initialize a new collider builder with a ball shape defined by its radius.
sourcepub fn halfspace(outward_normal: Unit<Vector<Real>>) -> Self
pub fn halfspace(outward_normal: Unit<Vector<Real>>) -> 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 builder 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 builder 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 builder 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 builder 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_x(half_height: Real, radius: Real) -> Self
pub fn capsule_x(half_height: Real, radius: Real) -> Self
Initialize a new collider builder 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 builder 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 builder 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 builder 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 builder with a round cuboid shape defined by its half-extents and border radius.
sourcepub fn segment(a: Point<Real>, b: Point<Real>) -> Self
pub fn segment(a: Point<Real>, b: Point<Real>) -> Self
Initializes a collider builder with a segment shape.
sourcepub fn triangle(a: Point<Real>, b: Point<Real>, c: Point<Real>) -> Self
pub fn triangle(a: Point<Real>, b: Point<Real>, c: Point<Real>) -> Self
Initializes a collider builder with a triangle shape.
sourcepub fn round_triangle(
a: Point<Real>,
b: Point<Real>,
c: Point<Real>,
border_radius: Real
) -> Self
pub fn round_triangle(
a: Point<Real>,
b: Point<Real>,
c: Point<Real>,
border_radius: Real
) -> Self
Initializes a collider builder with a triangle shape with round corners.
sourcepub fn polyline(
vertices: Vec<Point<Real>>,
indices: Option<Vec<[u32; 2]>>
) -> Self
pub fn polyline(
vertices: Vec<Point<Real>>,
indices: Option<Vec<[u32; 2]>>
) -> Self
Initializes a collider builder with a polyline shape defined by its vertex and index buffers.
sourcepub fn trimesh(vertices: Vec<Point<Real>>, indices: Vec<[u32; 3]>) -> Self
pub fn trimesh(vertices: Vec<Point<Real>>, indices: Vec<[u32; 3]>) -> Self
Initializes a collider builder with a triangle mesh shape defined by its vertex and index buffers.
sourcepub fn convex_decomposition(
vertices: &[Point<Real>],
indices: &[[u32; 3]]
) -> Self
pub fn convex_decomposition(
vertices: &[Point<Real>],
indices: &[[u32; 3]]
) -> Self
Initializes a collider builder 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: &[Point<Real>],
indices: &[[u32; 3]],
border_radius: Real
) -> Self
pub fn round_convex_decomposition(
vertices: &[Point<Real>],
indices: &[[u32; 3]],
border_radius: Real
) -> Self
Initializes a collider builder 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: &[Point<Real>],
indices: &[[u32; 3]],
params: &VHACDParameters
) -> Self
pub fn convex_decomposition_with_params(
vertices: &[Point<Real>],
indices: &[[u32; 3]],
params: &VHACDParameters
) -> Self
Initializes a collider builder 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: &[Point<Real>],
indices: &[[u32; 3]],
params: &VHACDParameters,
border_radius: Real
) -> Self
pub fn round_convex_decomposition_with_params(
vertices: &[Point<Real>],
indices: &[[u32; 3]],
params: &VHACDParameters,
border_radius: Real
) -> Self
Initializes a collider builder 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: &[Point<Real>]) -> Option<Self>
pub fn convex_hull(points: &[Point<Real>]) -> Option<Self>
Initializes a new collider builder 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: &[Point<Real>],
border_radius: Real
) -> Option<Self>
pub fn round_convex_hull(
points: &[Point<Real>],
border_radius: Real
) -> Option<Self>
Initializes a new collider builder 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<Point<Real>>,
indices: &[[u32; 3]]
) -> Option<Self>
pub fn convex_mesh(
points: Vec<Point<Real>>,
indices: &[[u32; 3]]
) -> Option<Self>
Creates a new collider builder 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<Point<Real>>,
indices: &[[u32; 3]],
border_radius: Real
) -> Option<Self>
pub fn round_convex_mesh(
points: Vec<Point<Real>>,
indices: &[[u32; 3]],
border_radius: Real
) -> Option<Self>
Creates a new collider builder 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: DMatrix<Real>, scale: Vector<Real>) -> Self
pub fn heightfield(heights: DMatrix<Real>, scale: Vector<Real>) -> Self
Initializes a collider builder with a heightfield shape defined by its set of height and a scale factor along each coordinate axis.
sourcepub fn default_friction() -> Real
pub fn default_friction() -> Real
The default friction coefficient used by the collider builder.
sourcepub fn default_density() -> Real
pub fn default_density() -> Real
The default density used by the collider builder.
sourcepub fn user_data(self, data: u128) -> Self
pub fn user_data(self, data: u128) -> Self
Sets an arbitrary user-defined 128-bit integer associated to the colliders built by this builder.
sourcepub fn collision_groups(self, groups: InteractionGroups) -> Self
pub fn collision_groups(self, groups: InteractionGroups) -> Self
Sets the collision groups used by this collider.
Two colliders will interact iff. their collision groups are compatible. See InteractionGroups::test for details.
sourcepub fn solver_groups(self, groups: InteractionGroups) -> Self
pub fn solver_groups(self, groups: InteractionGroups) -> Self
Sets the solver groups used by this collider.
Forces between two colliders in contact will be computed iff their solver groups are compatible. See InteractionGroups::test for details.
sourcepub fn sensor(self, is_sensor: bool) -> Self
pub fn sensor(self, is_sensor: bool) -> Self
Sets whether or not the collider built by this builder is a sensor.
Sensors will have a default density of zero,
but if you call Self::mass_properties
you can assign a mass to a sensor.
sourcepub fn active_hooks(self, active_hooks: ActiveHooks) -> Self
pub fn active_hooks(self, active_hooks: ActiveHooks) -> Self
The set of physics hooks enabled for this collider.
sourcepub fn active_events(self, active_events: ActiveEvents) -> Self
pub fn active_events(self, active_events: ActiveEvents) -> Self
The set of events enabled for this collider.
sourcepub fn active_collision_types(
self,
active_collision_types: ActiveCollisionTypes
) -> Self
pub fn active_collision_types(
self,
active_collision_types: ActiveCollisionTypes
) -> Self
The set of active collision types for this collider.
sourcepub fn friction(self, friction: Real) -> Self
pub fn friction(self, friction: Real) -> Self
Sets the friction coefficient of the collider this builder will build.
sourcepub fn friction_combine_rule(self, rule: CoefficientCombineRule) -> Self
pub fn friction_combine_rule(self, rule: CoefficientCombineRule) -> Self
Sets the rule to be used to combine two friction coefficients in a contact.
sourcepub fn restitution(self, restitution: Real) -> Self
pub fn restitution(self, restitution: Real) -> Self
Sets the restitution coefficient of the collider this builder will build.
sourcepub fn restitution_combine_rule(self, rule: CoefficientCombineRule) -> Self
pub fn restitution_combine_rule(self, rule: CoefficientCombineRule) -> Self
Sets the rule to be used to combine two restitution coefficients in a contact.
sourcepub fn density(self, density: Real) -> Self
pub fn density(self, density: Real) -> Self
Sets the uniform density of the collider this builder will build.
This will be overridden by a call to Self::mass_properties
so it only makes sense to call
either Self::density
or Self::mass_properties
.
sourcepub fn mass_properties(self, mass_properties: MassProperties) -> Self
pub fn mass_properties(self, mass_properties: MassProperties) -> Self
Sets the mass properties of the collider this builder will build.
If this is set, Self::density
will be ignored, so it only makes sense to call
either Self::density
or Self::mass_properties
.
sourcepub fn translation(self, translation: Vector<Real>) -> Self
pub fn translation(self, translation: Vector<Real>) -> Self
Sets the initial translation of the collider to be created.
If the collider will be attached to a rigid-body, this sets the translation relative to the rigid-body it will be attached to.
sourcepub fn rotation(self, angle: AngVector<Real>) -> Self
pub fn rotation(self, angle: AngVector<Real>) -> Self
Sets the initial orientation of the collider to be created.
If the collider will be attached to a rigid-body, this sets the orientation relative to the rigid-body it will be attached to.
sourcepub fn position(self, pos: Isometry<Real>) -> Self
pub fn position(self, pos: Isometry<Real>) -> Self
Sets the initial position (translation and orientation) of the collider to be created.
If the collider will be attached to a rigid-body, this sets the position relative to the rigid-body it will be attached to.
sourcepub fn position_wrt_parent(self, pos: Isometry<Real>) -> Self
👎 Deprecated: Use .position
instead.
pub fn position_wrt_parent(self, pos: Isometry<Real>) -> Self
Use .position
instead.
Sets the initial position (translation and orientation) of the collider to be created, relative to the rigid-body it is attached to.
sourcepub fn delta(self, delta: Isometry<Real>) -> Self
👎 Deprecated: Use .position
instead.
pub fn delta(self, delta: Isometry<Real>) -> Self
Use .position
instead.
Set the position of this collider in the local-space of the rigid-body it is attached to.
sourcepub fn components(
&self
) -> (ColliderChanges, ColliderPosition, ColliderBroadPhaseData, ColliderShape, ColliderType, ColliderMaterial, ColliderFlags, ColliderMassProps)
pub fn components(
&self
) -> (ColliderChanges, ColliderPosition, ColliderBroadPhaseData, ColliderShape, ColliderType, ColliderMaterial, ColliderFlags, ColliderMassProps)
Builds all the components required by a collider.
Trait Implementations
sourceimpl Clone for ColliderBuilder
impl Clone for ColliderBuilder
sourcefn clone(&self) -> ColliderBuilder
fn clone(&self) -> ColliderBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for ColliderBuilder
impl Send for ColliderBuilder
impl Sync for ColliderBuilder
impl Unpin for ColliderBuilder
impl !UnwindSafe for ColliderBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
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. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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. Read more
sourceimpl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
sourcefn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourcefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
sourcefn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
sourcefn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more