mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 01:09:34 -05:00
Feature/numeric slider updates (#1609)
* Remove Logarithmic ViewOption and instead always use exponent of NumericalProperty + set exponent of some renderables' properties * Add MinMaxRange ViewOption for Vec2 properties * Add MinMaxRange viewoption to some existing vec2 properties and combine some other related properties to be able to utilize it. For example Min and Max label sizes, fade in/out distances, inner and outer radius. OBS! Includes renaming several properties (**breaking change**) * Refactor and document labels code. OBS! Includes renaming several properties (**breaking change**) * Add comments for some assets that have labels that are not working correctly Renderables with rename properties: RenderableLabels , GlobeLabelsComponent, RenderableBillboardsCloud, RenderableDUMeshes, RenderableRadialGrid )
This commit is contained in:
@@ -33,23 +33,23 @@
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/crc32.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/crc32.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <cstdint>
|
||||
#include <locale>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -116,18 +116,11 @@ namespace {
|
||||
"The text size for the astronomical object labels."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelMinSizeInfo = {
|
||||
"TextMinSize",
|
||||
"Text Min Size",
|
||||
"The minimal size (in pixels) of the text for the labels for the astronomical "
|
||||
"objects being rendered."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelMaxSizeInfo = {
|
||||
"TextMaxSize",
|
||||
"Text Max Size",
|
||||
"The maximum size (in pixels) of the text for the labels for the astronomical "
|
||||
"objects being rendered."
|
||||
constexpr openspace::properties::Property::PropertyInfo LabelMinMaxSizeInfo = {
|
||||
"TextMinMaxSize",
|
||||
"Text Min/Max Size",
|
||||
"The minimal and maximal size (in pixels) of the text for the labels for the "
|
||||
"astronomical objects being rendered."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawElementsInfo = {
|
||||
@@ -178,48 +171,43 @@ namespace {
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DisableFadeInInfo = {
|
||||
"DisableFadeIn",
|
||||
"Disable Fade-in effect",
|
||||
"Disable Fade-in Effect",
|
||||
"Enables/Disables the Fade-in effect."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo BillboardMaxSizeInfo = {
|
||||
"BillboardMaxSize",
|
||||
"Billboard Max Size in Pixels",
|
||||
"The max size (in pixels) for the billboard representing the astronomical "
|
||||
"object."
|
||||
constexpr openspace::properties::Property::PropertyInfo PixelSizeControlInfo = {
|
||||
"EnablePixelSizeControl",
|
||||
"Enable Pixel Size Control",
|
||||
"Enable pixel size control for rectangular projections. If set to true, the "
|
||||
"billboard size is restricted by the min/max size in pixels property."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo BillboardMinSizeInfo = {
|
||||
"BillboardMinSize",
|
||||
"Billboard Min Size in Pixels",
|
||||
"The min size (in pixels) for the billboard representing the astronomical "
|
||||
"object."
|
||||
constexpr openspace::properties::Property::PropertyInfo BillboardMinMaxSizeInfo = {
|
||||
"BillboardMinMaxSize",
|
||||
"Billboard Min/Max Size in Pixels",
|
||||
"The minimum and maximum size (in pixels) for the billboard representing the "
|
||||
"astronomical object."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo
|
||||
CorrectionSizeEndDistanceInfo = {
|
||||
CorrectionSizeEndDistanceInfo =
|
||||
{
|
||||
"CorrectionSizeEndDistance",
|
||||
"Distance in 10^X meters where correction size stops acting.",
|
||||
"Distance in 10^X meters where correction size stops acting",
|
||||
"Distance in 10^X meters where correction size stops acting."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo CorrectionSizeFactorInfo = {
|
||||
"CorrectionSizeFactor",
|
||||
"Control variable for distance size.",
|
||||
"Control variable for distance size",
|
||||
""
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo PixelSizeControlInfo = {
|
||||
"EnablePixelSizeControl",
|
||||
"Enable pixel size control.",
|
||||
"Enable pixel size control for rectangular projections."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo UseLinearFiltering = {
|
||||
"UseLinearFiltering",
|
||||
"Use Linear Filtering",
|
||||
"Determines whether the provided color map should be sampled nearest neighbor "
|
||||
"(=off) or linearly (=on"
|
||||
"(=off) or linearly (=on)"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SetRangeFromData = {
|
||||
@@ -258,6 +246,8 @@ namespace {
|
||||
Gigaparsec [[codegen::key("Gpc")]],
|
||||
GigalightYears [[codegen::key("Gly")]]
|
||||
};
|
||||
// The unit used for all distances. Must match the unit of any
|
||||
// distances/positions in the data files
|
||||
std::optional<Unit> unit;
|
||||
|
||||
// [[codegen::verbatim(ScaleFactorInfo.description)]]
|
||||
@@ -289,11 +279,8 @@ namespace {
|
||||
// objects being rendered
|
||||
std::optional<std::string> labelFile;
|
||||
|
||||
// [[codegen::verbatim(LabelMinSizeInfo.description)]]
|
||||
std::optional<float> textMinSize;
|
||||
|
||||
// [[codegen::verbatim(LabelMaxSizeInfo.description)]]
|
||||
std::optional<float> textMaxSize;
|
||||
// [[codegen::verbatim(LabelMinMaxSizeInfo.description)]]
|
||||
std::optional<glm::ivec2> textMinMaxSize;
|
||||
|
||||
// [[codegen::verbatim(ColorOptionInfo.description)]]
|
||||
std::optional<std::vector<std::string>> colorOption;
|
||||
@@ -314,11 +301,8 @@ namespace {
|
||||
// [[codegen::verbatim(DisableFadeInInfo.description)]]
|
||||
std::optional<bool> disableFadeIn;
|
||||
|
||||
// [[codegen::verbatim(BillboardMaxSizeInfo.description)]]
|
||||
std::optional<float> billboardMaxSize;
|
||||
|
||||
// [[codegen::verbatim(BillboardMinSizeInfo.description)]]
|
||||
std::optional<float> billboardMinSize;
|
||||
// [[codegen::verbatim(BillboardMinMaxSizeInfo.description)]]
|
||||
std::optional<glm::vec2> billboardMinMaxSize;
|
||||
|
||||
// [[codegen::verbatim(CorrectionSizeEndDistanceInfo.description)]]
|
||||
std::optional<float> correctionSizeEndDistance;
|
||||
@@ -349,27 +333,34 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
, _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f)
|
||||
, _textSize(TextSizeInfo, 8.f, 0.5f, 24.f)
|
||||
, _textMinSize(LabelMinSizeInfo, 8.f, 0.5f, 24.f)
|
||||
, _textMaxSize(LabelMaxSizeInfo, 20.f, 0.5f, 100.f)
|
||||
, _textMinMaxSize(
|
||||
LabelMinMaxSizeInfo,
|
||||
glm::ivec2(8, 20),
|
||||
glm::ivec2(0),
|
||||
glm::ivec2(100)
|
||||
)
|
||||
, _drawElements(DrawElementsInfo, true)
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
, _pixelSizeControl(PixelSizeControlInfo, false)
|
||||
, _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _optionColorRangeData(OptionColorRangeInfo, glm::vec2(0.f))
|
||||
|
||||
, _datavarSizeOption(
|
||||
SizeOptionInfo,
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
, _fadeInDistance(
|
||||
, _fadeInDistances(
|
||||
FadeInDistancesInfo,
|
||||
glm::vec2(0.f),
|
||||
glm::vec2(0.f),
|
||||
glm::vec2(100.f)
|
||||
)
|
||||
, _disableFadeInDistance(DisableFadeInInfo, true)
|
||||
, _billboardMaxSize(BillboardMaxSizeInfo, 400.f, 0.f, 1000.f)
|
||||
, _billboardMinSize(BillboardMinSizeInfo, 0.f, 0.f, 100.f)
|
||||
, _billboardMinMaxSize(
|
||||
BillboardMinMaxSizeInfo,
|
||||
glm::vec2(0.f, 400.f),
|
||||
glm::vec2(0.f),
|
||||
glm::vec2(1000.f)
|
||||
)
|
||||
, _correctionSizeEndDistance(CorrectionSizeEndDistanceInfo, 17.f, 12.f, 25.f)
|
||||
, _correctionSizeFactor(CorrectionSizeFactorInfo, 8.f, 0.f, 20.f)
|
||||
, _useLinearFiltering(UseLinearFiltering, false)
|
||||
@@ -441,6 +432,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
|
||||
// @TODO (abock, 2021-01-31) I don't know why we only add this property if the
|
||||
// texture is given, but I think it's a bug
|
||||
// @TODO (emmbr, 2021-05-24) This goes for several properties in this renderable
|
||||
addProperty(_spriteTexturePath);
|
||||
}
|
||||
_hasSpriteTexture = p.texture.has_value();
|
||||
@@ -528,28 +520,28 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
_textSize = p.textSize.value_or(_textSize);
|
||||
addProperty(_textSize);
|
||||
|
||||
_textMinSize = p.textMinSize.value_or(_textMinSize);
|
||||
addProperty(_textMinSize);
|
||||
|
||||
_textMaxSize = p.textMaxSize.value_or(_textMaxSize);
|
||||
addProperty(_textMaxSize);
|
||||
_textMinMaxSize = p.textMinMaxSize.value_or(_textMinMaxSize);
|
||||
_textMinMaxSize.setViewOption(properties::Property::ViewOptions::MinMaxRange);
|
||||
addProperty(_textMinMaxSize);
|
||||
}
|
||||
|
||||
_transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix);
|
||||
|
||||
if (p.fadeInDistances.has_value()) {
|
||||
_fadeInDistance = *p.fadeInDistances;
|
||||
addProperty(_fadeInDistance);
|
||||
_fadeInDistances = *p.fadeInDistances;
|
||||
_fadeInDistances.setViewOption(properties::Property::ViewOptions::MinMaxRange);
|
||||
addProperty(_fadeInDistances);
|
||||
|
||||
_disableFadeInDistance = false;
|
||||
addProperty(_disableFadeInDistance);
|
||||
}
|
||||
|
||||
_billboardMaxSize = p.billboardMaxSize.value_or(_billboardMaxSize);
|
||||
addProperty(_billboardMaxSize);
|
||||
_pixelSizeControl = p.enablePixelSizeControl.value_or(_pixelSizeControl);
|
||||
addProperty(_pixelSizeControl);
|
||||
|
||||
_billboardMinSize = p.billboardMinSize.value_or(_billboardMinSize);
|
||||
addProperty(_billboardMinSize);
|
||||
_billboardMinMaxSize = p.billboardMinMaxSize.value_or(_billboardMinMaxSize);
|
||||
_billboardMinMaxSize.setViewOption(properties::Property::ViewOptions::MinMaxRange);
|
||||
addProperty(_billboardMinMaxSize);
|
||||
|
||||
_correctionSizeEndDistance =
|
||||
p.correctionSizeEndDistance.value_or(_correctionSizeEndDistance);
|
||||
@@ -560,11 +552,6 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
addProperty(_correctionSizeFactor);
|
||||
}
|
||||
|
||||
_pixelSizeControl = p.enablePixelSizeControl.value_or(_pixelSizeControl);
|
||||
if (p.enablePixelSizeControl.has_value()) {
|
||||
addProperty(_pixelSizeControl);
|
||||
}
|
||||
|
||||
_setRangeFromData.onChange([this]() {
|
||||
const int colorMapInUse =
|
||||
_hasColorMapFile ? _dataset.index(_colorOptionString) : 0;
|
||||
@@ -720,8 +707,11 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data,
|
||||
glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix()
|
||||
)
|
||||
);
|
||||
_program->setUniform(_uniformCache.minBillboardSize, _billboardMinSize); // in pixels
|
||||
_program->setUniform(_uniformCache.maxBillboardSize, _billboardMaxSize); // in pixels
|
||||
|
||||
const float minBillboardSize = _billboardMinMaxSize.value().x; // in pixels
|
||||
const float maxBillboardSize = _billboardMinMaxSize.value().y; // in pixels
|
||||
_program->setUniform(_uniformCache.minBillboardSize, minBillboardSize);
|
||||
_program->setUniform(_uniformCache.maxBillboardSize, maxBillboardSize);
|
||||
_program->setUniform(_uniformCache.color, _pointColor);
|
||||
_program->setUniform(_uniformCache.alphaValue, _opacity);
|
||||
_program->setUniform(_uniformCache.scaleFactor, _scaleFactor);
|
||||
@@ -774,8 +764,8 @@ void RenderableBillboardsCloud::renderLabels(const RenderData& data,
|
||||
ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo;
|
||||
labelInfo.orthoRight = orthoRight;
|
||||
labelInfo.orthoUp = orthoUp;
|
||||
labelInfo.minSize = static_cast<int>(_textMinSize);
|
||||
labelInfo.maxSize = static_cast<int>(_textMaxSize);
|
||||
labelInfo.minSize = _textMinMaxSize.value().x;
|
||||
labelInfo.maxSize = _textMinMaxSize.value().y;
|
||||
labelInfo.cameraPos = data.camera.positionVec3();
|
||||
labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace();
|
||||
labelInfo.renderType = _renderOption;
|
||||
@@ -801,7 +791,7 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {
|
||||
float fadeInVar = 1.f;
|
||||
if (!_disableFadeInDistance) {
|
||||
float distCamera = static_cast<float>(glm::length(data.camera.positionVec3()));
|
||||
const glm::vec2 fadeRange = _fadeInDistance;
|
||||
const glm::vec2 fadeRange = _fadeInDistances;
|
||||
const float a = static_cast<float>(
|
||||
1.f / ((fadeRange.y - fadeRange.x) * unitToMeter(_unit))
|
||||
);
|
||||
@@ -1136,7 +1126,7 @@ std::vector<float> RenderableBillboardsCloud::createDataSlice() {
|
||||
}
|
||||
}
|
||||
setBoundingSphere(maxRadius);
|
||||
_fadeInDistance.setMaxValue(glm::vec2(10.f * biggestCoord));
|
||||
_fadeInDistances.setMaxValue(glm::vec2(10.f * biggestCoord));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user