From 41d52f7f0455bc5fc1357327089cfaf9e9480bb8 Mon Sep 17 00:00:00 2001 From: Malin E Date: Fri, 26 Aug 2022 16:58:48 +0200 Subject: [PATCH] Start addressing PR comments --- .../digitaluniverse/constellationbounds.asset | 4 +- .../digitaluniverse/constellations.asset | 16 ++-- modules/space/CMakeLists.txt | 4 +- .../renderableconstellationbounds.cpp | 34 ++++---- .../rendering/renderableconstellationbounds.h | 4 +- .../renderableconstellationlines.cpp | 83 ++++++++++--------- .../rendering/renderableconstellationlines.h | 6 +- ...n.cpp => renderableconstellationsbase.cpp} | 82 +++++++++--------- ...ation.h => renderableconstellationsbase.h} | 23 ++--- .../space/shaders/constellationbounds_fs.glsl | 6 +- .../space/shaders/constellationlines_fs.glsl | 7 +- .../space/shaders/constellationlines_vs.glsl | 6 +- 12 files changed, 141 insertions(+), 134 deletions(-) rename modules/space/rendering/{renderableconstellation.cpp => renderableconstellationsbase.cpp} (84%) rename modules/space/rendering/{renderableconstellation.h => renderableconstellationsbase.h} (87%) diff --git a/data/assets/scene/digitaluniverse/constellationbounds.asset b/data/assets/scene/digitaluniverse/constellationbounds.asset index 4003e15b39..4c0494e4f3 100644 --- a/data/assets/scene/digitaluniverse/constellationbounds.asset +++ b/data/assets/scene/digitaluniverse/constellationbounds.asset @@ -16,8 +16,8 @@ local object = { Type = "RenderableConstellationBounds", Enabled = false, File = data .. "bound_20.dat", - ConstellationNamesFile = data .. "constellations.dat", - -- ConstellationSelection = zodiacs + NamesFile = data .. "constellations.dat", + -- Selection = zodiacs }, Transform = { Rotation = { diff --git a/data/assets/scene/digitaluniverse/constellations.asset b/data/assets/scene/digitaluniverse/constellations.asset index 1dafb17052..a5530f6eb1 100644 --- a/data/assets/scene/digitaluniverse/constellations.asset +++ b/data/assets/scene/digitaluniverse/constellations.asset @@ -18,15 +18,15 @@ local constellationsExtragalactic = { Opacity = 0.4, File = speck .. "constellationsEXGAL.speck", LabelFile = speck .. "constellationsEXGAL.label", - ConstellationNamesFile = speck .. "constellations.dat", + NamesFile = speck .. "constellations.dat", TextColor = { 0.8, 0.8, 0.8 }, TextOpacity = 0.4, TextSize = 20.0, TextMinMaxSize = { 20, 30 }, - ConstellationColor = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, + Colors = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, LabelUnit = "Mpc", - ConstellationUnit = "Mpc", - -- ConstellationSelection = zodiacs + LineUnit = "Mpc", + -- Selection = zodiacs }, GUI = { Name = "Constellations (Extragalactic)", @@ -42,15 +42,15 @@ local constellations = { Opacity = 0.3, File = speck .. "constellations.speck", LabelFile = speck .. "constellations.label", - ConstellationNamesFile = speck .. "constellations.dat", + NamesFile = speck .. "constellations.dat", TextColor = { 0.8, 0.8, 0.8 }, TextOpacity = 0.3, TextSize = 14.5, TextMinMaxSize = { 8, 170 }, - ConstellationColor = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, + Colors = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, LabelUnit = "pc", - ConstellationUnit = "pc", - -- ConstellationSelection = zodiacs + LineUnit = "pc", + -- Selection = zodiacs }, GUI = { Name = "Constellations", diff --git a/modules/space/CMakeLists.txt b/modules/space/CMakeLists.txt index c6e3ced6d8..3a28b950e4 100644 --- a/modules/space/CMakeLists.txt +++ b/modules/space/CMakeLists.txt @@ -28,7 +28,7 @@ set(HEADER_FILES horizonsfile.h kepler.h speckloader.h - rendering/renderableconstellation.h + rendering/renderableconstellationsbase.h rendering/renderableconstellationbounds.h rendering/renderableconstellationlines.h rendering/renderablefluxnodes.h @@ -50,7 +50,7 @@ set(SOURCE_FILES kepler.cpp spacemodule_lua.inl speckloader.cpp - rendering/renderableconstellation.cpp + rendering/renderableconstellationsbase.cpp rendering/renderableconstellationbounds.cpp rendering/renderableconstellationlines.cpp rendering/renderablefluxnodes.cpp diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index a1cafc053c..7972203696 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -73,7 +73,7 @@ documentation::Documentation RenderableConstellationBounds::Documentation() { RenderableConstellationBounds::RenderableConstellationBounds( const ghoul::Dictionary& dictionary) - : RenderableConstellation(dictionary) + : RenderableConstellationsBase(dictionary) , _vertexFilename(VertexInfo) , _color(ColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f)) { @@ -90,20 +90,20 @@ RenderableConstellationBounds::RenderableConstellationBounds( } void RenderableConstellationBounds::initialize() { - RenderableConstellation::initialize(); + RenderableConstellationsBase::initialize(); loadVertexFile(); - if (!_assetSelectedConstellations.empty()) { - const std::vector options = _constellationSelection.options(); + if (!_assetSelection.empty()) { + const std::vector options = _selection.options(); std::set selectedConstellations; - for (const std::string& s : _assetSelectedConstellations) { + for (const std::string& s : _assetSelection) { const auto it = std::find(options.begin(), options.end(), s); if (it == options.end()) { // The user has specified a constellation name that doesn't exist LWARNINGC( - "RenderableConstellation", + "RenderableConstellationsBase", fmt::format("Option '{}' not found in list of constellations", s) ); } @@ -111,7 +111,7 @@ void RenderableConstellationBounds::initialize() { selectedConstellations.insert(s); } } - _constellationSelection = selectedConstellations; + _selection = selectedConstellations; } } @@ -154,10 +154,13 @@ void RenderableConstellationBounds::deinitializeGL() { } bool RenderableConstellationBounds::isReady() const { - if (!_hasLabel) { - return _program && _vao != 0 && _vbo != 0; + bool isReady = _program && _vao != 0 && _vbo != 0; + + // If we have labels, they also need to be loaded + if (_hasLabel) { + return isReady && !_labelset.entries.empty(); } - return _program && _vao != 0 && _vbo != 0 && !_labelset.entries.empty(); + return isReady; } void RenderableConstellationBounds::render(const RenderData& data, RendererTasks& tasks) { @@ -177,7 +180,7 @@ void RenderableConstellationBounds::render(const RenderData& data, RendererTasks _program->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _program->setUniform("ModelTransform", glm::mat4(modelTransform)); _program->setUniform("color", _color); - _program->setUniform("alphaValue", opacity()); + _program->setUniform("opacity", opacity()); glLineWidth(_lineWidth); @@ -190,11 +193,10 @@ void RenderableConstellationBounds::render(const RenderData& data, RendererTasks glBindVertexArray(0); _program->deactivate(); - RenderableConstellation::render(data, tasks); + RenderableConstellationsBase::render(data, tasks); } -void RenderableConstellationBounds::update(const UpdateData& data) { -} +void RenderableConstellationBounds::update(const UpdateData& data) { } bool RenderableConstellationBounds::loadVertexFile() { if (_vertexFilename.value().empty()) { @@ -300,7 +302,7 @@ bool RenderableConstellationBounds::loadVertexFile() { void RenderableConstellationBounds::selectionPropertyHasChanged() { // If no values are selected (the default), we want to show all constellations - if (!_constellationSelection.hasSelected()) { + if (!_selection.hasSelected()) { for (ConstellationBound& b : _constellationBounds) { b.isEnabled = true; } @@ -308,7 +310,7 @@ void RenderableConstellationBounds::selectionPropertyHasChanged() { else { // Enable all constellations that are selected for (ConstellationBound& b : _constellationBounds) { - b.isEnabled = _constellationSelection.isSelected(b.constellationFullName); + b.isEnabled = _selection.isSelected(b.constellationFullName); } } } diff --git a/modules/space/rendering/renderableconstellationbounds.h b/modules/space/rendering/renderableconstellationbounds.h index 3925e37c6e..b5fcefe299 100644 --- a/modules/space/rendering/renderableconstellationbounds.h +++ b/modules/space/rendering/renderableconstellationbounds.h @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONBOUNDS___H__ #define __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONBOUNDS___H__ -#include +#include namespace ghoul::opengl { class ProgramObject; } @@ -42,7 +42,7 @@ namespace documentation { struct Documentation; } * _distance property. Currently, all constellation bounds are lines, which * leads to artifacts if the radius is very small. */ -class RenderableConstellationBounds : public RenderableConstellation { +class RenderableConstellationBounds : public RenderableConstellationsBase { public: RenderableConstellationBounds(const ghoul::Dictionary& dictionary); diff --git a/modules/space/rendering/renderableconstellationlines.cpp b/modules/space/rendering/renderableconstellationlines.cpp index 659f346809..852e17d3ef 100644 --- a/modules/space/rendering/renderableconstellationlines.cpp +++ b/modules/space/rendering/renderableconstellationlines.cpp @@ -25,13 +25,13 @@ #include #include -#include #include #include -#include +#include #include -#include +#include #include +#include #include #include #include @@ -43,7 +43,7 @@ namespace { constexpr std::string_view _loggerCat = "RenderableConstellationLines"; constexpr std::array UniformNames = { - "modelViewTransform", "projectionTransform", "alphaValue", "color" + "modelViewTransform", "projectionTransform", "opacity", "color" }; constexpr openspace::properties::Property::PropertyInfo DrawElementsInfo = { @@ -52,16 +52,17 @@ namespace { "Enables/Disables the drawing of the constellations" }; - constexpr openspace::properties::Property::PropertyInfo ConstellationUnitInfo = { - "ConstellationUnit", - "Constellation Unit", - "The unit used for the constellation data" + constexpr openspace::properties::Property::PropertyInfo LineUnitInfo = { + "LineUnit", + "Line Unit", + "The distance unit used for the constellation lines data" }; - constexpr openspace::properties::Property::PropertyInfo ConstellationColorInfo = { - "ConstellationColor", - "Constellation colors", - "The defined colors for the constellations to be rendered" + constexpr openspace::properties::Property::PropertyInfo ColorsInfo = { + "Colors", + "Constellation Colors", + "The defined colors for the constellations to be rendered. " + "There can be several groups of constellaitons that can have distinct colors." }; struct [[codegen::Dictionary(RenderableConstellationLines)]] Parameters { @@ -77,11 +78,11 @@ namespace { Gigaparsec [[codegen::key("Gpc")]], Gigalightyear [[codegen::key("Gly")]] }; - // [[codegen::verbatim(ConstellationUnitInfo.description)]] - std::optional constellationUnit; + // [[codegen::verbatim(LineUnitInfo.description)]] + std::optional lineUnit; - // [[codegen::verbatim(ConstellationColorInfo.description)]] - std::optional> constellationColor; + // [[codegen::verbatim(ColorsInfo.description)]] + std::optional> colors; }; #include "renderableconstellationlines_codegen.cpp" } // namespace @@ -94,7 +95,7 @@ documentation::Documentation RenderableConstellationLines::Documentation() { RenderableConstellationLines::RenderableConstellationLines( const ghoul::Dictionary& dictionary) - : RenderableConstellation(dictionary) + : RenderableConstellationsBase(dictionary) , _drawElements(DrawElementsInfo, true) { const Parameters p = codegen::bake(dictionary); @@ -104,15 +105,15 @@ RenderableConstellationLines::RenderableConstellationLines( _drawElements.onChange([&]() { _hasSpeckFile = !_hasSpeckFile; }); addProperty(_drawElements); - if (p.constellationUnit.has_value()) { - _constellationUnit = codegen::map(*p.constellationUnit); + if (p.lineUnit.has_value()) { + _constellationUnit = codegen::map(*p.lineUnit); } else { _constellationUnit = DistanceUnit::Meter; } - if (p.constellationColor.has_value()) { - std::vector ops = *p.constellationColor; + if (p.colors.has_value()) { + std::vector ops = *p.colors; for (size_t i = 0; i < ops.size(); ++i) { _constellationColorMap.insert({ static_cast(i) + 1, ops[i] }); } @@ -121,7 +122,7 @@ RenderableConstellationLines::RenderableConstellationLines( void RenderableConstellationLines::selectionPropertyHasChanged() { // If no values are selected (the default), we want to show all constellations - if (!_constellationSelection.hasSelected()) { + if (!_selection.hasSelected()) { for (std::pair& pair : _renderingConstellationsMap) { @@ -133,38 +134,39 @@ void RenderableConstellationLines::selectionPropertyHasChanged() { for (std::pair& pair : _renderingConstellationsMap) { - pair.second.isEnabled = - _constellationSelection.isSelected(pair.second.name); + pair.second.isEnabled = _selection.isSelected(pair.second.name); } } } bool RenderableConstellationLines::isReady() const { - if (!_hasLabel) { - return _program && !_renderingConstellationsMap.empty(); + bool isReady = _program && !_renderingConstellationsMap.empty(); + + // If we have labels, they also need to be loaded + if (_hasLabel) { + return isReady && !_labelset.entries.empty(); } - return _program && !_renderingConstellationsMap.empty() && - !_labelset.entries.empty(); + return isReady; } void RenderableConstellationLines::initialize() { - RenderableConstellation::initialize(); + RenderableConstellationsBase::initialize(); bool success = loadData(); if (!success) { throw ghoul::RuntimeError("Error loading data"); } - if (!_assetSelectedConstellations.empty()) { - const std::vector options = _constellationSelection.options(); + if (!_assetSelection.empty()) { + const std::vector options = _selection.options(); std::set selectedConstellations; - for (const std::string& s : _assetSelectedConstellations) { + for (const std::string& s : _assetSelection) { const auto it = std::find(options.begin(), options.end(), s); if (it == options.end()) { // The user has specified a constellation name that doesn't exist LWARNINGC( - "RenderableConstellation", + "RenderableConstellationsBase", fmt::format("Option '{}' not found in list of constellations", s) ); } @@ -172,7 +174,7 @@ void RenderableConstellationLines::initialize() { selectedConstellations.insert(s); } } - _constellationSelection = selectedConstellations; + _selection = selectedConstellations; } } @@ -215,7 +217,7 @@ void RenderableConstellationLines::renderConstellations(const RenderData&, _program->setUniform(_uniformCache.modelViewTransform, modelViewMatrix); _program->setUniform(_uniformCache.projectionTransform, projectionMatrix); - _program->setUniform(_uniformCache.alphaValue, opacity()); + _program->setUniform(_uniformCache.opacity, opacity()); for (const std::pair& pair : _renderingConstellationsMap) @@ -257,7 +259,7 @@ void RenderableConstellationLines::render(const RenderData& data, RendererTasks& renderConstellations(data, modelViewMatrix, projectionMatrix); } - RenderableConstellation::render(data, tasks); + RenderableConstellationsBase::render(data, tasks); } void RenderableConstellationLines::update(const UpdateData&) { @@ -331,10 +333,15 @@ bool RenderableConstellationLines::readSpeckFile() { std::string dummy; str >> dummy; // mesh command dummy.clear(); - str >> dummy; // color index command? + str >> dummy; // color index command do { if (dummy == "-c") { - str >> constellationLine.colorIndex; // color index command + str >> constellationLine.colorIndex; // color index + } + else { + std::string message = fmt::format("Unknown command '{}' found in " + "constellation file '{}'", dummy, _speckFile); + LWARNING(message); } dummy.clear(); str >> dummy; diff --git a/modules/space/rendering/renderableconstellationlines.h b/modules/space/rendering/renderableconstellationlines.h index e9fb792a6e..51dfe2044c 100644 --- a/modules/space/rendering/renderableconstellationlines.h +++ b/modules/space/rendering/renderableconstellationlines.h @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_MODULE_DIGITALUNIVERSE___RENDERABLECONSTELLATIONLINES___H__ #define __OPENSPACE_MODULE_DIGITALUNIVERSE___RENDERABLECONSTELLATIONLINES___H__ -#include +#include #include #include @@ -41,7 +41,7 @@ namespace openspace { namespace documentation { struct Documentation; } -class RenderableConstellationLines : public RenderableConstellation { +class RenderableConstellationLines : public RenderableConstellationsBase { public: explicit RenderableConstellationLines(const ghoul::Dictionary& dictionary); ~RenderableConstellationLines() override = default; @@ -88,7 +88,7 @@ private: properties::BoolProperty _drawElements; std::unique_ptr _program = nullptr; - UniformCache(modelViewTransform, projectionTransform, alphaValue, + UniformCache(modelViewTransform, projectionTransform, opacity, color) _uniformCache; std::string _speckFile; diff --git a/modules/space/rendering/renderableconstellation.cpp b/modules/space/rendering/renderableconstellationsbase.cpp similarity index 84% rename from modules/space/rendering/renderableconstellation.cpp rename to modules/space/rendering/renderableconstellationsbase.cpp index 01215c0a68..5925fd5da3 100644 --- a/modules/space/rendering/renderableconstellation.cpp +++ b/modules/space/rendering/renderableconstellationsbase.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include #include @@ -74,9 +74,9 @@ namespace { "constellations" }; - constexpr openspace::properties::Property::PropertyInfo ConstellationInfo = { - "ConstellationFile", - "Constellation File Path", + constexpr openspace::properties::Property::PropertyInfo NamesFileInfo = { + "NamesFile", + "Constellation Names File Path", "Specifies the file that contains the mapping between constellation " "abbreviations and full names of the constellations. If this value is empty, the " "abbreviations are used as the full names" @@ -112,12 +112,12 @@ namespace { "The constellations that are selected are displayed on the celestial sphere" }; - struct [[codegen::Dictionary(RenderableConstellation)]] Parameters { + struct [[codegen::Dictionary(RenderableConstellationsBase)]] Parameters { // [[codegen::verbatim(DrawLabelInfo.description)]] std::optional drawLabels; - // [[codegen::verbatim(ConstellationInfo.description)]] - std::optional constellationNamesFile; + // [[codegen::verbatim(NamesFileInfo.description)]] + std::optional namesFile; // [[codegen::verbatim(TextColorInfo.description)]] std::optional textColor [[codegen::color()]]; @@ -150,18 +150,18 @@ namespace { std::optional labelUnit; // [[codegen::verbatim(SelectionInfo.description)]] - std::optional> constellationSelection; + std::optional> selection; }; -#include "renderableconstellation_codegen.cpp" +#include "renderableconstellationsbase_codegen.cpp" } // namespace namespace openspace { -documentation::Documentation RenderableConstellation::Documentation() { - return codegen::doc("space_renderable_constellation"); +documentation::Documentation RenderableConstellationsBase::Documentation() { + return codegen::doc("space_renderable_constellationsbase"); } -RenderableConstellation::RenderableConstellation(const ghoul::Dictionary& dictionary) +RenderableConstellationsBase::RenderableConstellationsBase(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f) @@ -175,8 +175,8 @@ RenderableConstellation::RenderableConstellation(const ghoul::Dictionary& dictio ) , _lineWidth(LineWidthInfo, 2.f, 1.f, 16.f) , _renderOption(RenderOptionInfo, properties::OptionProperty::DisplayType::Dropdown) - , _constellationNamesFilename(ConstellationInfo) - , _constellationSelection(SelectionInfo) + , _namesFilename(NamesFileInfo) + , _selection(SelectionInfo) { const Parameters p = codegen::bake(dictionary); @@ -196,12 +196,11 @@ RenderableConstellation::RenderableConstellation(const ghoul::Dictionary& dictio addProperty(_renderOption); // Avoid reading files here, instead do it in multithreaded initialize() - if (p.constellationNamesFile.has_value()) { - _constellationNamesFilename = - absPath(p.constellationNamesFile.value().string()).string(); + if (p.namesFile.has_value()) { + _namesFilename = absPath(p.namesFile.value().string()).string(); } - _constellationNamesFilename.onChange([&]() { loadConstellationFile(); }); - addProperty(_constellationNamesFilename); + _namesFilename.onChange([&]() { loadConstellationFile(); }); + addProperty(_namesFilename); _lineWidth = p.lineWidth.value_or(_lineWidth); addProperty(_lineWidth); @@ -236,45 +235,44 @@ RenderableConstellation::RenderableConstellation(const ghoul::Dictionary& dictio } } - _constellationSelection.onChange([this]() { selectionPropertyHasChanged(); }); - addProperty(_constellationSelection); + _selection.onChange([this]() { selectionPropertyHasChanged(); }); + addProperty(_selection); - _assetSelectedConstellations = - p.constellationSelection.value_or(_assetSelectedConstellations); + _assetSelection = p.selection.value_or(_assetSelection); } -std::string RenderableConstellation::constellationFullName( +std::string RenderableConstellationsBase::constellationFullName( const std::string& identifier) const { - if (_constellationNamesTranslation.empty() || identifier.empty()) { + if (_namesTranslation.empty() || identifier.empty()) { std::string message = "List of constellations or the given identifier was empty"; - LWARNINGC("RenderableConstellation", message); + LWARNINGC("RenderableConstellationsBase", message); return ""; } try { - return _constellationNamesTranslation.at(identifier); + return _namesTranslation.at(identifier); } catch (const std::out_of_range&) { std::string message = fmt::format( "Identifier '{}' could not be found in list of constellations", identifier ); - throw ghoul::RuntimeError(message, "RenderableConstellation"); + throw ghoul::RuntimeError(message, "RenderableConstellationsBase"); } } -void RenderableConstellation::loadConstellationFile() { - if (_constellationNamesFilename.value().empty()) { +void RenderableConstellationsBase::loadConstellationFile() { + if (_namesFilename.value().empty()) { return; } // Reset - _constellationSelection.clearOptions(); - _constellationNamesTranslation.clear(); + _selection.clearOptions(); + _namesTranslation.clear(); std::ifstream file; file.exceptions(std::ifstream::goodbit); - file.open(absPath(_constellationNamesFilename)); + file.open(absPath(_namesFilename)); std::string line; while (file.good()) { @@ -290,19 +288,19 @@ void RenderableConstellation::loadConstellationFile() { std::string fullName; std::getline(s, fullName); ghoul::trimWhitespace(fullName); - _constellationNamesTranslation[abbreviation] = fullName; + _namesTranslation[abbreviation] = fullName; } fillSelectionProperty(); } -void RenderableConstellation::fillSelectionProperty() { - for (const std::pair& pair : _constellationNamesTranslation) { - _constellationSelection.addOption(pair.second); +void RenderableConstellationsBase::fillSelectionProperty() { + for (const std::pair& pair : _namesTranslation) { + _selection.addOption(pair.second); } } -void RenderableConstellation::initialize() { +void RenderableConstellationsBase::initialize() { loadConstellationFile(); if (!_hasLabel) { @@ -334,7 +332,7 @@ void RenderableConstellation::initialize() { } } -void RenderableConstellation::render(const RenderData& data, RendererTasks&) { +void RenderableConstellationsBase::render(const RenderData& data, RendererTasks&) { if (!_hasLabel || !_drawLabels) { return; } @@ -372,7 +370,7 @@ void RenderableConstellation::render(const RenderData& data, RendererTasks&) { renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp); } -void RenderableConstellation::renderLabels(const RenderData& data, +void RenderableConstellationsBase::renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, const glm::vec3& orthoRight, const glm::vec3& orthoUp) @@ -395,9 +393,7 @@ void RenderableConstellation::renderLabels(const RenderData& data, glm::vec4 textColor = glm::vec4(glm::vec3(_textColor), _textOpacity); for (const speck::Labelset::Entry& e : _labelset.entries) { - if (_constellationSelection.hasSelected() && - !_constellationSelection.isSelected(e.text)) - { + if (_selection.hasSelected() && !_selection.isSelected(e.text)) { continue; } diff --git a/modules/space/rendering/renderableconstellation.h b/modules/space/rendering/renderableconstellationsbase.h similarity index 87% rename from modules/space/rendering/renderableconstellation.h rename to modules/space/rendering/renderableconstellationsbase.h index 7d2a88f14c..8da74feedc 100644 --- a/modules/space/rendering/renderableconstellation.h +++ b/modules/space/rendering/renderableconstellationsbase.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATION___H__ -#define __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATION___H__ +#ifndef __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONSBASE___H__ +#define __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONSBASE___H__ #include @@ -44,9 +44,12 @@ namespace openspace { namespace documentation { struct Documentation; } -class RenderableConstellation : public Renderable { +/** + * This is a base class for constellation lines and bounds + */ +class RenderableConstellationsBase : public Renderable { public: - virtual ~RenderableConstellation() override = default; + virtual ~RenderableConstellationsBase() override = default; virtual void initialize() override; virtual void initializeGL() override = 0; @@ -62,7 +65,7 @@ public: static documentation::Documentation Documentation(); protected: - explicit RenderableConstellation(const ghoul::Dictionary& dictionary); + explicit RenderableConstellationsBase(const ghoul::Dictionary& dictionary); /** * Callback method that gets triggered when _constellationSelection @@ -78,11 +81,11 @@ protected: properties::FloatProperty _lineWidth; // Property that stores all constellations chosen by the user to be drawn - properties::SelectionProperty _constellationSelection; + properties::SelectionProperty _selection; // Temporary storage of which constellations should be rendered as stated in the // asset file - std::vector _assetSelectedConstellations; + std::vector _assetSelection; // Label text settings bool _hasLabel = false; @@ -92,7 +95,7 @@ protected: private: // Map over the constellations names and their abbreviations // key = abbreviation, value = full name - std::map _constellationNamesTranslation; + std::map _namesTranslation; /** * Loads the file specified in _constellationNamesFilename that contains @@ -104,7 +107,7 @@ private: void fillSelectionProperty(); // The file containing constellation names and abbreviations - properties::StringProperty _constellationNamesFilename; + properties::StringProperty _namesFilename; // Label text settings std::string _labelFile; @@ -120,4 +123,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATION___H__ +#endif // __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONSBASE___H__ diff --git a/modules/space/shaders/constellationbounds_fs.glsl b/modules/space/shaders/constellationbounds_fs.glsl index 0d138b106d..ce1a490d4e 100644 --- a/modules/space/shaders/constellationbounds_fs.glsl +++ b/modules/space/shaders/constellationbounds_fs.glsl @@ -28,18 +28,18 @@ in vec4 vs_position; uniform vec3 color; -uniform float alphaValue; +uniform float opacity; Fragment getFragment() { Fragment frag; - if (alphaValue == 0.0) { + if (opacity == 0.0) { discard; } vec4 position = vs_position; - frag.color = vec4(color, alphaValue); + frag.color = vec4(color, opacity); frag.depth = pscDepth(position); return frag; diff --git a/modules/space/shaders/constellationlines_fs.glsl b/modules/space/shaders/constellationlines_fs.glsl index f8cfcda68d..06311674c6 100644 --- a/modules/space/shaders/constellationlines_fs.glsl +++ b/modules/space/shaders/constellationlines_fs.glsl @@ -28,19 +28,18 @@ in float vs_screenSpaceDepth; in vec4 vs_positionViewSpace; uniform vec3 color; -uniform float alphaValue; +uniform float opacity; Fragment getFragment() { Fragment frag; - if (alphaValue == 0.0) { + if (opacity == 0.0) { discard; } - frag.color = vec4(color, alphaValue); + frag.color = vec4(color, opacity); frag.depth = vs_screenSpaceDepth; - // JCC: Need to change the position to camera space frag.gPosition = vs_positionViewSpace; frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); diff --git a/modules/space/shaders/constellationlines_vs.glsl b/modules/space/shaders/constellationlines_vs.glsl index e8611e67d3..1fa6aa80fe 100644 --- a/modules/space/shaders/constellationlines_vs.glsl +++ b/modules/space/shaders/constellationlines_vs.glsl @@ -36,11 +36,11 @@ uniform dmat4 projectionTransform; void main() { - dvec4 positionViewSpace = modelViewTransform * dvec4(in_position, 1.0); - vec4 positionClipSpace = vec4(projectionTransform * positionViewSpace); + dvec4 positionViewSpace = modelViewTransform * dvec4(in_position, 1.0); + vec4 positionClipSpace = vec4(projectionTransform * positionViewSpace); vec4 positionScreenSpace = vec4(z_normalization(positionClipSpace)); - vs_screenSpaceDepth = positionScreenSpace.w; + vs_screenSpaceDepth = positionScreenSpace.w; vs_positionViewSpace = vec4(positionViewSpace); gl_Position = positionScreenSpace;