pub enum ColliderComponent {
Sphere {
offset: DVec3,
radius: f64,
is_trigger: bool,
},
Box {
offset: DVec3,
half_extents: DVec3,
is_trigger: bool,
},
Capsule {
offset: DVec3,
radius: f64,
half_height: f64,
is_trigger: bool,
},
Compound {
offset: DVec3,
shape: CompoundShape,
is_trigger: bool,
},
Mesh {
mesh: TriangleMesh,
is_trigger: bool,
},
}Expand description
A shape attached to an entity for physics queries.
This bundles a collider shape with a trigger flag. The shape is stored
by-value; there is no indirection to the crate::PhysicsWorld — the
physics system is responsible for syncing colliders into the world.
Variants§
Sphere
A sphere collider, its offset turned with its body in the contact
pipeline and the query world (crate::PhysicsSystem::world) alike.
Fields
offset: DVec3Offset from the entity’s Transform::position in the body’s
frame.
Box
A box collider, turned with its body: the offset and the faces are
turned by the body’s rotation, in the contact pipeline and the query
world (crate::PhysicsSystem::world) alike.
Fields
offset: DVec3Offset from the entity’s Transform::position in the body’s
frame.
Capsule
A capsule collider along the body’s Y, turned with its body: the
offset and the core are turned by the body’s rotation, in the contact
pipeline and the query world (crate::PhysicsSystem::world) alike.
Fields
offset: DVec3Offset from the entity’s Transform::position in the body’s
frame.
Compound
Several boxes fixed in the body’s frame, turning with it: see
CompoundShape.
The offset and every part are turned by the body’s rotation wherever
they are placed. In a system with contacts each part collides on its
own; in the query world (crate::PhysicsSystem::world) the compound
is one collider whose rays, sweeps and overlaps answer for the parts
themselves, each hit naming its part in
ShapeHit::part
(crate::PhysicsWorld::add_compound).
Fields
offset: DVec3Offset of the shape’s frame from the entity’s
Transform::position, in the body’s frame: minus the centre of
mass for a body CompoundShape::dynamic_body builds.
shape: CompoundShapeThe parts.
Mesh
A static triangle mesh, its vertices in the body’s frame, turning with
it: see TriangleMesh.
For static and kinematic bodies only: a mesh has no volume to
weigh, so crate::PhysicsSystem::set_collider and
crate::PhysicsSystem::set_body refuse to put one on a dynamic body.
In a system with contacts each triangle collides on its own, one-sided;
the query world (crate::PhysicsSystem::world) holds the mesh
itself, and its rays, sweeps and overlaps hit the triangles exactly.
Implementations§
Source§impl ColliderComponent
impl ColliderComponent
Sourcepub fn max_extent(&self) -> f64
pub fn max_extent(&self) -> f64
How far its farthest point is from the body’s origin, which the body turns about, in metres: what an angular speed is multiplied by to give the fastest a point of the body moves.
Exact for a sphere, a box and a compound (their farthest corners), and for a capsule (the farther cap). A mesh answers the farthest vertex; it is never on a dynamic body, which is the only kind that sleeps.
Sourcepub fn part_count(&self) -> usize
pub fn part_count(&self) -> usize
How many shapes it is to the contact pipeline: its parts for a compound, its triangles for a mesh, one for anything else.