Skip to main content

ColliderComponent

Enum ColliderComponent 

Source
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: DVec3

Offset from the entity’s Transform::position in the body’s frame.

§radius: f64

Radius in metres.

§is_trigger: bool

Whether this collider is a trigger (non-solid, overlap-only).

§

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: DVec3

Offset from the entity’s Transform::position in the body’s frame.

§half_extents: DVec3

Half-extents along the body’s own axes, in metres.

§is_trigger: bool

Whether this collider is a trigger.

§

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: DVec3

Offset from the entity’s Transform::position in the body’s frame.

§radius: f64

Radius in metres.

§half_height: f64

Half the length of the cylindrical section.

§is_trigger: bool

Whether this collider is a trigger.

§

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: DVec3

Offset 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: CompoundShape

The parts.

§is_trigger: bool

Whether this collider is a trigger.

§

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.

Fields

§mesh: TriangleMesh

The mesh.

§is_trigger: bool

Whether this collider is a trigger.

Implementations§

Source§

impl ColliderComponent

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for ColliderComponent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColliderComponent

Source§

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

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

impl PartialEq for ColliderComponent

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ColliderComponent

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.