Fix collision detection by calculating positive penetration depth.#949
Fix collision detection by calculating positive penetration depth.#949ak-1 wants to merge 1 commit intobevyengine:masterfrom ak-1:fix_collide
Conversation
|
To reproduce the issue play breakout with the following change applied: --- a/examples/game/breakout.rs
+++ b/examples/game/breakout.rs
@@ -59,7 +59,7 @@ fn setup(
.spawn(SpriteBundle {
material: materials.add(Color::rgb(1.0, 0.5, 0.5).into()),
transform: Transform::from_translation(Vec3::new(0.0, -50.0, 1.0)),
- sprite: Sprite::new(Vec2::new(30.0, 30.0)),
+ sprite: Sprite::new(Vec2::new(100.0, 100.0)),
..Default::default()
})
.with(Ball {Here is a demo: https://ibb.co/bHr8LHq |
|
The fix in this pr definitely solves the issue in question. I can reproduce the error shown in the video and the pr resolves it, but I think flipping the sign just shifts the problem elsewhere (in a way that is more favorable for the breakout example). I think the core issue is that the penetration depth is a signed comparison, when it should really be absolute. Applying this change instead both resolves the bug in the demo video and resolves a bunch of other collision jank. Can we adjust this pr to do that instead? |
|
Looks good to me. I wanted to update this PR but closed it accidentaly and was not able to re-open it. #966 is the followup. |

I had an issue with collision detection not working properly. Changing in collide_aabb the calculation of the penetration depth (making it a positive value) fixed it for me.