diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index b2763d8045..6ef7bd79d8 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -262,22 +262,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) _selectedMeshes.onChange([this]() { selectionPropertyHasChanged(); }); addProperty(_selectedMeshes); - if (p.selectedMeshes.has_value()) { - const std::vector options = _selectedMeshes.options(); - std::set selectedNames; - - for (const std::string& s : *p.selectedMeshes) { - const auto it = std::find(options.begin(), options.end(), s); - if (it == options.end()) { - // The user has specified a mesh name that doesn't exist - LWARNING(fmt::format("Option '{}' not found in list of meshes", s)); - } - else { - selectedNames.insert(s); - } - } - _selectedMeshes = selectedNames; - } + _assetSelectedMeshes = p.selectedMeshes.value_or(_assetSelectedMeshes); } void RenderableDUMeshes::fillSelectionProperty() { @@ -318,6 +303,30 @@ bool RenderableDUMeshes::isReady() const { (!_renderingMeshesMap.empty() || (!_labelset.entries.empty())); } +void RenderableDUMeshes::initialize() { + bool success = loadData(); + if (!success) { + throw ghoul::RuntimeError("Error loading data"); + } + + fillSelectionProperty(); + + const std::vector options = _selectedMeshes.options(); + std::set selectedNames; + + for (const std::string& s : _assetSelectedMeshes) { + const auto it = std::find(options.begin(), options.end(), s); + if (it == options.end()) { + // The user has specified a mesh name that doesn't exist + LWARNING(fmt::format("Option '{}' not found in list of meshes", s)); + } + else { + selectedNames.insert(s); + } + } + _selectedMeshes = selectedNames; +} + void RenderableDUMeshes::initializeGL() { _program = DigitalUniverseModule::ProgramObjectManager.request( "RenderableDUMeshes", @@ -332,11 +341,6 @@ void RenderableDUMeshes::initializeGL() { ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); - bool success = loadData(); - if (!success) { - throw ghoul::RuntimeError("Error loading data"); - } - createMeshes(); if (_hasLabel) { @@ -690,8 +694,6 @@ bool RenderableDUMeshes::readSpeckFile() { } } } - - fillSelectionProperty(); setBoundingSphere(maxRadius); return true; diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index 3d6f991711..4e331daab5 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -56,6 +56,7 @@ public: explicit RenderableDUMeshes(const ghoul::Dictionary& dictionary); ~RenderableDUMeshes() override = default; + void initialize() override; void initializeGL() override; void deinitializeGL() override; @@ -118,6 +119,7 @@ private: bool _dataIsDirty = true; bool _textColorIsDirty = true; bool _hasLabel = false; + std::vector _assetSelectedMeshes; properties::Vec3Property _textColor; properties::FloatProperty _textOpacity;