I'm making an RPG-style game, and it has a *lot* of UI.
I recently upgraded to 0.7.1, and I've been toying around with some UI optimizations. In the process, I discovered my per-tick call to CEGUI::System::getSingleton().injectTimePulse(..) was taking a lot of time. This function recurses through every CEGUI Window (i.e. every widget) that exists in your application, and calls Window::update(..). In my game, this was a significant bottleneck. I think this bottleneck was always around - not caused by the 0.7.1 upgrade.
Even though my game has a lot of UI, the vast majority of it is not visible at any given time. (A common trait of RPG games).
So, this optimization made a huge difference to the frame rate in my game:
Old Code:
(CEGUIWindow.cpp)
Code: Select all
void Window::update(float elapsed)
{
// ...
// update child windows
for (size_t i = 0; i < getChildCount(); ++i)
d_children[i]->update(elapsed);
}
New Code:
Code: Select all
void Window::update(float elapsed)
{
// ...
// update child windows
for (size_t i = 0; i < getChildCount(); ++i)
{
if ( d_children[i]->isVisible( true ) )
{
d_children[i]->update(elapsed);
}
}
}
Note the additional isVisible check.
This doesn't appear to have any bad side-effects in my testing, it just speeds everything up.