mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 14:29:03 -06:00
Load spaeck file in initialize instead of initialiseGL
This commit is contained in:
@@ -262,22 +262,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
|
||||
_selectedMeshes.onChange([this]() { selectionPropertyHasChanged(); });
|
||||
addProperty(_selectedMeshes);
|
||||
|
||||
if (p.selectedMeshes.has_value()) {
|
||||
const std::vector<std::string> options = _selectedMeshes.options();
|
||||
std::set<std::string> 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<std::string> options = _selectedMeshes.options();
|
||||
std::set<std::string> 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;
|
||||
|
||||
@@ -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<std::string> _assetSelectedMeshes;
|
||||
|
||||
properties::Vec3Property _textColor;
|
||||
properties::FloatProperty _textOpacity;
|
||||
|
||||
Reference in New Issue
Block a user