mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 20:39:08 -06:00
Merge branch 'feature/globebrowsing' of github.com:OpenSpace/OpenSpace-Development into feature/globebrowsing
This commit is contained in:
@@ -34,6 +34,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunk.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunkrenderer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator.h
|
||||
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.h
|
||||
@@ -60,6 +61,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentqueue.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/debugrenderer.h
|
||||
|
||||
|
||||
)
|
||||
@@ -73,6 +75,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunk.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunkrenderer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator.cpp
|
||||
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.cpp
|
||||
@@ -98,6 +101,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/debugrenderer.cpp
|
||||
|
||||
|
||||
)
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace openspace {
|
||||
const Camera& camRef = savedCamera != nullptr ? *savedCamera : data.camera;
|
||||
RenderData myRenderData = { camRef, data.position, data.doPerformanceMeasurement };
|
||||
|
||||
|
||||
_isVisible = true;
|
||||
if (_owner->testIfCullable(*this, myRenderData)) {
|
||||
_isVisible = false;
|
||||
@@ -122,132 +123,5 @@ namespace openspace {
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// Chunk evaluation //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
int EvaluateChunkLevelByDistance::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
ChunkedLodGlobe const * globe = chunk.owner();
|
||||
const Ellipsoid& ellipsoid = globe->ellipsoid();
|
||||
|
||||
Vec3 cameraPosition = data.camera.positionVec3();
|
||||
Geodetic2 pointOnPatch = chunk.surfacePatch().closestPoint(
|
||||
ellipsoid.cartesianToGeodetic2(cameraPosition));
|
||||
|
||||
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
|
||||
|
||||
Vec3 globePosition = data.position.dvec3();
|
||||
Vec3 patchPosition = globePosition + ellipsoid.cartesianSurfacePosition(pointOnPatch);
|
||||
Vec3 cameraToChunk = patchPosition - cameraPosition;
|
||||
|
||||
|
||||
// Calculate desired level based on distance
|
||||
Scalar distanceToPatch = glm::length(cameraToChunk);
|
||||
Scalar distance = distanceToPatch - heights.min; // distance to actual minimum heights
|
||||
|
||||
Scalar scaleFactor = globe->lodScaleFactor * ellipsoid.minimumRadius();
|
||||
Scalar projectedScaleFactor = scaleFactor / distance;
|
||||
int desiredLevel = ceil(log2(projectedScaleFactor));
|
||||
return desiredLevel;
|
||||
}
|
||||
|
||||
int EvaluateChunkLevelByProjectedArea::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
ChunkedLodGlobe const * globe = chunk.owner();
|
||||
const Ellipsoid& ellipsoid = globe->ellipsoid();
|
||||
Vec3 cameraPosition = data.camera.positionVec3();
|
||||
Vec3 globePosition = data.position.dvec3();
|
||||
Vec3 cameraToEllipseCenter = globePosition - cameraPosition;
|
||||
|
||||
Geodetic2 camPos = ellipsoid.cartesianToGeodetic2(cameraPosition);
|
||||
/*
|
||||
struct CornerDist {
|
||||
Geodetic2 corner;
|
||||
float dist;
|
||||
};
|
||||
|
||||
struct {
|
||||
bool operator()(const CornerDist& a, const CornerDist& b) {
|
||||
return a.dist < b.dist;
|
||||
}
|
||||
} byDist;
|
||||
|
||||
std::vector<CornerDist> cornerDists(4);
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
const Geodetic2& c = chunk.surfacePatch().getCorner((Quad)i);
|
||||
Geodetic2 diff = (camPos - c);
|
||||
float latDiff = fAngle::fromRadians(diff.lat).getNormalizedAround(fAngle::ZERO).asRadians();
|
||||
float lonDiff = fAngle::fromRadians(diff.lon).getNormalizedAround(fAngle::ZERO).asRadians();
|
||||
cornerDists[i].corner = c;
|
||||
cornerDists[i].dist = latDiff*latDiff + lonDiff*lonDiff;;
|
||||
}
|
||||
|
||||
std::sort(cornerDists.begin(), cornerDists.end(), byDist);
|
||||
|
||||
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
|
||||
|
||||
const Geodetic3 c0 = { cornerDists[0].corner, heights.min };
|
||||
const Geodetic3 c1 = { cornerDists[1].corner, heights.min };
|
||||
const Geodetic3 c2 = { cornerDists[2].corner, heights.max };
|
||||
const Geodetic3 c3 = { cornerDists[3].corner, heights.max };
|
||||
*/
|
||||
|
||||
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
|
||||
|
||||
const Geodetic3 c0 = { chunk.surfacePatch().getCorner((Quad)0), heights.min };
|
||||
const Geodetic3 c1 = { chunk.surfacePatch().getCorner((Quad)1), heights.min };
|
||||
const Geodetic3 c2 = { chunk.surfacePatch().getCorner((Quad)2), heights.min };
|
||||
const Geodetic3 c3 = { chunk.surfacePatch().getCorner((Quad)3), heights.min };
|
||||
|
||||
Vec3 A = cameraToEllipseCenter + ellipsoid.cartesianPosition(c0);
|
||||
Vec3 B = cameraToEllipseCenter + ellipsoid.cartesianPosition(c1);
|
||||
Vec3 C = cameraToEllipseCenter + ellipsoid.cartesianPosition(c2);
|
||||
Vec3 D = cameraToEllipseCenter + ellipsoid.cartesianPosition(c3);
|
||||
|
||||
// Project points onto unit sphere
|
||||
A = glm::normalize(A);
|
||||
B = glm::normalize(B);
|
||||
C = glm::normalize(C);
|
||||
D = glm::normalize(D);
|
||||
|
||||
|
||||
/*
|
||||
A-----____
|
||||
| '''-----B
|
||||
| __--' |
|
||||
| __--'' |
|
||||
C-----------------D
|
||||
*/
|
||||
|
||||
const Vec3 AB = B - A;
|
||||
const Vec3 AC = C - A;
|
||||
const Vec3 DC = C - D;
|
||||
const Vec3 DB = B - D;
|
||||
|
||||
double areaTriangle1 = 0.5 * glm::length(glm::cross(AC, AB));
|
||||
double areaTriangle2 = 0.5 * glm::length(glm::cross(DC, DB));
|
||||
double projectedChunkAreaApprox = areaTriangle1 + areaTriangle2;
|
||||
|
||||
double scaledArea = globe->lodScaleFactor * projectedChunkAreaApprox;
|
||||
return chunk.index().level + round(scaledArea - 1);
|
||||
}
|
||||
|
||||
int EvaluateChunkLevelByAvailableTileData::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
auto tileProvidermanager = chunk.owner()->getTileProviderManager();
|
||||
auto heightMapProviders = tileProvidermanager->getActivatedLayerCategory(LayeredTextures::HeightMaps);
|
||||
int currLevel = chunk.index().level;
|
||||
|
||||
// simply check the first heigtmap
|
||||
if (heightMapProviders.size() > 0) {
|
||||
Tile::Status heightTileStatus = heightMapProviders[0]->getTileStatus(chunk.index());
|
||||
if (heightTileStatus == Tile::Status::IOError || heightTileStatus == Tile::Status::OutOfRange) {
|
||||
return currLevel-1;
|
||||
}
|
||||
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
}
|
||||
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <modules/globebrowsing/chunk/culling.h>
|
||||
#include <modules/globebrowsing/chunk/chunkindex.h>
|
||||
#include <modules/globebrowsing/chunk/chunklevelevaluator.h>
|
||||
|
||||
|
||||
#include <modules/globebrowsing/geometry/geodetic2.h>
|
||||
#include <modules/globebrowsing/geometry/angle.h>
|
||||
@@ -80,30 +82,6 @@ namespace openspace {
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DesiredChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const = 0;
|
||||
static const int UNKNOWN_DESIRED_LEVEL = -1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class EvaluateChunkLevelByDistance : public DesiredChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const;
|
||||
};
|
||||
|
||||
class EvaluateChunkLevelByProjectedArea : public DesiredChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const;
|
||||
};
|
||||
|
||||
class EvaluateChunkLevelByAvailableTileData : public DesiredChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include <modules/globebrowsing/meshes/skirtedgrid.h>
|
||||
#include <modules/globebrowsing/chunk/culling.h>
|
||||
#include <modules/globebrowsing/chunk/chunklevelevaluator.h>
|
||||
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
@@ -131,7 +133,7 @@ namespace openspace {
|
||||
|
||||
if (limitLevelByAvailableHeightData) {
|
||||
int desiredLevelByAvailableData = _chunkEvaluatorByAvailableTiles->getDesiredLevel(chunk, renderData);
|
||||
if (desiredLevelByAvailableData != DesiredChunkLevelEvaluator::UNKNOWN_DESIRED_LEVEL) {
|
||||
if (desiredLevelByAvailableData != ChunkLevelEvaluator::UNKNOWN_DESIRED_LEVEL) {
|
||||
desiredLevel = min(desiredLevel, desiredLevelByAvailableData);
|
||||
}
|
||||
}
|
||||
@@ -140,11 +142,16 @@ namespace openspace {
|
||||
return desiredLevel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChunkedLodGlobe::render(const RenderData& data){
|
||||
|
||||
|
||||
minDistToCamera = INFINITY;
|
||||
ChunkNode::renderedChunks = 0;
|
||||
|
||||
_leftRoot->updateChunkTree(data);
|
||||
_rightRoot->updateChunkTree(data);
|
||||
|
||||
renderChunkTree(_leftRoot.get(), data);
|
||||
renderChunkTree(_rightRoot.get(), data);
|
||||
|
||||
@@ -159,7 +166,6 @@ namespace openspace {
|
||||
}
|
||||
|
||||
void ChunkedLodGlobe::renderChunkTree(ChunkNode* node, const RenderData& data) const {
|
||||
node->updateChunkTree(data);
|
||||
if (renderSmallChunksFirst) {
|
||||
node->renderReversedBreadthFirst(data);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace ghoul {
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
class ChunkLevelEvaluator;
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ChunkedLodGlobe : public Renderable {
|
||||
@@ -132,9 +136,9 @@ namespace openspace {
|
||||
|
||||
std::vector<ChunkCuller*> _chunkCullers;
|
||||
|
||||
std::unique_ptr<DesiredChunkLevelEvaluator> _chunkEvaluatorByAvailableTiles;
|
||||
std::unique_ptr<DesiredChunkLevelEvaluator> _chunkEvaluatorByProjectedArea;
|
||||
std::unique_ptr<DesiredChunkLevelEvaluator> _chunkEvaluatorByDistance;
|
||||
std::unique_ptr<ChunkLevelEvaluator> _chunkEvaluatorByAvailableTiles;
|
||||
std::unique_ptr<ChunkLevelEvaluator> _chunkEvaluatorByProjectedArea;
|
||||
std::unique_ptr<ChunkLevelEvaluator> _chunkEvaluatorByDistance;
|
||||
|
||||
const Ellipsoid& _ellipsoid;
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <modules/globebrowsing/chunk/chunkindex.h>
|
||||
#include <modules/globebrowsing/geometry/geodetic2.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ChunkIndex";
|
||||
@@ -78,6 +79,23 @@ namespace openspace {
|
||||
return x ^ (y << 16) ^ (level << 24);
|
||||
}
|
||||
|
||||
std::string ChunkIndex::toString() const {
|
||||
std::stringstream ss;
|
||||
for (int i = level; i > 0; i--){
|
||||
char digit = '0';
|
||||
int mask = 1 << (i - 1);
|
||||
if ((x & mask) != 0) {
|
||||
digit++;
|
||||
}
|
||||
if ((y & mask) != 0) {
|
||||
digit++;
|
||||
digit++;
|
||||
}
|
||||
ss << digit;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool ChunkIndex::operator==(const ChunkIndex& other) const {
|
||||
return x == other.x && y == other.y && level == other.level;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ struct ChunkIndex {
|
||||
|
||||
ChunkIndex child(Quad q) const;
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
/**
|
||||
Gets the tile at a specified offset from this tile.
|
||||
Accepts delta indices ranging from [-2^level, Infinity[
|
||||
|
||||
168
modules/globebrowsing/chunk/chunklevelevaluator.cpp
Normal file
168
modules/globebrowsing/chunk/chunklevelevaluator.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 <ghoul/misc/assert.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <modules/globebrowsing/chunk/chunklevelevaluator.h>
|
||||
#include <modules/globebrowsing/chunk/chunk.h>
|
||||
#include <modules/globebrowsing/chunk/chunkedlodglobe.h>
|
||||
#include <modules/globebrowsing/tile/layeredtextures.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ChunkLevelEvaluator";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
int EvaluateChunkLevelByDistance::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
ChunkedLodGlobe const * globe = chunk.owner();
|
||||
const Ellipsoid& ellipsoid = globe->ellipsoid();
|
||||
|
||||
Vec3 cameraPosition = data.camera.positionVec3();
|
||||
Geodetic2 pointOnPatch = chunk.surfacePatch().closestPoint(
|
||||
ellipsoid.cartesianToGeodetic2(cameraPosition));
|
||||
|
||||
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
|
||||
|
||||
Vec3 globePosition = data.position.dvec3();
|
||||
Vec3 patchPosition = globePosition + ellipsoid.cartesianSurfacePosition(pointOnPatch);
|
||||
Vec3 cameraToChunk = patchPosition - cameraPosition;
|
||||
|
||||
|
||||
// Calculate desired level based on distance
|
||||
Scalar distanceToPatch = glm::length(cameraToChunk);
|
||||
Scalar distance = distanceToPatch - heights.min; // distance to actual minimum heights
|
||||
|
||||
Scalar scaleFactor = globe->lodScaleFactor * ellipsoid.minimumRadius();
|
||||
Scalar projectedScaleFactor = scaleFactor / distance;
|
||||
int desiredLevel = ceil(log2(projectedScaleFactor));
|
||||
return desiredLevel;
|
||||
}
|
||||
|
||||
int EvaluateChunkLevelByProjectedArea::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
ChunkedLodGlobe const * globe = chunk.owner();
|
||||
const Ellipsoid& ellipsoid = globe->ellipsoid();
|
||||
Vec3 cameraPosition = data.camera.positionVec3();
|
||||
Vec3 globePosition = data.position.dvec3();
|
||||
Vec3 cameraToEllipseCenter = globePosition - cameraPosition;
|
||||
|
||||
Geodetic2 camPos = ellipsoid.cartesianToGeodetic2(cameraPosition);
|
||||
/*
|
||||
struct CornerDist {
|
||||
Geodetic2 corner;
|
||||
float dist;
|
||||
};
|
||||
|
||||
struct {
|
||||
bool operator()(const CornerDist& a, const CornerDist& b) {
|
||||
return a.dist < b.dist;
|
||||
}
|
||||
} byDist;
|
||||
|
||||
std::vector<CornerDist> cornerDists(4);
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
const Geodetic2& c = chunk.surfacePatch().getCorner((Quad)i);
|
||||
Geodetic2 diff = (camPos - c);
|
||||
float latDiff = fAngle::fromRadians(diff.lat).getNormalizedAround(fAngle::ZERO).asRadians();
|
||||
float lonDiff = fAngle::fromRadians(diff.lon).getNormalizedAround(fAngle::ZERO).asRadians();
|
||||
cornerDists[i].corner = c;
|
||||
cornerDists[i].dist = latDiff*latDiff + lonDiff*lonDiff;;
|
||||
}
|
||||
|
||||
std::sort(cornerDists.begin(), cornerDists.end(), byDist);
|
||||
|
||||
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
|
||||
|
||||
const Geodetic3 c0 = { cornerDists[0].corner, heights.min };
|
||||
const Geodetic3 c1 = { cornerDists[1].corner, heights.min };
|
||||
const Geodetic3 c2 = { cornerDists[2].corner, heights.max };
|
||||
const Geodetic3 c3 = { cornerDists[3].corner, heights.max };
|
||||
*/
|
||||
|
||||
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
|
||||
|
||||
const Geodetic3 c0 = { chunk.surfacePatch().getCorner((Quad)0), heights.min };
|
||||
const Geodetic3 c1 = { chunk.surfacePatch().getCorner((Quad)1), heights.min };
|
||||
const Geodetic3 c2 = { chunk.surfacePatch().getCorner((Quad)2), heights.min };
|
||||
const Geodetic3 c3 = { chunk.surfacePatch().getCorner((Quad)3), heights.min };
|
||||
|
||||
Vec3 A = cameraToEllipseCenter + ellipsoid.cartesianPosition(c0);
|
||||
Vec3 B = cameraToEllipseCenter + ellipsoid.cartesianPosition(c1);
|
||||
Vec3 C = cameraToEllipseCenter + ellipsoid.cartesianPosition(c2);
|
||||
Vec3 D = cameraToEllipseCenter + ellipsoid.cartesianPosition(c3);
|
||||
|
||||
// Project points onto unit sphere
|
||||
A = glm::normalize(A);
|
||||
B = glm::normalize(B);
|
||||
C = glm::normalize(C);
|
||||
D = glm::normalize(D);
|
||||
|
||||
|
||||
/*
|
||||
A-----____
|
||||
| '''-----B
|
||||
| __--' |
|
||||
| __--'' |
|
||||
C-----------------D
|
||||
*/
|
||||
|
||||
const Vec3 AB = B - A;
|
||||
const Vec3 AC = C - A;
|
||||
const Vec3 DC = C - D;
|
||||
const Vec3 DB = B - D;
|
||||
|
||||
double areaTriangle1 = 0.5 * glm::length(glm::cross(AC, AB));
|
||||
double areaTriangle2 = 0.5 * glm::length(glm::cross(DC, DB));
|
||||
double projectedChunkAreaApprox = areaTriangle1 + areaTriangle2;
|
||||
|
||||
double scaledArea = globe->lodScaleFactor * projectedChunkAreaApprox;
|
||||
return chunk.index().level + round(scaledArea - 1);
|
||||
}
|
||||
|
||||
int EvaluateChunkLevelByAvailableTileData::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
auto tileProvidermanager = chunk.owner()->getTileProviderManager();
|
||||
auto heightMapProviders = tileProvidermanager->getActivatedLayerCategory(LayeredTextures::HeightMaps);
|
||||
int currLevel = chunk.index().level;
|
||||
|
||||
// simply check the first heigtmap
|
||||
if (heightMapProviders.size() > 0) {
|
||||
Tile::Status heightTileStatus = heightMapProviders[0]->getTileStatus(chunk.index());
|
||||
if (heightTileStatus == Tile::Status::IOError || heightTileStatus == Tile::Status::OutOfRange) {
|
||||
return currLevel-1;
|
||||
}
|
||||
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
}
|
||||
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
65
modules/globebrowsing/chunk/chunklevelevaluator.h
Normal file
65
modules/globebrowsing/chunk/chunklevelevaluator.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __CHUNK_LEVEL_EVALUATOR_H__
|
||||
#define __CHUNK_LEVEL_EVALUATOR_H__
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
|
||||
#include <modules/globebrowsing/chunk/chunk.h>
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const = 0;
|
||||
static const int UNKNOWN_DESIRED_LEVEL = -1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class EvaluateChunkLevelByDistance : public ChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const;
|
||||
};
|
||||
|
||||
class EvaluateChunkLevelByProjectedArea : public ChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const;
|
||||
};
|
||||
|
||||
class EvaluateChunkLevelByAvailableTileData : public ChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // __CHUNK_LEVEL_EVALUATOR_H__
|
||||
@@ -98,6 +98,16 @@ bool ChunkNode::updateChunkTree(const RenderData& data) {
|
||||
}
|
||||
}
|
||||
|
||||
void ChunkNode::depthFirst(const std::function<void(const Chunk&)>& f) const {
|
||||
f(_chunk);
|
||||
if (!isLeaf()) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
_children[i]->depthFirst(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChunkNode::renderReversedBreadthFirst(const RenderData& data) {
|
||||
std::stack<ChunkNode*> S;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <modules/globebrowsing/geometry/geodetic2.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +61,8 @@ public:
|
||||
|
||||
bool isRoot() const;
|
||||
bool isLeaf() const;
|
||||
|
||||
void depthFirst(const std::function<void(const Chunk&)>& f) const;
|
||||
|
||||
|
||||
const ChunkNode& getChild(Quad quad) const;
|
||||
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
properties::BoolProperty levelByProjArea;
|
||||
properties::BoolProperty limitLevelByAvailableHeightData;
|
||||
|
||||
|
||||
private:
|
||||
std::string _frame;
|
||||
|
||||
|
||||
44
modules/globebrowsing/other/debugrenderer.cpp
Normal file
44
modules/globebrowsing/other/debugrenderer.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 <glm/glm.hpp>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <thread>
|
||||
#include <queue>
|
||||
|
||||
#include <modules/globebrowsing/other/concurrentqueue.h>
|
||||
#include <modules/globebrowsing/other/threadpool.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
48
modules/globebrowsing/other/debugrenderer.h
Normal file
48
modules/globebrowsing/other/debugrenderer.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __DEBUG_RENDERER_H__
|
||||
#define __DEBUG_RENDERER_H__
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <thread>
|
||||
#include <queue>
|
||||
|
||||
#include <modules/globebrowsing/other/concurrentqueue.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class DebugRenderer {
|
||||
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
|
||||
#endif // __DEBUG_RENDERER_H__
|
||||
Reference in New Issue
Block a user