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:
Lioncash 2020-06-09 23:07:45 -04:00
parent 3d4f2d60eb
commit c285207f24
1 changed files with 13 additions and 14 deletions

View File

@ -26,8 +26,7 @@ CSceneNode::CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent)
CSceneNode::~CSceneNode() CSceneNode::~CSceneNode()
{ {
smNumNodes--; smNumNodes--;
for (auto it = mChildren.begin(); it != mChildren.end(); it++) DeleteChildren();
delete (*it);
} }
// ************ VIRTUAL ************ // ************ VIRTUAL ************
@ -69,8 +68,8 @@ void CSceneNode::OnLoadFinished()
{ {
PostLoad(); PostLoad();
for (auto it = mChildren.begin(); it != mChildren.end(); it++) for (auto* child : mChildren)
(*it)->OnLoadFinished(); child->OnLoadFinished();
} }
void CSceneNode::Unparent() void CSceneNode::Unparent()
@ -85,7 +84,7 @@ void CSceneNode::Unparent()
void CSceneNode::RemoveChild(CSceneNode *pChild) 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) if (*it == pChild)
{ {
@ -97,8 +96,8 @@ void CSceneNode::RemoveChild(CSceneNode *pChild)
void CSceneNode::DeleteChildren() void CSceneNode::DeleteChildren()
{ {
for (auto it = mChildren.begin(); it != mChildren.end(); it++) for (auto* child : mChildren)
delete *it; delete child;
mChildren.clear(); mChildren.clear();
} }
@ -317,8 +316,8 @@ void CSceneNode::ForceRecalculateTransform() const
// If so, the children will already be marked // If so, the children will already be marked
if (!_mTransformDirty) if (!_mTransformDirty)
{ {
for (auto it = mChildren.begin(); it != mChildren.end(); it++) for (auto* child : mChildren)
(*it)->MarkTransformChanged(); child->MarkTransformChanged();
} }
_mTransformDirty = false; _mTransformDirty = false;
} }
@ -327,8 +326,8 @@ void CSceneNode::MarkTransformChanged() const
{ {
if (!_mTransformDirty) if (!_mTransformDirty)
{ {
for (auto it = mChildren.begin(); it != mChildren.end(); it++) for (auto* child : mChildren)
(*it)->MarkTransformChanged(); child->MarkTransformChanged();
} }
_mTransformDirty = true; _mTransformDirty = true;
@ -355,7 +354,7 @@ CVector3f CSceneNode::AbsolutePosition() const
{ {
CVector3f ret = mPosition; CVector3f ret = mPosition;
if ((mpParent) && (InheritsPosition())) if (mpParent != nullptr && InheritsPosition())
ret += mpParent->AbsolutePosition(); ret += mpParent->AbsolutePosition();
return ret; return ret;
@ -365,7 +364,7 @@ CQuaternion CSceneNode::AbsoluteRotation() const
{ {
CQuaternion ret = mRotation; CQuaternion ret = mRotation;
if ((mpParent) && (InheritsRotation())) if (mpParent != nullptr && InheritsRotation())
ret *= mpParent->AbsoluteRotation(); ret *= mpParent->AbsoluteRotation();
return ret; return ret;
@ -375,7 +374,7 @@ CVector3f CSceneNode::AbsoluteScale() const
{ {
CVector3f ret = mScale; CVector3f ret = mScale;
if ((mpParent) && (InheritsScale())) if (mpParent != nullptr && InheritsScale())
ret *= mpParent->AbsoluteScale(); ret *= mpParent->AbsoluteScale();
return ret; return ret;