mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-03 18:14:01 +00:00
remove RenderObject::childGarbage
This commit is contained in:
parent
140f750d00
commit
06270eaac0
2 changed files with 21 additions and 30 deletions
|
@ -137,6 +137,7 @@ RenderObject::RenderObject()
|
|||
idx = -1;
|
||||
_fv = false;
|
||||
_fh = false;
|
||||
_markedForDelete = false;
|
||||
updateCull = -1;
|
||||
|
||||
layer = LR_NONE;
|
||||
|
@ -385,12 +386,6 @@ void RenderObject::destroy()
|
|||
texture = NULL;
|
||||
}
|
||||
|
||||
const RenderObject &RenderObject::operator=(const RenderObject &r)
|
||||
{
|
||||
errorLog("Operator= not defined for RenderObject. Use 'copyProperties'");
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector RenderObject::getRealPosition()
|
||||
{
|
||||
if (parent)
|
||||
|
@ -833,18 +828,6 @@ void RenderObject::removeChild(RenderObject *r)
|
|||
}
|
||||
}
|
||||
|
||||
void RenderObject::enqueueChildDeletion(RenderObject *r)
|
||||
{
|
||||
if (r->parent == this)
|
||||
{
|
||||
// Don't garbage a child more than once
|
||||
for (size_t i = 0; i < childGarbage.size(); ++i)
|
||||
if(childGarbage[i] == r)
|
||||
return;
|
||||
childGarbage.push_back(r);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderObject::safeKill()
|
||||
{
|
||||
alpha = 0;
|
||||
|
@ -858,8 +841,7 @@ void RenderObject::safeKill()
|
|||
|
||||
if (this->parent)
|
||||
{
|
||||
parent->enqueueChildDeletion(this);
|
||||
|
||||
_markedForDelete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -920,6 +902,7 @@ void RenderObject::onUpdate(float dt)
|
|||
beforeScaleOffset.update(dt);
|
||||
rotationOffset.update(dt);
|
||||
|
||||
bool hasChildrenToDelete = false;
|
||||
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
if (shareAlphaWithChildren)
|
||||
|
@ -931,17 +914,27 @@ void RenderObject::onUpdate(float dt)
|
|||
{
|
||||
(*i)->update(dt);
|
||||
}
|
||||
hasChildrenToDelete |= (*i)->_markedForDelete;
|
||||
|
||||
}
|
||||
|
||||
if (!childGarbage.empty())
|
||||
if (hasChildrenToDelete)
|
||||
{
|
||||
for (Children::iterator i = childGarbage.begin(); i != childGarbage.end(); i++)
|
||||
size_t w = 0;
|
||||
const size_t N = children.size();
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
{
|
||||
removeChild(*i);
|
||||
(*i)->destroy();
|
||||
delete (*i);
|
||||
RenderObject *ro = children[i];
|
||||
if(ro->_markedForDelete)
|
||||
{
|
||||
ro->parent = NULL;
|
||||
ro->destroy();
|
||||
delete ro;
|
||||
}
|
||||
else
|
||||
children[w++] = ro;
|
||||
}
|
||||
childGarbage.clear();
|
||||
children.resize(w);
|
||||
}
|
||||
|
||||
if (MotionBlurData *mb = this->motionBlur)
|
||||
|
|
|
@ -240,6 +240,7 @@ public:
|
|||
bool _dead;
|
||||
bool _hidden;
|
||||
bool _fv, _fh;
|
||||
bool _markedForDelete;
|
||||
|
||||
unsigned char pm; // unsigned char to save space
|
||||
|
||||
|
@ -280,7 +281,7 @@ public:
|
|||
// ----------------------
|
||||
|
||||
typedef std::vector<RenderObject*> Children;
|
||||
Children children, childGarbage;
|
||||
Children children;
|
||||
|
||||
protected:
|
||||
RenderObject *parent;
|
||||
|
@ -307,9 +308,6 @@ protected:
|
|||
size_t idx; // index in layer
|
||||
StateData *stateData;
|
||||
MotionBlurData *motionBlur;
|
||||
|
||||
private:
|
||||
void enqueueChildDeletion(RenderObject *r);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue