Skip to main content

Collider

Trait Collider 

Source
pub trait Collider {
    // Required methods
    fn shape(&self) -> ColliderShape;
    fn bounding_box(&self) -> Rect;
    fn contains_point(&self, point: Vector2D) -> bool;
    fn center(&self) -> Vector2D;
}
Expand description

A trait for objects that can participate in collision detection.

Required Methods§

Source

fn shape(&self) -> ColliderShape

Returns the geometric shape of this collider.

§Returns
  • ColliderShape - The shape variant.
Source

fn bounding_box(&self) -> Rect

Returns the axis-aligned bounding box that encloses this collider.

§Returns
  • Rect - The bounding box.
Source

fn contains_point(&self, point: Vector2D) -> bool

Tests whether this collider contains the given point.

§Arguments
  • Vector2D - The point to test.
§Returns
  • bool - True if the point is inside.
Source

fn center(&self) -> Vector2D

Returns the center point of this collider.

§Returns
  • Vector2D - The center point.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Collider for AabbCollider

Implements the Collider trait for AabbCollider.

Source§

impl Collider for CircleCollider

Implements the Collider trait for CircleCollider.