dimforge / ncollide

2 and 3-dimensional collision detection library in Rust.
https://ncollide.org
Apache License 2.0
921 stars 105 forks source link

2D - Simple collision detection/resolution fails in a certain case #333

Closed RybekU closed 4 years ago

RybekU commented 4 years ago

Discussion and analysis of the cause is on discord in the #ncollide channel. A picture (in this case gif) is worth 100s words: QQ7VEnrNjv The root cause is in the EPA algorithm for 2D implementation (0 dimensions of simplex).

Bug can be reproduced in this below branch of my repository. Try to overlap edges of another rectangle while being under it. obraz Gray is the rectangle you move as, red is the corners you can reproduce the bug on. The information printed on console when this bug occurs can be configured in this file: https://github.com/RybekU/Slimeu/blob/ncollide_bug/src/phx/collision/detection.rs#L51 Movement with WASD keys, run with cargo run --features debug-info to see hitboxes (sprite is just a transparent rectangle).