Merge branch 'master' of github.com:OpenSpace/OpenSpace into feature/data-management

This commit is contained in:
Emil Axelsson
2017-12-04 10:52:12 +01:00
175 changed files with 5984 additions and 4556 deletions
+4 -2
View File
@@ -301,7 +301,8 @@ void MemoryAwareTileCache::update() {
size_t MemoryAwareTileCache::getGPUAllocatedDataSize() const {
return std::accumulate(
_textureContainerMap.cbegin(),
_textureContainerMap.cend(), 0,
_textureContainerMap.cend(),
size_t(0),
[](size_t s, const std::pair<const TileTextureInitData::HashKey,
TextureContainerTileCache>& p)
{
@@ -316,7 +317,8 @@ size_t MemoryAwareTileCache::getGPUAllocatedDataSize() const {
size_t MemoryAwareTileCache::getCPUAllocatedDataSize() const {
size_t dataSize = std::accumulate(
_textureContainerMap.cbegin(),
_textureContainerMap.cend(), 0,
_textureContainerMap.cend(),
size_t(0),
[](size_t s, const std::pair<const TileTextureInitData::HashKey,
TextureContainerTileCache>& p)
{
@@ -38,7 +38,8 @@ namespace openspace::globebrowsing::chunklevelevaluator {
*/
class ProjectedArea : public Evaluator {
public:
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const;
virtual int getDesiredLevel(
const Chunk& chunk, const RenderData& data) const override;
};
} // namespace openspace::globebrowsing::chunklevelevaluator
@@ -502,16 +502,11 @@ std::string GlobeBrowsingModule::layerTypeNamesList() {
void GlobeBrowsingModule::loadWMSCapabilities(std::string name, std::string globe,
std::string url)
{
auto downloadFunction = [](const std::string& url) {
auto downloadFunction = [](const std::string& downloadUrl) {
GDALDatasetH dataset = GDALOpen(
url.c_str(),
downloadUrl.c_str(),
GA_ReadOnly
);
// GDAL_OF_READONLY | GDAL_OF_RASTER | GDAL_OF_VERBOSE_ERROR,
// nullptr,
// nullptr,
// nullptr
//);
char** subDatasets = GDALGetMetadata(dataset, "SUBDATASETS");
int nSubdatasets = CSLCount(subDatasets);
@@ -162,8 +162,8 @@ int goToGeo(lua_State* L) {
return luaL_error(L, "Expected 2 or 3 arguments.");
}
double latitude = static_cast<double>(lua_tonumber(L, 1));
double longitude = static_cast<double>(lua_tonumber(L, 2));
double latitude = lua_tonumber(L, 1);
double longitude = lua_tonumber(L, 2);
if (nArguments == 2) {
OsEng.moduleEngine().module<GlobeBrowsingModule>()->goToGeo(latitude, longitude);
+1 -1
View File
@@ -95,7 +95,7 @@ void PointGlobe::initialize() {
// Position at location 0
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(glm::vec2), 0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(glm::vec2), nullptr);
glBindVertexArray(0);
}
+12 -12
View File
@@ -55,10 +55,10 @@ void TriangleSoup::setVertexPositions(std::vector<glm::vec4> positions) {
_gpuDataNeedUpdate = true;
_vertexData.resize(positions.size());
for (size_t i = 0; i < positions.size(); i++) {
_vertexData[i].position[0] = static_cast<GLfloat>(positions[i].x);
_vertexData[i].position[1] = static_cast<GLfloat>(positions[i].y);
_vertexData[i].position[2] = static_cast<GLfloat>(positions[i].z);
_vertexData[i].position[3] = static_cast<GLfloat>(positions[i].w);
_vertexData[i].position[0] = positions[i].x;
_vertexData[i].position[1] = positions[i].y;
_vertexData[i].position[2] = positions[i].z;
_vertexData[i].position[3] = positions[i].w;
}
}
@@ -67,8 +67,8 @@ void TriangleSoup::setVertexTextureCoordinates(std::vector<glm::vec2> textures)
_gpuDataNeedUpdate = true;
_vertexData.resize(textures.size());
for (size_t i = 0; i < textures.size(); i++) {
_vertexData[i].texture[0] = static_cast<GLfloat>(textures[i].s);
_vertexData[i].texture[1] = static_cast<GLfloat>(textures[i].t);
_vertexData[i].texture[0] = textures[i].s;
_vertexData[i].texture[1] = textures[i].t;
}
}
@@ -77,9 +77,9 @@ void TriangleSoup::setVertexNormals(std::vector<glm::vec3> normals) {
_gpuDataNeedUpdate = true;
_vertexData.resize(normals.size());
for (size_t i = 0; i < normals.size(); i++) {
_vertexData[i].normal[0] = static_cast<GLfloat>(normals[i].x);
_vertexData[i].normal[1] = static_cast<GLfloat>(normals[i].y);
_vertexData[i].normal[2] = static_cast<GLfloat>(normals[i].z);
_vertexData[i].normal[0] = normals[i].x;
_vertexData[i].normal[1] = normals[i].y;
_vertexData[i].normal[2] = normals[i].z;
}
}
@@ -87,7 +87,7 @@ void TriangleSoup::setElements(std::vector<unsigned int> elements) {
_elementData.resize(elements.size());
_gpuDataNeedUpdate = true;
for (size_t i = 0; i < elements.size(); i++) {
_elementData[i] = static_cast<GLuint>(elements[i]);
_elementData[i] = elements[i];
}
}
@@ -128,8 +128,8 @@ bool TriangleSoup::updateDataOnGPU() {
// Positions at location 0
if (_useVertexPositions) {
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, position)));
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr);
//reinterpret_cast<const GLvoid*>(offsetof(Vertex, position)));
}
// Textures at location 1
if (_useTextureCoordinates) {
+1 -1
View File
@@ -38,7 +38,7 @@ PixelBuffer::PixelBuffer(size_t numBytes, Usage usage)
{
glGenBuffers(1, &_id);
bind();
glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, 0, static_cast<GLenum>(_usage));
glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, nullptr, static_cast<GLenum>(_usage));
unbind();
}
@@ -293,7 +293,7 @@ void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& dat
Geodetic2 corner = chunk.surfacePatch().getCorner(q);
glm::dvec3 cornerModelSpace = ellipsoid.cartesianSurfacePosition(corner);
glm::dvec3 cornerCameraSpace =
glm::dvec3(dmat4(modelViewTransform) * glm::dvec4(cornerModelSpace, 1));
glm::dvec3(modelViewTransform * glm::dvec4(cornerModelSpace, 1));
cornersCameraSpace[i] = cornerCameraSpace;
programObject->setUniform(cornerNames[i], vec3(cornerCameraSpace));
}
@@ -69,8 +69,8 @@ LayerGroup::LayerGroup(layergroupid::GroupID id, const ghoul::Dictionary& dict)
try {
addLayer(fallbackLayerDict);
}
catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
catch (const ghoul::RuntimeError& except) {
LERRORC(except.component, except.message);
continue;
}
}
@@ -48,7 +48,8 @@ public:
void initialize();
void deinitialize();
std::shared_ptr<Layer> addLayer(layergroupid::GroupID groupId, ghoul::Dictionary layerDict);
std::shared_ptr<Layer> addLayer(layergroupid::GroupID groupId,
ghoul::Dictionary layerDict);
void deleteLayer(layergroupid::GroupID groupId, std::string layerName);
const LayerGroup& layerGroup(size_t groupId);
+4 -4
View File
@@ -118,12 +118,12 @@ void PixelRegion::scale(double s) {
void PixelRegion::downscalePow2(int exponent, PixelCoordinate wrt) {
start += wrt;
start.x = ceil(start.x / static_cast<float>(pow(2, exponent)));// >>= exponent;
start.y = ceil(start.y / static_cast<float>(pow(2, exponent)));// >>= exponent;
start.x = static_cast<int>(ceil(start.x / static_cast<float>(pow(2, exponent))));
start.y = static_cast<int>(ceil(start.y / static_cast<float>(pow(2, exponent))));
numPixels.x =
ceil(numPixels.x / static_cast<float>(pow(2, exponent)));// >>= exponent;
static_cast<int>(ceil(numPixels.x / static_cast<float>(pow(2, exponent))));
numPixels.y =
ceil(numPixels.y / static_cast<float>(pow(2, exponent)));// >>= exponent;
static_cast<int>(ceil(numPixels.y / static_cast<float>(pow(2, exponent))));
start -= wrt;
}
+1 -1
View File
@@ -43,7 +43,7 @@ RawTile RawTile::createDefault(const TileTextureInitData& initData) {
defaultRes.textureInitData = std::make_shared<TileTextureInitData>(initData);
defaultRes.imageData = new char[initData.totalNumBytes()];
std::fill_n(
static_cast<char*>(defaultRes.imageData),
defaultRes.imageData,
initData.totalNumBytes(),
char(0)
);
@@ -126,12 +126,17 @@ void GdalRawTileDataReader::initialize() {
// Assume all raster bands have the same data type
_gdalDatasetMetaDataCached.rasterCount = _dataset->GetRasterCount();
_gdalDatasetMetaDataCached.scale = _dataset->GetRasterBand(1)->GetScale();
_gdalDatasetMetaDataCached.offset = _dataset->GetRasterBand(1)->GetOffset();
_gdalDatasetMetaDataCached.scale = static_cast<float>(
_dataset->GetRasterBand(1)->GetScale()
);
_gdalDatasetMetaDataCached.offset = static_cast<float>(
_dataset->GetRasterBand(1)->GetOffset()
);
_gdalDatasetMetaDataCached.rasterXSize = _dataset->GetRasterXSize();
_gdalDatasetMetaDataCached.rasterYSize = _dataset->GetRasterYSize();
_gdalDatasetMetaDataCached.noDataValue =
_dataset->GetRasterBand(1)->GetNoDataValue();
_gdalDatasetMetaDataCached.noDataValue = static_cast<float>(
_dataset->GetRasterBand(1)->GetNoDataValue()
);
_gdalDatasetMetaDataCached.dataType =
tiledatatype::getGdalDataType(_initData.glType());
@@ -145,7 +150,7 @@ void GdalRawTileDataReader::initialize() {
calculateTileLevelDifference(_initData.dimensions().x);
int numOverviews = _dataset->GetRasterBand(1)->GetOverviewCount();
_cached._maxLevel = -_cached._tileLevelDifference;
_cached._maxLevel = static_cast<int>(-_cached._tileLevelDifference);
if (numOverviews > 0) {
_cached._maxLevel += numOverviews - 1;
}
@@ -162,7 +167,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
);
PixelRegion::PixelCoordinate end = io.write.region.end();
size_t largestIndex =
[[maybe_unused]] size_t largestIndex =
(end.y - 1) * io.write.bytesPerLine + (end.x - 1) * _initData.bytesPerPixel();
ghoul_assert(largestIndex <= io.write.totalNumBytes, "Invalid write region");
@@ -191,7 +196,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
io.write.region.numPixels.y, // width to write y in destination
_gdalDatasetMetaDataCached.dataType, // Type
static_cast<int>(_initData.bytesPerPixel()), // Pixel spacing
static_cast<int>(-io.write.bytesPerLine) // Line spacing
-static_cast<int>(io.write.bytesPerLine) // Line spacing
);
// Convert error to RawTile::ReadError
@@ -236,7 +241,7 @@ int GdalRawTileDataReader::calculateTileLevelDifference(int minimumPixelSize) co
}
int sizeLevel0 = maxOverview->GetXSize();
double diff = log2(minimumPixelSize) - log2(sizeLevel0);
return diff;
return static_cast<int>(diff);
}
} // namespace openspace::globebrowsing
@@ -577,7 +577,7 @@ TileDepthTransform RawTileDataReader::calculateTileDepthTransform() {
TileDepthTransform transform;
transform.depthOffset = depthOffset();
transform.depthScale = depthScale() * maximumValue;
transform.depthScale = static_cast<float>(depthScale() * maximumValue);
return transform;
}
@@ -115,14 +115,16 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead(
y * _initData.bytesPerLine() +
x * _initData.bytesPerPixel();
int xInSource =
int xInSource = static_cast<int>(
io.read.region.start.x +
static_cast<float>(x) / io.write.region.numPixels.x *
io.read.region.numPixels.x;
int yInSource =
io.read.region.numPixels.x
);
int yInSource = static_cast<int>(
io.read.region.start.y +
static_cast<float>(y) / io.write.region.numPixels.y *
io.read.region.numPixels.y;
io.read.region.numPixels.y
);
glm::vec4 sourceTexel = _dataTexture->texelAsFloat(xInSource, yInSource);
@@ -141,7 +143,7 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead(
char value = static_cast<char>(
sourceTexel[rasterBand - 1] * 255
);
*reinterpret_cast<char*>(pixelWriteDestination) = value;
*pixelWriteDestination = value;
break;
}
case GL_UNSIGNED_SHORT: {
@@ -141,6 +141,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 2:
@@ -169,6 +170,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 3:
@@ -198,6 +200,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 4:
@@ -227,11 +230,12 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) {
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
default:
LERROR("Unknown number of channels for OpenGL texture: " << rasterCount);
break;
throw ghoul::MissingCaseException();
}
return format;
}
@@ -267,6 +271,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 2:
@@ -295,6 +300,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 3:
@@ -324,6 +330,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
case 4:
@@ -353,11 +360,12 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
// break;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
throw ghoul::MissingCaseException();
}
break;
default:
LERROR("Unknown number of channels for OpenGL texture: " << rasterCount);
break;
throw ghoul::MissingCaseException();
}
return format;
}
@@ -380,7 +388,7 @@ GLenum getOpenGLDataType(GDALDataType gdalType) {
return GL_DOUBLE;
default:
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
return GL_UNSIGNED_BYTE;
throw ghoul::MissingCaseException();
}
}
@@ -402,7 +410,7 @@ GDALDataType getGdalDataType(GLenum glType) {
return GDT_Float64;
default:
LERROR("OpenGL data type unknown to GDAL: " << glType);
return GDT_Unknown;
throw ghoul::MissingCaseException();
}
}
@@ -410,12 +418,16 @@ GDALDataType getGdalDataType(GLenum glType) {
size_t numberOfRasters(ghoul::opengl::Texture::Format format) {
switch (format) {
case ghoul::opengl::Texture::Format::Red: return 1;
case ghoul::opengl::Texture::Format::RG: return 2;
case ghoul::opengl::Texture::Format::RGB:;
[[fallthrough]]; case ghoul::opengl::Texture::Format::BGR: return 3;
case ghoul::opengl::Texture::Format::RGBA:;
[[fallthrough]]; case ghoul::opengl::Texture::Format::BGRA: return 4;
case ghoul::opengl::Texture::Format::Red:
return 1;
case ghoul::opengl::Texture::Format::RG:
return 2;
case ghoul::opengl::Texture::Format::RGB:
case ghoul::opengl::Texture::Format::BGR:
return 3;
case ghoul::opengl::Texture::Format::RGBA:
case ghoul::opengl::Texture::Format::BGRA:
return 4;
default: {
ghoul_assert(false, "Unknown format");
return 0;
@@ -436,7 +448,7 @@ size_t numberOfBytes(GLenum glType) {
case GL_DOUBLE: return sizeof(GLdouble);
default: {
ghoul_assert(false, "Unknown data type");
return 0;
throw ghoul::MissingCaseException();
}
}
}
@@ -455,7 +467,7 @@ size_t getMaximumValue(GLenum glType) {
return 1ULL << 31ULL;
default: {
ghoul_assert(false, "Unknown data type");
return 0ULL;
throw ghoul::MissingCaseException();
}
}
}
@@ -480,7 +492,7 @@ float interpretFloat(GLenum glType, const char* src) {
return static_cast<float>(*reinterpret_cast<const GLdouble*>(src));
default: {
ghoul_assert(false, "Unknown data type");
return 0;
throw ghoul::MissingCaseException();
}
}
}
@@ -504,7 +516,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::RG:
switch (glType) {
@@ -523,7 +535,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::RGB:
switch (glType) {
@@ -542,7 +554,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::RGBA:
switch (glType) {
@@ -561,7 +573,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::BGR:
switch (glType) {
@@ -580,7 +592,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
case ghoul::opengl::Texture::Format::BGRA:
switch (glType) {
@@ -599,16 +611,16 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
default:
ghoul_assert(false, "glType data type unknown");
LERROR("glType data type unknown: " << glType);
return GLenum(0);
throw ghoul::MissingCaseException();
}
default:
LERROR(
"Unknown format for OpenGL texture: " <<
static_cast<std::underlying_type_t<
ghoul::opengl::Texture::Format>
>(format)
static_cast<std::underlying_type_t<ghoul::opengl::Texture::Format>>(
format
)
);
return GLenum(0);
throw ghoul::MissingCaseException();
}
}
+6 -6
View File
@@ -38,16 +38,16 @@ namespace {
namespace openspace::globebrowsing {
TileIndex::TileIndex(int x, int y, int level)
: x(x), y(y), level(level)
TileIndex::TileIndex(int x_, int y_, int level_)
: x(x_), y(y_), level(level_)
{}
TileIndex::TileIndex(const TileIndex& other)
: x(other.x), y(other.y), level(other.level)
{}
TileIndex::TileIndex(const Geodetic2& point, int level)
: level(level)
TileIndex::TileIndex(const Geodetic2& point, int level_)
: level(level_)
{
int numIndicesAtLevel = 1 << level;
double u = 0.5 + point.lon / (2 * glm::pi<double>());
@@ -55,8 +55,8 @@ TileIndex::TileIndex(const Geodetic2& point, int level)
double xIndexSpace = u * numIndicesAtLevel;
double yIndexSpace = v * numIndicesAtLevel;
x = floor(xIndexSpace);
y = floor(yIndexSpace);
x = static_cast<int>(floor(xIndexSpace));
y = static_cast<int>(floor(yIndexSpace));
}
TileIndex::TileIndex(const ghoul::Dictionary& dict) {
@@ -500,7 +500,7 @@ std::vector<Time> TimeQuantizer::quantized(const Time& start, const Time& end) c
const double delta = endSeconds - startSeconds;
ghoul_assert(int(delta) % int(_resolution) == 0, "Quantization error");
const int nSteps = delta / _resolution;
const int nSteps = static_cast<int>(delta / _resolution);
std::vector<Time> result(nSteps + 1);
for (int i = 0; i <= nSteps; ++i) {
@@ -56,7 +56,7 @@ bool TextTileProvider::initialize() {
_font = OsEng.fontManager().font("Mono", static_cast<float>(_fontSize));
_fontRenderer = std::unique_ptr<FontRenderer>(FontRenderer::createDefault());
_fontRenderer = FontRenderer::createDefault();
_fontRenderer->setFramebufferSize(glm::vec2(_initData.dimensions()));
glGenFramebuffers(1, &_fbo);
@@ -61,7 +61,7 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
"Must define key '" + std::string(KeyMaxLevel) + "'"
);
}
maxLevel = std::round(floatMaxLevel);
maxLevel = static_cast<int>(std::round(floatMaxLevel));
ghoul::Dictionary providerDict;
if (!levelProviderDict.getValue<ghoul::Dictionary>(KeyTileProvider, providerDict))
@@ -129,7 +129,7 @@ bool TileProviderByLevel::deinitialize() {
for (const std::shared_ptr<TileProvider>& tp : _levelTileProviders) {
success &= tp->deinitialize();
}
return TileProvider::deinitialize() && success;
}
@@ -155,7 +155,7 @@ unsigned int TileTextureInitData::getUniqueIdFromTextureFormat(
case Format::DepthComponent:
return 6;
default:
ghoul_assert(false, "Unknown texture format");
throw ghoul::MissingCaseException();
}
}