From 7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Thu, 29 Dec 2016 19:03:16 -0200 Subject: Parent/child optimization implemented And others bugfixes. --- Project/Element.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Project/Element.cpp') diff --git a/Project/Element.cpp b/Project/Element.cpp index 4de5ebd..85280d6 100644 --- a/Project/Element.cpp +++ b/Project/Element.cpp @@ -456,6 +456,23 @@ void Element::ReplaceParent(Element* oldParent, Element* newParent) } } +void Element::AddChild(Element* child) { m_childList.push_back(child); } + +void Element::RemoveChild(Element* child) +{ + for(auto it = m_childList.begin(); it != m_childList.end(); ++it) { + Element* element = *it; + if(element == child) m_childList.erase(it--); + } +} + +void Element::ReplaceChild(Element* oldChild, Element* newChild) +{ + for(int i = 0; i < (int)m_childList.size(); i++) { + if(m_childList[i] == oldChild) m_childList[i] = newChild; + } +} + void OpenGLColour::SetRGBA(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) { rgba[0] = red; -- cgit