mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
Various code cleanup
This commit is contained in:
@@ -54,10 +54,10 @@ namespace {
|
||||
constexpr const char* KeyStaticFilterReplacement = "StaticFilterReplacement";
|
||||
|
||||
constexpr const std::array<const char*, 16> UniformNames = {
|
||||
"modelMatrix", "cameraUp", "cameraViewProjectionMatrix",
|
||||
"colorOption", "magnitudeExponent", "eyePosition", "psfParamConf",
|
||||
"lumCent", "radiusCent", "brightnessCent", "colorTexture",
|
||||
"alphaValue", "psfTexture", "otherDataTexture", "otherDataRange",
|
||||
"modelMatrix", "cameraUp", "cameraViewProjectionMatrix",
|
||||
"colorOption", "magnitudeExponent", "eyePosition", "psfParamConf",
|
||||
"lumCent", "radiusCent", "brightnessCent", "colorTexture",
|
||||
"alphaValue", "psfTexture", "otherDataTexture", "otherDataRange",
|
||||
"filterOutOfRange"
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace {
|
||||
"Speck File",
|
||||
"The speck file that is loaded to get the data for rendering these stars."
|
||||
};
|
||||
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo ColorTextureInfo = {
|
||||
"ColorMap",
|
||||
"ColorBV Texture",
|
||||
@@ -172,7 +172,7 @@ namespace {
|
||||
"Stars closer than this distance are given full opacity. "
|
||||
"Farther away, stars dim proportionally to the logarithm of their distance."
|
||||
};
|
||||
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RenderMethodOptionInfo = {
|
||||
"RenderMethod",
|
||||
"Render Method",
|
||||
@@ -214,7 +214,7 @@ namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo LumPercentInfo = {
|
||||
"LumPercent",
|
||||
"Luminosity Contribution",
|
||||
"Luminosity Contribution."
|
||||
"Luminosity Contribution."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RadiusPercentInfo = {
|
||||
@@ -398,8 +398,14 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
, _filterOutOfRange(FilterOutOfRangeInfo, false)
|
||||
, _pointSpreadFunctionTexturePath(PsfTextureInfo)
|
||||
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
|
||||
, _psfMethodOption(PSFMethodOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _psfMultiplyOption(SizeCompositionOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _psfMethodOption(
|
||||
PSFMethodOptionInfo,
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
, _psfMultiplyOption(
|
||||
SizeCompositionOptionInfo,
|
||||
properties::OptionProperty::DisplayType::Dropdown
|
||||
)
|
||||
, _lumCent(LumPercentInfo, 0.5f, 0.f, 3.f)
|
||||
, _radiusCent(RadiusPercentInfo, 0.5f, 0.f, 3.f)
|
||||
, _brightnessCent(BrightnessPercentInfo, 0.5f, 0.f, 3.f)
|
||||
@@ -447,7 +453,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
dictionary.value<std::string>(OtherDataColorMapInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
_colorOption.addOptions({
|
||||
{ ColorOption::Color, "Color" },
|
||||
{ ColorOption::Velocity, "Velocity" },
|
||||
@@ -475,7 +481,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_colorOption);
|
||||
|
||||
_colorTexturePath.onChange([&] { _colorTextureIsDirty = true; });
|
||||
_colorTextureFile->setCallback([&](const File&) {
|
||||
_colorTextureFile->setCallback([&](const File&) {
|
||||
_colorTextureIsDirty = true;
|
||||
});
|
||||
addProperty(_colorTexturePath);
|
||||
@@ -520,10 +526,10 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
"Point Spread Function Based"
|
||||
);
|
||||
_renderingMethodOption.addOption(RenderOptionTexture, "Textured Based");
|
||||
addProperty(_renderingMethodOption);
|
||||
addProperty(_renderingMethodOption);
|
||||
|
||||
if (dictionary.hasKey(RenderMethodOptionInfo.identifier)) {
|
||||
std::string renderingMethod =
|
||||
std::string renderingMethod =
|
||||
dictionary.value<std::string>(RenderMethodOptionInfo.identifier);
|
||||
if (renderingMethod == "PSF") {
|
||||
_renderingMethodOption = RenderOptionPointSpreadFunction;
|
||||
@@ -540,14 +546,14 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
PsfTextureInfo.identifier
|
||||
));
|
||||
_pointSpreadFunctionFile = std::make_unique<File>(_pointSpreadFunctionTexturePath);
|
||||
_pointSpreadFunctionTexturePath.onChange([&]() {
|
||||
_pointSpreadFunctionTextureIsDirty = true;
|
||||
_pointSpreadFunctionTexturePath.onChange([&]() {
|
||||
_pointSpreadFunctionTextureIsDirty = true;
|
||||
});
|
||||
_pointSpreadFunctionFile->setCallback([&](const File&) {
|
||||
_pointSpreadFunctionFile->setCallback([&](const File&) {
|
||||
_pointSpreadFunctionTextureIsDirty = true;
|
||||
});
|
||||
_userProvidedTextureOwner.addProperty(_pointSpreadFunctionTexturePath);
|
||||
|
||||
|
||||
if (dictionary.hasKey(TransparencyInfo.identifier)) {
|
||||
_alphaValue = static_cast<float>(
|
||||
dictionary.value<double>(TransparencyInfo.identifier)
|
||||
@@ -569,9 +575,9 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
_psfMultiplyOption.addOption(5, "Distance Modulus");
|
||||
|
||||
if (dictionary.hasKey(MagnitudeExponentInfo.identifier)) {
|
||||
std::string sizeCompositionOption =
|
||||
std::string sizeCompositionOption =
|
||||
dictionary.value<std::string>(SizeCompositionOptionInfo.identifier);
|
||||
|
||||
|
||||
if (sizeCompositionOption == "App Brightness") {
|
||||
_psfMultiplyOption = 0;
|
||||
} else if (sizeCompositionOption == "Lum and Size") {
|
||||
@@ -782,9 +788,9 @@ void RenderableStars::renderPSFToTexture() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, psfFBO);
|
||||
GLenum drawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
|
||||
glDrawBuffers(1, drawBuffers);
|
||||
|
||||
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, _psfTexture, 0);
|
||||
|
||||
|
||||
glViewport(0, 0, _psfTextureSize, _psfTextureSize);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -812,7 +818,7 @@ void RenderableStars::renderPSFToTexture() {
|
||||
glBindVertexArray(_psfVao);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
program->deactivate();
|
||||
|
||||
// JCC: Convolution is disabled while FFT is not enabled
|
||||
@@ -824,9 +830,9 @@ void RenderableStars::renderPSFToTexture() {
|
||||
//glDrawBuffers(1, drawBuffers);
|
||||
|
||||
//glFramebufferTexture(
|
||||
// GL_FRAMEBUFFER,
|
||||
// GL_COLOR_ATTACHMENT0,
|
||||
// _convolvedTexture,
|
||||
// GL_FRAMEBUFFER,
|
||||
// GL_COLOR_ATTACHMENT0,
|
||||
// _convolvedTexture,
|
||||
// 0
|
||||
//);
|
||||
|
||||
@@ -853,7 +859,7 @@ void RenderableStars::renderPSFToTexture() {
|
||||
|
||||
//programConvolve->setUniform("psfTextureSize", _psfTextureSize);
|
||||
//programConvolve->setUniform(
|
||||
// "convolvedfTextureSize",
|
||||
// "convolvedfTextureSize",
|
||||
// _convolvedfTextureSize
|
||||
//);
|
||||
|
||||
@@ -884,7 +890,7 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) {
|
||||
if (_fullData.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Saving current OpenGL state
|
||||
GLenum blendEquationRGB;
|
||||
GLenum blendEquationAlpha;
|
||||
@@ -934,14 +940,14 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) {
|
||||
);
|
||||
_program->setUniform(_uniformCache.colorOption, _colorOption);
|
||||
_program->setUniform(_uniformCache.magnitudeExponent, _magnitudeExponent);
|
||||
|
||||
|
||||
_program->setUniform(_uniformCache.psfParamConf, _psfMultiplyOption.value());
|
||||
_program->setUniform(_uniformCache.lumCent, _lumCent);
|
||||
_program->setUniform(_uniformCache.radiusCent, _radiusCent);
|
||||
_program->setUniform(_uniformCache.brightnessCent, _brightnessCent);
|
||||
|
||||
_program->setUniform(_uniformCache.alphaValue, _alphaValue);
|
||||
|
||||
|
||||
ghoul::opengl::TextureUnit psfUnit;
|
||||
psfUnit.activate();
|
||||
|
||||
@@ -1361,7 +1367,7 @@ void RenderableStars::readSpeckFile() {
|
||||
|
||||
// +3 because the position x, y, z
|
||||
if (name == "lum") {
|
||||
_lumArrayPos = _nValuesPerStar + 3;
|
||||
_lumArrayPos = _nValuesPerStar + 3;
|
||||
}
|
||||
else if (name == "absmag") {
|
||||
_absMagArrayPos = _nValuesPerStar + 3;
|
||||
@@ -1404,9 +1410,9 @@ void RenderableStars::readSpeckFile() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
minLumValue = values[_lumArrayPos] < minLumValue ?
|
||||
minLumValue = values[_lumArrayPos] < minLumValue ?
|
||||
values[_lumArrayPos] : minLumValue;
|
||||
maxLumValue = values[_lumArrayPos] > maxLumValue ?
|
||||
maxLumValue = values[_lumArrayPos] > maxLumValue ?
|
||||
values[_lumArrayPos] : maxLumValue;
|
||||
if (!nullArray) {
|
||||
_fullData.insert(_fullData.end(), values.begin(), values.end());
|
||||
@@ -1415,7 +1421,7 @@ void RenderableStars::readSpeckFile() {
|
||||
|
||||
// Normalize Luminosity:
|
||||
for (size_t i = 0; i < _fullData.size(); i += _nValuesPerStar) {
|
||||
_fullData[i + _lumArrayPos] =
|
||||
_fullData[i + _lumArrayPos] =
|
||||
(_fullData[i + _lumArrayPos] - minLumValue) / (maxLumValue - minLumValue);
|
||||
}
|
||||
}
|
||||
@@ -1494,7 +1500,7 @@ void RenderableStars::saveCachedFile(const std::string& file) const {
|
||||
fileStream.write(reinterpret_cast<const char*>(&_appMagArrayPos), sizeof(int32_t));
|
||||
fileStream.write(reinterpret_cast<const char*>(&_bvColorArrayPos), sizeof(int32_t));
|
||||
fileStream.write(reinterpret_cast<const char*>(&_velocityArrayPos), sizeof(int32_t));
|
||||
fileStream.write(reinterpret_cast<const char*>(&_speedArrayPos), sizeof(int32_t));
|
||||
fileStream.write(reinterpret_cast<const char*>(&_speedArrayPos), sizeof(int32_t));
|
||||
|
||||
// -3 as we don't want to save the xyz values that are in the beginning of the file
|
||||
for (int i = 0; i < _nValuesPerStar - 3; ++i) {
|
||||
@@ -1516,7 +1522,11 @@ void RenderableStars::createDataSlice(ColorOption option) {
|
||||
);
|
||||
|
||||
for (size_t i = 0; i < _fullData.size(); i += _nValuesPerStar) {
|
||||
glm::vec3 position = glm::vec3(_fullData[i + 0], _fullData[i + 1], _fullData[i + 2]);
|
||||
glm::vec3 position = glm::vec3(
|
||||
_fullData[i + 0],
|
||||
_fullData[i + 1],
|
||||
_fullData[i + 2]
|
||||
);
|
||||
position *= openspace::distanceconstants::Parsec;
|
||||
|
||||
switch (option) {
|
||||
@@ -1606,8 +1616,8 @@ void RenderableStars::createDataSlice(ColorOption option) {
|
||||
layout.value.position = { { position[0], position[1], position[2] } };
|
||||
|
||||
int index = _otherDataOption.value();
|
||||
// plus 3 because of the position
|
||||
layout.value.value = _fullData[i + index + 3];
|
||||
// plus 3 because of the position
|
||||
layout.value.value = _fullData[i + index + 3];
|
||||
|
||||
if (_staticFilterValue.has_value() &&
|
||||
layout.value.value == _staticFilterValue)
|
||||
|
||||
@@ -93,8 +93,8 @@ private:
|
||||
//properties::StringProperty _shapeTexturePath;
|
||||
//std::unique_ptr<ghoul::opengl::Texture> _shapeTexture;
|
||||
//std::unique_ptr<ghoul::filesystem::File> _shapeTextureFile;
|
||||
|
||||
properties::OptionProperty _colorOption;
|
||||
|
||||
properties::OptionProperty _colorOption;
|
||||
properties::OptionProperty _otherDataOption;
|
||||
properties::StringProperty _otherDataColorMapPath;
|
||||
properties::Vec2Property _otherDataRange;
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
properties::StringProperty _pointSpreadFunctionTexturePath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _pointSpreadFunctionTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _pointSpreadFunctionFile;
|
||||
|
||||
|
||||
properties::FloatProperty _alphaValue;
|
||||
properties::OptionProperty _psfMethodOption;
|
||||
properties::OptionProperty _psfMultiplyOption;
|
||||
@@ -126,13 +126,13 @@ private:
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
|
||||
UniformCache(
|
||||
modelMatrix, cameraUp, cameraViewProjectionMatrix,
|
||||
colorOption, magnitudeExponent, eyePosition, psfParamConf,
|
||||
lumCent, radiusCent, brightnessCent, colorTexture,
|
||||
alphaValue, psfTexture, otherDataTexture, otherDataRange,
|
||||
modelMatrix, cameraUp, cameraViewProjectionMatrix,
|
||||
colorOption, magnitudeExponent, eyePosition, psfParamConf,
|
||||
lumCent, radiusCent, brightnessCent, colorTexture,
|
||||
alphaValue, psfTexture, otherDataTexture, otherDataRange,
|
||||
filterOutOfRange
|
||||
) _uniformCache;
|
||||
|
||||
|
||||
bool _speckFileIsDirty = true;
|
||||
bool _pointSpreadFunctionTextureIsDirty = true;
|
||||
bool _colorTextureIsDirty = true;
|
||||
@@ -145,7 +145,7 @@ private:
|
||||
|
||||
std::vector<float> _slicedData;
|
||||
std::vector<float> _fullData;
|
||||
|
||||
|
||||
int _nValuesPerStar = 0;
|
||||
std::string _queuedOtherData;
|
||||
std::vector<std::string> _dataNames;
|
||||
|
||||
Reference in New Issue
Block a user