| Zombie simulator: a milestone |
|
| Thursday, 07 January 2010 12:00 |
|
I've reached somewhat of a milestone with the addition of doors and windows. I've now got a rudimentary world with most of the necessary structure in place to incrementally improve on it from here. Another new feature is the clickable mini-map in the upper right corner to make navigation speedier. I've also run some tests with different sized worlds, scaling up to a size of 256 x 256 map squares. This worked out to approximately 2,200 separate buildings, with about 1/3rd of them four story office blocks. The overall frame rate was still reasonable, running at about 90fps to 150fps depening on the amount of on-screen detail. Total memory usage was about 150MB for a map of this size.
Code profilingI tried out code::blocks' code profiler (it actually uses GProf), trying to see if there was anything I could easily change in order to improve the engine's performance. First results showed a call to retrieve the camera's transform matrix was was chewing up about 5% of CPU time because it was being done repeatedly. The quick fix was simply to cache the value whenever the camera position changed. The next problem that showed up was that the polygon culling function, isTriangleVisible, was chewing up about 15% of CPU time. It was at this point that I realised that this function was largely redundant since I'd switched to culling buildings before rendering. Removing the code for this gave an immediate 100% performance improvement, but the code will still be useful. I'll add it back in for culling polygons on buildings that are at the edge of the camera view, which should squeeze out a few more percentage points. At this stage, I don't want to go too far into performance tweaking because there's still lots to do and the fixes I make now could be wiped away with future changes. What's nextThe city is looking pretty plain, the buildings are all the same, using the same dull, repetitive texture. What's next on the agenda is getting the props and sprites to appear in the city, then I can worry about prettifying. blog comments powered by Disqus |

