Skip to content

Commit

Permalink
v3: add collides extension function on shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornaz committed Aug 20, 2023
1 parent 3a64c78 commit 091b96e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/v3/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#![allow(missing_docs)]

use sealed::sealed;

#[cfg(feature = "unstable-v3-aabb")]
pub use aabb::Aabb;
pub use point::Point;
use range::Range;
use sealed::sealed;
pub use vector::Vec2;

#[cfg(feature = "unstable-v3-aabb")]
Expand All @@ -28,6 +27,22 @@ pub trait Shape {
fn project_on(&self, axis: Vec2) -> Range;
}

#[sealed]
pub trait Collides<Rhs> {
fn collides(&self, other: &Rhs) -> bool;
}

#[sealed]
impl<A, B> Collides<B> for A
where
A: Shape,
B: Shape,
{
fn collides(&self, other: &B) -> bool {
check_collision(self, other)
}
}

#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct Contact {
Expand Down

0 comments on commit 091b96e

Please sign in to comment.