mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 20:21:24 -06:00
Cleanup of the globebrowsing support code
This commit is contained in:
@@ -87,6 +87,7 @@ set(SOURCE_FILES
|
||||
src/layer.cpp
|
||||
src/layeradjustment.cpp
|
||||
src/layergroup.cpp
|
||||
src/layergroupid.cpp
|
||||
src/layermanager.cpp
|
||||
src/layerrendersettings.cpp
|
||||
src/memoryawaretilecache.cpp
|
||||
|
||||
@@ -306,35 +306,16 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
FactoryManager::ref().factory<TileProvider>();
|
||||
ghoul_assert(fTileProvider, "TileProvider factory was not created");
|
||||
|
||||
{
|
||||
using namespace layergroupid;
|
||||
fTileProvider->registerClass<DefaultTileProvider>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::DefaultTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<SingleImageProvider>(std::string(LAYER_TYPE_NAMES[static_cast<int>(TypeID::SingleImageTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<ImageSequenceTileProvider>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::ImageSequenceTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<SpoutImageProvider>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::SpoutImageTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<TemporalTileProvider>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::TemporalTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<TileIndexTileProvider>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::TileIndexTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<SizeReferenceTileProvider>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::SizeReferenceTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<TileProviderByLevel>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::ByLevelTileLayer)]
|
||||
));
|
||||
fTileProvider->registerClass<TileProviderByIndex>(std::string(
|
||||
LAYER_TYPE_NAMES[static_cast<int>(TypeID::ByIndexTileLayer)]
|
||||
));
|
||||
}
|
||||
|
||||
fTileProvider->registerClass<DefaultTileProvider>("DefaultTileLayer");
|
||||
fTileProvider->registerClass<SingleImageProvider>("SingleImageTileLayer");
|
||||
fTileProvider->registerClass<ImageSequenceTileProvider>("ImageSequenceTileLayer");
|
||||
fTileProvider->registerClass<SpoutImageProvider>("SpoutImageTileLayer");
|
||||
fTileProvider->registerClass<TemporalTileProvider>("TemporalTileLayer");
|
||||
fTileProvider->registerClass<TileIndexTileProvider>("TileIndexTileLayer");
|
||||
fTileProvider->registerClass<SizeReferenceTileProvider>("SizeReferenceTileLayer");
|
||||
fTileProvider->registerClass<TileProviderByLevel>("ByLevelTileLayer");
|
||||
fTileProvider->registerClass<TileProviderByIndex>("ByIndexTileLayer");
|
||||
|
||||
ghoul::TemplateFactory<DashboardItem>* fDashboard =
|
||||
FactoryManager::ref().factory<DashboardItem>();
|
||||
@@ -596,41 +577,6 @@ GlobeBrowsingModule::castFocusNodeRenderableToGlobe()
|
||||
}
|
||||
}
|
||||
|
||||
std::string GlobeBrowsingModule::layerGroupNamesList() {
|
||||
std::string listLayerGroups;
|
||||
for (int i = 0; i < globebrowsing::layergroupid::NUM_LAYER_GROUPS - 1; ++i) {
|
||||
listLayerGroups += fmt::format(
|
||||
"{}, ", globebrowsing::layergroupid::LAYER_GROUP_IDENTIFIERS[i]
|
||||
);
|
||||
}
|
||||
|
||||
return fmt::format(
|
||||
"{} and {}",
|
||||
listLayerGroups,
|
||||
globebrowsing::layergroupid::LAYER_GROUP_IDENTIFIERS[
|
||||
globebrowsing::layergroupid::NUM_LAYER_GROUPS - 1
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
std::string GlobeBrowsingModule::layerTypeNamesList() {
|
||||
std::string listLayerTypes;
|
||||
for (int i = 0; i < globebrowsing::layergroupid::NUM_LAYER_TYPES - 1; ++i) {
|
||||
listLayerTypes += fmt::format(
|
||||
"{}, ",
|
||||
globebrowsing::layergroupid::LAYER_TYPE_NAMES[i]
|
||||
);
|
||||
}
|
||||
|
||||
return fmt::format(
|
||||
"{} and {}",
|
||||
listLayerTypes,
|
||||
globebrowsing::layergroupid::LAYER_TYPE_NAMES[
|
||||
globebrowsing::layergroupid::NUM_LAYER_TYPES - 1
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
void GlobeBrowsingModule::loadWMSCapabilities(std::string name, std::string globe,
|
||||
std::string url)
|
||||
{
|
||||
@@ -745,8 +691,6 @@ uint64_t GlobeBrowsingModule::wmsCacheSize() const {
|
||||
}
|
||||
|
||||
scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const {
|
||||
std::string listLayerGroups = layerGroupNamesList();
|
||||
|
||||
scripting::LuaLibrary res;
|
||||
res.name = "globebrowsing";
|
||||
res.functions = {
|
||||
|
||||
@@ -113,17 +113,6 @@ private:
|
||||
glm::dquat lookDownCameraRotation(const globebrowsing::RenderableGlobe& globe,
|
||||
glm::dvec3 cameraPositionModelSpace, globebrowsing::Geodetic2 geo2);
|
||||
|
||||
/**
|
||||
\return a comma separated list of layer group names.
|
||||
*/
|
||||
static std::string layerGroupNamesList();
|
||||
|
||||
/**
|
||||
\return a comma separated list of layer type names.
|
||||
*/
|
||||
static std::string layerTypeNamesList();
|
||||
|
||||
|
||||
properties::BoolProperty _wmsCacheEnabled;
|
||||
properties::BoolProperty _offlineMode;
|
||||
properties::StringProperty _wmsCacheLocation;
|
||||
|
||||
@@ -51,10 +51,8 @@ namespace {
|
||||
}
|
||||
|
||||
// Get the layer group
|
||||
layergroupid::GroupID groupID = ghoul::from_string<layergroupid::GroupID>(
|
||||
layerGroupName
|
||||
);
|
||||
if (groupID == layergroupid::GroupID::Unknown) {
|
||||
layers::Group::ID groupID = ghoul::from_string<layers::Group::ID>(layerGroupName);
|
||||
if (groupID == layers::Group::ID::Unknown) {
|
||||
throw ghoul::lua::LuaError("Unknown layer group: " + layerGroupName);
|
||||
}
|
||||
|
||||
@@ -91,10 +89,8 @@ namespace {
|
||||
}
|
||||
|
||||
// Get the layer group
|
||||
layergroupid::GroupID groupID = ghoul::from_string<layergroupid::GroupID>(
|
||||
layerGroupName
|
||||
);
|
||||
if (groupID == layergroupid::GroupID::Unknown) {
|
||||
layers::Group::ID groupID = ghoul::from_string<layers::Group::ID>(layerGroupName);
|
||||
if (groupID == layers::Group::ID::Unknown) {
|
||||
throw ghoul::lua::LuaError("Unknown layer group: " + layerGroupName);
|
||||
}
|
||||
|
||||
@@ -135,18 +131,17 @@ namespace {
|
||||
throw ghoul::lua::LuaError("Identifier must be a RenderableGlobe");
|
||||
}
|
||||
|
||||
globebrowsing::layergroupid::GroupID group =
|
||||
ghoul::from_string<globebrowsing::layergroupid::GroupID>(layer);
|
||||
if (group == globebrowsing::layergroupid::GroupID::Unknown) {
|
||||
layers::Group::ID group = ghoul::from_string<layers::Group::ID>(layer);
|
||||
if (group == layers::Group::ID::Unknown) {
|
||||
throw ghoul::lua::LuaError("Unknown layer groupd: " + layer);
|
||||
}
|
||||
|
||||
const globebrowsing::LayerGroup& lg = globe->layerManager().layerGroup(group);
|
||||
std::vector<globebrowsing::Layer*> layers = lg.layers();
|
||||
const LayerGroup& lg = globe->layerManager().layerGroup(group);
|
||||
std::vector<Layer*> layers = lg.layers();
|
||||
|
||||
std::vector<std::string> res;
|
||||
res.reserve(layers.size());
|
||||
for (globebrowsing::Layer* l : layers) {
|
||||
for (Layer* l : layers) {
|
||||
res.push_back(l->identifier());
|
||||
}
|
||||
return res;
|
||||
@@ -181,13 +176,12 @@ namespace {
|
||||
throw ghoul::lua::LuaError("Identifier must be a RenderableGlobe");
|
||||
}
|
||||
|
||||
globebrowsing::layergroupid::GroupID group =
|
||||
ghoul::from_string<globebrowsing::layergroupid::GroupID>(layer);
|
||||
if (group == globebrowsing::layergroupid::GroupID::Unknown) {
|
||||
layers::Group::ID group = ghoul::from_string<layers::Group::ID>(layer);
|
||||
if (group == layers::Group::ID::Unknown) {
|
||||
throw ghoul::lua::LuaError("Unknown layer groupd: " + layer);
|
||||
}
|
||||
|
||||
globebrowsing::LayerGroup& lg = globe->layerManager().layerGroup(group);
|
||||
LayerGroup& lg = globe->layerManager().layerGroup(group);
|
||||
lg.moveLayer(oldPosition, newPosition);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ void GPULayerGroup::setValue(ghoul::opengl::ProgramObject& program,
|
||||
program.setUniform(galuc.multiplier, al.renderSettings().multiplier);
|
||||
program.setUniform(galuc.offset, al.renderSettings().offset);
|
||||
|
||||
if (al.layerAdjustment().type() == layergroupid::AdjustmentTypeID::ChromaKey) {
|
||||
if (al.layerAdjustment().type() == layers::Adjustment::ID::ChromaKey) {
|
||||
program.setUniform(
|
||||
galuc.chromaKeyColor,
|
||||
al.layerAdjustment().chromaKeyColor()
|
||||
@@ -66,15 +66,15 @@ void GPULayerGroup::setValue(ghoul::opengl::ProgramObject& program,
|
||||
|
||||
switch (al.type()) {
|
||||
// Intentional fall through. Same for all tile layers
|
||||
case layergroupid::TypeID::DefaultTileLayer:
|
||||
case layergroupid::TypeID::SingleImageTileLayer:
|
||||
case layergroupid::TypeID::SpoutImageTileLayer:
|
||||
case layergroupid::TypeID::ImageSequenceTileLayer:
|
||||
case layergroupid::TypeID::SizeReferenceTileLayer:
|
||||
case layergroupid::TypeID::TemporalTileLayer:
|
||||
case layergroupid::TypeID::TileIndexTileLayer:
|
||||
case layergroupid::TypeID::ByIndexTileLayer:
|
||||
case layergroupid::TypeID::ByLevelTileLayer: {
|
||||
case layers::Layer::ID::DefaultTileLayer:
|
||||
case layers::Layer::ID::SingleImageTileLayer:
|
||||
case layers::Layer::ID::SpoutImageTileLayer:
|
||||
case layers::Layer::ID::ImageSequenceTileLayer:
|
||||
case layers::Layer::ID::SizeReferenceTileLayer:
|
||||
case layers::Layer::ID::TemporalTileLayer:
|
||||
case layers::Layer::ID::TileIndexTileLayer:
|
||||
case layers::Layer::ID::ByIndexTileLayer:
|
||||
case layers::Layer::ID::ByLevelTileLayer: {
|
||||
const ChunkTilePile& ctp = al.chunkTilePile(
|
||||
tileIndex,
|
||||
layerGroup.pileSize()
|
||||
@@ -101,7 +101,7 @@ void GPULayerGroup::setValue(ghoul::opengl::ProgramObject& program,
|
||||
);
|
||||
break;
|
||||
}
|
||||
case layergroupid::TypeID::SolidColor:
|
||||
case layers::Layer::ID::SolidColor:
|
||||
program.setUniform(galuc.color, al.solidColor());
|
||||
break;
|
||||
default:
|
||||
@@ -115,10 +115,7 @@ void GPULayerGroup::setValue(ghoul::opengl::ProgramObject& program,
|
||||
}
|
||||
}
|
||||
|
||||
void GPULayerGroup::bind(ghoul::opengl::ProgramObject& p,
|
||||
const LayerGroup& layerGroup, std::string_view nameBase,
|
||||
int category)
|
||||
{
|
||||
void GPULayerGroup::bind(ghoul::opengl::ProgramObject& p, const LayerGroup& layerGroup) {
|
||||
const std::vector<Layer*>& activeLayers = layerGroup.activeLayers();
|
||||
_gpuActiveLayers.resize(activeLayers.size());
|
||||
const int pileSize = layerGroup.pileSize();
|
||||
@@ -126,9 +123,9 @@ void GPULayerGroup::bind(ghoul::opengl::ProgramObject& p,
|
||||
GPULayer& gal = _gpuActiveLayers[i];
|
||||
auto& galuc = gal.uniformCache;
|
||||
const Layer& al = *activeLayers[i];
|
||||
std::string name = fmt::format("{}[{}].", nameBase, i);
|
||||
std::string name = fmt::format("{}[{}].", layerGroup.identifier(), i);
|
||||
|
||||
if (category == layergroupid::GroupID::HeightLayers) {
|
||||
if (layerGroup.isHeightLayer()) {
|
||||
gal.isHeightLayer = true;
|
||||
}
|
||||
|
||||
@@ -137,7 +134,7 @@ void GPULayerGroup::bind(ghoul::opengl::ProgramObject& p,
|
||||
galuc.multiplier = p.uniformLocation(name + "settings.multiplier");
|
||||
galuc.offset = p.uniformLocation(name + "settings.offset");
|
||||
|
||||
if (al.layerAdjustment().type() == layergroupid::AdjustmentTypeID::ChromaKey) {
|
||||
if (al.layerAdjustment().type() == layers::Adjustment::ID::ChromaKey) {
|
||||
galuc.chromaKeyColor = p.uniformLocation(
|
||||
name + "adjustment.chromaKeyColor"
|
||||
);
|
||||
@@ -148,15 +145,15 @@ void GPULayerGroup::bind(ghoul::opengl::ProgramObject& p,
|
||||
|
||||
switch (al.type()) {
|
||||
// Intentional fall through. Same for all tile layers
|
||||
case layergroupid::TypeID::DefaultTileLayer:
|
||||
case layergroupid::TypeID::SingleImageTileLayer:
|
||||
case layergroupid::TypeID::SpoutImageTileLayer:
|
||||
case layergroupid::TypeID::ImageSequenceTileLayer:
|
||||
case layergroupid::TypeID::SizeReferenceTileLayer:
|
||||
case layergroupid::TypeID::TemporalTileLayer:
|
||||
case layergroupid::TypeID::TileIndexTileLayer:
|
||||
case layergroupid::TypeID::ByIndexTileLayer:
|
||||
case layergroupid::TypeID::ByLevelTileLayer: {
|
||||
case layers::Layer::ID::DefaultTileLayer:
|
||||
case layers::Layer::ID::SingleImageTileLayer:
|
||||
case layers::Layer::ID::SpoutImageTileLayer:
|
||||
case layers::Layer::ID::ImageSequenceTileLayer:
|
||||
case layers::Layer::ID::SizeReferenceTileLayer:
|
||||
case layers::Layer::ID::TemporalTileLayer:
|
||||
case layers::Layer::ID::TileIndexTileLayer:
|
||||
case layers::Layer::ID::ByIndexTileLayer:
|
||||
case layers::Layer::ID::ByLevelTileLayer: {
|
||||
gal.gpuChunkTiles.resize(pileSize);
|
||||
for (size_t j = 0; j < gal.gpuChunkTiles.size(); ++j) {
|
||||
GPULayer::GPUChunkTile& t = gal.gpuChunkTiles[j];
|
||||
@@ -177,7 +174,7 @@ void GPULayerGroup::bind(ghoul::opengl::ProgramObject& p,
|
||||
|
||||
break;
|
||||
}
|
||||
case layergroupid::TypeID::SolidColor:
|
||||
case layers::Layer::ID::SolidColor:
|
||||
galuc.color = p.uniformLocation(name + "color");
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -62,8 +62,7 @@ public:
|
||||
* with nameBase within the provided shader program.
|
||||
* After this method has been called, users may invoke setValue.
|
||||
*/
|
||||
void bind(ghoul::opengl::ProgramObject& programObject,
|
||||
const LayerGroup& layerGroup, std::string_view nameBase, int category);
|
||||
void bind(ghoul::opengl::ProgramObject& programObject, const LayerGroup& layerGroup);
|
||||
|
||||
/**
|
||||
* Deactivates any <code>TextureUnit</code>s assigned by this object.
|
||||
|
||||
@@ -183,8 +183,7 @@ documentation::Documentation Layer::Documentation() {
|
||||
return codegen::doc<Parameters>("globebrowsing_layer");
|
||||
}
|
||||
|
||||
Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
LayerGroup& parent)
|
||||
Layer::Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGroup& parent)
|
||||
: properties::PropertyOwner({
|
||||
layerDict.value<std::string>(KeyIdentifier),
|
||||
layerDict.hasKey(KeyName) ? layerDict.value<std::string>(KeyName) : "",
|
||||
@@ -203,15 +202,15 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(layerDict);
|
||||
|
||||
layergroupid::TypeID typeID;
|
||||
layers::Layer::ID typeID;
|
||||
if (p.type.has_value()) {
|
||||
typeID = ghoul::from_string<layergroupid::TypeID>(*p.type);
|
||||
if (typeID == layergroupid::TypeID::Unknown) {
|
||||
typeID = ghoul::from_string<layers::Layer::ID>(*p.type);
|
||||
if (typeID == layers::Layer::ID::Unknown) {
|
||||
throw ghoul::RuntimeError("Unknown layer type!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
typeID = layergroupid::TypeID::DefaultTileLayer;
|
||||
typeID = layers::Layer::ID::DefaultTileLayer;
|
||||
}
|
||||
|
||||
initializeBasedOnType(typeID, layerDict);
|
||||
@@ -243,38 +242,38 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
}
|
||||
|
||||
// Add options to option properties
|
||||
for (int i = 0; i < layergroupid::NUM_LAYER_TYPES; ++i) {
|
||||
_typeOption.addOption(i, std::string(layergroupid::LAYER_TYPE_NAMES[i]));
|
||||
for (const layers::Layer& li : layers::Layers) {
|
||||
_typeOption.addOption(static_cast<int>(li.id), std::string(li.identifier));
|
||||
}
|
||||
_typeOption.setValue(static_cast<int>(typeID));
|
||||
_type = static_cast<layergroupid::TypeID>(_typeOption.value());
|
||||
_type = static_cast<layers::Layer::ID>(_typeOption.value());
|
||||
|
||||
for (int i = 0; i < layergroupid::NUM_BLEND_MODES; ++i) {
|
||||
_blendModeOption.addOption(i, std::string(layergroupid::BLEND_MODE_NAMES[i]));
|
||||
for (const layers::Blend& bi : layers::Blends) {
|
||||
_blendModeOption.addOption(static_cast<int>(bi.id), std::string(bi.identifier));
|
||||
}
|
||||
|
||||
// Initialize blend mode
|
||||
if (p.blendMode.has_value()) {
|
||||
switch (*p.blendMode) {
|
||||
case Parameters::BlendMode::Normal:
|
||||
_blendModeOption = static_cast<int>(layergroupid::BlendModeID::Normal);
|
||||
_blendModeOption = static_cast<int>(layers::Blend::ID::Normal);
|
||||
break;
|
||||
case Parameters::BlendMode::Multiply:
|
||||
_blendModeOption = static_cast<int>(layergroupid::BlendModeID::Multiply);
|
||||
_blendModeOption = static_cast<int>(layers::Blend::ID::Multiply);
|
||||
break;
|
||||
case Parameters::BlendMode::Add:
|
||||
_blendModeOption = static_cast<int>(layergroupid::BlendModeID::Add);
|
||||
_blendModeOption = static_cast<int>(layers::Blend::ID::Add);
|
||||
break;
|
||||
case Parameters::BlendMode::Subtract:
|
||||
_blendModeOption = static_cast<int>(layergroupid::BlendModeID::Subtract);
|
||||
_blendModeOption = static_cast<int>(layers::Blend::ID::Subtract);
|
||||
break;
|
||||
case Parameters::BlendMode::Color:
|
||||
_blendModeOption = static_cast<int>(layergroupid::BlendModeID::Color);
|
||||
_blendModeOption = static_cast<int>(layers::Blend::ID::Color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_blendModeOption = static_cast<int>(layergroupid::BlendModeID::Normal);
|
||||
_blendModeOption = static_cast<int>(layers::Blend::ID::Normal);
|
||||
}
|
||||
|
||||
// On change callbacks definitions
|
||||
@@ -300,27 +299,27 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
_typeOption.onChange([&]() {
|
||||
switch (type()) {
|
||||
// Intentional fall through. Same for all tile layers
|
||||
case layergroupid::TypeID::DefaultTileLayer:
|
||||
case layergroupid::TypeID::SingleImageTileLayer:
|
||||
case layergroupid::TypeID::SpoutImageTileLayer:
|
||||
case layergroupid::TypeID::ImageSequenceTileLayer:
|
||||
case layergroupid::TypeID::SizeReferenceTileLayer:
|
||||
case layergroupid::TypeID::TemporalTileLayer:
|
||||
case layergroupid::TypeID::TileIndexTileLayer:
|
||||
case layergroupid::TypeID::ByIndexTileLayer:
|
||||
case layergroupid::TypeID::ByLevelTileLayer:
|
||||
case layers::Layer::ID::DefaultTileLayer:
|
||||
case layers::Layer::ID::SingleImageTileLayer:
|
||||
case layers::Layer::ID::SpoutImageTileLayer:
|
||||
case layers::Layer::ID::ImageSequenceTileLayer:
|
||||
case layers::Layer::ID::SizeReferenceTileLayer:
|
||||
case layers::Layer::ID::TemporalTileLayer:
|
||||
case layers::Layer::ID::TileIndexTileLayer:
|
||||
case layers::Layer::ID::ByIndexTileLayer:
|
||||
case layers::Layer::ID::ByLevelTileLayer:
|
||||
if (_tileProvider) {
|
||||
removePropertySubOwner(*_tileProvider);
|
||||
}
|
||||
break;
|
||||
case layergroupid::TypeID::SolidColor:
|
||||
case layers::Layer::ID::SolidColor:
|
||||
removeProperty(_solidColor);
|
||||
break;
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
|
||||
_type = static_cast<layergroupid::TypeID>(_typeOption.value());
|
||||
_type = static_cast<layers::Layer::ID>(_typeOption.value());
|
||||
initializeBasedOnType(type(), {});
|
||||
addVisibleProperties();
|
||||
if (_onChangeCallback) {
|
||||
@@ -395,12 +394,12 @@ Tile::Status Layer::tileStatus(const TileIndex& index) const {
|
||||
Tile::Status::Unavailable;
|
||||
}
|
||||
|
||||
layergroupid::TypeID Layer::type() const {
|
||||
layers::Layer::ID Layer::type() const {
|
||||
return _type;
|
||||
}
|
||||
|
||||
layergroupid::BlendModeID Layer::blendMode() const {
|
||||
return static_cast<layergroupid::BlendModeID>(_blendModeOption.value());
|
||||
layers::Blend::ID Layer::blendMode() const {
|
||||
return static_cast<layers::Blend::ID>(_blendModeOption.value());
|
||||
}
|
||||
|
||||
TileDepthTransform Layer::depthTransform() const {
|
||||
@@ -466,18 +465,18 @@ glm::vec2 Layer::tileUvToTextureSamplePosition(const TileUvTransform& uvTransfor
|
||||
return sourceToCurrentSize * (uv - glm::vec2(_padTilePixelStartOffset) / sourceSize);
|
||||
}
|
||||
|
||||
void Layer::initializeBasedOnType(layergroupid::TypeID id, ghoul::Dictionary initDict) {
|
||||
void Layer::initializeBasedOnType(layers::Layer::ID id, ghoul::Dictionary initDict) {
|
||||
switch (id) {
|
||||
// Intentional fall through. Same for all tile layers
|
||||
case layergroupid::TypeID::DefaultTileLayer:
|
||||
case layergroupid::TypeID::SingleImageTileLayer:
|
||||
case layergroupid::TypeID::SpoutImageTileLayer:
|
||||
case layergroupid::TypeID::ImageSequenceTileLayer:
|
||||
case layergroupid::TypeID::SizeReferenceTileLayer:
|
||||
case layergroupid::TypeID::TemporalTileLayer:
|
||||
case layergroupid::TypeID::TileIndexTileLayer:
|
||||
case layergroupid::TypeID::ByIndexTileLayer:
|
||||
case layergroupid::TypeID::ByLevelTileLayer: {
|
||||
case layers::Layer::ID::DefaultTileLayer:
|
||||
case layers::Layer::ID::SingleImageTileLayer:
|
||||
case layers::Layer::ID::SpoutImageTileLayer:
|
||||
case layers::Layer::ID::ImageSequenceTileLayer:
|
||||
case layers::Layer::ID::SizeReferenceTileLayer:
|
||||
case layers::Layer::ID::TemporalTileLayer:
|
||||
case layers::Layer::ID::TileIndexTileLayer:
|
||||
case layers::Layer::ID::ByIndexTileLayer:
|
||||
case layers::Layer::ID::ByLevelTileLayer:
|
||||
// We add the id to the dictionary since it needs to be known by
|
||||
// the tile provider
|
||||
initDict.setValue(
|
||||
@@ -490,13 +489,11 @@ void Layer::initializeBasedOnType(layergroupid::TypeID id, ghoul::Dictionary ini
|
||||
}
|
||||
_tileProvider = TileProvider::createFromDictionary(id, std::move(initDict));
|
||||
break;
|
||||
}
|
||||
case layergroupid::TypeID::SolidColor: {
|
||||
case layers::Layer::ID::SolidColor:
|
||||
if (initDict.hasValue<glm::dvec3>(ColorInfo.identifier)) {
|
||||
_solidColor = initDict.value<glm::dvec3>(ColorInfo.identifier);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
@@ -505,21 +502,20 @@ void Layer::initializeBasedOnType(layergroupid::TypeID id, ghoul::Dictionary ini
|
||||
void Layer::addVisibleProperties() {
|
||||
switch (type()) {
|
||||
// Intentional fall through. Same for all tile layers
|
||||
case layergroupid::TypeID::DefaultTileLayer:
|
||||
case layergroupid::TypeID::SingleImageTileLayer:
|
||||
case layergroupid::TypeID::SpoutImageTileLayer:
|
||||
case layergroupid::TypeID::ImageSequenceTileLayer:
|
||||
case layergroupid::TypeID::SizeReferenceTileLayer:
|
||||
case layergroupid::TypeID::TemporalTileLayer:
|
||||
case layergroupid::TypeID::TileIndexTileLayer:
|
||||
case layergroupid::TypeID::ByIndexTileLayer:
|
||||
case layergroupid::TypeID::ByLevelTileLayer: {
|
||||
case layers::Layer::ID::DefaultTileLayer:
|
||||
case layers::Layer::ID::SingleImageTileLayer:
|
||||
case layers::Layer::ID::SpoutImageTileLayer:
|
||||
case layers::Layer::ID::ImageSequenceTileLayer:
|
||||
case layers::Layer::ID::SizeReferenceTileLayer:
|
||||
case layers::Layer::ID::TemporalTileLayer:
|
||||
case layers::Layer::ID::TileIndexTileLayer:
|
||||
case layers::Layer::ID::ByIndexTileLayer:
|
||||
case layers::Layer::ID::ByLevelTileLayer:
|
||||
if (_tileProvider) {
|
||||
addPropertySubOwner(*_tileProvider);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case layergroupid::TypeID::SolidColor: {
|
||||
case layers::Layer::ID::SolidColor: {
|
||||
addProperty(_solidColor);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ struct TileProvider;
|
||||
|
||||
class Layer : public properties::PropertyOwner {
|
||||
public:
|
||||
Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
LayerGroup& parent);
|
||||
Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGroup& parent);
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
@@ -53,8 +52,8 @@ public:
|
||||
ChunkTilePile chunkTilePile(const TileIndex& tileIndex, int pileSize) const;
|
||||
Tile::Status tileStatus(const TileIndex& index) const;
|
||||
|
||||
layergroupid::TypeID type() const;
|
||||
layergroupid::BlendModeID blendMode() const;
|
||||
layers::Layer::ID type() const;
|
||||
layers::Blend::ID blendMode() const;
|
||||
TileDepthTransform depthTransform() const;
|
||||
void setEnabled(bool enabled);
|
||||
bool enabled() const;
|
||||
@@ -75,7 +74,7 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
void initializeBasedOnType(layergroupid::TypeID typeId, ghoul::Dictionary initDict);
|
||||
void initializeBasedOnType(layers::Layer::ID typeId, ghoul::Dictionary initDict);
|
||||
void addVisibleProperties();
|
||||
|
||||
LayerGroup& _parent;
|
||||
@@ -87,7 +86,7 @@ private:
|
||||
properties::TriggerProperty _remove;
|
||||
properties::StringProperty _guiDescription;
|
||||
|
||||
layergroupid::TypeID _type;
|
||||
layers::Layer::ID _type;
|
||||
std::unique_ptr<TileProvider> _tileProvider;
|
||||
properties::Vec3Property _solidColor;
|
||||
LayerRenderSettings _renderSettings;
|
||||
@@ -96,7 +95,7 @@ private:
|
||||
glm::ivec2 _padTilePixelStartOffset = glm::ivec2(0);
|
||||
glm::ivec2 _padTilePixelSizeDifference = glm::ivec2(0);
|
||||
|
||||
const layergroupid::GroupID _layerGroupId;
|
||||
const layers::Group::ID _layerGroupId;
|
||||
|
||||
std::function<void(Layer*)> _onChangeCallback;
|
||||
};
|
||||
|
||||
@@ -80,25 +80,24 @@ LayerAdjustment::LayerAdjustment()
|
||||
, _typeOption(TypeInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
{
|
||||
// Add options to option properties
|
||||
for (int i = 0; i < layergroupid::NUM_ADJUSTMENT_TYPES; ++i) {
|
||||
_typeOption.addOption(i, std::string(layergroupid::ADJUSTMENT_TYPE_NAMES[i]));
|
||||
for (const layers::Adjustment& ai : layers::Adjustments) {
|
||||
_typeOption.addOption(static_cast<int>(ai.id), std::string(ai.identifier));
|
||||
}
|
||||
_typeOption.setValue(static_cast<int>(layergroupid::AdjustmentTypeID::None));
|
||||
_type = static_cast<layergroupid::AdjustmentTypeID>(_typeOption.value());
|
||||
_typeOption.setValue(static_cast<int>(layers::Adjustment::ID::None));
|
||||
_type = static_cast<layers::Adjustment::ID>(_typeOption.value());
|
||||
|
||||
_typeOption.onChange([&]() {
|
||||
switch (type()) {
|
||||
case layergroupid::AdjustmentTypeID::None:
|
||||
case layers::Adjustment::ID::None:
|
||||
break;
|
||||
case layergroupid::AdjustmentTypeID::ChromaKey: {
|
||||
case layers::Adjustment::ID::ChromaKey:
|
||||
removeProperty(_chromaKeyColor);
|
||||
removeProperty(_chromaKeyTolerance);
|
||||
break;
|
||||
}
|
||||
case layergroupid::AdjustmentTypeID::TransferFunction:
|
||||
case layers::Adjustment::ID::TransferFunction:
|
||||
break;
|
||||
}
|
||||
_type = static_cast<layergroupid::AdjustmentTypeID>(_typeOption.value());
|
||||
_type = static_cast<layers::Adjustment::ID>(_typeOption.value());
|
||||
addVisibleProperties();
|
||||
if (_onChangeCallback) {
|
||||
_onChangeCallback();
|
||||
@@ -116,14 +115,13 @@ void LayerAdjustment::setValuesFromDictionary(const ghoul::Dictionary& adjustmen
|
||||
if (p.type.has_value()) {
|
||||
switch (*p.type) {
|
||||
case Parameters::Type::None:
|
||||
_typeOption = static_cast<int>(layergroupid::AdjustmentTypeID::None);
|
||||
_typeOption = static_cast<int>(layers::Adjustment::ID::None);
|
||||
break;
|
||||
case Parameters::Type::ChromaKey:
|
||||
_typeOption = static_cast<int>(layergroupid::AdjustmentTypeID::ChromaKey);
|
||||
_typeOption = static_cast<int>(layers::Adjustment::ID::ChromaKey);
|
||||
break;
|
||||
case Parameters::Type::TransferFunction:
|
||||
_typeOption =
|
||||
static_cast<int>(layergroupid::AdjustmentTypeID::TransferFunction);
|
||||
_typeOption = static_cast<int>(layers::Adjustment::ID::TransferFunction);
|
||||
break;
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
@@ -134,20 +132,19 @@ void LayerAdjustment::setValuesFromDictionary(const ghoul::Dictionary& adjustmen
|
||||
_chromaKeyTolerance = p.chromaKeyTolerance.value_or(_chromaKeyTolerance);
|
||||
}
|
||||
|
||||
layergroupid::AdjustmentTypeID LayerAdjustment::type() const {
|
||||
layers::Adjustment::ID LayerAdjustment::type() const {
|
||||
return _type;
|
||||
}
|
||||
|
||||
void LayerAdjustment::addVisibleProperties() {
|
||||
switch (type()) {
|
||||
case layergroupid::AdjustmentTypeID::None:
|
||||
case layers::Adjustment::ID::None:
|
||||
break;
|
||||
case layergroupid::AdjustmentTypeID::ChromaKey: {
|
||||
case layers::Adjustment::ID::ChromaKey:
|
||||
addProperty(_chromaKeyColor);
|
||||
addProperty(_chromaKeyTolerance);
|
||||
break;
|
||||
}
|
||||
case layergroupid::AdjustmentTypeID::TransferFunction:
|
||||
case layers::Adjustment::ID::TransferFunction:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
void setValuesFromDictionary(const ghoul::Dictionary& adjustmentDict);
|
||||
|
||||
layergroupid::AdjustmentTypeID type() const;
|
||||
layers::Adjustment::ID type() const;
|
||||
|
||||
glm::vec3 chromaKeyColor() const;
|
||||
float chromaKeyTolerance() const;
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
properties::FloatProperty _chromaKeyTolerance;
|
||||
|
||||
properties::OptionProperty _typeOption;
|
||||
layergroupid::AdjustmentTypeID _type;
|
||||
layers::Adjustment::ID _type;
|
||||
|
||||
std::function<void(void)> _onChangeCallback;
|
||||
};
|
||||
|
||||
@@ -47,12 +47,9 @@ namespace {
|
||||
|
||||
namespace openspace::globebrowsing {
|
||||
|
||||
LayerGroup::LayerGroup(layergroupid::GroupID id)
|
||||
: properties::PropertyOwner({
|
||||
std::string(layergroupid::LAYER_GROUP_IDENTIFIERS[id]),
|
||||
std::string(layergroupid::LAYER_GROUP_NAMES[id])
|
||||
})
|
||||
, _groupId(id)
|
||||
LayerGroup::LayerGroup(layers::Group group)
|
||||
: properties::PropertyOwner({ std::string(group.identifier), std::string(group.name)})
|
||||
, _groupId(group.id)
|
||||
, _levelBlendingEnabled(BlendTileInfo, true)
|
||||
{
|
||||
addProperty(_levelBlendingEnabled);
|
||||
@@ -248,4 +245,8 @@ void LayerGroup::onChange(std::function<void(Layer*)> callback) {
|
||||
}
|
||||
}
|
||||
|
||||
bool LayerGroup::isHeightLayer() const {
|
||||
return _groupId == layers::Group::ID::HeightLayers;
|
||||
}
|
||||
|
||||
} // namespace openspace::globebrowsing
|
||||
|
||||
@@ -39,7 +39,7 @@ struct TileProvider;
|
||||
* Convenience class for dealing with multiple <code>Layer</code>s.
|
||||
*/
|
||||
struct LayerGroup : public properties::PropertyOwner {
|
||||
LayerGroup(layergroupid::GroupID id);
|
||||
LayerGroup(layers::Group group);
|
||||
|
||||
void setLayersFromDict(const ghoul::Dictionary& dict);
|
||||
|
||||
@@ -66,8 +66,10 @@ struct LayerGroup : public properties::PropertyOwner {
|
||||
|
||||
void onChange(std::function<void(Layer*)> callback);
|
||||
|
||||
bool isHeightLayer() const;
|
||||
|
||||
private:
|
||||
const layergroupid::GroupID _groupId;
|
||||
const layers::Group::ID _groupId;
|
||||
std::vector<std::unique_ptr<Layer>> _layers;
|
||||
std::vector<Layer*> _activeLayers;
|
||||
|
||||
|
||||
170
modules/globebrowsing/src/layergroupid.cpp
Normal file
170
modules/globebrowsing/src/layergroupid.cpp
Normal file
@@ -0,0 +1,170 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2022 *
|
||||
* *
|
||||
* 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/src/layergroupid.h>
|
||||
|
||||
namespace openspace::globebrowsing::layers {
|
||||
|
||||
// The order and values of these enums are implicitly used in many places in the code and
|
||||
// in the shaders, so we need to ensure that the order is not messed with
|
||||
|
||||
|
||||
static_assert(
|
||||
std::is_sorted(
|
||||
Groups.begin(),
|
||||
Groups.end(),
|
||||
[](const Group& lhs, const Group& rhs) { return lhs.id < rhs.id; }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Groups.begin(),
|
||||
Groups.end(),
|
||||
[](const Group& gi) { return !gi.identifier.empty(); }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Groups.begin(),
|
||||
Groups.end(),
|
||||
[](const Group& gi) { return !gi.name.empty(); }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Groups.begin(),
|
||||
Groups.end(),
|
||||
[](const Group& gi) {
|
||||
auto it = std::find_if(
|
||||
Groups.begin(),
|
||||
Groups.end(),
|
||||
[gi](const Group& g) { return g.id == gi.id; }
|
||||
);
|
||||
std::ptrdiff_t pos = std::distance(Groups.begin(), it);
|
||||
return static_cast<int>(pos) == static_cast<int>(gi.id);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
static_assert(
|
||||
std::is_sorted(
|
||||
Layers.begin(),
|
||||
Layers.end(),
|
||||
[](const Layer& lhs, const Layer& rhs) { return lhs.id < rhs.id; }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Layers.begin(),
|
||||
Layers.end(),
|
||||
[](const Layer& li) { return !li.identifier.empty(); }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Layers.begin(),
|
||||
Layers.end(),
|
||||
[](const Layer& li) {
|
||||
auto it = std::find_if(
|
||||
Layers.begin(),
|
||||
Layers.end(),
|
||||
[li](const Layer& l) { return l.id == li.id; }
|
||||
);
|
||||
std::ptrdiff_t pos = std::distance(Layers.begin(), it);
|
||||
return static_cast<int>(pos) == static_cast<int>(li.id);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
static_assert(static_cast<int>(Adjustments[0].id) == 0);
|
||||
static_assert(static_cast<size_t>(Adjustments.back().id) == Adjustments.size() - 1);
|
||||
static_assert(
|
||||
std::is_sorted(
|
||||
Adjustments.begin(),
|
||||
Adjustments.end(),
|
||||
[](const Adjustment& lhs, const Adjustment& rhs) { return lhs.id < rhs.id; }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Adjustments.begin(),
|
||||
Adjustments.end(),
|
||||
[](const Adjustment& ai) { return !ai.identifier.empty(); }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Adjustments.begin(),
|
||||
Adjustments.end(),
|
||||
[](const Adjustment& ai) {
|
||||
auto it = std::find_if(
|
||||
Adjustments.begin(),
|
||||
Adjustments.end(),
|
||||
[ai](const Adjustment& a) { return a.id == ai.id; }
|
||||
);
|
||||
std::ptrdiff_t pos = std::distance(Adjustments.begin(), it);
|
||||
return static_cast<int>(pos) == static_cast<int>(ai.id);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
static_assert(static_cast<int>(Blends[0].id) == 0);
|
||||
static_assert(static_cast<size_t>(Blends.back().id) == Blends.size() - 1);
|
||||
static_assert(
|
||||
std::is_sorted(
|
||||
Blends.begin(),
|
||||
Blends.end(),
|
||||
[](const Blend& lhs, const Blend& rhs) { return lhs.id < rhs.id; }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Blends.begin(),
|
||||
Blends.end(),
|
||||
[](const Blend& bi) { return !bi.identifier.empty(); }
|
||||
)
|
||||
);
|
||||
static_assert(
|
||||
std::all_of(
|
||||
Blends.begin(),
|
||||
Blends.end(),
|
||||
[](const Blend& bi) {
|
||||
auto it = std::find_if(
|
||||
Blends.begin(),
|
||||
Blends.end(),
|
||||
[bi](const Blend& b) { return b.id == bi.id; }
|
||||
);
|
||||
std::ptrdiff_t pos = std::distance(Blends.begin(), it);
|
||||
return static_cast<int>(pos) == static_cast<int>(bi.id);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
} // namespace openspace::globebrowsing::layers
|
||||
@@ -26,159 +26,167 @@
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___LAYERGROUPID___H__
|
||||
|
||||
#include <ghoul/misc/stringconversion.h>
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
namespace openspace::globebrowsing::layergroupid {
|
||||
namespace openspace::globebrowsing::layers {
|
||||
|
||||
static constexpr int NUM_LAYER_GROUPS = 5;
|
||||
static constexpr std::string_view LAYER_GROUP_IDENTIFIERS[NUM_LAYER_GROUPS] = {
|
||||
"HeightLayers",
|
||||
"ColorLayers",
|
||||
"Overlays",
|
||||
"NightLayers",
|
||||
"WaterMasks"
|
||||
struct Group {
|
||||
enum class ID {
|
||||
HeightLayers = 0,
|
||||
ColorLayers,
|
||||
Overlays,
|
||||
NightLayers,
|
||||
WaterMasks,
|
||||
Unknown
|
||||
};
|
||||
|
||||
ID id;
|
||||
std::string_view identifier;
|
||||
std::string_view name;
|
||||
};
|
||||
|
||||
static constexpr std::string_view LAYER_GROUP_NAMES[NUM_LAYER_GROUPS] = {
|
||||
"Height Layers",
|
||||
"Color Layers",
|
||||
"Overlays",
|
||||
"Night Layers",
|
||||
"Water Masks"
|
||||
constexpr std::array<Group, 5> Groups = {
|
||||
Group{ Group::ID::HeightLayers, "HeightLayers", "Height Layers" },
|
||||
Group{ Group::ID::ColorLayers, "ColorLayers", "Color Layers" },
|
||||
Group{ Group::ID::Overlays, "Overlays", "Overlays" },
|
||||
Group{ Group::ID::NightLayers, "NightLayers", "Night Layers" },
|
||||
Group{ Group::ID::WaterMasks, "WaterMasks", "Water Masks" }
|
||||
};
|
||||
|
||||
enum GroupID {
|
||||
HeightLayers,
|
||||
ColorLayers,
|
||||
Overlays,
|
||||
NightLayers,
|
||||
WaterMasks,
|
||||
Unknown
|
||||
|
||||
|
||||
struct Layer {
|
||||
enum class ID {
|
||||
DefaultTileLayer = 0,
|
||||
SingleImageTileLayer,
|
||||
ImageSequenceTileLayer,
|
||||
SizeReferenceTileLayer,
|
||||
TemporalTileLayer,
|
||||
TileIndexTileLayer,
|
||||
ByIndexTileLayer,
|
||||
ByLevelTileLayer,
|
||||
SolidColor,
|
||||
SpoutImageTileLayer,
|
||||
Unknown
|
||||
};
|
||||
|
||||
ID id;
|
||||
std::string_view identifier;
|
||||
};
|
||||
|
||||
static constexpr int NUM_LAYER_TYPES = 10;
|
||||
static constexpr std::string_view LAYER_TYPE_NAMES[NUM_LAYER_TYPES] = {
|
||||
"DefaultTileLayer",
|
||||
"SingleImageTileLayer",
|
||||
"ImageSequenceTileLayer",
|
||||
"SizeReferenceTileLayer",
|
||||
"TemporalTileLayer",
|
||||
"TileIndexTileLayer",
|
||||
"ByIndexTileLayer",
|
||||
"ByLevelTileLayer",
|
||||
"SolidColor",
|
||||
"SpoutImageTileLayer"
|
||||
constexpr std::array<Layer, 10> Layers = {
|
||||
Layer{ Layer::ID::DefaultTileLayer, "DefaultTileLayer" },
|
||||
Layer{ Layer::ID::SingleImageTileLayer, "SingleImageTileLayer" },
|
||||
Layer{ Layer::ID::ImageSequenceTileLayer, "ImageSequenceTileLayer" },
|
||||
Layer{ Layer::ID::SizeReferenceTileLayer, "SizeReferenceTileLayer" },
|
||||
Layer{ Layer::ID::TemporalTileLayer, "TemporalTileLayer" },
|
||||
Layer{ Layer::ID::TileIndexTileLayer, "TileIndexTileLayer" },
|
||||
Layer{ Layer::ID::ByIndexTileLayer, "ByIndexTileLayer" },
|
||||
Layer{ Layer::ID::ByLevelTileLayer, "ByLevelTileLayer" },
|
||||
Layer{ Layer::ID::SolidColor, "SolidColor" },
|
||||
Layer{ Layer::ID::SpoutImageTileLayer, "SpoutImageTileLayer" }
|
||||
};
|
||||
|
||||
/**
|
||||
This enumeration is specified explicitly since it is used in the shader as well.
|
||||
*/
|
||||
enum class TypeID {
|
||||
Unknown = -1,
|
||||
DefaultTileLayer = 0,
|
||||
SingleImageTileLayer = 1,
|
||||
ImageSequenceTileLayer = 2,
|
||||
SizeReferenceTileLayer = 3,
|
||||
TemporalTileLayer = 4,
|
||||
TileIndexTileLayer = 5,
|
||||
ByIndexTileLayer = 6,
|
||||
ByLevelTileLayer = 7,
|
||||
SolidColor = 8,
|
||||
SpoutImageTileLayer = 9
|
||||
|
||||
|
||||
struct Adjustment {
|
||||
enum class ID {
|
||||
None = 0,
|
||||
ChromaKey,
|
||||
TransferFunction,
|
||||
};
|
||||
|
||||
ID id;
|
||||
std::string_view identifier;
|
||||
};
|
||||
|
||||
static constexpr int NUM_ADJUSTMENT_TYPES = 3;
|
||||
static constexpr std::string_view ADJUSTMENT_TYPE_NAMES[NUM_ADJUSTMENT_TYPES] = {
|
||||
"None",
|
||||
"ChromaKey",
|
||||
"TransferFunction",
|
||||
constexpr std::array<Adjustment, 3> Adjustments = {
|
||||
Adjustment{ Adjustment::ID::None, "None" },
|
||||
Adjustment{ Adjustment::ID::ChromaKey, "ChromaKey" },
|
||||
Adjustment{ Adjustment::ID::TransferFunction, "TransferFunction" }
|
||||
};
|
||||
|
||||
/**
|
||||
This enumeration is specified explicitly since it is used in the shader as well.
|
||||
*/
|
||||
enum class AdjustmentTypeID {
|
||||
None = 0,
|
||||
ChromaKey = 1,
|
||||
TransferFunction = 2,
|
||||
|
||||
|
||||
struct Blend {
|
||||
enum class ID {
|
||||
Normal = 0,
|
||||
Multiply = 1,
|
||||
Add = 2,
|
||||
Subtract = 3,
|
||||
Color = 4,
|
||||
};
|
||||
|
||||
ID id;
|
||||
std::string_view identifier;
|
||||
};
|
||||
|
||||
static constexpr int NUM_BLEND_MODES = 5;
|
||||
static constexpr std::string_view BLEND_MODE_NAMES[NUM_BLEND_MODES] = {
|
||||
"Normal",
|
||||
"Multiply",
|
||||
"Add",
|
||||
"Subtract",
|
||||
"Color",
|
||||
constexpr std::array<Blend, 5> Blends = {
|
||||
Blend{ Blend::ID::Normal, "Normal" },
|
||||
Blend{ Blend::ID::Multiply, "Multiply" },
|
||||
Blend{ Blend::ID::Add, "Add" },
|
||||
Blend{ Blend::ID::Subtract, "Subtract" },
|
||||
Blend{ Blend::ID::Color, "Color" }
|
||||
};
|
||||
|
||||
/**
|
||||
This enumeration is specified explicitly since it is used in the shader as well.
|
||||
*/
|
||||
enum class BlendModeID {
|
||||
Normal = 0,
|
||||
Multiply = 1,
|
||||
Add = 2,
|
||||
Subtract = 3,
|
||||
Color = 4,
|
||||
};
|
||||
|
||||
} // namespace openspace::globebrowsing::layergroupid
|
||||
} // namespace openspace::globebrowsing::layers
|
||||
|
||||
namespace ghoul {
|
||||
|
||||
template <>
|
||||
constexpr openspace::globebrowsing::layergroupid::TypeID from_string(
|
||||
std::string_view string)
|
||||
constexpr openspace::globebrowsing::layers::Layer::ID from_string(std::string_view string)
|
||||
{
|
||||
for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_LAYER_TYPES; ++i) {
|
||||
if (string == openspace::globebrowsing::layergroupid::LAYER_TYPE_NAMES[i]) {
|
||||
return static_cast<openspace::globebrowsing::layergroupid::TypeID>(i);
|
||||
}
|
||||
}
|
||||
return openspace::globebrowsing::layergroupid::TypeID::Unknown;
|
||||
using namespace openspace::globebrowsing::layers;
|
||||
|
||||
auto it = std::find_if(
|
||||
Layers.begin(),
|
||||
Layers.end(),
|
||||
[&string](const Layer& li) { return li.identifier == string; }
|
||||
);
|
||||
return it != Layers.end() ? it->id : Layer::ID::Unknown;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr openspace::globebrowsing::layergroupid::GroupID from_string(
|
||||
std::string_view string)
|
||||
constexpr openspace::globebrowsing::layers::Group::ID from_string(std::string_view string)
|
||||
{
|
||||
for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_LAYER_GROUPS; ++i) {
|
||||
if (string == openspace::globebrowsing::layergroupid::LAYER_GROUP_IDENTIFIERS[i])
|
||||
{
|
||||
return static_cast<openspace::globebrowsing::layergroupid::GroupID>(i);
|
||||
}
|
||||
}
|
||||
return openspace::globebrowsing::layergroupid::GroupID::Unknown;
|
||||
using namespace openspace::globebrowsing::layers;
|
||||
|
||||
auto it = std::find_if(
|
||||
Groups.begin(),
|
||||
Groups.end(),
|
||||
[&string](const Group& gi) { return gi.identifier == string; }
|
||||
);
|
||||
return it != Groups.end() ? it->id: Group::ID::Unknown;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr openspace::globebrowsing::layergroupid::AdjustmentTypeID from_string(
|
||||
constexpr openspace::globebrowsing::layers::Adjustment::ID from_string(
|
||||
std::string_view string)
|
||||
{
|
||||
for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_ADJUSTMENT_TYPES; ++i)
|
||||
{
|
||||
if (string == openspace::globebrowsing::layergroupid::ADJUSTMENT_TYPE_NAMES[i]) {
|
||||
return
|
||||
static_cast<openspace::globebrowsing::layergroupid::AdjustmentTypeID>(i);
|
||||
}
|
||||
}
|
||||
return openspace::globebrowsing::layergroupid::AdjustmentTypeID::None;
|
||||
using namespace openspace::globebrowsing::layers;
|
||||
|
||||
auto it = std::find_if(
|
||||
Adjustments.begin(),
|
||||
Adjustments.end(),
|
||||
[&string](const Adjustment& ai) { return ai.identifier == string; }
|
||||
);
|
||||
return it != Adjustments.end() ? it->id : Adjustment::ID::None;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr openspace::globebrowsing::layergroupid::BlendModeID from_string(
|
||||
std::string_view string)
|
||||
constexpr openspace::globebrowsing::layers::Blend::ID from_string(std::string_view string)
|
||||
{
|
||||
for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_BLEND_MODES; ++i) {
|
||||
if (string == openspace::globebrowsing::layergroupid::BLEND_MODE_NAMES[i]) {
|
||||
return static_cast<openspace::globebrowsing::layergroupid::BlendModeID>(i);
|
||||
}
|
||||
}
|
||||
return openspace::globebrowsing::layergroupid::BlendModeID::Normal;
|
||||
using namespace openspace::globebrowsing::layers;
|
||||
|
||||
auto it = std::find_if(
|
||||
Blends.begin(),
|
||||
Blends.end(),
|
||||
[&string](const Blend& bi) { return bi.identifier == string; }
|
||||
);
|
||||
return it != Blends.end() ? it->id : Blend::ID::Normal;
|
||||
}
|
||||
|
||||
} // ghoul
|
||||
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___LAYERGROUPID___H__
|
||||
|
||||
@@ -58,14 +58,15 @@ void LayerManager::initialize(const ghoul::Dictionary& layerGroupsDict) {
|
||||
|
||||
// First create empty layer groups in case not all are specified
|
||||
for (size_t i = 0; i < _layerGroups.size(); ++i) {
|
||||
_layerGroups[i] = std::make_unique<LayerGroup>(layergroupid::GroupID(i));
|
||||
_layerGroups[i] = std::make_unique<LayerGroup>(layers::Groups[i]);
|
||||
}
|
||||
|
||||
// Create all the layer groups
|
||||
for (std::string_view groupName : layerGroupsDict.keys()) {
|
||||
layergroupid::GroupID id = ghoul::from_string<layergroupid::GroupID>(groupName);
|
||||
using namespace layers;
|
||||
Group::ID id = ghoul::from_string<Group::ID>(groupName);
|
||||
|
||||
if (id != layergroupid::GroupID::Unknown) {
|
||||
if (id != Group::ID::Unknown) {
|
||||
ghoul::Dictionary d = layerGroupsDict.value<ghoul::Dictionary>(groupName);
|
||||
_layerGroups[static_cast<int>(id)]->setLayersFromDict(d);
|
||||
}
|
||||
@@ -89,14 +90,13 @@ void LayerManager::deinitialize() {
|
||||
}
|
||||
}
|
||||
|
||||
Layer* LayerManager::addLayer(layergroupid::GroupID groupId,
|
||||
const ghoul::Dictionary& layerDict)
|
||||
{
|
||||
Layer* LayerManager::addLayer(layers::Group::ID id, const ghoul::Dictionary& layerDict) {
|
||||
ZoneScoped
|
||||
|
||||
ghoul_assert(groupId != layergroupid::Unknown, "Layer group ID must be known");
|
||||
ghoul_assert(id != layergroupid::Group::ID::Unknown, "Layer group ID must be known");
|
||||
|
||||
try {
|
||||
return _layerGroups[groupId]->addLayer(layerDict);
|
||||
return _layerGroups[static_cast<size_t>(id)]->addLayer(layerDict);
|
||||
}
|
||||
catch (const documentation::SpecificationError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
@@ -114,19 +114,19 @@ Layer* LayerManager::addLayer(layergroupid::GroupID groupId,
|
||||
}
|
||||
}
|
||||
|
||||
void LayerManager::deleteLayer(layergroupid::GroupID id, const std::string& layerName) {
|
||||
void LayerManager::deleteLayer(layers::Group::ID id, const std::string& layerName) {
|
||||
ZoneScoped
|
||||
|
||||
ghoul_assert(id != layergroupid::Unknown, "Layer group ID must be known");
|
||||
_layerGroups[id]->deleteLayer(layerName);
|
||||
ghoul_assert(id != layergroupid::Group::ID::Unknown, "Layer group ID must be known");
|
||||
_layerGroups[static_cast<size_t>(id)]->deleteLayer(layerName);
|
||||
}
|
||||
|
||||
LayerGroup& LayerManager::layerGroup(layergroupid::GroupID groupId) {
|
||||
return *_layerGroups[groupId];
|
||||
LayerGroup& LayerManager::layerGroup(layers::Group::ID groupId) {
|
||||
return *_layerGroups[static_cast<size_t>(groupId)];
|
||||
}
|
||||
|
||||
const LayerGroup& LayerManager::layerGroup(layergroupid::GroupID groupId) const {
|
||||
return *_layerGroups[groupId];
|
||||
const LayerGroup& LayerManager::layerGroup(layers::Group::ID groupId) const {
|
||||
return *_layerGroups[static_cast<size_t>(groupId)];
|
||||
}
|
||||
|
||||
bool LayerManager::hasAnyBlendingLayersEnabled() const {
|
||||
|
||||
@@ -48,19 +48,18 @@ class TileTextureInitData;
|
||||
*/
|
||||
class LayerManager : public properties::PropertyOwner {
|
||||
public:
|
||||
constexpr static const int NumLayerGroups = layergroupid::NUM_LAYER_GROUPS;
|
||||
constexpr static size_t NumLayerGroups = layers::Groups.size();
|
||||
|
||||
LayerManager();
|
||||
|
||||
void initialize(const ghoul::Dictionary& layerGroupsDict);
|
||||
void deinitialize();
|
||||
|
||||
Layer* addLayer(layergroupid::GroupID groupId,
|
||||
const ghoul::Dictionary& layerDict);
|
||||
void deleteLayer(layergroupid::GroupID groupId, const std::string& layerName);
|
||||
Layer* addLayer(layers::Group::ID groupId, const ghoul::Dictionary& layerDict);
|
||||
void deleteLayer(layers::Group::ID groupId, const std::string& layerName);
|
||||
|
||||
LayerGroup& layerGroup(layergroupid::GroupID);
|
||||
const LayerGroup& layerGroup(layergroupid::GroupID) const;
|
||||
LayerGroup& layerGroup(layers::Group::ID groupId);
|
||||
const LayerGroup& layerGroup(layers::Group::ID groupId) const;
|
||||
|
||||
bool hasAnyBlendingLayersEnabled() const;
|
||||
|
||||
|
||||
@@ -315,11 +315,8 @@ void MemoryAwareTileCache::clear() {
|
||||
void MemoryAwareTileCache::createDefaultTextureContainers() {
|
||||
ZoneScoped
|
||||
|
||||
for (int id = 0; id < layergroupid::NUM_LAYER_GROUPS; id++) {
|
||||
TileTextureInitData initData = tileTextureInitData(
|
||||
layergroupid::GroupID(id),
|
||||
true
|
||||
);
|
||||
for (const layers::Group& gi : layers::Groups) {
|
||||
TileTextureInitData initData = tileTextureInitData(gi.id, true);
|
||||
assureTextureContainerExists(initData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager&
|
||||
// a single raster image. If it is not we will just use the first raster
|
||||
// (that is channel 0).
|
||||
const size_t HeightChannel = 0;
|
||||
const LayerGroup& heightmaps = lm.layerGroup(layergroupid::GroupID::HeightLayers);
|
||||
const LayerGroup& heightmaps = lm.layerGroup(layers::Group::ID::HeightLayers);
|
||||
|
||||
ChunkTileVector chunkTileSettingPairs = tilesAndSettingsUnsorted(
|
||||
heightmaps,
|
||||
@@ -399,8 +399,7 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager&
|
||||
bool colorAvailableForChunk(const Chunk& chunk, const LayerManager& lm) {
|
||||
ZoneScoped
|
||||
|
||||
const LayerGroup& colorLayers = lm.layerGroup(layergroupid::GroupID::ColorLayers);
|
||||
|
||||
const LayerGroup& colorLayers = lm.layerGroup(layers::Group::ID::ColorLayers);
|
||||
for (Layer* lyr : colorLayers.activeLayers()) {
|
||||
if (lyr->tileProvider()) {
|
||||
ChunkTile t = lyr->tileProvider()->chunkTile(chunk.tileIndex);
|
||||
@@ -978,9 +977,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
|
||||
for (size_t i = 0; i < layerGroups.size(); ++i) {
|
||||
_globalRenderer.gpuLayerGroups[i].bind(
|
||||
*_globalRenderer.program,
|
||||
*layerGroups[i],
|
||||
layergroupid::LAYER_GROUP_IDENTIFIERS[i],
|
||||
static_cast<int>(i)
|
||||
*layerGroups[i]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1002,9 +999,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
|
||||
for (size_t i = 0; i < layerGroups.size(); ++i) {
|
||||
_localRenderer.gpuLayerGroups[i].bind(
|
||||
*_localRenderer.program,
|
||||
*layerGroups[i],
|
||||
layergroupid::LAYER_GROUP_IDENTIFIERS[i],
|
||||
static_cast<int>(i)
|
||||
*layerGroups[i]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1063,9 +1058,8 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
|
||||
|
||||
_globalRenderer.program->setUniform("modelViewTransform", modelViewTransform);
|
||||
|
||||
const bool hasHeightLayer = !_layerManager.layerGroup(
|
||||
layergroupid::HeightLayers
|
||||
).activeLayers().empty();
|
||||
const bool hasHeightLayer =
|
||||
!_layerManager.layerGroup(layers::Group::ID::HeightLayers).activeLayers().empty();
|
||||
if (_generalProperties.useAccurateNormals && hasHeightLayer) {
|
||||
// Apply an extra scaling to the height if the object is scaled
|
||||
_globalRenderer.program->setUniform(
|
||||
@@ -1076,10 +1070,11 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
|
||||
);
|
||||
}
|
||||
|
||||
using namespace layers;
|
||||
const bool nightLayersActive =
|
||||
!_layerManager.layerGroup(layergroupid::NightLayers).activeLayers().empty();
|
||||
!_layerManager.layerGroup(Group::ID::NightLayers).activeLayers().empty();
|
||||
const bool waterLayersActive =
|
||||
!_layerManager.layerGroup(layergroupid::WaterMasks).activeLayers().empty();
|
||||
!_layerManager.layerGroup(Group::ID::WaterMasks).activeLayers().empty();
|
||||
|
||||
if (nightLayersActive || waterLayersActive || _generalProperties.performShading) {
|
||||
const glm::dvec3 directionToSunWorldSpace =
|
||||
@@ -1406,7 +1401,8 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d
|
||||
patchNormalCameraSpace
|
||||
);
|
||||
|
||||
if (!_layerManager.layerGroup(layergroupid::HeightLayers).activeLayers().empty()) {
|
||||
using namespace layers;
|
||||
if (!_layerManager.layerGroup(Group::ID::HeightLayers).activeLayers().empty()) {
|
||||
// Apply an extra scaling to the height if the object is scaled
|
||||
program.setUniform(
|
||||
"heightScale",
|
||||
@@ -1501,10 +1497,12 @@ void RenderableGlobe::debugRenderChunk(const Chunk& chunk, const glm::dmat4& mvp
|
||||
void RenderableGlobe::setCommonUniforms(ghoul::opengl::ProgramObject& programObject,
|
||||
const Chunk& chunk, const RenderData& data)
|
||||
{
|
||||
using namespace layers;
|
||||
|
||||
ZoneScoped
|
||||
|
||||
if (_generalProperties.useAccurateNormals &&
|
||||
!_layerManager.layerGroup(layergroupid::HeightLayers).activeLayers().empty())
|
||||
!_layerManager.layerGroup(Group::ID::HeightLayers).activeLayers().empty())
|
||||
{
|
||||
const glm::dvec3 corner00 = _ellipsoid.cartesianSurfacePosition(
|
||||
chunk.surfacePatch.corner(Quad::SOUTH_WEST)
|
||||
@@ -1555,13 +1553,12 @@ void RenderableGlobe::recompileShaders() {
|
||||
struct LayerGroupPreprocessingData {
|
||||
int lastLayerIdx;
|
||||
bool layerBlendingEnabled;
|
||||
std::vector<layergroupid::TypeID> layerType;
|
||||
std::vector<layergroupid::BlendModeID> blendMode;
|
||||
std::vector<layergroupid::AdjustmentTypeID> layerAdjustmentType;
|
||||
std::vector<layers::Layer::ID> layerType;
|
||||
std::vector<layers::Blend::ID> blendMode;
|
||||
std::vector<layers::Adjustment::ID> layerAdjustmentType;
|
||||
};
|
||||
|
||||
std::array<LayerGroupPreprocessingData, layergroupid::NUM_LAYER_GROUPS>
|
||||
layeredTextureInfo;
|
||||
std::array<LayerGroupPreprocessingData, layers::Groups.size()> layeredTextureInfo;
|
||||
std::vector<std::pair<std::string, std::string>> keyValuePairs;
|
||||
};
|
||||
|
||||
@@ -1571,11 +1568,11 @@ void RenderableGlobe::recompileShaders() {
|
||||
|
||||
LayerShaderPreprocessingData preprocessingData;
|
||||
|
||||
for (size_t i = 0; i < layergroupid::NUM_LAYER_GROUPS; i++) {
|
||||
for (size_t i = 0; i < layers::Groups.size(); i++) {
|
||||
LayerShaderPreprocessingData::LayerGroupPreprocessingData layeredTextureInfo;
|
||||
|
||||
const LayerGroup& layerGroup = _layerManager.layerGroup(layergroupid::GroupID(i));
|
||||
const std::vector<Layer*>& layers = layerGroup.activeLayers();
|
||||
const LayerGroup& group = _layerManager.layerGroup(layers::Group::ID(i));
|
||||
const std::vector<Layer*>& layers = group.activeLayers();
|
||||
|
||||
// This check was implicit before; not sure if it will fire or will be handled
|
||||
// elsewhere
|
||||
@@ -1584,9 +1581,9 @@ void RenderableGlobe::recompileShaders() {
|
||||
// "If activeLayers is empty the following line will lead to an overflow"
|
||||
//);
|
||||
layeredTextureInfo.lastLayerIdx = static_cast<int>(
|
||||
layerGroup.activeLayers().size() - 1
|
||||
group.activeLayers().size() - 1
|
||||
);
|
||||
layeredTextureInfo.layerBlendingEnabled = layerGroup.layerBlendingEnabled();
|
||||
layeredTextureInfo.layerBlendingEnabled = group.layerBlendingEnabled();
|
||||
|
||||
for (Layer* layer : layers) {
|
||||
layeredTextureInfo.layerType.push_back(layer->type());
|
||||
@@ -1602,9 +1599,8 @@ void RenderableGlobe::recompileShaders() {
|
||||
std::vector<std::pair<std::string, std::string>>& pairs =
|
||||
preprocessingData.keyValuePairs;
|
||||
|
||||
const bool hasHeightLayer = !_layerManager.layerGroup(
|
||||
layergroupid::HeightLayers
|
||||
).activeLayers().empty();
|
||||
const bool hasHeightLayer =
|
||||
!_layerManager.layerGroup(layers::Group::ID::HeightLayers).activeLayers().empty();
|
||||
|
||||
pairs.emplace_back("useAccurateNormals",
|
||||
std::to_string(_generalProperties.useAccurateNormals && hasHeightLayer)
|
||||
@@ -1643,22 +1639,26 @@ void RenderableGlobe::recompileShaders() {
|
||||
for (size_t i = 0; i < preprocessingData.layeredTextureInfo.size(); i++) {
|
||||
// lastLayerIndex must be at least 0 for the shader to compile,
|
||||
// the layer type is inactivated by setting use to false
|
||||
std::string groupName = std::string(layergroupid::LAYER_GROUP_IDENTIFIERS[i]);
|
||||
shaderDictionary.setValue(
|
||||
"lastLayerIndex" + groupName,
|
||||
fmt::format("lastLayerIndex{}", layers::Groups[i].identifier),
|
||||
glm::max(preprocessingData.layeredTextureInfo[i].lastLayerIdx, 0)
|
||||
);
|
||||
shaderDictionary.setValue(
|
||||
"use" + groupName,
|
||||
fmt::format("use{}", layers::Groups[i].identifier),
|
||||
preprocessingData.layeredTextureInfo[i].lastLayerIdx >= 0
|
||||
);
|
||||
shaderDictionary.setValue(
|
||||
"blend" + groupName,
|
||||
fmt::format("blend{}", layers::Groups[i].identifier),
|
||||
preprocessingData.layeredTextureInfo[i].layerBlendingEnabled
|
||||
);
|
||||
|
||||
// This is to avoid errors from shader preprocessor
|
||||
shaderDictionary.setValue(groupName + "0" + "LayerType", 0);
|
||||
shaderDictionary.setValue(
|
||||
fmt::format("{}0LayerType", layers::Groups[i].identifier),
|
||||
0
|
||||
);
|
||||
|
||||
std::string groupName = std::string(layers::Groups[i].identifier);
|
||||
|
||||
for (int j = 0;
|
||||
j < preprocessingData.layeredTextureInfo[i].lastLayerIdx + 1;
|
||||
@@ -1701,10 +1701,10 @@ void RenderableGlobe::recompileShaders() {
|
||||
}
|
||||
|
||||
ghoul::Dictionary layerGroupNames;
|
||||
for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
|
||||
for (int i = 0; i < layers::Groups.size(); ++i) {
|
||||
layerGroupNames.setValue(
|
||||
std::to_string(i),
|
||||
std::string(layergroupid::LAYER_GROUP_IDENTIFIERS[i])
|
||||
std::string(layers::Groups[i].identifier)
|
||||
);
|
||||
}
|
||||
shaderDictionary.setValue("layerGroups", layerGroupNames);
|
||||
@@ -1881,7 +1881,7 @@ float RenderableGlobe::getHeight(const glm::dvec3& position) const {
|
||||
|
||||
// Get the tile providers for the height maps
|
||||
const std::vector<Layer*>& heightMapLayers =
|
||||
_layerManager.layerGroup(layergroupid::GroupID::HeightLayers).activeLayers();
|
||||
_layerManager.layerGroup(layers::Group::ID::HeightLayers).activeLayers();
|
||||
|
||||
for (Layer* layer : heightMapLayers) {
|
||||
TileProvider* tileProvider = layer->tileProvider();
|
||||
@@ -2271,11 +2271,10 @@ int RenderableGlobe::desiredLevelByAvailableTileData(const Chunk& chunk) const {
|
||||
ZoneScoped
|
||||
|
||||
const int currLevel = chunk.tileIndex.level;
|
||||
|
||||
for (size_t i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
|
||||
for (Layer* layer :
|
||||
_layerManager.layerGroup(layergroupid::GroupID(i)).activeLayers())
|
||||
{
|
||||
|
||||
for (const layers::Group& gi : layers::Groups) {
|
||||
const std::vector<Layer*>& lyrs = _layerManager.layerGroup(gi.id).activeLayers();
|
||||
for (Layer* layer : lyrs) {
|
||||
Tile::Status status = layer->tileStatus(chunk.tileIndex);
|
||||
if (status == Tile::Status::OK) {
|
||||
return UnknownDesiredLevel;
|
||||
|
||||
@@ -94,7 +94,7 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary)
|
||||
// 1. Get required Keys
|
||||
_filePath = p.filePath;
|
||||
|
||||
_layerGroupID = layergroupid::GroupID(p.layerGroupID);
|
||||
_layerGroupID = layers::Group::ID(p.layerGroupID);
|
||||
|
||||
// 2. Initialize default values for any optional Keys
|
||||
// getValue does not work for integers
|
||||
@@ -102,11 +102,7 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary)
|
||||
_padTiles = p.padTiles.value_or(_padTiles);
|
||||
|
||||
// Only preprocess height layers by default
|
||||
switch (_layerGroupID) {
|
||||
case layergroupid::GroupID::HeightLayers: _performPreProcessing = true; break;
|
||||
default: _performPreProcessing = false; break;
|
||||
}
|
||||
|
||||
_performPreProcessing = _layerGroupID == layers::Group::ID::HeightLayers;
|
||||
_performPreProcessing = p.performPreProcessing.value_or(_performPreProcessing);
|
||||
|
||||
TileTextureInitData initData(
|
||||
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
properties::IntProperty _tilePixelSize;
|
||||
|
||||
std::unique_ptr<AsyncTileDataProvider> _asyncTextureDataProvider;
|
||||
layergroupid::GroupID _layerGroupID = layergroupid::GroupID::Unknown;
|
||||
layers::Group::ID _layerGroupID = layers::Group::ID::Unknown;
|
||||
bool _performPreProcessing = false;
|
||||
bool _padTiles = true;
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ documentation::Documentation SizeReferenceTileProvider::Documentation() {
|
||||
}
|
||||
|
||||
SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& dictionary)
|
||||
: TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false))
|
||||
: TextTileProvider(tileTextureInitData(layers::Group::ID::ColorLayers, false))
|
||||
{
|
||||
ZoneScoped
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
namespace openspace::globebrowsing {
|
||||
|
||||
TileIndexTileProvider::TileIndexTileProvider(const ghoul::Dictionary&)
|
||||
: TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false))
|
||||
: TextTileProvider(tileTextureInitData(layers::Group::ID::ColorLayers, false))
|
||||
{}
|
||||
|
||||
Tile TileIndexTileProvider::tile(const TileIndex& tileIndex) {
|
||||
|
||||
@@ -70,12 +70,12 @@ Tile DefaultTile = Tile { nullptr, std::nullopt, Tile::Status::Unavailable };
|
||||
unsigned int TileProvider::NumTileProviders = 0;
|
||||
|
||||
std::unique_ptr<TileProvider> TileProvider::createFromDictionary(
|
||||
layergroupid::TypeID layerTypeID,
|
||||
layers::Layer::ID layerTypeID,
|
||||
const ghoul::Dictionary& dictionary)
|
||||
{
|
||||
ZoneScoped
|
||||
|
||||
std::string_view type = layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layerTypeID)];
|
||||
std::string_view type = layers::Layers[static_cast<int>(layerTypeID)].identifier;
|
||||
|
||||
ghoul::TemplateFactory<TileProvider>* factory =
|
||||
FactoryManager::ref().factory<TileProvider>();
|
||||
|
||||
@@ -74,7 +74,7 @@ struct TileProvider : public properties::PropertyOwner {
|
||||
static unsigned int NumTileProviders;
|
||||
|
||||
static std::unique_ptr<TileProvider> createFromDictionary(
|
||||
layergroupid::TypeID layerTypeID, const ghoul::Dictionary& dictionary);
|
||||
layers::Layer::ID layerTypeID, const ghoul::Dictionary& dictionary);
|
||||
|
||||
static void initializeDefaultTile();
|
||||
static void deinitializeDefaultTile();
|
||||
|
||||
@@ -69,12 +69,12 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) {
|
||||
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
layergroupid::TypeID typeID = layergroupid::TypeID::DefaultTileLayer;
|
||||
layers::Layer::ID typeID = layers::Layer::ID::DefaultTileLayer;
|
||||
if (p.defaultProvider.hasValue<std::string>("Type")) {
|
||||
std::string type = p.defaultProvider.value<std::string>("Type");
|
||||
typeID = ghoul::from_string<layergroupid::TypeID>(type);
|
||||
typeID = ghoul::from_string<layers::Layer::ID>(type);
|
||||
|
||||
if (typeID == layergroupid::TypeID::Unknown) {
|
||||
if (typeID == layers::Layer::ID::Unknown) {
|
||||
throw ghoul::RuntimeError("Unknown layer type: " + type);
|
||||
}
|
||||
}
|
||||
@@ -88,18 +88,18 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) {
|
||||
static_cast<uint8_t>(ip.tileIndex.level)
|
||||
);
|
||||
|
||||
layergroupid::TypeID providerTypeID = layergroupid::TypeID::DefaultTileLayer;
|
||||
layers::Layer::ID providerID = layers::Layer::ID::DefaultTileLayer;
|
||||
if (ip.tileProvider.hasValue<std::string>("Type")) {
|
||||
std::string type = ip.tileProvider.value<std::string>("Type");
|
||||
providerTypeID = ghoul::from_string<layergroupid::TypeID>(type);
|
||||
providerID = ghoul::from_string<layers::Layer::ID>(type);
|
||||
|
||||
if (providerTypeID == layergroupid::TypeID::Unknown) {
|
||||
if (providerID == layers::Layer::ID::Unknown) {
|
||||
throw ghoul::RuntimeError("Unknown layer type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<TileProvider> stp = createFromDictionary(
|
||||
providerTypeID,
|
||||
providerID,
|
||||
ip.tileProvider
|
||||
);
|
||||
TileIndex::TileHashKey key = tileIndex.hashKey();
|
||||
|
||||
@@ -50,18 +50,18 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
|
||||
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
layergroupid::GroupID layerGroup = static_cast<layergroupid::GroupID>(p.layerGroupID);
|
||||
layers::Group::ID group = static_cast<layers::Group::ID>(p.layerGroupID);
|
||||
|
||||
for (Parameters::Provider provider : p.levelTileProviders) {
|
||||
ghoul::Dictionary& tileProviderDict = provider.tileProvider;
|
||||
tileProviderDict.setValue("LayerGroupID", static_cast<int>(layerGroup));
|
||||
tileProviderDict.setValue("LayerGroupID", static_cast<int>(group));
|
||||
|
||||
layergroupid::TypeID typeID = layergroupid::TypeID::DefaultTileLayer;
|
||||
layers::Layer::ID typeID = layers::Layer::ID::DefaultTileLayer;
|
||||
if (tileProviderDict.hasValue<std::string>("Type")) {
|
||||
std::string type = tileProviderDict.value<std::string>("Type");
|
||||
typeID = ghoul::from_string<layergroupid::TypeID>(type);
|
||||
typeID = ghoul::from_string<layers::Layer::ID>(type);
|
||||
|
||||
if (typeID == layergroupid::TypeID::Unknown) {
|
||||
if (typeID == layers::Layer::ID::Unknown) {
|
||||
throw ghoul::RuntimeError("Unknown layer type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,11 +105,11 @@ openspace::globebrowsing::TileTextureInitData::HashKey calculateHashKey(
|
||||
|
||||
namespace openspace::globebrowsing {
|
||||
|
||||
TileTextureInitData tileTextureInitData(layergroupid::GroupID id, bool shouldPadTiles,
|
||||
size_t preferredTileSize)
|
||||
TileTextureInitData tileTextureInitData(layers::Group::ID id, bool shouldPadTiles,
|
||||
size_t preferredTileSize)
|
||||
{
|
||||
switch (id) {
|
||||
case layergroupid::GroupID::HeightLayers: {
|
||||
case layers::Group::ID::HeightLayers: {
|
||||
const size_t tileSize = preferredTileSize ? preferredTileSize : 64;
|
||||
return TileTextureInitData(
|
||||
tileSize,
|
||||
@@ -120,7 +120,7 @@ TileTextureInitData tileTextureInitData(layergroupid::GroupID id, bool shouldPad
|
||||
TileTextureInitData::ShouldAllocateDataOnCPU::Yes
|
||||
);
|
||||
}
|
||||
case layergroupid::GroupID::ColorLayers: {
|
||||
case layers::Group::ID::ColorLayers: {
|
||||
const size_t tileSize = preferredTileSize ? preferredTileSize : 512;
|
||||
return TileTextureInitData(
|
||||
tileSize,
|
||||
@@ -130,7 +130,7 @@ TileTextureInitData tileTextureInitData(layergroupid::GroupID id, bool shouldPad
|
||||
TileTextureInitData::PadTiles(shouldPadTiles)
|
||||
);
|
||||
}
|
||||
case layergroupid::GroupID::Overlays: {
|
||||
case layers::Group::ID::Overlays: {
|
||||
const size_t tileSize = preferredTileSize ? preferredTileSize : 512;
|
||||
return TileTextureInitData(
|
||||
tileSize,
|
||||
@@ -140,7 +140,7 @@ TileTextureInitData tileTextureInitData(layergroupid::GroupID id, bool shouldPad
|
||||
TileTextureInitData::PadTiles(shouldPadTiles)
|
||||
);
|
||||
}
|
||||
case layergroupid::GroupID::NightLayers: {
|
||||
case layers::Group::ID::NightLayers: {
|
||||
const size_t tileSize = preferredTileSize ? preferredTileSize : 512;
|
||||
return TileTextureInitData(
|
||||
tileSize,
|
||||
@@ -150,7 +150,7 @@ TileTextureInitData tileTextureInitData(layergroupid::GroupID id, bool shouldPad
|
||||
TileTextureInitData::PadTiles(shouldPadTiles)
|
||||
);
|
||||
}
|
||||
case layergroupid::GroupID::WaterMasks: {
|
||||
case layers::Group::ID::WaterMasks: {
|
||||
const size_t tileSize = preferredTileSize ? preferredTileSize : 512;
|
||||
return TileTextureInitData(
|
||||
tileSize,
|
||||
|
||||
@@ -68,8 +68,8 @@ public:
|
||||
const HashKey hashKey;
|
||||
};
|
||||
|
||||
TileTextureInitData tileTextureInitData(layergroupid::GroupID id,
|
||||
bool shouldPadTiles, size_t preferredTileSize = 0);
|
||||
TileTextureInitData tileTextureInitData(layers::Group::ID id, bool shouldPadTiles,
|
||||
size_t preferredTileSize = 0);
|
||||
|
||||
} // namespace openspace::globebrowsing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user