mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-09 13:24: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;
|
idx = -1;
|
||||||
_fv = false;
|
_fv = false;
|
||||||
_fh = false;
|
_fh = false;
|
||||||
|
_markedForDelete = false;
|
||||||
updateCull = -1;
|
updateCull = -1;
|
||||||
|
|
||||||
layer = LR_NONE;
|
layer = LR_NONE;
|
||||||
|
@ -385,12 +386,6 @@ void RenderObject::destroy()
|
||||||
texture = NULL;
|
texture = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RenderObject &RenderObject::operator=(const RenderObject &r)
|
|
||||||
{
|
|
||||||
errorLog("Operator= not defined for RenderObject. Use 'copyProperties'");
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector RenderObject::getRealPosition()
|
Vector RenderObject::getRealPosition()
|
||||||
{
|
{
|
||||||
if (parent)
|
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()
|
void RenderObject::safeKill()
|
||||||
{
|
{
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
|
@ -858,8 +841,7 @@ void RenderObject::safeKill()
|
||||||
|
|
||||||
if (this->parent)
|
if (this->parent)
|
||||||
{
|
{
|
||||||
parent->enqueueChildDeletion(this);
|
_markedForDelete = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -920,6 +902,7 @@ void RenderObject::onUpdate(float dt)
|
||||||
beforeScaleOffset.update(dt);
|
beforeScaleOffset.update(dt);
|
||||||
rotationOffset.update(dt);
|
rotationOffset.update(dt);
|
||||||
|
|
||||||
|
bool hasChildrenToDelete = false;
|
||||||
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
||||||
{
|
{
|
||||||
if (shareAlphaWithChildren)
|
if (shareAlphaWithChildren)
|
||||||
|
@ -931,17 +914,27 @@ void RenderObject::onUpdate(float dt)
|
||||||
{
|
{
|
||||||
(*i)->update(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);
|
RenderObject *ro = children[i];
|
||||||
(*i)->destroy();
|
if(ro->_markedForDelete)
|
||||||
delete (*i);
|
{
|
||||||
|
ro->parent = NULL;
|
||||||
|
ro->destroy();
|
||||||
|
delete ro;
|
||||||
}
|
}
|
||||||
childGarbage.clear();
|
else
|
||||||
|
children[w++] = ro;
|
||||||
|
}
|
||||||
|
children.resize(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MotionBlurData *mb = this->motionBlur)
|
if (MotionBlurData *mb = this->motionBlur)
|
||||||
|
|
|
@ -240,6 +240,7 @@ public:
|
||||||
bool _dead;
|
bool _dead;
|
||||||
bool _hidden;
|
bool _hidden;
|
||||||
bool _fv, _fh;
|
bool _fv, _fh;
|
||||||
|
bool _markedForDelete;
|
||||||
|
|
||||||
unsigned char pm; // unsigned char to save space
|
unsigned char pm; // unsigned char to save space
|
||||||
|
|
||||||
|
@ -280,7 +281,7 @@ public:
|
||||||
// ----------------------
|
// ----------------------
|
||||||
|
|
||||||
typedef std::vector<RenderObject*> Children;
|
typedef std::vector<RenderObject*> Children;
|
||||||
Children children, childGarbage;
|
Children children;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RenderObject *parent;
|
RenderObject *parent;
|
||||||
|
@ -307,9 +308,6 @@ protected:
|
||||||
size_t idx; // index in layer
|
size_t idx; // index in layer
|
||||||
StateData *stateData;
|
StateData *stateData;
|
||||||
MotionBlurData *motionBlur;
|
MotionBlurData *motionBlur;
|
||||||
|
|
||||||
private:
|
|
||||||
void enqueueChildDeletion(RenderObject *r);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue