pub struct HitDetection;Expand description
Geometric hit detection utilities.
All hit detection is point-vs-shape — no physics engine is required.
Implementations§
Source§impl HitDetection
impl HitDetection
Sourcepub fn point_in_sphere(point: Vec3, center: Vec3, radius: f32) -> bool
pub fn point_in_sphere(point: Vec3, center: Vec3, radius: f32) -> bool
Point vs sphere. Returns true if point is within radius of center.
Sourcepub fn point_in_aabb(point: Vec3, min: Vec3, max: Vec3) -> bool
pub fn point_in_aabb(point: Vec3, min: Vec3, max: Vec3) -> bool
Point vs AABB. Returns true if point is inside the box.
Sourcepub fn point_in_cylinder(
point: Vec3,
center: Vec3,
radius: f32,
half_height: f32,
) -> bool
pub fn point_in_cylinder( point: Vec3, center: Vec3, radius: f32, half_height: f32, ) -> bool
Point vs cylinder (along Y axis). Returns true if point is inside.
Sourcepub fn sphere_overlap(ca: Vec3, ra: f32, cb: Vec3, rb: f32) -> f32
pub fn sphere_overlap(ca: Vec3, ra: f32, cb: Vec3, rb: f32) -> f32
Sphere vs sphere intersection. Returns overlap depth (negative = no overlap).
Sourcepub fn point_in_cone(
target: Vec3,
origin: Vec3,
direction: Vec3,
half_angle_rad: f32,
range: f32,
) -> bool
pub fn point_in_cone( target: Vec3, origin: Vec3, direction: Vec3, half_angle_rad: f32, range: f32, ) -> bool
Cone hit test — used for directional attacks (breath, slam, sweep).
Returns true if target is inside a cone from origin pointing direction,
with half-angle half_angle_rad and max range range.
Sourcepub fn ray_vs_sphere(
ray_origin: Vec3,
ray_dir: Vec3,
sphere_center: Vec3,
sphere_radius: f32,
) -> Option<f32>
pub fn ray_vs_sphere( ray_origin: Vec3, ray_dir: Vec3, sphere_center: Vec3, sphere_radius: f32, ) -> Option<f32>
Raycast against a sphere. Returns distance to hit (None if miss).
Auto Trait Implementations§
impl Freeze for HitDetection
impl RefUnwindSafe for HitDetection
impl Send for HitDetection
impl Sync for HitDetection
impl Unpin for HitDetection
impl UnsafeUnpin for HitDetection
impl UnwindSafe for HitDetection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.