Thursday 31 May 2012

Even Simpler!!!

I was just thinking about the hashing function when I realized...I can make my life even SIMPLER! Scrap the hashing altogether. At the beginning of the game, I check the dynamic objects positions against all the tunnel segments, I get the index of that segment and store it. THAT is the main index I need to check against, every frame I only ever check against the one that the dynamic object is at, the one before and the one after. After that I check to see which of those three I am nearest to and use that one as the main segment. This way, I only ever check against 3 segments and I adjust which is the main one accordingly moving up and down the list of segments as needed!!

This is what I was hoping to achieve when I first started thinking about how to deal with the collision detection, now finally after a round about through octrees and hash tables, I've got the best/simplest method I can think of that is the least demanding. With a few clever tweaks I can even spread the collision checks to have it check only the tunnel segment I am most likely to be colliding with, reducing the checks to 1-2 max per frame per dynamic object!

No comments:

Post a Comment