Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physics: Collision resolution fails and is not robust #575

Open
kpreid opened this issue Jan 28, 2025 · 0 comments
Open

Physics: Collision resolution fails and is not robust #575

kpreid opened this issue Jan 28, 2025 · 0 comments
Labels
area: simulation Things related to what can happen in the world as time progresses. kind: bug Something isn't working as it should

Comments

@kpreid
Copy link
Owner

kpreid commented Jan 28, 2025

We currently define body collision in terms of self.collision_box translated by self.position. The problem with this definition is that rounding error means that it is difficult for collision detection to achieve the specific absolute positions of the box's faces that definitely don’t collide with any block, because after picking a value for self.position, the resulting translated collision box then has
rounding error. nudge_on_ray() tries to fix this during collision resolution, but doesn’t succeed sometimes.

I think we can solve this problem by defining a collision box in absolute coordinates, which can be computed sometimes-exactly to
ensure they land on the correct side of surfaces collided with. As a brute-force strategy, we can always slightly squish the box to
compensate for rounding errors that lead to intersection. Then, by also keeping the original relative-coordinate collision box, we can restore the intended shape when no collision occurs.

Commit 8b74029 implements the first part of this, by adding the absolute collision box (named occupying). However, I still need to actually make it used in this way; right now it is only written, not read.

Blocking #272.

@kpreid kpreid added area: simulation Things related to what can happen in the world as time progresses. kind: bug Something isn't working as it should labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: simulation Things related to what can happen in the world as time progresses. kind: bug Something isn't working as it should
Projects
None yet
Development

No branches or pull requests

1 participant