Fix collision detection by calculating positive penetration depth. (#966)
This commit is contained in:
parent
ef99e59469
commit
0b818d7b32
@ -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
|
// if we had an "x" and a "y" collision, pick the "primary" side using penetration depth
|
||||||
match (x_collision, y_collision) {
|
match (x_collision, y_collision) {
|
||||||
(Some(x_collision), Some(y_collision)) => {
|
(Some(x_collision), Some(y_collision)) => {
|
||||||
if y_depth < x_depth {
|
if y_depth.abs() < x_depth.abs() {
|
||||||
Some(y_collision)
|
Some(y_collision)
|
||||||
} else {
|
} else {
|
||||||
Some(x_collision)
|
Some(x_collision)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user