Collision Detection Needs Work
Opened this issue · 1 comments
BKaperick commented
There are a few issues with how collisions are currently handled:
- We oversample currently to reduce the maximum magnitude of overlap in any collisions occuring on the most recent time step, so we need to add in one additional step of self.time_disc - dt before update() is done so that each frame represents a consistent unit of time.
- Magnitude is not being reduced
BKaperick commented
This is currently no longer an issue. The biggest collision issue that occurs now is objects passing through each other when they move past each other in between the current time discretization.
One solution for this would be to:
- Run the full simulation to predefined length at predefined time step.
- Keep track of the fastest moving object (MAX_SPEED) and the smallest width object (SHORTEST_WIDTH).
- Re run simulation with a time discretization small enough to ensure an object attaining this MAX_SPEED will travel at most SHORTEST_WIDTH.
(i.e. DT = SHORTEST_WIDTH / MAX_SPEED)
I suspect this would be a very safe choice of time step since an object is likely to attain its max speed after failing a collision check (e.g. object escapes the frame and accelerates freely until the simulation finishes)