/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include "Drawable.hpp" #include "Scene.hpp" namespace openVulkanoCpp { namespace Scene { void Drawable::SetScene(Scene* scene) { if (this->scene == scene) return; if (scene && this->scene) throw std::runtime_error("Drawable has been associated with a scene already!"); const auto oldScene = this->scene; this->scene = scene; if(scene) scene->RegisterDrawable(this); else if (oldScene) oldScene->RemoveDrawable(this); } void Drawable::RemoveNode(Node* node) { Utils::Remove(nodes, node); if (nodes.empty()) { scene = nullptr; scene->RemoveDrawable(this); } } } }