Fix collision detection by calculating positive penetration depth. (#966)

This commit is contained in:
Andre Kuehne 2020-12-01 09:33:52 +01:00 committed by GitHub
parent ef99e59469
commit 0b818d7b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,7 @@ pub fn collide(a_pos: Vec3, a_size: Vec2, b_pos: Vec3, b_size: Vec2) -> Option<C
// if we had an "x" and a "y" collision, pick the "primary" side using penetration depth
match (x_collision, y_collision) {
(Some(x_collision), Some(y_collision)) => {
if y_depth < x_depth {
if y_depth.abs() < x_depth.abs() {
Some(y_collision)
} else {
Some(x_collision)