Cleanup Node

This commit is contained in:
2020-10-17 00:53:30 +02:00
parent aea890971b
commit d50a14f9c9
3 changed files with 159 additions and 153 deletions

View File

@@ -1,3 +1,9 @@
/*
* 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"
@@ -9,8 +15,10 @@ namespace openVulkanoCpp
{
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)