Various code cleanup

This commit is contained in:
Alexander Bock
2019-06-18 10:47:15 +02:00
parent 8f6520ea8f
commit d0c04cfc6b
26 changed files with 154 additions and 123 deletions
+12 -5
View File
@@ -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);
}
+1 -1
View File
@@ -271,7 +271,7 @@ private:
size_t _iterationsOfUnavailableData = 0;
Layer* _lastChangedLayer = nullptr;
// Labels
// Labels
GlobeLabelsComponent _globeLabelsComponent;
ghoul::Dictionary _labelsDictionary;
};