Well, it's been a couple of days of pain.
I added in the ability to handle multiple cars and create them like sprites, causing the engine's frame rate drop alarmingly.
I've been able to work through it though, sprites have been merged into a couple of mesh buffers allowing me to have thousands of billboards with little performance affect.
I also found a work around for the slowdown caused by Irrlicht setting all material properties for every mesh buffer for every scene node. That alone had eaten up about 20% of the frame rate because of the number of meshbuffers I'm using, but the solution is pretty specific to my implementation, so don't get excited.
Finally, the big performance killer turned out to be toOpenGLColor(), which ate about 44% of the frame rate for nothing more than converting DirectX colours (Irrlicht internal) to OpenGL format, for every vertex, for every frame. I've got a sort of work-around which halved the performance hit to about 21%, you need to change the function in SColor.h to
Code: Select all
void toOpenGLColor(u8* dest) const
{
if (color == 0xFFFFFFFF) *((u32*) dest) = 0xFFFFFFFF;
else {
*dest = (u8)getRed();
*++dest = (u8)getGreen();
*++dest = (u8)getBlue();
*++dest = (u8)getAlpha();
}
}
But the code is only faster if most of your objects have all white vertices. It'll be slower if you use colours extensively. It basically just checks if the colour to convert is all white, and if it is simply assigns it rather than mess around. It would be better if this function were not used at all though.
Anyway, the gory details are on the blog and I'm back on track with a frame rate measured in hundreds rather than dozens.