Skip to main content

Shape

Trait Shape 

Source
pub trait Shape:
    Debug
    + Send
    + Sync {
    // Required methods
    fn bounding_box(&self) -> Aabb;
    fn support_point(&self, direction: &Vec3) -> Vec3;
    fn volume(&self) -> Real;
    fn center_of_mass(&self) -> Vec3;
    fn inertia_tensor(&self, mass: Real) -> Mat3;
    fn ray_cast(
        &self,
        ray_origin: &Vec3,
        ray_direction: &Vec3,
        max_toi: Real,
    ) -> Option<RayHit>;

    // Provided method
    fn mass_properties(&self, density: Real) -> MassProperties { ... }
}
Expand description

Trait for geometric shapes used in physics simulation.

Required Methods§

Source

fn bounding_box(&self) -> Aabb

Compute the axis-aligned bounding box of this shape (in local space).

Source

fn support_point(&self, direction: &Vec3) -> Vec3

Compute the support point in the given direction (for GJK).

Source

fn volume(&self) -> Real

Compute the volume of this shape.

Source

fn center_of_mass(&self) -> Vec3

Compute the center of mass in local space.

Source

fn inertia_tensor(&self, mass: Real) -> Mat3

Compute the inertia tensor for the given mass.

Source

fn ray_cast( &self, ray_origin: &Vec3, ray_direction: &Vec3, max_toi: Real, ) -> Option<RayHit>

Cast a ray against this shape (in local space). Returns the first intersection within max_toi.

Provided Methods§

Source

fn mass_properties(&self, density: Real) -> MassProperties

Compute full mass properties for a given density.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§