Fix asset selection of constellations

This commit is contained in:
Malin E
2022-08-09 17:01:41 +02:00
parent ceaf85f606
commit 87a45e7376
9 changed files with 55 additions and 41 deletions
@@ -1,7 +1,7 @@
local data = asset.syncedResource({
Name = "Constellation Bounds Data",
Name = "Constellation Files",
Type = "HttpSynchronization",
Identifier = "digitaluniverse_constellationbounds_data",
Identifier = "digitaluniverse_constellations_data",
Version = 1
})
@@ -1,8 +1,8 @@
local speck = asset.syncedResource({
Name = "Constellation Speck Files",
Name = "Constellation Files",
Type = "HttpSynchronization",
Identifier = "digitaluniverse_constellations_speck",
Version = 2
Identifier = "digitaluniverse_constellations_data",
Version = 1
})
local constellationsExtragalactic = {
@@ -34,7 +34,7 @@ local constellations = {
Opacity = 0.3,
File = speck .. "constellations.speck",
LabelFile = speck .. "constellations.label",
ConstellationNamesFile = "C:/Users/malej60/Documents/Sync/http/digitaluniverse_constellationbounds_data/1/constellations.dat",
ConstellationNamesFile = speck .. "constellations.dat",
TextColor = { 0.8, 0.8, 0.8 },
TextOpacity = 0.3,
TextSize = 14.5,
@@ -300,26 +300,6 @@ void RenderableConstellation::fillSelectionProperty() {
void RenderableConstellation::initialize() {
loadConstellationFile();
if (!_assetSelectedConstellations.empty()) {
const std::vector<std::string> options = _constellationSelection.options();
std::set<std::string> selectedConstellations;
for (const std::string& s : _assetSelectedConstellations) {
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
LWARNINGC(
"RenderableConstellation",
fmt::format("Option '{}' not found in list of meshes", s)
);
}
else {
selectedConstellations.insert(s);
}
}
_constellationSelection = selectedConstellations;
}
if (!_hasLabel) {
return;
}
@@ -50,7 +50,6 @@ public:
virtual void initialize() override;
virtual void initializeGL() override = 0;
virtual void deinitialize() override = 0;
virtual void deinitializeGL() override = 0;
virtual bool isReady() const override = 0;
@@ -81,6 +80,10 @@ protected:
// Property that stores all constellations chosen by the user to be drawn
properties::SelectionProperty _constellationSelection;
// Temporary storage of which constellations should be rendered as stated in the
// asset file
std::vector<std::string> _assetSelectedConstellations;
// Label text settings
bool _hasLabel = false;
speck::Labelset _labelset;
@@ -91,9 +94,7 @@ private:
// key = abbreviation, value = full name
std::map<std::string, std::string> _constellationNamesTranslation;
// Temporary storage of which constellations should be rendered as stated in the
// asset file
std::vector<std::string> _assetSelectedConstellations;
/**
* Loads the file specified in <code>_constellationNamesFilename</code> that contains
@@ -93,6 +93,26 @@ void RenderableConstellationBounds::initialize() {
RenderableConstellation::initialize();
loadVertexFile();
if (!_assetSelectedConstellations.empty()) {
const std::vector<std::string> options = _constellationSelection.options();
std::set<std::string> selectedConstellations;
for (const std::string& s : _assetSelectedConstellations) {
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
LWARNINGC(
"RenderableConstellation",
fmt::format("Option '{}' not found in list of meshes", s)
);
}
else {
selectedConstellations.insert(s);
}
}
_constellationSelection = selectedConstellations;
}
}
void RenderableConstellationBounds::initializeGL() {
@@ -121,9 +141,6 @@ void RenderableConstellationBounds::initializeGL() {
glBindVertexArray(0);
}
void RenderableConstellationBounds::deinitialize() {
}
void RenderableConstellationBounds::deinitializeGL() {
glDeleteBuffers(1, &_vbo);
_vbo = 0;
@@ -48,7 +48,6 @@ public:
void initialize() override;
void initializeGL() override;
void deinitialize() override;
void deinitializeGL() override;
bool isReady() const override;
@@ -151,6 +151,26 @@ void RenderableConstellationLines::initialize() {
if (!success) {
throw ghoul::RuntimeError("Error loading data");
}
if (!_assetSelectedConstellations.empty()) {
const std::vector<std::string> options = _constellationSelection.options();
std::set<std::string> selectedConstellations;
for (const std::string& s : _assetSelectedConstellations) {
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
LWARNINGC(
"RenderableConstellation",
fmt::format("Option '{}' not found in list of meshes", s)
);
}
else {
selectedConstellations.insert(s);
}
}
_constellationSelection = selectedConstellations;
}
}
void RenderableConstellationLines::initializeGL() {
@@ -165,11 +185,10 @@ void RenderableConstellationLines::initializeGL() {
createConstellations();
}
void RenderableConstellationLines::deinitialize() {
}
void RenderableConstellationLines::deinitializeGL() {
for (const std::pair<const int, ConstellationLine>& pair : _renderingConstellationsMap) {
for (const std::pair<const int, ConstellationLine>& pair :
_renderingConstellationsMap)
{
glDeleteVertexArrays(1, &pair.second.vaoArray);
glDeleteBuffers(1, &pair.second.vboArray);
}
@@ -48,7 +48,6 @@ public:
void initialize() override;
void initializeGL() override;
void deinitialize() override;
void deinitializeGL() override;
bool isReady() const override;
@@ -33,7 +33,6 @@ uniform float alphaValue;
Fragment getFragment() {
Fragment frag;
if (alphaValue == 0.0) {
discard;
}
@@ -44,6 +43,6 @@ Fragment getFragment() {
// JCC: Need to change the position to camera space
frag.gPosition = vs_positionViewSpace;
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
return frag;
}