Skip to main content

CollisionDetector

Trait CollisionDetector 

Source
pub trait CollisionDetector: Send + Sync {
    // Required methods
    fn check_collision(
        &self,
        bbox: &BoundingBox,
        existing: &[BoundingBox],
    ) -> bool;
    fn find_free_position(
        &self,
        bbox: &BoundingBox,
        existing: &[BoundingBox],
        bounds: &BoundingBox,
    ) -> Option<(f32, f32)>;
}
Expand description

Trait for collision detection strategies

Required Methods§

Source

fn check_collision(&self, bbox: &BoundingBox, existing: &[BoundingBox]) -> bool

Check if a bounding box collides with existing elements

Source

fn find_free_position( &self, bbox: &BoundingBox, existing: &[BoundingBox], bounds: &BoundingBox, ) -> Option<(f32, f32)>

Find a non-colliding position for a bounding box

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§