Skip to main content

Collision

Struct Collision 

Source
pub struct Collision;
Expand description

Zero-sized type that hosts collision detection functions.

All methods are static (no self receiver) and are used by the #[goud_api] proc-macro to auto-generate #[no_mangle] extern "C" FFI wrappers. The free functions below delegate to these methods.

Implementations§

Source§

impl Collision

Source

pub fn aabb_aabb( center_a: Vec2, half_extents_a: Vec2, center_b: Vec2, half_extents_b: Vec2, ) -> Option<Contact>

Tests collision between two axis-aligned bounding boxes.

Source

pub fn circle_circle( center_a: Vec2, radius_a: f32, center_b: Vec2, radius_b: f32, ) -> Option<Contact>

Tests collision between two circles.

Source

pub fn circle_aabb( circle_center: Vec2, circle_radius: f32, box_center: Vec2, box_half_extents: Vec2, ) -> Option<Contact>

Tests collision between a circle and an AABB.

Source

pub fn point_in_rect(point: Vec2, rect_origin: Vec2, rect_size: Vec2) -> bool

Checks whether a point lies inside a rectangle.

Source

pub fn point_in_circle( point: Vec2, circle_center: Vec2, circle_radius: f32, ) -> bool

Checks whether a point lies inside a circle.

Source

pub fn aabb_overlap(min_a: Vec2, max_a: Vec2, min_b: Vec2, max_b: Vec2) -> bool

Fast boolean overlap test for two AABBs using min/max corners.

Source

pub fn circle_overlap( center_a: Vec2, radius_a: f32, center_b: Vec2, radius_b: f32, ) -> bool

Fast boolean overlap test for two circles.

Source

pub fn distance(a: Vec2, b: Vec2) -> f32

Returns the Euclidean distance between two points.

Source

pub fn distance_squared(a: Vec2, b: Vec2) -> f32

Returns the squared Euclidean distance between two points.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Event for T
where T: Send + Sync + 'static,

Source§

impl<T> Resource for T
where T: Send + Sync + 'static,