CSceneNode: Collapse loops into ranged for loops
Where applicable, we can simplify some loops a little bit, migrating off the slightly more verbose iterator means of traversing standard containers.
This commit is contained in:
parent
3d4f2d60eb
commit
c285207f24
|
@ -26,8 +26,7 @@ CSceneNode::CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent)
|
|||
CSceneNode::~CSceneNode()
|
||||
{
|
||||
smNumNodes--;
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
delete (*it);
|
||||
DeleteChildren();
|
||||
}
|
||||
|
||||
// ************ VIRTUAL ************
|
||||
|
@ -69,8 +68,8 @@ void CSceneNode::OnLoadFinished()
|
|||
{
|
||||
PostLoad();
|
||||
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
(*it)->OnLoadFinished();
|
||||
for (auto* child : mChildren)
|
||||
child->OnLoadFinished();
|
||||
}
|
||||
|
||||
void CSceneNode::Unparent()
|
||||
|
@ -85,7 +84,7 @@ void CSceneNode::Unparent()
|
|||
|
||||
void CSceneNode::RemoveChild(CSceneNode *pChild)
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); ++it)
|
||||
{
|
||||
if (*it == pChild)
|
||||
{
|
||||
|
@ -97,8 +96,8 @@ void CSceneNode::RemoveChild(CSceneNode *pChild)
|
|||
|
||||
void CSceneNode::DeleteChildren()
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
delete *it;
|
||||
for (auto* child : mChildren)
|
||||
delete child;
|
||||
|
||||
mChildren.clear();
|
||||
}
|
||||
|
@ -317,8 +316,8 @@ void CSceneNode::ForceRecalculateTransform() const
|
|||
// If so, the children will already be marked
|
||||
if (!_mTransformDirty)
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
(*it)->MarkTransformChanged();
|
||||
for (auto* child : mChildren)
|
||||
child->MarkTransformChanged();
|
||||
}
|
||||
_mTransformDirty = false;
|
||||
}
|
||||
|
@ -327,8 +326,8 @@ void CSceneNode::MarkTransformChanged() const
|
|||
{
|
||||
if (!_mTransformDirty)
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
(*it)->MarkTransformChanged();
|
||||
for (auto* child : mChildren)
|
||||
child->MarkTransformChanged();
|
||||
}
|
||||
|
||||
_mTransformDirty = true;
|
||||
|
@ -355,7 +354,7 @@ CVector3f CSceneNode::AbsolutePosition() const
|
|||
{
|
||||
CVector3f ret = mPosition;
|
||||
|
||||
if ((mpParent) && (InheritsPosition()))
|
||||
if (mpParent != nullptr && InheritsPosition())
|
||||
ret += mpParent->AbsolutePosition();
|
||||
|
||||
return ret;
|
||||
|
@ -365,7 +364,7 @@ CQuaternion CSceneNode::AbsoluteRotation() const
|
|||
{
|
||||
CQuaternion ret = mRotation;
|
||||
|
||||
if ((mpParent) && (InheritsRotation()))
|
||||
if (mpParent != nullptr && InheritsRotation())
|
||||
ret *= mpParent->AbsoluteRotation();
|
||||
|
||||
return ret;
|
||||
|
@ -375,7 +374,7 @@ CVector3f CSceneNode::AbsoluteScale() const
|
|||
{
|
||||
CVector3f ret = mScale;
|
||||
|
||||
if ((mpParent) && (InheritsScale()))
|
||||
if (mpParent != nullptr && InheritsScale())
|
||||
ret *= mpParent->AbsoluteScale();
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue