mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 11:18:22 -05:00
Various code cleanup
This commit is contained in:
@@ -407,10 +407,9 @@ std::pair<glm::dvec3, std::string> DashboardItemDistance::positionAndLabel(
|
||||
if (!anchor) {
|
||||
return { glm::dvec3(0.0), "Unknown" };
|
||||
}
|
||||
return {
|
||||
global::navigationHandler.orbitalNavigator().anchorNode()->worldPosition(),
|
||||
"focus"
|
||||
};
|
||||
else {
|
||||
return { anchor->worldPosition(), "focus" };
|
||||
}
|
||||
}
|
||||
case Type::Camera:
|
||||
return { global::renderEngine.scene()->camera()->positionVec3(), "camera" };
|
||||
|
||||
@@ -197,8 +197,13 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
, _specularIntensity(SpecularIntensityInfo, 1.f, 0.f, 1.f)
|
||||
, _performShading(ShadingInfo, true)
|
||||
, _disableFaceCulling(DisableFaceCullingInfo, false)
|
||||
, _modelTransform(ModelTransformInfo, glm::dmat3(1.0), glm::dmat3(-1.0), glm::dmat3(1.0))
|
||||
, _rotationVec(RotationVecInfo, glm::dvec3(0), glm::dvec3(0), glm::dvec3(360))
|
||||
, _modelTransform(
|
||||
ModelTransformInfo,
|
||||
glm::dmat3(1.0),
|
||||
glm::dmat3(-1.0),
|
||||
glm::dmat3(1.0)
|
||||
)
|
||||
, _rotationVec(RotationVecInfo, glm::dvec3(0.0), glm::dvec3(0.0), glm::dvec3(360.0))
|
||||
, _lightSourcePropertyOwner({ "LightSources", "Light Sources" })
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
@@ -274,10 +279,12 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
|
||||
_rotationVec.onChange([this]() {
|
||||
glm::vec3 degreeVector = _rotationVec;
|
||||
glm::vec3 radianVector = glm::vec3(glm::radians(degreeVector.x),
|
||||
glm::radians(degreeVector.y), glm::radians(degreeVector.z));
|
||||
_modelTransform = glm::mat4_cast(
|
||||
glm::quat(radianVector));
|
||||
glm::vec3 radianVector = glm::vec3(
|
||||
glm::radians(degreeVector.x),
|
||||
glm::radians(degreeVector.y),
|
||||
glm::radians(degreeVector.z)
|
||||
);
|
||||
_modelTransform = glm::mat4_cast(glm::quat(radianVector));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -405,13 +412,13 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
if (_disableFaceCulling) {
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
|
||||
_geometry->render();
|
||||
|
||||
if (_disableFaceCulling) {
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
|
||||
_program->deactivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace {
|
||||
"This value specifies an image that is loaded from disk and is used as a texture "
|
||||
"that is applied to this plane. This image has to be square."
|
||||
};
|
||||
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RenderableTypeInfo = {
|
||||
"RenderableType",
|
||||
"RenderableType",
|
||||
|
||||
@@ -747,7 +747,7 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data,
|
||||
|
||||
glEnablei(GL_BLEND, 0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
|
||||
_program->activate();
|
||||
|
||||
const glm::dmat4 projMatrix = glm::dmat4(data.camera.projectionMatrix());
|
||||
|
||||
@@ -183,10 +183,14 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
_wmsCacheLocation = dict.value<std::string>(WMSCacheLocationInfo.identifier);
|
||||
}
|
||||
if (dict.hasKeyAndValue<double>(WMSCacheSizeInfo.identifier)) {
|
||||
_wmsCacheSizeMB = static_cast<int>(dict.value<double>(WMSCacheSizeInfo.identifier));
|
||||
_wmsCacheSizeMB = static_cast<int>(
|
||||
dict.value<double>(WMSCacheSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
if (dict.hasKeyAndValue<double>(TileCacheSizeInfo.identifier)) {
|
||||
_tileCacheSizeMB = static_cast<int>(dict.value<double>(TileCacheSizeInfo.identifier));
|
||||
_tileCacheSizeMB = static_cast<int>(
|
||||
dict.value<double>(TileCacheSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
@@ -207,7 +211,9 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
|
||||
// Initialize
|
||||
global::callback::initializeGL.emplace_back([&]() {
|
||||
_tileCache = std::make_unique<globebrowsing::cache::MemoryAwareTileCache>(_tileCacheSizeMB);
|
||||
_tileCache = std::make_unique<globebrowsing::cache::MemoryAwareTileCache>(
|
||||
_tileCacheSizeMB
|
||||
);
|
||||
addPropertySubOwner(*_tileCache);
|
||||
|
||||
tileprovider::initializeDefaultTile();
|
||||
@@ -486,9 +492,10 @@ void GlobeBrowsingModule::goToGeodetic2(Camera& camera, globebrowsing::Geodetic2
|
||||
return;
|
||||
}
|
||||
|
||||
const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3();
|
||||
interaction::NavigationHandler& nav = global::navigationHandler;
|
||||
const glm::dvec3 cameraPosition = nav.camera()->positionVec3();
|
||||
const glm::dmat4 inverseModelTransform =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode()->inverseModelTransform();
|
||||
nav.orbitalNavigator().anchorNode()->inverseModelTransform();
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
|
||||
const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
|
||||
|
||||
@@ -207,7 +207,7 @@ int getGeoPositionForCamera(lua_State* L) {
|
||||
}
|
||||
|
||||
const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3();
|
||||
const SceneGraphNode* anchor =
|
||||
const SceneGraphNode* anchor =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
const glm::dmat4 inverseModelTransform = anchor->inverseModelTransform();
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
|
||||
@@ -306,7 +306,7 @@ GlobeLabelsComponent::GlobeLabelsComponent()
|
||||
addProperty(_labelAlignmentOption);
|
||||
}
|
||||
|
||||
void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary,
|
||||
void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary,
|
||||
globebrowsing::RenderableGlobe* globe)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
@@ -314,7 +314,7 @@ void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary,
|
||||
dictionary,
|
||||
"GlobeLabelsComponent"
|
||||
);
|
||||
|
||||
|
||||
_globe = globe;
|
||||
|
||||
// Reads labels' file and build cache file if necessary
|
||||
@@ -339,7 +339,7 @@ void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary,
|
||||
// enables the label automatically.
|
||||
_labelsEnabled = true;
|
||||
}
|
||||
|
||||
|
||||
if (dictionary.hasKey(LabelsFontSizeInfo.identifier)) {
|
||||
_labelsFontSize = dictionary.value<float>(LabelsFontSizeInfo.identifier);
|
||||
_labelsFontSize.onChange([this]() { initializeFonts(); });
|
||||
@@ -475,7 +475,7 @@ bool GlobeLabelsComponent::readLabelsFile(const std::string& file) {
|
||||
if (!csvLabelFile.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
_labels.labelsArray.clear();
|
||||
|
||||
std::string sline;
|
||||
@@ -488,14 +488,14 @@ bool GlobeLabelsComponent::readLabelsFile(const std::string& file) {
|
||||
std::istringstream iss(sline);
|
||||
std::string token;
|
||||
std::getline(iss, token, ',');
|
||||
|
||||
|
||||
// First line is just the Header
|
||||
if (token == "Feature_Name") {
|
||||
continue;
|
||||
}
|
||||
|
||||
LabelEntry lEntry;
|
||||
|
||||
|
||||
// Non-ascii characters aren't displayed correctly by the text
|
||||
// rendering (We don't have the non-ascii character in the texture
|
||||
// atlas)
|
||||
@@ -516,16 +516,16 @@ bool GlobeLabelsComponent::readLabelsFile(const std::string& file) {
|
||||
}
|
||||
|
||||
std::getline(iss, token, ','); // Target is not used
|
||||
|
||||
|
||||
std::getline(iss, token, ','); // Diameter
|
||||
lEntry.diameter = std::stof(token);
|
||||
|
||||
|
||||
std::getline(iss, token, ','); // Latitude
|
||||
lEntry.latitude = std::stof(token);
|
||||
|
||||
|
||||
std::getline(iss, token, ','); // Longitude
|
||||
lEntry.longitude = std::stof(token);
|
||||
|
||||
|
||||
std::getline(iss, token, ','); // Coord System
|
||||
std::string coordinateSystem(token);
|
||||
std::size_t found = coordinateSystem.find("West");
|
||||
@@ -552,7 +552,7 @@ bool GlobeLabelsComponent::readLabelsFile(const std::string& file) {
|
||||
|
||||
_labels.labelsArray.push_back(lEntry);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const std::fstream::failure& e) {
|
||||
@@ -623,9 +623,9 @@ void GlobeLabelsComponent::draw(const RenderData& data) {
|
||||
viewTransform;
|
||||
glm::dmat4 mvp = vp * _globe->modelTransform();
|
||||
|
||||
glm::dvec3 globePositionWorld = glm::dvec3(_globe->modelTransform() *
|
||||
glm::dvec3 globePositionWorld = glm::dvec3(_globe->modelTransform() *
|
||||
glm::vec4(0.f, 0.f, 0.f, 1.f));
|
||||
glm::dvec3 cameraToGlobeDistanceWorld = globePositionWorld -
|
||||
glm::dvec3 cameraToGlobeDistanceWorld = globePositionWorld -
|
||||
data.camera.positionVec3();
|
||||
double distanceCameraGlobeWorld = glm::length(cameraToGlobeDistanceWorld);
|
||||
|
||||
@@ -667,7 +667,7 @@ void GlobeLabelsComponent::draw(const RenderData& data) {
|
||||
}
|
||||
|
||||
void GlobeLabelsComponent::renderLabels(const RenderData& data,
|
||||
const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::dmat4& modelViewProjectionMatrix,
|
||||
float distToCamera,
|
||||
float fadeInVariable
|
||||
) {
|
||||
@@ -682,7 +682,7 @@ void GlobeLabelsComponent::renderLabels(const RenderData& data,
|
||||
|
||||
glm::dvec4 cameraPosWorld = invCombinedView * glm::dvec4(0.0, 0.0, 0.0, 1.0);
|
||||
glm::dvec3 cameraPosObj = glm::dvec3(invMP * cameraPosWorld);
|
||||
glm::dvec4 cameraUpVecWorld = glm::dvec4(data.camera.lookUpVectorWorldSpace(), 0.0);
|
||||
glm::dvec4 cameraUpVecWorld = glm::dvec4(data.camera.lookUpVectorWorldSpace(), 0.0);
|
||||
glm::dvec3 cameraLookUpObj = glm::dvec3(invMP * cameraUpVecWorld);
|
||||
|
||||
glm::dmat4 VP = glm::dmat4(data.camera.sgctInternal.projectionMatrix()) *
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace ghoul::opengl { class ProgramObject; }
|
||||
namespace openspace {
|
||||
|
||||
struct RenderData;
|
||||
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
namespace globebrowsing { class RenderableGlobe; }
|
||||
|
||||
|
||||
@@ -475,10 +475,10 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_generalProperties.useAccurateNormals);
|
||||
addProperty(_generalProperties.eclipseShadowsEnabled);
|
||||
addProperty(_generalProperties.eclipseHardShadows);
|
||||
_generalProperties.targetLodScaleFactor.onChange([this]() {
|
||||
_generalProperties.targetLodScaleFactor.onChange([this]() {
|
||||
float sf = _generalProperties.targetLodScaleFactor;
|
||||
_generalProperties.currentLodScaleFactor = sf;
|
||||
_lodScaleFactorDirty = true;
|
||||
_lodScaleFactorDirty = true;
|
||||
});
|
||||
addProperty(_generalProperties.targetLodScaleFactor);
|
||||
addProperty(_generalProperties.currentLodScaleFactor);
|
||||
@@ -2197,7 +2197,6 @@ bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) {
|
||||
if (isLeaf(cn)) {
|
||||
updateChunk(cn, data);
|
||||
|
||||
|
||||
if (cn.status == Chunk::Status::WantSplit) {
|
||||
splitChunkNode(cn, 1);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ private:
|
||||
size_t _iterationsOfUnavailableData = 0;
|
||||
Layer* _lastChangedLayer = nullptr;
|
||||
|
||||
// Labels
|
||||
// Labels
|
||||
GlobeLabelsComponent _globeLabelsComponent;
|
||||
ghoul::Dictionary _labelsDictionary;
|
||||
};
|
||||
|
||||
@@ -80,7 +80,7 @@ void TimeTopic::handleJson(const nlohmann::json& json) {
|
||||
sendCurrentTime();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
_deltaTimeCallbackHandle = global::timeManager.addDeltaTimeChangeCallback([this]() {
|
||||
// Throttle by last update,
|
||||
// but force update if pause state or target delta changes.
|
||||
|
||||
@@ -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