mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-10 23:38:38 -05:00
Clean up and remove unused code
This commit is contained in:
@@ -56,8 +56,8 @@ function postInitialization()
|
||||
openspace.setPropertyValue("SunMarker.renderable.enabled", false)
|
||||
|
||||
openspace.setPropertyValue("Earth.RenderableGlobe.atmosphere", true)
|
||||
openspace.setPropertyValue("Earth.RenderableGlobe.Layers.NightTextures.Earth at Night 2012.gamma", 1.8)
|
||||
openspace.setPropertyValue("Earth.RenderableGlobe.Layers.NightTextures.Earth at Night 2012.multiplier", 10)
|
||||
openspace.setPropertyValue("Earth.RenderableGlobe.Layers.NightTextures.Earth at Night 2012.settings.gamma", 1.8)
|
||||
openspace.setPropertyValue("Earth.RenderableGlobe.Layers.NightTextures.Earth at Night 2012.settings.multiplier", 10)
|
||||
|
||||
openspace.resetCameraDirection()
|
||||
openspace.time.setDeltaTime(0)
|
||||
|
||||
@@ -68,10 +68,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextureshaderprovider.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextures.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/perlayersetting.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layer/layer.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.h
|
||||
@@ -123,11 +120,8 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tile/layermanager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layer/layer.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextureshaderprovider.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextures.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/perlayersetting.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <modules/globebrowsing/chunk/chunk.h>
|
||||
#include <modules/globebrowsing/globes/renderableglobe.h>
|
||||
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
#include <modules/globebrowsing/tile/tileioresult.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -104,11 +103,11 @@ namespace globebrowsing {
|
||||
auto layerManager = owner().chunkedLodGlobe()->layerManager();
|
||||
|
||||
|
||||
auto heightMapProviders = layerManager->layerGroup(LayeredTextures::HeightMaps).activeLayers();
|
||||
auto heightMapProviders = layerManager->layerGroup(LayerManager::HeightMaps).activeLayers();
|
||||
|
||||
|
||||
size_t HEIGHT_CHANNEL = 0;
|
||||
const LayerGroup& heightmaps = layerManager->layerGroup(LayeredTextures::HeightMaps);
|
||||
const LayerGroup& heightmaps = layerManager->layerGroup(LayerManager::HeightMaps);
|
||||
std::vector<ChunkTile> tiles = TileSelector::getTilesSortedByHighestResolution(heightmaps, _tileIndex);
|
||||
bool lastHadMissingData = true;
|
||||
for (auto tile : tiles) {
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <modules/globebrowsing/chunk/chunk.h>
|
||||
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
|
||||
#include <modules/globebrowsing/globes/renderableglobe.h>
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
@@ -162,12 +161,12 @@ namespace globebrowsing {
|
||||
}
|
||||
|
||||
int EvaluateChunkLevelByAvailableTileData::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
auto tileProvidermanager = chunk.owner().chunkedLodGlobe()->layerManager();
|
||||
auto heightLayers = tileProvidermanager->layerGroup(LayeredTextures::HeightMaps).activeLayers();
|
||||
auto layerManager = chunk.owner().chunkedLodGlobe()->layerManager();
|
||||
auto heightLayers = layerManager->layerGroup(LayerManager::HeightMaps).activeLayers();
|
||||
int currLevel = chunk.tileIndex().level;
|
||||
|
||||
for (size_t i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; i++) {
|
||||
for (auto& layer : tileProvidermanager->layerGroup(i).activeLayers()) {
|
||||
|
||||
for (size_t i = 0; i < LayerManager::NUM_LAYER_GROUPS; i++) {
|
||||
for (auto& layer : layerManager->layerGroup(i).activeLayers()) {
|
||||
Tile::Status tileStatus = layer->tileProvider()->getTileStatus(chunk.tileIndex());
|
||||
if (tileStatus == Tile::Status::OK) {
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <modules/globebrowsing/chunk/chunkrenderer.h>
|
||||
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
|
||||
#include <modules/globebrowsing/globes/renderableglobe.h>
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
#include <modules/globebrowsing/tile/layermanager.h>
|
||||
#include <modules/globebrowsing/tile/chunktile.h>
|
||||
|
||||
@@ -103,16 +102,13 @@ namespace globebrowsing {
|
||||
|
||||
LayeredTexturePreprocessingData layeredTexturePreprocessingData;
|
||||
|
||||
for (size_t category = 0;
|
||||
category < LayeredTextures::NUM_TEXTURE_CATEGORIES;
|
||||
category++) {
|
||||
|
||||
for (size_t i = 0; i < LayerManager::NUM_LAYER_GROUPS; i++) {
|
||||
LayeredTextureInfo layeredTextureInfo;
|
||||
auto layerGroup = _layerManager->layerGroup(category);
|
||||
auto layerGroup = _layerManager->layerGroup(i);
|
||||
layeredTextureInfo.lastLayerIdx = layerGroup.activeLayers().size() - 1;
|
||||
layeredTextureInfo.layerBlendingEnabled = layerGroup.layerBlendingEnabled();
|
||||
|
||||
layeredTexturePreprocessingData.layeredTextureInfo[category] = layeredTextureInfo;
|
||||
layeredTexturePreprocessingData.layeredTextureInfo[i] = layeredTextureInfo;
|
||||
}
|
||||
|
||||
const auto& generalProps = chunk.owner().generalProperties();
|
||||
@@ -191,10 +187,8 @@ namespace globebrowsing {
|
||||
programObject->setUniform("lonLatScalingFactor", vec2(patchSize.toLonLatVec2()));
|
||||
programObject->setUniform("radiiSquared", vec3(ellipsoid.radiiSquared()));
|
||||
|
||||
if (_layerManager->layerGroup(
|
||||
LayeredTextures::NightTextures).activeLayers().size() > 0 ||
|
||||
_layerManager->layerGroup(
|
||||
LayeredTextures::WaterMasks).activeLayers().size() > 0 ||
|
||||
if (_layerManager->layerGroup(LayerManager::NightTextures).activeLayers().size() > 0 ||
|
||||
_layerManager->layerGroup(LayerManager::WaterMasks).activeLayers().size() > 0 ||
|
||||
chunk.owner().generalProperties().atmosphereEnabled ||
|
||||
chunk.owner().generalProperties().performShading) {
|
||||
glm::vec3 directionToSunWorldSpace =
|
||||
@@ -268,12 +262,11 @@ namespace globebrowsing {
|
||||
programObject->setUniform("patchNormalCameraSpace", patchNormalCameraSpace);
|
||||
programObject->setUniform("projectionTransform", data.camera.projectionMatrix());
|
||||
|
||||
if (_layerManager->layerGroup(
|
||||
LayeredTextures::NightTextures).activeLayers().size() > 0 ||
|
||||
_layerManager->layerGroup(
|
||||
LayeredTextures::WaterMasks).activeLayers().size() > 0 ||
|
||||
if (_layerManager->layerGroup(LayerManager::NightTextures).activeLayers().size() > 0 ||
|
||||
_layerManager->layerGroup(LayerManager::WaterMasks).activeLayers().size() > 0 ||
|
||||
chunk.owner().generalProperties().atmosphereEnabled ||
|
||||
chunk.owner().generalProperties().performShading) {
|
||||
chunk.owner().generalProperties().performShading)
|
||||
{
|
||||
glm::vec3 directionToSunWorldSpace =
|
||||
glm::normalize(-data.modelTransform.translation);
|
||||
glm::vec3 directionToSunCameraSpace =
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace globebrowsing {
|
||||
geoDiffPoint.lon / geoDiffPatch.lon, geoDiffPoint.lat / geoDiffPatch.lat);
|
||||
|
||||
// Get the tile providers for the height maps
|
||||
const auto& heightMapLayers = _layerManager->layerGroup(LayeredTextures::HeightMaps).activeLayers();
|
||||
const auto& heightMapLayers = _layerManager->layerGroup(LayerManager::HeightMaps).activeLayers();
|
||||
|
||||
for (const auto& layer : heightMapLayers) {
|
||||
TileProvider* tileProvider = layer->tileProvider();
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <modules/globebrowsing/globes/pointglobe.h>
|
||||
#include <modules/globebrowsing/meshes/trianglesoup.h>
|
||||
#include <modules/globebrowsing/geometry/ellipsoid.h>
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
#include <modules/globebrowsing/other/distanceswitch.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/layer/layer.h>
|
||||
|
||||
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
|
||||
#include <modules/globebrowsing/tile/tileselector.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "Layer";
|
||||
|
||||
const std::string KEY_NAME = "Name";
|
||||
const std::string KEY_ENABLED = "Enabled";
|
||||
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
/*
|
||||
Layer::Layer(const ghoul::Dictionary& dict){
|
||||
dict.getValue(KEY_NAME, _name);
|
||||
dict.getValue(KEY_ENABLED, _enabled);
|
||||
_tileProvider = std::unique_ptr<TileProvider>(TileProvider::createFromDictionary(dict));
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
/*
|
||||
void Layer::bind(ProgramObject* programObject, const TileIndex& tileIndex){
|
||||
|
||||
ChunkTile tat = TileSelector::getHighestResolutionTile(_tileProvider.get(), tileIndex);
|
||||
if (tat.tile.status == Tile::Status::Unavailable) {
|
||||
tat.tile = _tileProvider->getDefaultTile();
|
||||
tat.uvTransform.uvOffset = { 0, 0 };
|
||||
tat.uvTransform.uvScale = { 1, 1 };
|
||||
}
|
||||
|
||||
activateTileAndSetTileUniforms(
|
||||
programUniformHandler,
|
||||
LayeredTextures::TextureCategory(category),
|
||||
LayeredTextures::BlendLayerSuffixes::none,
|
||||
i,
|
||||
texUnits[category][i].blendTexture0,
|
||||
tat);
|
||||
|
||||
// If blending is enabled, two more textures are needed
|
||||
if (layeredTexturePreprocessingData.layeredTextureInfo[category].layerBlendingEnabled) {
|
||||
tat tatParent1 = TileSelector::getHighestResolutionTile(_tileProvider.get(), tileIndex, 1);
|
||||
if (tatParent1.tile.status == Tile::Status::Unavailable) {
|
||||
tatParent1 = tat;
|
||||
}
|
||||
activateTileAndSetTileUniforms(
|
||||
programUniformHandler,
|
||||
LayeredTextures::TextureCategory(category),
|
||||
LayeredTextures::BlendLayerSuffixes::Parent1,
|
||||
i,
|
||||
texUnits[category][i].blendTexture1,
|
||||
tatParent1);
|
||||
|
||||
ChunkTile tatParent2 = TileSelector::getHighestResolutionTile(_tileProvider.get(), tileIndex, 2);
|
||||
if (tatParent2.tile.status == Tile::Status::Unavailable) {
|
||||
tatParent2 = tatParent1;
|
||||
}
|
||||
activateTileAndSetTileUniforms(
|
||||
programUniformHandler,
|
||||
LayeredTextures::TextureCategory(category),
|
||||
LayeredTextures::BlendLayerSuffixes::Parent2,
|
||||
i,
|
||||
texUnits[category][i].blendTexture2,
|
||||
tatParent2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void Layer::ensureIdsAreUpdated(LayeredTextureShaderProvider* shaderProvider){
|
||||
if (shaderProvider->updatedOnLastCall())
|
||||
{
|
||||
_shaderProvider = shaderProvider;
|
||||
// Ignore errors since this loops through even uniforms that does not exist.
|
||||
_shaderProvider->_programObject->setIgnoreUniformLocationError(
|
||||
ProgramObject::IgnoreError::Yes);
|
||||
for (size_t i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; i++)
|
||||
{
|
||||
for (size_t j = 0; j < LayeredTextures::NUM_BLEND_TEXTURES; j++)
|
||||
{
|
||||
for (size_t k = 0; k < LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY;
|
||||
k++)
|
||||
{
|
||||
for (size_t l = 0; l < LayeredTextures::NUM_TILE_DATA_VARIABLES; l++)
|
||||
{
|
||||
_tileUniformIds[i][j][k][l] =
|
||||
_shaderProvider->_programObject->uniformLocation(
|
||||
LayeredTextures::TEXTURE_CATEGORY_NAMES[i] +
|
||||
LayeredTextures::blendLayerSuffixes[j] +
|
||||
"[" + std::to_string(k) + "]." +
|
||||
LayeredTextures::glslTileDataNames[l]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; i++)
|
||||
{
|
||||
for (size_t k = 0; k < LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY;
|
||||
k++)
|
||||
{
|
||||
for (size_t l = 0; l < LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES; l++)
|
||||
{
|
||||
_layerSettingsUniformIds[i][k][l] =
|
||||
_shaderProvider->_programObject->uniformLocation(
|
||||
LayeredTextures::TEXTURE_CATEGORY_NAMES[i] +
|
||||
"Settings" +
|
||||
"[" + std::to_string(k) + "]." +
|
||||
LayeredTextures::layerSettingsIds[l]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Reset ignore errors
|
||||
_shaderProvider->_programObject->setIgnoreUniformLocationError(
|
||||
ProgramObject::IgnoreError::No);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
@@ -1,73 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef LAYER_H
|
||||
#define LAYER_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <modules/globebrowsing/layered_rendering/perlayersetting.h>
|
||||
#include <modules/globebrowsing/tile/tileindex.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
/*
|
||||
class TileProvider;
|
||||
|
||||
class Layer : public properties::PropertyOwner {
|
||||
public:
|
||||
Layer(const ghoul::Dictionary& dict);
|
||||
|
||||
void bind(ProgramObject* program, const TileIndex& tileIndex);
|
||||
|
||||
|
||||
static const size_t NUM_LAYER_SETTINGS_VARIABLES = 3;
|
||||
static const size_t NUM_TILE_DATA_VARIABLES = 3;
|
||||
static const size_t NUM_BLEND_TEXTURES = 3;
|
||||
|
||||
private:
|
||||
|
||||
//void ensureIdsAreUpdated(LayeredTextureShaderProvider* shaderProvider);
|
||||
|
||||
|
||||
std::string _name;
|
||||
std::unique_ptr<TileProvider> _tileProvider;
|
||||
|
||||
std::array<std::array<GLint, NUM_TILE_DATA_VARIABLES>,NUM_BLEND_TEXTURES> _tileUniformIds;
|
||||
std::array<GLint, NUM_LAYER_SETTINGS_VARIABLES> _layerSettingsUniformIds;
|
||||
|
||||
bool _enabled;
|
||||
|
||||
};
|
||||
*/
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
#endif // LAYER_H
|
||||
@@ -1,124 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "LayeredTextures";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
const size_t LayeredTextures::NUM_TEXTURE_CATEGORIES;
|
||||
const size_t LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY;
|
||||
const size_t LayeredTextures::NUM_SETTINGS_PER_CATEGORY;
|
||||
const size_t LayeredTextures::NUM_TILE_DATA_VARIABLES;
|
||||
const size_t LayeredTextures::NUM_BLEND_TEXTURES;
|
||||
const size_t LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES;
|
||||
|
||||
const std::string LayeredTextures::TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES] =
|
||||
{
|
||||
"ColorTextures",
|
||||
"GrayScaleTextures",
|
||||
"GrayScaleOverlays",
|
||||
"NightTextures",
|
||||
"WaterMasks",
|
||||
"Overlays",
|
||||
"HeightMaps",
|
||||
};
|
||||
|
||||
const std::string LayeredTextures::glslKeyPrefixes[NUM_SETTINGS_PER_CATEGORY] =
|
||||
{
|
||||
"lastLayerIndex",
|
||||
"use",
|
||||
"blend",
|
||||
};
|
||||
|
||||
const std::string LayeredTextures::glslTileDataNames[
|
||||
NUM_TILE_DATA_VARIABLES] =
|
||||
{
|
||||
"textureSampler",
|
||||
"depthTransform.depthScale",
|
||||
"depthTransform.depthOffset",
|
||||
"uvTransform.uvOffset",
|
||||
"uvTransform.uvScale"
|
||||
};
|
||||
|
||||
const std::string LayeredTextures::blendLayerSuffixes[
|
||||
NUM_BLEND_TEXTURES] =
|
||||
{
|
||||
"",
|
||||
"Parent1",
|
||||
"Parent2",
|
||||
};
|
||||
|
||||
const std::string LayeredTextures::layerSettingsIds[
|
||||
NUM_LAYER_SETTINGS_VARIABLES] =
|
||||
{
|
||||
"opacity",
|
||||
"gamma",
|
||||
"multiplier",
|
||||
};
|
||||
|
||||
PerLayerSettings::PerLayerSettings()
|
||||
{
|
||||
/*
|
||||
// Here, all the per layer settings are specified and added
|
||||
_array[LayeredTextures::LayerSettingsIds::opacity] = std::make_shared<PerLayerFloatSetting>(
|
||||
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::opacity],
|
||||
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::opacity],
|
||||
1,
|
||||
0,
|
||||
1);
|
||||
_array[LayeredTextures::LayerSettingsIds::gamma] = std::make_shared<PerLayerFloatSetting>(
|
||||
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::gamma],
|
||||
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::gamma],
|
||||
1,
|
||||
0,
|
||||
5);
|
||||
_array[LayeredTextures::LayerSettingsIds::multiplier] = std::make_shared<PerLayerFloatSetting>(
|
||||
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::multiplier],
|
||||
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::multiplier],
|
||||
1,
|
||||
0,
|
||||
20);
|
||||
|
||||
// Make sure all settings have been spacified and added
|
||||
for (int i = 0; i < LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES; ++i) {
|
||||
ghoul_assert(_array[i], "The setting " +
|
||||
LayeredTextures::layerSettingsIds[i] + "is not specified!");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
PerLayerSettings::~PerLayerSettings() {};
|
||||
|
||||
const std::array<std::shared_ptr<PerLayerSetting>,
|
||||
LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES>& PerLayerSettings::array() const {
|
||||
return _array;
|
||||
}
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
@@ -1,141 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __LAYERED_TEXTURES_H__
|
||||
#define __LAYERED_TEXTURES_H__
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
|
||||
#include <modules/globebrowsing/layered_rendering/perlayersetting.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
class LayeredTextures {
|
||||
|
||||
public:
|
||||
|
||||
static const size_t NUM_TEXTURE_CATEGORIES = 7;
|
||||
static const size_t MAX_NUM_TEXTURES_PER_CATEGORY = 5;
|
||||
|
||||
static const size_t NUM_SETTINGS_PER_CATEGORY = 3;
|
||||
|
||||
static const size_t NUM_TILE_DATA_VARIABLES = 5;
|
||||
static const size_t NUM_BLEND_TEXTURES = 3;
|
||||
static const size_t NUM_LAYER_SETTINGS_VARIABLES = 3;
|
||||
|
||||
enum GlslKeyPrefixes
|
||||
{
|
||||
lastLayerIndex,
|
||||
use,
|
||||
blend,
|
||||
};
|
||||
|
||||
enum TextureCategory {
|
||||
ColorTextures,
|
||||
GrayScaleTextures,
|
||||
GrayScaleOverlays,
|
||||
NightTextures,
|
||||
WaterMasks,
|
||||
Overlays,
|
||||
HeightMaps,
|
||||
};
|
||||
|
||||
/**
|
||||
* Each texture can have these uniform variables associated with it in the shader
|
||||
* code.
|
||||
*
|
||||
* <code>textureSampler</code> is the actual texture that can be sampled in the
|
||||
* shader program. The associated GLSL type is <code>sampler2D</code>.
|
||||
* <code>depthTransform_depthScale</code> specifies the scale part of the depth
|
||||
* transform. Useful for height maps. The associated GLSL type is
|
||||
* <code>float</code>.
|
||||
* <code>depthTransform_depthOffset</code> specifies the offset part of the depth
|
||||
* transform. Useful for height maps. The associated GLSL type is
|
||||
* <code>float</code>.
|
||||
* <code>uvTransform_uvOffset</code> specifies an offset that can be used when
|
||||
* sampling from the texture. The associated GLSL type is <code>vec2</code>.
|
||||
* <code>uvTransform_uvScale</code> specifies a scale that can be used when
|
||||
* sampling from the texture. The associated GLSL type is <code>vec2</code>.
|
||||
*
|
||||
* The corresponding struct in GLSL code for storing these data is a
|
||||
* <code>Tile</code>. The names of the uniforms are the ones specified in
|
||||
* <code>glslTileDataNames</code>.
|
||||
*/
|
||||
enum GlslTileDataId {
|
||||
textureSampler,
|
||||
depthTransform_depthScale,
|
||||
depthTransform_depthOffset,
|
||||
uvTransform_uvOffset,
|
||||
uvTransform_uvScale,
|
||||
};
|
||||
|
||||
/**
|
||||
* These suffixes are used when naming <code>Tile</code>s in GLSL code. The names
|
||||
* of the <code>Tile</code>s is one of
|
||||
* <code>LayeredTextures::TEXTURE_CATEGORY_NAMES</code> followed by the suffixes
|
||||
* defined in <code>blendLayerSuffixes</code>.
|
||||
*/
|
||||
enum BlendLayerSuffixes {
|
||||
none,
|
||||
Parent1,
|
||||
Parent2,
|
||||
};
|
||||
|
||||
enum LayerSettingsIds {
|
||||
opacity,
|
||||
gamma,
|
||||
multiplier,
|
||||
};
|
||||
|
||||
static const std::string glslKeyPrefixes[NUM_SETTINGS_PER_CATEGORY];
|
||||
static const std::string TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES];
|
||||
static const std::string glslTileDataNames[NUM_TILE_DATA_VARIABLES];
|
||||
static const std::string blendLayerSuffixes[NUM_BLEND_TEXTURES];
|
||||
static const std::string layerSettingsIds[NUM_LAYER_SETTINGS_VARIABLES];
|
||||
};
|
||||
|
||||
class PerLayerSettings {
|
||||
public:
|
||||
PerLayerSettings();
|
||||
~PerLayerSettings();
|
||||
|
||||
const std::array<std::shared_ptr<PerLayerSetting>,
|
||||
LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES>& array() const;
|
||||
private:
|
||||
std::array<std::shared_ptr<PerLayerSetting>,
|
||||
LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES> _array;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __LAYERED_TEXTURES_H__
|
||||
@@ -107,21 +107,10 @@ namespace globebrowsing {
|
||||
for (size_t i = 0; i < textureTypes.size(); i++) {
|
||||
// lastLayerIndex must be at least 0 for the shader to compile,
|
||||
// the layer type is inactivated by setting use to false
|
||||
shaderDictionary.setValue(
|
||||
LayeredTextures::glslKeyPrefixes[
|
||||
LayeredTextures::GlslKeyPrefixes::lastLayerIndex] +
|
||||
LayeredTextures::TEXTURE_CATEGORY_NAMES[i],
|
||||
glm::max(textureTypes[i].lastLayerIdx, 0));
|
||||
shaderDictionary.setValue(
|
||||
LayeredTextures::glslKeyPrefixes[
|
||||
LayeredTextures::GlslKeyPrefixes::use] +
|
||||
LayeredTextures::TEXTURE_CATEGORY_NAMES[i],
|
||||
textureTypes[i].lastLayerIdx >= 0);
|
||||
shaderDictionary.setValue(
|
||||
LayeredTextures::glslKeyPrefixes[
|
||||
LayeredTextures::GlslKeyPrefixes::blend] +
|
||||
LayeredTextures::TEXTURE_CATEGORY_NAMES[i],
|
||||
textureTypes[i].layerBlendingEnabled);
|
||||
std::string groupName = LayerManager::LAYER_GROUP_NAMES[i];
|
||||
shaderDictionary.setValue("lastLayerIndex" + groupName, glm::max(textureTypes[i].lastLayerIdx, 0));
|
||||
shaderDictionary.setValue("use" + groupName, textureTypes[i].lastLayerIdx >= 0);
|
||||
shaderDictionary.setValue("blend" + groupName, textureTypes[i].layerBlendingEnabled);
|
||||
}
|
||||
|
||||
// Other settings such as "useAtmosphere"
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#ifndef __LAYERED_TEXTURE_SHADER_PROVIDER__
|
||||
#define __LAYERED_TEXTURE_SHADER_PROVIDER__
|
||||
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
|
||||
#include <modules/globebrowsing/tile/gpustructs.h>
|
||||
#include <modules/globebrowsing/tile/layermanager.h>
|
||||
|
||||
@@ -66,7 +64,7 @@ namespace globebrowsing {
|
||||
*/
|
||||
struct LayeredTexturePreprocessingData {
|
||||
|
||||
std::array<LayeredTextureInfo, LayeredTextures::NUM_TEXTURE_CATEGORIES>
|
||||
std::array<LayeredTextureInfo, LayerManager::NUM_LAYER_GROUPS>
|
||||
layeredTextureInfo;
|
||||
std::vector<std::pair<std::string, std::string> > keyValuePairs;
|
||||
bool operator==(const LayeredTexturePreprocessingData& other) const;
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/layered_rendering/perlayersetting.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
PerLayerSetting::PerLayerSetting() {}
|
||||
PerLayerSetting::~PerLayerSetting() {}
|
||||
|
||||
PerLayerFloatSetting::PerLayerFloatSetting(
|
||||
std::string name,
|
||||
std::string guiName,
|
||||
float defaultValue,
|
||||
float minimumValue,
|
||||
float maximumValue)
|
||||
: _property(name, guiName, defaultValue, minimumValue, maximumValue) { }
|
||||
PerLayerFloatSetting::~PerLayerFloatSetting(){};
|
||||
|
||||
void PerLayerFloatSetting::uploadUniform(
|
||||
ProgramObject& programObject,
|
||||
GLint settingsId) {
|
||||
programObject.setUniform(settingsId, _property);
|
||||
}
|
||||
|
||||
properties::Property* PerLayerFloatSetting::property() {
|
||||
return &_property;
|
||||
}
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
@@ -1,70 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __PER_LAYER_SETTING_H__
|
||||
#define __PER_LAYER_SETTING_H__
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
using namespace ghoul::opengl;
|
||||
|
||||
class PerLayerSetting {
|
||||
public:
|
||||
PerLayerSetting();
|
||||
~PerLayerSetting();
|
||||
|
||||
virtual void uploadUniform(
|
||||
ProgramObject& programObject,
|
||||
GLint settingsId) = 0;
|
||||
virtual properties::Property* property() = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
class PerLayerFloatSetting : public PerLayerSetting {
|
||||
public:
|
||||
PerLayerFloatSetting(
|
||||
std::string name,
|
||||
std::string guiName,
|
||||
float defaultValue,
|
||||
float minimumValue,
|
||||
float maximumValue);
|
||||
~PerLayerFloatSetting();
|
||||
virtual void uploadUniform(ProgramObject& programObject, GLint settingsId);
|
||||
virtual properties::Property* property();
|
||||
private:
|
||||
properties::FloatProperty _property;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __PER_LAYER_SETTING_H__
|
||||
@@ -23,15 +23,12 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/tile/gpustructs.h>
|
||||
|
||||
#include <modules/globebrowsing/tile/tileIndex.h>
|
||||
#include <modules/globebrowsing/tile/chunktile.h>
|
||||
#include <modules/globebrowsing/tile/tileselector.h>
|
||||
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
|
||||
#include <modules/globebrowsing/tile/layermanager.h>
|
||||
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
@@ -177,7 +174,7 @@ namespace globebrowsing {
|
||||
int pileSize = layerGroup.pileSize();
|
||||
for (size_t i = 0; i < gpuActiveLayers.size(); ++i){
|
||||
// should maybe a proper GPULayer factory
|
||||
gpuActiveLayers[i] = category == LayeredTextures::TextureCategory::HeightMaps ?
|
||||
gpuActiveLayers[i] = category == LayerManager::HeightMaps ?
|
||||
std::make_unique<GPUHeightLayer>() :
|
||||
std::make_unique<GPULayer>();
|
||||
std::string nameExtension = "[" + std::to_string(i) + "].";
|
||||
@@ -197,7 +194,6 @@ namespace globebrowsing {
|
||||
void GPULayerManager::setValue(ProgramObject* programObject, const LayerManager& layerManager, const TileIndex& tileIndex){
|
||||
auto layerGroups = layerManager.layerGroups();
|
||||
for (size_t i = 0; i < layerGroups.size(); ++i){
|
||||
std::string nameBase = LayeredTextures::TEXTURE_CATEGORY_NAMES[i];
|
||||
gpuLayerGroups[i]->setValue(programObject, *layerGroups[i], tileIndex);
|
||||
}
|
||||
}
|
||||
@@ -212,7 +208,7 @@ namespace globebrowsing {
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < layerGroups.size(); ++i){
|
||||
std::string nameBase = LayeredTextures::TEXTURE_CATEGORY_NAMES[i];
|
||||
std::string nameBase = LayerManager::LAYER_GROUP_NAMES[i];
|
||||
gpuLayerGroups[i]->updateUniformLocations(programObject, *layerGroups[i], nameBase, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,31 +144,34 @@ namespace globebrowsing {
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// LayerManager //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
LayerManager::LayerManager(const ghoul::Dictionary& textureCategoriesDictionary) {
|
||||
|
||||
const std::string LayerManager::LAYER_GROUP_NAMES[NUM_LAYER_GROUPS] = {
|
||||
"ColorTextures",
|
||||
"GrayScaleTextures",
|
||||
"GrayScaleOverlays",
|
||||
"NightTextures",
|
||||
"WaterMasks",
|
||||
"Overlays",
|
||||
"HeightMaps",
|
||||
};
|
||||
|
||||
LayerManager::LayerManager(const ghoul::Dictionary& layerGroupsDict) {
|
||||
|
||||
setName("Layers");
|
||||
|
||||
// Create all the categories of tile providers
|
||||
for (size_t i = 0; i < textureCategoriesDictionary.size(); i++) {
|
||||
ghoul::Dictionary texturesDict = textureCategoriesDictionary.value<ghoul::Dictionary>(
|
||||
LayeredTextures::TEXTURE_CATEGORY_NAMES[i]);
|
||||
|
||||
ghoul_assert(texturesDict.size() <=
|
||||
LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY,
|
||||
"Too many textures! Number of textures per category must be less than or equal to "
|
||||
<< LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY);
|
||||
for (size_t i = 0; i < layerGroupsDict.size(); i++) {
|
||||
std::string groupName = LayerManager::LAYER_GROUP_NAMES[i];
|
||||
ghoul::Dictionary layerGroupDict = layerGroupsDict.value<ghoul::Dictionary>(groupName);
|
||||
|
||||
TileProviderInitData initData;
|
||||
initData.minimumPixelSize = 512;
|
||||
initData.threads = 1;
|
||||
initData.cacheSize = 5000;
|
||||
initData.framesUntilRequestQueueFlush = 60;
|
||||
initData.preprocessTiles = (i == LayerManager::HeightMaps); // Only preprocess height maps.
|
||||
|
||||
// Only preprocess height maps.
|
||||
initData.preprocessTiles = i == LayeredTextures::HeightMaps;
|
||||
std::string groupName = LayeredTextures::TEXTURE_CATEGORY_NAMES[i];
|
||||
|
||||
_layerGroups.push_back(std::make_shared<LayerGroup>(groupName, texturesDict));
|
||||
_layerGroups.push_back(std::make_shared<LayerGroup>(groupName, layerGroupDict));
|
||||
}
|
||||
|
||||
for(auto layerGroup : _layerGroups){
|
||||
@@ -184,8 +187,8 @@ namespace globebrowsing {
|
||||
return *_layerGroups[groupId];
|
||||
}
|
||||
|
||||
LayerGroup& LayerManager::layerGroup(LayeredTextures::TextureCategory category) {
|
||||
return *_layerGroups[category];
|
||||
LayerGroup& LayerManager::layerGroup(LayerGroupId groupId) {
|
||||
return *_layerGroups[groupId];
|
||||
}
|
||||
|
||||
bool LayerManager::hasAnyBlendingLayersEnabled() const {
|
||||
|
||||
@@ -29,11 +29,12 @@
|
||||
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
|
||||
#include <modules/globebrowsing/tile/chunktile.h>
|
||||
#include <modules/globebrowsing/tile/tileselector.h>
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/util/gpudata.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -78,6 +79,7 @@ namespace globebrowsing {
|
||||
* Convenience class for dealing with multiple <code>Layer</code>s.
|
||||
*/
|
||||
struct LayerGroup : public properties::PropertyOwner {
|
||||
|
||||
LayerGroup(std::string name);
|
||||
LayerGroup(std::string name, const ghoul::Dictionary& dict);
|
||||
|
||||
@@ -109,18 +111,30 @@ namespace globebrowsing {
|
||||
class LayerManager : public properties::PropertyOwner {
|
||||
public:
|
||||
|
||||
static const size_t NUM_LAYER_GROUPS = 7;
|
||||
static const std::string LAYER_GROUP_NAMES[NUM_LAYER_GROUPS];
|
||||
static enum LayerGroupId{
|
||||
ColorTextures,
|
||||
GrayScaleTextures,
|
||||
GrayScaleOverlays,
|
||||
NightTextures,
|
||||
WaterMasks,
|
||||
Overlays,
|
||||
HeightMaps
|
||||
};
|
||||
|
||||
LayerManager(const ghoul::Dictionary& textureCategoriesDictionary);
|
||||
~LayerManager();
|
||||
|
||||
LayerGroup& layerGroup(size_t groupId);
|
||||
LayerGroup& layerGroup(LayeredTextures::TextureCategory);
|
||||
LayerGroup& layerGroup(LayerGroupId);
|
||||
|
||||
bool hasAnyBlendingLayersEnabled() const;
|
||||
|
||||
const std::vector<std::shared_ptr<LayerGroup>>& layerGroups() const;
|
||||
|
||||
void update();
|
||||
void reset(bool includingInactive = false);
|
||||
void reset(bool includingDisabled = false);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
#include <modules/globebrowsing/tile/layermanager.h>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include "cpl_minixml.h"
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "LayerManager";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// Tile Provider Group //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void LayerGroup::update() {
|
||||
_activeLayers.clear();
|
||||
|
||||
for (Layer& layer : layers) {
|
||||
if (layer.isActive) {
|
||||
layer.tileProvider->update();
|
||||
_activeLayers.push_back(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Layer>& LayerGroup::activeLayers() const {
|
||||
return _activeLayers;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// Layer Manager //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LayerManager::LayerManager(
|
||||
const ghoul::Dictionary& textureCategoriesDictionary,
|
||||
const ghoul::Dictionary& textureInitDictionary){
|
||||
|
||||
// Create all the categories of tile providers
|
||||
for (size_t i = 0; i < textureCategoriesDictionary.size(); i++) {
|
||||
ghoul::Dictionary texturesDict = textureCategoriesDictionary.value<ghoul::Dictionary>(
|
||||
LayeredTextures::TEXTURE_CATEGORY_NAMES[i]);
|
||||
|
||||
ghoul_assert(texturesDict.size() <=
|
||||
LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY,
|
||||
"Too many textures! Number of textures per category must be less than or equal to "
|
||||
<< LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY);
|
||||
|
||||
TileProviderInitData initData;
|
||||
|
||||
initData.minimumPixelSize = 512;
|
||||
initData.threads = 1;
|
||||
initData.cacheSize = 5000;
|
||||
initData.framesUntilRequestQueueFlush = 60;
|
||||
// Only preprocess height maps.
|
||||
initData.preprocessTiles = i == LayeredTextures::HeightMaps;
|
||||
|
||||
initTexures(
|
||||
layerGroups[i].layers,
|
||||
texturesDict,
|
||||
initData);
|
||||
|
||||
// init level blending to be true
|
||||
layerGroups[i].levelBlendingEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
LayerManager::~LayerManager()
|
||||
{
|
||||
}
|
||||
|
||||
void LayerManager::initTexures(std::vector<Layer>& dest,
|
||||
const ghoul::Dictionary& texturesDict, const TileProviderInitData& initData)
|
||||
{
|
||||
// Create TileProviders for all textures within this category
|
||||
for (size_t i = 0; i < texturesDict.size(); i++) {
|
||||
std::string name, path;
|
||||
|
||||
std::string dictKey = std::to_string(i + 1);
|
||||
ghoul::Dictionary texDict = texturesDict.value<ghoul::Dictionary>(dictKey);
|
||||
texDict.getValue("Name", name);
|
||||
texDict.getValue("FilePath", path);
|
||||
|
||||
std::string type = "LRUCaching"; // if type is unspecified
|
||||
texDict.getValue("Type", type);
|
||||
|
||||
TileProvider* tileProvider;
|
||||
auto tileProviderFactory = FactoryManager::ref().factory<TileProvider>();
|
||||
try {
|
||||
tileProvider = tileProviderFactory->create(type, texDict);
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR(e.what());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Something else went wrong and no exception was thrown
|
||||
if (tileProvider == nullptr) {
|
||||
LERROR("Unable to create TileProvider '" << name << "' of type '"
|
||||
<< type << "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
bool enabled = false; // defaults to false if unspecified
|
||||
texDict.getValue("Enabled", enabled);
|
||||
|
||||
dest.push_back({ name, std::shared_ptr<TileProvider>(tileProvider), enabled });
|
||||
}
|
||||
}
|
||||
|
||||
LayerGroup& LayerManager::layerGroup(size_t groupId) {
|
||||
return layerGroups[groupId];
|
||||
}
|
||||
|
||||
LayerGroup& LayerManager::layerGroup(LayeredTextures::TextureCategory category) {
|
||||
return layerGroups[category];
|
||||
}
|
||||
|
||||
void LayerManager::update() {
|
||||
for (LayerGroup& layerGroup : layerGroups) {
|
||||
layerGroup.update();
|
||||
}
|
||||
}
|
||||
|
||||
void LayerManager::reset(bool includingInactive) {
|
||||
for (LayerGroup& layerGroup : layerGroups) {
|
||||
for (Layer& layer : layerGroup.layers) {
|
||||
if (layer.isActive) {
|
||||
layer.tileProvider->reset();
|
||||
}
|
||||
else if (includingInactive) {
|
||||
layer.tileProvider->reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
@@ -1,89 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __TILE_PROVIDER_MANAGER_H__
|
||||
#define __TILE_PROVIDER_MANAGER_H__
|
||||
|
||||
|
||||
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
|
||||
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
struct Layer {
|
||||
std::string name;
|
||||
std::shared_ptr<TileProvider> tileProvider;
|
||||
bool isActive;
|
||||
|
||||
PerLayerSettings settings;
|
||||
};
|
||||
|
||||
struct LayerGroup {
|
||||
|
||||
void update();
|
||||
const std::vector<Layer>& activeLayers() const;
|
||||
|
||||
std::vector<Layer> layers;
|
||||
bool levelBlendingEnabled;
|
||||
|
||||
private:
|
||||
std::vector<Layer> _activeLayers;
|
||||
};
|
||||
|
||||
class LayerManager {
|
||||
public:
|
||||
|
||||
LayerManager(
|
||||
const ghoul::Dictionary& textureCategoriesDictionary,
|
||||
const ghoul::Dictionary& textureInitDictionary);
|
||||
~LayerManager();
|
||||
|
||||
|
||||
LayerGroup& layerGroup(size_t groupId);
|
||||
LayerGroup& layerGroup(LayeredTextures::TextureCategory);
|
||||
|
||||
void update();
|
||||
void reset(bool includingInactive = false);
|
||||
private:
|
||||
static void initTexures(
|
||||
std::vector<Layer>& destination,
|
||||
const ghoul::Dictionary& dict,
|
||||
const TileProviderInitData& initData);
|
||||
|
||||
std::array<LayerGroup, LayeredTextures::NUM_TEXTURE_CATEGORIES> layerGroups;
|
||||
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __TILE_PROVIDER_MANAGER_H__
|
||||
Reference in New Issue
Block a user