Sunday, June 22, 2008

Extinctathon: the long road ahead

I've spent the last week preparing my code for broadphase collision detection using a sweep and prune algorithm. I'm working on the actual sweep and prune process now, but getting it to work at a reasonable speed on the XBox seems like it's going to be an uphill battle. I'll be working on it for at least another week, and hopefully by that point I won't have decided to give up and focus solely on the PC.

I read an excellent article by John Wells on the topic of broadphase collision detection particularly geared towards optimizations for the XBox 360 (bit of a refresher: my game currently uses the most naive collision detection algorithm in the universe, checking every object with every other object, i.e. a O(n²) algorithm which absolutely breaks down on the 360 after five or six enemies are present). The two main goals are elimination of cases, i.e. testing the fewest possible number of collisions by implementing some rather simple logic, and the avoidance of garbage. The XBox 360 hates garbage. When you create heap-based objects, it spits in your face. It slows to a crawl. It writes goth poetry. It doesn't like new objects.

The first issue, the elimination of unneccessary cases, is easy enough to do. I'm still working on it, but I can finish it in a day or two. The second part, however, is far more complicated (to me) because it involves lots of C# functions (and even syntax) that I've never before seen. I need to learn how to do it, but it's rather complicated. I'll have to work on it later.

I'll post some more of the details a bit later when I have more time.

No comments: