From 302a741764ebb935704b5719b19780e5fc176c8f Mon Sep 17 00:00:00 2001 From: CobaltXII Date: Tue, 1 Jan 2019 12:10:18 -0500 Subject: [PATCH] Implemented float hitbox_x_depth --- src/inc/hitbox.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/inc/hitbox.hpp b/src/inc/hitbox.hpp index 2a3d1ec..bdc0429 100644 --- a/src/inc/hitbox.hpp +++ b/src/inc/hitbox.hpp @@ -42,3 +42,19 @@ inline bool hitbox_intersect(hitbox a, hitbox b) (a.z <= b.z + b.zr && a.z + a.zr >= b.z) ); } + +// Get the X depth of two intersecting hitboxes. + +#define eps 0.00128f + +float hitbox_x_depth(hitbox a, hitbox b) +{ + if (a.x + a.xr > b.x + b.xr) + { + return (b.x + b.xr) - a.x + eps; + } + else + { + return b.x - (a.x + a.xr) - eps; + } +}