diff --git a/src/Core/Scene/CSceneNode.cpp b/src/Core/Scene/CSceneNode.cpp index 4260a5ef..132c8f8c 100644 --- a/src/Core/Scene/CSceneNode.cpp +++ b/src/Core/Scene/CSceneNode.cpp @@ -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;