1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-09 13:24:01 +00:00

very minor perf thing: skip some RenderObject child checks when there are no children

This commit is contained in:
fgenesis 2024-07-13 06:48:30 +02:00
parent 1573eea051
commit a046038c33

View file

@ -749,40 +749,43 @@ void RenderObject::onUpdate(float dt)
internalOffset.update(dt); internalOffset.update(dt);
rotationOffset.update(dt); rotationOffset.update(dt);
bool hasChildrenToDelete = false; if(!children.empty())
for (Children::iterator i = children.begin(); i != children.end(); i++)
{ {
if (shareAlphaWithChildren) bool hasChildrenToDelete = false;
(*i)->alpha.x = this->alpha.x; for (Children::iterator i = children.begin(); i != children.end(); i++)
if (shareColorWithChildren)
(*i)->color = this->color;
if ((*i)->pm != PM_NONE)
{ {
(*i)->update(dt); if (shareAlphaWithChildren)
} (*i)->alpha.x = this->alpha.x;
hasChildrenToDelete |= (*i)->_markedForDelete; if (shareColorWithChildren)
(*i)->color = this->color;
} if ((*i)->pm != PM_NONE)
if (hasChildrenToDelete)
{
size_t w = 0;
const size_t N = children.size();
for (size_t i = 0; i < N; ++i)
{
RenderObject *ro = children[i];
if(ro->_markedForDelete)
{ {
ro->parent = NULL; (*i)->update(dt);
ro->destroy();
if(ro->pm == PM_POINTER)
delete ro;
} }
else hasChildrenToDelete |= (*i)->_markedForDelete;
children[w++] = ro;
}
if (hasChildrenToDelete)
{
size_t w = 0;
const size_t N = children.size();
for (size_t i = 0; i < N; ++i)
{
RenderObject *ro = children[i];
if(ro->_markedForDelete)
{
ro->parent = NULL;
ro->destroy();
if(ro->pm == PM_POINTER)
delete ro;
}
else
children[w++] = ro;
}
children.resize(w);
} }
children.resize(w);
} }
if (MotionBlurData *mb = this->motionBlur) if (MotionBlurData *mb = this->motionBlur)