mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 03:00:58 -06:00
Correctly deinitialize scenegraph nodes that are added at runtime
This commit is contained in:
@@ -84,12 +84,6 @@ public:
|
||||
Scene(std::unique_ptr<SceneInitializer> initializer);
|
||||
virtual ~Scene() override;
|
||||
|
||||
/**
|
||||
* Clear the scene graph,
|
||||
* i.e. set the root node to nullptr and deallocate all scene graph nodes.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Attach node to the root
|
||||
*/
|
||||
|
||||
@@ -685,20 +685,6 @@ void OpenSpaceEngine::loadAssets() {
|
||||
global::windowDelegate->setBarrier(true);
|
||||
};
|
||||
|
||||
if (_scene) {
|
||||
ZoneScopedN("Reset scene")
|
||||
|
||||
global::syncEngine->removeSyncables(global::timeManager->syncables());
|
||||
if (_scene && _scene->camera()) {
|
||||
global::syncEngine->removeSyncables(_scene->camera()->syncables());
|
||||
}
|
||||
global::renderEngine->setScene(nullptr);
|
||||
global::renderEngine->setCamera(nullptr);
|
||||
global::navigationHandler->setCamera(nullptr);
|
||||
_scene->clear();
|
||||
global::rootPropertyOwner->removePropertySubOwner(_scene.get());
|
||||
}
|
||||
|
||||
std::unique_ptr<SceneInitializer> sceneInitializer;
|
||||
if (global::configuration->useMultithreadedInitialization) {
|
||||
unsigned int nAvailableThreads = std::min(
|
||||
|
||||
@@ -108,7 +108,18 @@ Scene::Scene(std::unique_ptr<SceneInitializer> initializer)
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
clear();
|
||||
LINFO("Clearing current scene graph");
|
||||
for (SceneGraphNode* node : _topologicallySortedNodes) {
|
||||
if (node->identifier() == "Root") {
|
||||
continue;
|
||||
}
|
||||
// There might still be scene graph nodes around that weren't removed by the asset
|
||||
// manager as they would have been added manually by the user. This also serves as
|
||||
// a backstop for assets that forgot to implement the onDeinitialize functions
|
||||
node->deinitializeGL();
|
||||
node->deinitialize();
|
||||
}
|
||||
_rootDummy.clearChildren();
|
||||
_rootDummy.setScene(nullptr);
|
||||
}
|
||||
|
||||
@@ -309,11 +320,6 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) {
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::clear() {
|
||||
LINFO("Clearing current scene graph");
|
||||
_rootDummy.clearChildren();
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, SceneGraphNode*>& Scene::nodesByIdentifier() const {
|
||||
return _nodesByIdentifier;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user