Devember Day 4 - GJK Collision Detection

by Tim Liou • in misc • on Dec. 04, 2015

Today's code is on this tag. The complete code can be found in here.

Yesterday, I use player_info to deal with multiplayer problem. Today, I spend a while thinking more harder. I realize that it may be a good time to bring the concept of entity into the code.

struct entity
{
    b32 Exist;
    entity_type Type;
    v2 ddP;
    v2 dP;
    v2 P;
    v2 WidthHeight;
    b32 Collide;
};

Following is about collision detection. I use well-known GJK algorithm. You can learn how it work via Casey's video and William Bittle's post. I might write a separate post to explan GJK in chinese.

Anyway, here is what it looks like.

Really cool, right?

Tomorrow, I will make entities truly collide with each others. Until then.