Trait Shape

Source
pub trait Shape {
    // Required methods
    fn aabb(&self) -> Rect;
    fn contains(&self, point: Vec2) -> bool;
    fn intersects(&self, other: &Self) -> bool;

    // Provided method
    fn contains_rect(&self, rect: &Rect) -> bool { ... }
}
Expand description

A trait for shapes that can be used to query the Quadtree. Shapes must be able to provide their start and end points, their center point, and check if they contain a point. They must also be able to check if they intersect with another shape.

Required Methods§

Source

fn aabb(&self) -> Rect

Get the bounding rect of the shape

Source

fn contains(&self, point: Vec2) -> bool

Check if the shape contains a point

Source

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

Check if the shape shares any space with another shape

Provided Methods§

Source

fn contains_rect(&self, rect: &Rect) -> bool

Check if the shape fully contains a given rect

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§