From 218a4c142c84b0d3443619855a00889a3181916b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 6 Apr 2013 19:48:48 +0200 Subject: [PATCH] SceneGraph: fixed Object::setClean(). Now also all non-clean parent objects are cleaned. --- src/SceneGraph/Object.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/SceneGraph/Object.hpp b/src/SceneGraph/Object.hpp index 5855813ef..15b659aab 100644 --- a/src/SceneGraph/Object.hpp +++ b/src/SceneGraph/Object.hpp @@ -321,6 +321,22 @@ template void Object::setClean(std::vector /* No dirty objects left, done */ if(objects.empty()) return; + /* Add non-clean parents to the list. Mark each added object as visited, so + they aren't added more than once */ + for(std::size_t end = objects.size(), i = 0; i != end; ++i) { + Object* o = objects[i]; + o->flags |= Flag::Visited; + + Object* parent = o->parent(); + while(parent && !(parent->flags & Flag::Visited) && parent->isDirty()) { + objects.push_back(parent); + parent = parent->parent(); + } + } + + /* Cleanup all marks */ + for(auto o: objects) o->flags &= ~Flag::Visited; + /* Compute absolute transformations */ Scene* scene = objects[0]->scene(); CORRADE_ASSERT(scene, "Object::setClean(): objects must be part of some scene", );