Crate collide

Crate collide 

Source
Expand description

A generic collider trait designed for use by collision detection libraries.

You can define new colliders and implement the Collider trait, making them usable with different collision detection libraries that adopt this trait.

Collision detection libraries can be generic over vector types, scalar types, and dimensions, or specialized for specific ones.

§Example

use collide::{Collider, CollisionInfo};

#[derive(Copy, Clone, Debug, PartialEq)]
struct Vec2(f32, f32);

// Basic operation implementations here

struct Sphere {
    center: Vec2,
    radius: f32,
}

impl Collider for Sphere {
    type Vector = Vec2;

    fn collision_info(&self, other: &Self) -> Option<CollisionInfo<Vec2>> {
        // Collision logic here
        None
    }
}

Structs§

CollisionInfo
Information about a detected collision between collider objects. The data is stored in the specified vector type.

Traits§

Collider
The collider trait that all colliders must implement.