mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 14:29:42 -05:00
Start addressing PR comments
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<std::string> options = _constellationSelection.options();
|
||||
if (!_assetSelection.empty()) {
|
||||
const std::vector<std::string> options = _selection.options();
|
||||
std::set<std::string> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#ifndef __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONBOUNDS___H__
|
||||
#define __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONBOUNDS___H__
|
||||
|
||||
#include <modules/space/rendering/renderableconstellation.h>
|
||||
#include <modules/space/rendering/renderableconstellationsbase.h>
|
||||
|
||||
namespace ghoul::opengl { class ProgramObject; }
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace documentation { struct Documentation; }
|
||||
* <code>_distance</code> 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);
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
#include <modules/space/rendering/renderableconstellationlines.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/misc.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/misc.h>
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <array>
|
||||
@@ -43,7 +43,7 @@ namespace {
|
||||
constexpr std::string_view _loggerCat = "RenderableConstellationLines";
|
||||
|
||||
constexpr std::array<const char*, 4> 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<Unit> constellationUnit;
|
||||
// [[codegen::verbatim(LineUnitInfo.description)]]
|
||||
std::optional<Unit> lineUnit;
|
||||
|
||||
// [[codegen::verbatim(ConstellationColorInfo.description)]]
|
||||
std::optional<std::vector<glm::vec3>> constellationColor;
|
||||
// [[codegen::verbatim(ColorsInfo.description)]]
|
||||
std::optional<std::vector<glm::vec3>> 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<Parameters>(dictionary);
|
||||
@@ -104,15 +105,15 @@ RenderableConstellationLines::RenderableConstellationLines(
|
||||
_drawElements.onChange([&]() { _hasSpeckFile = !_hasSpeckFile; });
|
||||
addProperty(_drawElements);
|
||||
|
||||
if (p.constellationUnit.has_value()) {
|
||||
_constellationUnit = codegen::map<DistanceUnit>(*p.constellationUnit);
|
||||
if (p.lineUnit.has_value()) {
|
||||
_constellationUnit = codegen::map<DistanceUnit>(*p.lineUnit);
|
||||
}
|
||||
else {
|
||||
_constellationUnit = DistanceUnit::Meter;
|
||||
}
|
||||
|
||||
if (p.constellationColor.has_value()) {
|
||||
std::vector<glm::vec3> ops = *p.constellationColor;
|
||||
if (p.colors.has_value()) {
|
||||
std::vector<glm::vec3> ops = *p.colors;
|
||||
for (size_t i = 0; i < ops.size(); ++i) {
|
||||
_constellationColorMap.insert({ static_cast<int>(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<const int, ConstellationLine>& pair :
|
||||
_renderingConstellationsMap)
|
||||
{
|
||||
@@ -133,38 +134,39 @@ void RenderableConstellationLines::selectionPropertyHasChanged() {
|
||||
for (std::pair<const int, ConstellationLine>& 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<std::string> options = _constellationSelection.options();
|
||||
if (!_assetSelection.empty()) {
|
||||
const std::vector<std::string> options = _selection.options();
|
||||
std::set<std::string> 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<const int, ConstellationLine>& 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;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#ifndef __OPENSPACE_MODULE_DIGITALUNIVERSE___RENDERABLECONSTELLATIONLINES___H__
|
||||
#define __OPENSPACE_MODULE_DIGITALUNIVERSE___RENDERABLECONSTELLATIONLINES___H__
|
||||
|
||||
#include <modules/space/rendering/renderableconstellation.h>
|
||||
#include <modules/space/rendering/renderableconstellationsbase.h>
|
||||
|
||||
#include <ghoul/opengl/uniformcache.h>
|
||||
#include <unordered_map>
|
||||
@@ -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<ghoul::opengl::ProgramObject> _program = nullptr;
|
||||
UniformCache(modelViewTransform, projectionTransform, alphaValue,
|
||||
UniformCache(modelViewTransform, projectionTransform, opacity,
|
||||
color) _uniformCache;
|
||||
|
||||
std::string _speckFile;
|
||||
|
||||
+39
-43
@@ -22,7 +22,7 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/space/rendering/renderableconstellation.h>
|
||||
#include <modules/space/rendering/renderableconstellationsbase.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
@@ -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<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(ConstellationInfo.description)]]
|
||||
std::optional<std::filesystem::path> constellationNamesFile;
|
||||
// [[codegen::verbatim(NamesFileInfo.description)]]
|
||||
std::optional<std::filesystem::path> namesFile;
|
||||
|
||||
// [[codegen::verbatim(TextColorInfo.description)]]
|
||||
std::optional<glm::vec3> textColor [[codegen::color()]];
|
||||
@@ -150,18 +150,18 @@ namespace {
|
||||
std::optional<Unit> labelUnit;
|
||||
|
||||
// [[codegen::verbatim(SelectionInfo.description)]]
|
||||
std::optional<std::vector<std::string>> constellationSelection;
|
||||
std::optional<std::vector<std::string>> selection;
|
||||
};
|
||||
#include "renderableconstellation_codegen.cpp"
|
||||
#include "renderableconstellationsbase_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableConstellation::Documentation() {
|
||||
return codegen::doc<Parameters>("space_renderable_constellation");
|
||||
documentation::Documentation RenderableConstellationsBase::Documentation() {
|
||||
return codegen::doc<Parameters>("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<Parameters>(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<std::string, std::string>& pair : _constellationNamesTranslation) {
|
||||
_constellationSelection.addOption(pair.second);
|
||||
void RenderableConstellationsBase::fillSelectionProperty() {
|
||||
for (const std::pair<std::string, std::string>& 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;
|
||||
}
|
||||
|
||||
+13
-10
@@ -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 <openspace/rendering/renderable.h>
|
||||
|
||||
@@ -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 <code>_constellationSelection</code>
|
||||
@@ -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<std::string> _assetSelectedConstellations;
|
||||
std::vector<std::string> _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<std::string, std::string> _constellationNamesTranslation;
|
||||
std::map<std::string, std::string> _namesTranslation;
|
||||
|
||||
/**
|
||||
* Loads the file specified in <code>_constellationNamesFilename</code> 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__
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user