mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-13 16:16:08 +00:00
Use std::vector instead of std::list for RenderObject children
This commit is contained in:
parent
35c8086802
commit
300f326777
5 changed files with 18 additions and 70 deletions
|
@ -9328,7 +9328,7 @@ void Game::toggleKeyConfigMenu(bool f)
|
||||||
|
|
||||||
//group_keyConfig->children[group_keyConfig->children.size()-3]
|
//group_keyConfig->children[group_keyConfig->children.size()-3]
|
||||||
|
|
||||||
RenderObjectList::reverse_iterator i = group_keyConfig->children.rbegin();
|
RenderObject::Children::reverse_iterator i = group_keyConfig->children.rbegin();
|
||||||
AquariaKeyConfig *upright0 = (AquariaKeyConfig*)(*i);
|
AquariaKeyConfig *upright0 = (AquariaKeyConfig*)(*i);
|
||||||
i++;
|
i++;
|
||||||
AquariaKeyConfig *upright = (AquariaKeyConfig*)(*i);
|
AquariaKeyConfig *upright = (AquariaKeyConfig*)(*i);
|
||||||
|
|
|
@ -153,6 +153,9 @@ void ScriptedEntity::initEmitter(int emit, const std::string &file)
|
||||||
|
|
||||||
void ScriptedEntity::startEmitter(int emit)
|
void ScriptedEntity::startEmitter(int emit)
|
||||||
{
|
{
|
||||||
|
if(emit >= emitters.size())
|
||||||
|
return;
|
||||||
|
|
||||||
if (emitters[emit])
|
if (emitters[emit])
|
||||||
{
|
{
|
||||||
emitters[emit]->start();
|
emitters[emit]->start();
|
||||||
|
@ -161,6 +164,9 @@ void ScriptedEntity::startEmitter(int emit)
|
||||||
|
|
||||||
void ScriptedEntity::stopEmitter(int emit)
|
void ScriptedEntity::stopEmitter(int emit)
|
||||||
{
|
{
|
||||||
|
if(emit >= emitters.size())
|
||||||
|
return;
|
||||||
|
|
||||||
if (emitters[emit])
|
if (emitters[emit])
|
||||||
{
|
{
|
||||||
emitters[emit]->stop();
|
emitters[emit]->stop();
|
||||||
|
|
|
@ -1099,26 +1099,6 @@ void RenderObject::lookAt(const Vector &pos, float t, float minAngle, float maxA
|
||||||
rotation.interpolateTo(Vector(0,0,angle), t);
|
rotation.interpolateTo(Vector(0,0,angle), t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::removeAllChildren()
|
|
||||||
{
|
|
||||||
if (!children.empty())
|
|
||||||
{
|
|
||||||
removeChild(children.front());
|
|
||||||
removeAllChildren();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderObject::recursivelyRemoveEveryChild()
|
|
||||||
{
|
|
||||||
if (!children.empty())
|
|
||||||
{
|
|
||||||
RenderObject *child = (children.front());
|
|
||||||
child->recursivelyRemoveEveryChild();
|
|
||||||
removeChild(child);
|
|
||||||
recursivelyRemoveEveryChild();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderObject::update(float dt)
|
void RenderObject::update(float dt)
|
||||||
{
|
{
|
||||||
if (ignoreUpdate)
|
if (ignoreUpdate)
|
||||||
|
@ -1149,8 +1129,14 @@ void RenderObject::update(float dt)
|
||||||
|
|
||||||
void RenderObject::removeChild(RenderObject *r)
|
void RenderObject::removeChild(RenderObject *r)
|
||||||
{
|
{
|
||||||
children.remove(r);
|
|
||||||
r->parent = 0;
|
r->parent = 0;
|
||||||
|
Children::iterator oldend = children.end();
|
||||||
|
Children::iterator newend = std::remove(children.begin(), oldend, r);
|
||||||
|
if(oldend != newend)
|
||||||
|
{
|
||||||
|
children.resize(std::distance(children.begin(), newend));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
||||||
{
|
{
|
||||||
|
@ -1301,29 +1287,6 @@ void RenderObject::onUpdate(float dt)
|
||||||
// updateCullVariables();
|
// updateCullVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::propogateAlpha()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if (!shareAlphaWithChildren) return;
|
|
||||||
for (int i = 0; i < children.size(); i++)
|
|
||||||
{
|
|
||||||
children[i]->alpha = this->alpha * children[i]->parentAlphaModifier.getValue();
|
|
||||||
children[i]->propogateAlpha();
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
if (shareAlphaWithChildren && !children.empty())
|
|
||||||
{
|
|
||||||
for (int i = 0; i < children.size(); i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
//children[i]->alpha = this->alpha * children[i]->parentAlphaModifier.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderObject::unloadDevice()
|
void RenderObject::unloadDevice()
|
||||||
{
|
{
|
||||||
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
||||||
|
@ -1375,7 +1338,7 @@ void RenderObject::addChild(RenderObject *r, ParentManaged pm, RenderBeforeParen
|
||||||
if (order == CHILD_BACK)
|
if (order == CHILD_BACK)
|
||||||
children.push_back(r);
|
children.push_back(r);
|
||||||
else
|
else
|
||||||
children.push_front(r);
|
children.insert(children.begin(), r);
|
||||||
|
|
||||||
r->pm = pm;
|
r->pm = pm;
|
||||||
|
|
||||||
|
@ -1407,15 +1370,6 @@ void RenderObject::setOverrideCullRadius(float ovr)
|
||||||
overrideCullRadiusSqr = ovr * ovr;
|
overrideCullRadiusSqr = ovr * ovr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::propogateParentManagedStatic()
|
|
||||||
{
|
|
||||||
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
|
||||||
{
|
|
||||||
(*i)->pm = PM_STATIC;
|
|
||||||
(*i)->propogateParentManagedStatic();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderObject::isCoordinateInRadius(const Vector &pos, float r)
|
bool RenderObject::isCoordinateInRadius(const Vector &pos, float r)
|
||||||
{
|
{
|
||||||
Vector d = pos-getRealPosition();
|
Vector d = pos-getRealPosition();
|
||||||
|
|
|
@ -167,8 +167,6 @@ public:
|
||||||
|
|
||||||
void addChild(RenderObject *r, ParentManaged pm, RenderBeforeParent rbp = RBP_NONE, ChildOrder order = CHILD_BACK);
|
void addChild(RenderObject *r, ParentManaged pm, RenderBeforeParent rbp = RBP_NONE, ChildOrder order = CHILD_BACK);
|
||||||
void removeChild(RenderObject *r);
|
void removeChild(RenderObject *r);
|
||||||
void removeAllChildren();
|
|
||||||
void recursivelyRemoveEveryChild();
|
|
||||||
|
|
||||||
Vector getRealPosition();
|
Vector getRealPosition();
|
||||||
Vector getRealScale();
|
Vector getRealScale();
|
||||||
|
@ -279,7 +277,7 @@ public:
|
||||||
InterpolatedVector *positionSnapTo;
|
InterpolatedVector *positionSnapTo;
|
||||||
|
|
||||||
//DestroyType destroyType;
|
//DestroyType destroyType;
|
||||||
typedef std::list<RenderObject*> Children;
|
typedef std::vector<RenderObject*> Children;
|
||||||
Children children, childGarbage;
|
Children children, childGarbage;
|
||||||
|
|
||||||
//Flags flags;
|
//Flags flags;
|
||||||
|
@ -312,10 +310,6 @@ protected:
|
||||||
virtual void deathNotify(RenderObject *r);
|
virtual void deathNotify(RenderObject *r);
|
||||||
virtual void onEndOfLife() {}
|
virtual void onEndOfLife() {}
|
||||||
|
|
||||||
// spread parentManagedStatic flag to the entire child tree
|
|
||||||
void propogateParentManagedStatic();
|
|
||||||
void propogateAlpha();
|
|
||||||
|
|
||||||
inline void updateLife(float dt)
|
inline void updateLife(float dt)
|
||||||
{
|
{
|
||||||
if (decayRate > 0)
|
if (decayRate > 0)
|
||||||
|
|
|
@ -1144,16 +1144,10 @@ void SkeletalSprite::prevAnimation()
|
||||||
void SkeletalSprite::deleteBones()
|
void SkeletalSprite::deleteBones()
|
||||||
{
|
{
|
||||||
bones.clear();
|
bones.clear();
|
||||||
if (!children.empty())
|
for(Children::iterator it = children.begin(); it != children.end(); ++it)
|
||||||
{
|
{
|
||||||
// remove child had better be recursive
|
(*it)->safeKill();
|
||||||
Bone *b = (Bone*)children.front();
|
|
||||||
//removeChild(b);
|
|
||||||
b->destroy();
|
|
||||||
delete b;
|
|
||||||
deleteBones();
|
|
||||||
}
|
}
|
||||||
children.clear();
|
|
||||||
bones.clear();
|
bones.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue