PurpleKingdomGames / indigo

An FP game engine for Scala.
https://indigoengine.io/
MIT License
648 stars 60 forks source link

Consider switching to Separating Axis Theorem for collision checks #757

Open davesmith00000 opened 4 months ago

davesmith00000 commented 4 months ago

Narrow phase bounds checks are currently done using different methods for the two shapes, and special cased when the two collide (which won't scale).

Since all our shapes are axis aligned, generalising to use SAT collision checks should be pretty straightforward, and I think it will give us the restitution values for free, regarding the other open ticket around box corner collisions.

Proposed approach is in two stages:

Stage 1

Produce a demo that implements separating axis theorem - it could even be a fun visual demo! No need to worry about the details of integrating it into the engine at this stage because...

Stage 2

We do the engine integration. However this might depend on the ticket about collision pairs.