Handmade Hero»Forums»Game
Jason Bricco
2 posts
Collision Detection
Edited by Jason Bricco on Reason: Initial post
Hi all,

I’m wondering if Casey does any work with collision detection past day 130 (that’s where I’m at right now). Judging by the titles of the videos to come, I am under the impression he doesn’t and in fact removed the need for collision detection entirely somewhere around day 270 with a cell-based movement system.

If that’s true, it’s unfortunate. I was looking forward to seeing an implementation of a more robust collision system. I’ve been trying to extend the one I learned from day 30-50ish to 3D and find myself constantly stuck on walls and such. And it’s quite hard (for me anyway) to find resources online to learn this stuff.

Assuming Casey isn’t going to do this, if anyone has any advice/resources for learning to do proper 3D collision ‘and response’ (smoothly sliding for example), I’d greatly appreciate it. Even if it’s just for AABB collision!

Thanks a lot.
Oliver Marsh
193 posts / 1 project
Olster1.github.io
Collision Detection
Edited by Oliver Marsh on
Hi Jason,

From as far as I know he doesn't do any more on the collision detection.

https://handmade.network/forums/t..._implementation_and_visualization

This post talks about a common implementation for collision detection. It's GJK which gives you a yes/no answer whether two polygons are colliding, then EPA gives you the resolution vector so your not colliding anymore. Casey did a great video on GJK . The great thing about the algorithm is that your less likely to get stuck in walls, since it isn't continuous, it just gives you the answer at a snapshot in time. Whereas in the approach on handmade hero, once your in the shape, it's hard to get out of. (You cast your velocity vector on the inside of the walls.)

For collision response (i.e. sliding on the walls), I found Chris Hecker's physics articles really good . Part 3 has the collision response equations. The one in handmade hero is similar to the one without angular response (linear), and to get sliding you just have a coefficient of restitution of zero, and one for bouncy walls.

Ian Parberry & Feltcher Dunn's Math Primer book also has the derivation of the equations (which I found a bit easier to understand).

NOTE: With the angular collision response, you need the point in space where the collision occurred. GJK/EPA doesn't give you this info as far as I know. I'm not sure this best way to get this. I found casting a ray after resolving the collision in the opposite direction as the resolution vector could be used.