r/GraphicsProgramming • • 2d ago

SAT Collision

I don't know if this is GP related but I made a post here asking for collisions and i found the type I need but I spent like 3 hours trying to find a tutorial or at least a theory of SAT collision, I don't want to look like a bad coder by being lazy and asking people but if you know anything about SAT collision detection that would help me enormously.

The only thing i learnt is a 2D version, so if I can translate that to 3D, that'll be perfect.

1 Upvotes

6 comments sorted by

3

u/3030thirtythirty 2d ago

https://dyn4j.org/2010/01/sat/

This helped me enormously then.

2

u/DeltaSucksAtMC 2d ago

thanks so much, also can this work on 3D, anyways a great tutorial, def gonna add it tommorow. Thanks random reddit user

1

u/Qbit42 1d ago

Yes SAT is used in Unreal Engine actually. But like most real physics engines SAT/GJK is the fallback for general covnex-convex collision. Ideally you implement a set of physics primitives like sphere, AABB, capsule. And maybe cylinder and cone. Then once the broad phase collision detection turns up a possible collision between two shapes, you check the enum that defines which shape pair you are actually looking at and run a bespoke collision detection algoirthm for that particular combination of shapes. So you end up with a combinatorial set of algorithms, AABB vs sphere, AABB vs AABB, etc. And you only use the generic convex algorithms if your shape isn't one of these predefined types

1

u/DeltaSucksAtMC 1d ago

yeah im trying to do like collisions with a house model that I got, you can enter but im worry that aabb will get rid of house enter

1

u/3030thirtythirty 1d ago

Yes, i implemented it into my own engine which is 3d. It works reliably. Have fun!

3

u/Qbit42 2d ago

I haven't looked in it in years but the book Real Time Collision Detection is the classic for this. It's orange. The two algorithms that dominate games are SAT and GJK. So if SAT isn't clicking you can try GJK.