mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-11 07:48:37 -05:00
Solve merge conflict.
This commit is contained in:
@@ -42,9 +42,10 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/geodetics/angle.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/geodetics/ellipsoid.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/frustumculler.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/patchrenderer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/frustrumculler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/texturetileset.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/twmstileprovider.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/gdaldataconverter.h
|
||||
@@ -69,9 +70,10 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/geodetics/angle.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/geodetics/ellipsoid.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/patchrenderer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/frustumculler.cpp
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/patchrenderer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/frustrumculler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/texturetileset.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/twmstileprovider.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/other/gdaldataconverter.cpp
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace openspace {
|
||||
|
||||
_patchRenderer.reset(new LatLonPatchRenderer(geometry));
|
||||
|
||||
_frustrumCuller = std::shared_ptr<FrustrumCuller>(new FrustrumCuller());
|
||||
_frustumCuller = std::shared_ptr<FrustumCuller>(new FrustumCuller());
|
||||
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ namespace openspace {
|
||||
return *_patchRenderer;
|
||||
}
|
||||
|
||||
FrustrumCuller& ChunkLodGlobe::getFrustrumCuller() {
|
||||
return *_frustrumCuller;
|
||||
FrustumCuller& ChunkLodGlobe::getFrustumCuller() {
|
||||
return *_frustumCuller;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include <modules/globebrowsing/geodetics/ellipsoid.h>
|
||||
#include <modules/globebrowsing/globes/chunknode.h>
|
||||
#include <modules/globebrowsing/other/patchrenderer.h>
|
||||
#include <modules/globebrowsing/rendering/patchrenderer.h>
|
||||
#include <modules/globebrowsing/other/twmstileprovider.h>
|
||||
|
||||
namespace ghoul {
|
||||
@@ -58,7 +58,7 @@ namespace openspace {
|
||||
~ChunkLodGlobe();
|
||||
|
||||
LatLonPatchRenderer& getPatchRenderer();
|
||||
FrustrumCuller& getFrustrumCuller();
|
||||
FrustumCuller& getFrustumCuller();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
@@ -85,7 +85,7 @@ namespace openspace {
|
||||
std::unique_ptr<ChunkNode> _rightRoot;
|
||||
|
||||
// Frustrum culler
|
||||
std::shared_ptr<FrustrumCuller> _frustrumCuller;
|
||||
std::shared_ptr<FrustumCuller> _frustumCuller;
|
||||
|
||||
// the patch used for actual rendering
|
||||
std::unique_ptr<LatLonPatchRenderer> _patchRenderer;
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <modules/globebrowsing/globes/chunklodglobe.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/frustumculler.h>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ChunkNode";
|
||||
const std::string _loggerCat = "ChunkNode";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -46,148 +46,150 @@ ChunkNode::ChunkNode(ChunkLodGlobe& owner, const GeodeticPatch& patch, ChunkNode
|
||||
: _owner(owner)
|
||||
, _patch(patch)
|
||||
, _parent(parent)
|
||||
, _isVisible(true)
|
||||
{
|
||||
_children[0] = nullptr;
|
||||
_children[1] = nullptr;
|
||||
_children[2] = nullptr;
|
||||
_children[3] = nullptr;
|
||||
instanceCount++;
|
||||
_children[0] = nullptr;
|
||||
_children[1] = nullptr;
|
||||
_children[2] = nullptr;
|
||||
_children[3] = nullptr;
|
||||
instanceCount++;
|
||||
}
|
||||
|
||||
ChunkNode::~ChunkNode() {
|
||||
instanceCount--;
|
||||
instanceCount--;
|
||||
}
|
||||
|
||||
bool ChunkNode::isRoot() const {
|
||||
return _parent == nullptr;
|
||||
return _parent == nullptr;
|
||||
}
|
||||
|
||||
bool ChunkNode::isLeaf() const {
|
||||
return _children[0] == nullptr;
|
||||
return _children[0] == nullptr;
|
||||
}
|
||||
|
||||
|
||||
void ChunkNode::render(const RenderData& data, ChunkIndex traverseData) {
|
||||
ghoul_assert(isRoot(), "this method should only be invoked on root");
|
||||
//LDEBUG("-------------");
|
||||
internalUpdateChunkTree(data, traverseData);
|
||||
internalRender(data, traverseData);
|
||||
ghoul_assert(isRoot(), "this method should only be invoked on root");
|
||||
//LDEBUG("-------------");
|
||||
internalUpdateChunkTree(data, traverseData);
|
||||
internalRender(data, traverseData);
|
||||
}
|
||||
|
||||
|
||||
// Returns true or false wether this node can be merge or not
|
||||
bool ChunkNode::internalUpdateChunkTree(const RenderData& data, ChunkIndex& traverseData) {
|
||||
using namespace glm;
|
||||
Geodetic2 center = _patch.center();
|
||||
using namespace glm;
|
||||
Geodetic2 center = _patch.center();
|
||||
|
||||
//LDEBUG("x: " << patch.x << " y: " << patch.y << " level: " << patch.level << " lat: " << center.lat << " lon: " << center.lon);
|
||||
|
||||
//LDEBUG("x: " << patch.x << " y: " << patch.y << " level: " << patch.level << " lat: " << center.lat << " lon: " << center.lon);
|
||||
if (isLeaf()) {
|
||||
|
||||
if (isLeaf()) {
|
||||
int desiredLevel = calculateDesiredLevel(data, traverseData);
|
||||
desiredLevel = glm::clamp(desiredLevel, _owner.minSplitDepth, _owner.maxSplitDepth);
|
||||
if (desiredLevel > traverseData.level) {
|
||||
split();
|
||||
}
|
||||
else if(desiredLevel < traverseData.level){
|
||||
return true; // request a merge from parent
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
int requestedMergeMask = 0;
|
||||
std::vector<ChunkIndex> childIndices = traverseData.childIndices();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (_children[i]->internalUpdateChunkTree(data, childIndices[i])) {
|
||||
requestedMergeMask |= (1 << i);
|
||||
}
|
||||
}
|
||||
int desiredLevel = calculateDesiredLevelAndUpdateIsVisible(data, traverseData);
|
||||
desiredLevel = glm::clamp(desiredLevel, _owner.minSplitDepth, _owner.maxSplitDepth);
|
||||
if (desiredLevel > traverseData.level) {
|
||||
split();
|
||||
}
|
||||
else if(desiredLevel < traverseData.level){
|
||||
return true; // request a merge from parent
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
int requestedMergeMask = 0;
|
||||
std::vector<ChunkIndex> childIndices = traverseData.childIndices();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (_children[i]->internalUpdateChunkTree(data, childIndices[i])) {
|
||||
requestedMergeMask |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
// check if all children requested merge
|
||||
if (requestedMergeMask == 0xf) {
|
||||
merge();
|
||||
// check if all children requested merge
|
||||
if (requestedMergeMask == 0xf) {
|
||||
merge();
|
||||
|
||||
// re-run this method on this, now that this is a leaf node
|
||||
return internalUpdateChunkTree(data, traverseData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// re-run this method on this, now that this is a leaf node
|
||||
return internalUpdateChunkTree(data, traverseData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ChunkNode::internalRender(const RenderData& data, ChunkIndex& traverseData) {
|
||||
if (isLeaf()) {
|
||||
if (isLeaf()) {
|
||||
if (_isVisible) {
|
||||
TileIndex ti = { traverseData.x, traverseData.y, traverseData.level };
|
||||
|
||||
TileIndex ti = { traverseData.x, traverseData.y, traverseData.level };
|
||||
LatLonPatchRenderer& patchRenderer = _owner.getPatchRenderer();
|
||||
|
||||
LatLonPatchRenderer& patchRenderer = _owner.getPatchRenderer();
|
||||
|
||||
patchRenderer.renderPatch(_patch, data, _owner.ellipsoid(), ti);
|
||||
ChunkNode::renderedPatches++;
|
||||
|
||||
}
|
||||
else {
|
||||
std::vector<ChunkIndex> childIndices = traverseData.childIndices();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
_children[i]->internalRender(data, childIndices[i]);
|
||||
}
|
||||
}
|
||||
patchRenderer.renderPatch(_patch, data, _owner.ellipsoid(), ti);
|
||||
ChunkNode::renderedPatches++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::vector<ChunkIndex> childIndices = traverseData.childIndices();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
_children[i]->internalRender(data, childIndices[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ChunkNode::calculateDesiredLevel(
|
||||
int ChunkNode::calculateDesiredLevelAndUpdateIsVisible(
|
||||
const RenderData& data,
|
||||
const ChunkIndex& traverseData) {
|
||||
|
||||
|
||||
Vec3 globePosition = data.position.dvec3();
|
||||
//Vec3 patchNormal = _patch.center().asUnitCartesian();
|
||||
_isVisible = true;
|
||||
Vec3 globePosition = data.position.dvec3();
|
||||
Vec3 patchPosition =
|
||||
globePosition +
|
||||
_owner.ellipsoid().geodetic2ToCartesian(_patch.center());
|
||||
|
||||
Vec3 cameraPosition = data.camera.position().dvec3();
|
||||
Vec3 cameraDirection = Vec3(data.camera.viewDirection());
|
||||
Vec3 cameraToChunk = patchPosition - cameraPosition;
|
||||
Vec3 cameraPosition = data.camera.position().dvec3();
|
||||
Vec3 cameraDirection = Vec3(data.camera.viewDirection());
|
||||
Vec3 cameraToChunk = patchPosition - cameraPosition;
|
||||
|
||||
|
||||
// if camera points at same direction as latlon patch normal,
|
||||
// we see the back side and dont have to split it
|
||||
//Scalar cosNormalCameraDirection = glm::dot(patchNormal, cameraDirection);
|
||||
// if camera points at same direction as latlon patch normal,
|
||||
// we see the back side and dont have to split it
|
||||
//Scalar cosNormalCameraDirection = glm::dot(patchNormal, cameraDirection);
|
||||
|
||||
Vec3 globeToCamera = cameraPosition - globePosition;
|
||||
Vec3 globeToCamera = cameraPosition - globePosition;
|
||||
|
||||
Geodetic2 cameraPositionOnGlobe = _owner.ellipsoid().cartesianToGeodetic2(globeToCamera);
|
||||
Geodetic2 cameraPositionOnGlobe =
|
||||
_owner.ellipsoid().cartesianToGeodetic2(globeToCamera);
|
||||
Geodetic2 closestPatchPoint = _patch.closestPoint(cameraPositionOnGlobe);
|
||||
|
||||
Vec3 normalOfClosestPatchPoint = _owner.ellipsoid().geodeticSurfaceNormal(closestPatchPoint);
|
||||
Scalar cosPatchNormalNormalizedGlobeToCamera = glm::dot(normalOfClosestPatchPoint, glm::normalize(globeToCamera));
|
||||
Vec3 normalOfClosestPatchPoint =
|
||||
_owner.ellipsoid().geodeticSurfaceNormal(closestPatchPoint);
|
||||
Scalar cosPatchNormalNormalizedGlobeToCamera =
|
||||
glm::dot(normalOfClosestPatchPoint, glm::normalize(globeToCamera));
|
||||
|
||||
//LDEBUG(cosPatchNormalCameraDirection);
|
||||
//LDEBUG(cosPatchNormalCameraDirection);
|
||||
|
||||
// Get the minimum radius from the ellipsoid. The closer the ellipsoid is to a
|
||||
// sphere, the better this will make the splitting. Using the minimum radius to
|
||||
// be safe. This means that if the ellipsoid has high difference between radii,
|
||||
// splitting might accur even though it is not needed.
|
||||
Scalar minimumGlobeRadius = _owner.ellipsoid().minimumRadius();
|
||||
|
||||
double cosAngleToHorizon = minimumGlobeRadius / glm::length(globeToCamera);
|
||||
if (cosPatchNormalNormalizedGlobeToCamera < cosAngleToHorizon) {
|
||||
_isVisible = false;
|
||||
return traverseData.level - 1;
|
||||
}
|
||||
|
||||
if (cosPatchNormalNormalizedGlobeToCamera < cosAngleToHorizon) {
|
||||
return traverseData.level - 1;
|
||||
}
|
||||
|
||||
|
||||
// Do frustrum culling
|
||||
FrustrumCuller& culler = _owner.getFrustrumCuller();
|
||||
// Do frustrum culling
|
||||
FrustumCuller& culler = _owner.getFrustumCuller();
|
||||
|
||||
if (!culler.isVisible(data, _patch, _owner.ellipsoid())) {
|
||||
_isVisible = false;
|
||||
return traverseData.level - 1;
|
||||
}
|
||||
|
||||
// Calculate desired level based on distance
|
||||
Scalar distance = glm::length(cameraToChunk);
|
||||
_owner.minDistToCamera = fmin(_owner.minDistToCamera, distance);
|
||||
|
||||
// Calculate desired level based on distance
|
||||
Scalar distance = glm::length(cameraToChunk);
|
||||
_owner.minDistToCamera = fmin(_owner.minDistToCamera, distance);
|
||||
|
||||
Scalar scaleFactor = 100 * minimumGlobeRadius;
|
||||
Scalar projectedScaleFactor = scaleFactor / distance;
|
||||
@@ -198,44 +200,44 @@ int ChunkNode::calculateDesiredLevel(
|
||||
|
||||
|
||||
void ChunkNode::split(int depth) {
|
||||
if (depth > 0 && isLeaf()) {
|
||||
if (depth > 0 && isLeaf()) {
|
||||
|
||||
// Defining short handles for center, halfSize and quarterSize
|
||||
const Geodetic2& c = _patch.center();
|
||||
const Geodetic2& hs = _patch.halfSize();
|
||||
Geodetic2 qs = Geodetic2(0.5 * hs.lat, 0.5 * hs.lon);
|
||||
// Defining short handles for center, halfSize and quarterSize
|
||||
const Geodetic2& c = _patch.center();
|
||||
const Geodetic2& hs = _patch.halfSize();
|
||||
Geodetic2 qs = Geodetic2(0.5 * hs.lat, 0.5 * hs.lon);
|
||||
|
||||
// Subdivide bounds
|
||||
GeodeticPatch nwBounds = GeodeticPatch(Geodetic2(c.lat + qs.lat, c.lon - qs.lon), qs);
|
||||
GeodeticPatch neBounds = GeodeticPatch(Geodetic2(c.lat - qs.lat, c.lon - qs.lon), qs);
|
||||
GeodeticPatch swBounds = GeodeticPatch(Geodetic2(c.lat + qs.lat, c.lon + qs.lon), qs);
|
||||
GeodeticPatch seBounds = GeodeticPatch(Geodetic2(c.lat - qs.lat, c.lon + qs.lon), qs);
|
||||
// Subdivide bounds
|
||||
GeodeticPatch nwBounds = GeodeticPatch(Geodetic2(c.lat + qs.lat, c.lon - qs.lon), qs);
|
||||
GeodeticPatch neBounds = GeodeticPatch(Geodetic2(c.lat - qs.lat, c.lon - qs.lon), qs);
|
||||
GeodeticPatch swBounds = GeodeticPatch(Geodetic2(c.lat + qs.lat, c.lon + qs.lon), qs);
|
||||
GeodeticPatch seBounds = GeodeticPatch(Geodetic2(c.lat - qs.lat, c.lon + qs.lon), qs);
|
||||
|
||||
// Create new chunk nodes
|
||||
_children[Quad::NORTH_WEST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, nwBounds, this));
|
||||
_children[Quad::NORTH_EAST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, neBounds, this));
|
||||
_children[Quad::SOUTH_WEST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, swBounds, this));
|
||||
_children[Quad::SOUTH_EAST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, seBounds, this));
|
||||
}
|
||||
// Create new chunk nodes
|
||||
_children[Quad::NORTH_WEST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, nwBounds, this));
|
||||
_children[Quad::NORTH_EAST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, neBounds, this));
|
||||
_children[Quad::SOUTH_WEST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, swBounds, this));
|
||||
_children[Quad::SOUTH_EAST] = std::unique_ptr<ChunkNode>(new ChunkNode(_owner, seBounds, this));
|
||||
}
|
||||
|
||||
if (depth - 1 > 0) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
_children[i]->split(depth - 1);
|
||||
}
|
||||
}
|
||||
if (depth - 1 > 0) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
_children[i]->split(depth - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChunkNode::merge() {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (_children[i] != nullptr) {
|
||||
_children[i]->merge();
|
||||
}
|
||||
_children[i] = nullptr;
|
||||
}
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (_children[i] != nullptr) {
|
||||
_children[i]->merge();
|
||||
}
|
||||
_children[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const ChunkNode& ChunkNode::getChild(Quad quad) const {
|
||||
return *_children[quad];
|
||||
return *_children[quad];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,66 +31,66 @@
|
||||
#include <ostream>
|
||||
|
||||
#include <modules/globebrowsing/geodetics/geodetic2.h>
|
||||
#include <modules/globebrowsing/other/patchrenderer.h>
|
||||
#include <modules/globebrowsing/rendering/patchrenderer.h>
|
||||
|
||||
|
||||
|
||||
// forward declaration
|
||||
namespace openspace {
|
||||
class ChunkLodGlobe;
|
||||
class ChunkLodGlobe;
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
enum Quad {
|
||||
NORTH_WEST,
|
||||
NORTH_EAST,
|
||||
SOUTH_WEST,
|
||||
SOUTH_EAST
|
||||
NORTH_WEST,
|
||||
NORTH_EAST,
|
||||
SOUTH_WEST,
|
||||
SOUTH_EAST
|
||||
};
|
||||
|
||||
|
||||
struct ChunkIndex {
|
||||
int x, y, level;
|
||||
|
||||
std::vector<ChunkIndex> childIndices() const {
|
||||
return {
|
||||
{ 2 * x + 0, 2 * y + 0, level + 1 },
|
||||
{ 2 * x + 1, 2 * y + 0, level + 1 },
|
||||
{ 2 * x + 0, 2 * y + 1, level + 1 },
|
||||
{ 2 * x + 1, 2 * y + 1, level + 1 },
|
||||
};
|
||||
}
|
||||
int x, y, level;
|
||||
|
||||
std::vector<ChunkIndex> childIndices() const {
|
||||
return {
|
||||
{ 2 * x + 0, 2 * y + 0, level + 1 },
|
||||
{ 2 * x + 1, 2 * y + 0, level + 1 },
|
||||
{ 2 * x + 0, 2 * y + 1, level + 1 },
|
||||
{ 2 * x + 1, 2 * y + 1, level + 1 },
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ChunkNode {
|
||||
public:
|
||||
ChunkNode(ChunkLodGlobe&, const GeodeticPatch&, ChunkNode* parent = nullptr);
|
||||
~ChunkNode();
|
||||
ChunkNode(ChunkLodGlobe&, const GeodeticPatch&, ChunkNode* parent = nullptr);
|
||||
~ChunkNode();
|
||||
|
||||
|
||||
void split(int depth = 1);
|
||||
void merge();
|
||||
void split(int depth = 1);
|
||||
void merge();
|
||||
|
||||
bool isRoot() const;
|
||||
bool isLeaf() const;
|
||||
|
||||
const ChunkNode& getChild(Quad quad) const;
|
||||
bool isRoot() const;
|
||||
bool isLeaf() const;
|
||||
|
||||
|
||||
const ChunkNode& getChild(Quad quad) const;
|
||||
|
||||
void render(const RenderData& data, ChunkIndex);
|
||||
void render(const RenderData& data, ChunkIndex);
|
||||
|
||||
static int instanceCount;
|
||||
static int renderedPatches;
|
||||
static int instanceCount;
|
||||
static int renderedPatches;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void internalRender(const RenderData& data, ChunkIndex&);
|
||||
bool internalUpdateChunkTree(const RenderData& data, ChunkIndex&);
|
||||
bool internalUpdateChunkTree(const RenderData& data, ChunkIndex& traverseData);
|
||||
|
||||
/**
|
||||
Uses horizon culling, frustum culling and distance to camera to determine a
|
||||
@@ -101,16 +101,16 @@ private:
|
||||
be safe. This means that if the ellipsoid has high difference between radii,
|
||||
splitting might accur even though it is not needed.
|
||||
*/
|
||||
int calculateDesiredLevel(const RenderData& data, const ChunkIndex& traverseData);
|
||||
int calculateDesiredLevelAndUpdateIsVisible(
|
||||
const RenderData& data,
|
||||
const ChunkIndex& traverseData);
|
||||
|
||||
|
||||
ChunkNode* _parent;
|
||||
std::unique_ptr<ChunkNode> _children[4];
|
||||
|
||||
ChunkLodGlobe& _owner;
|
||||
|
||||
GeodeticPatch _patch;
|
||||
|
||||
std::unique_ptr<ChunkNode> _children[4];
|
||||
ChunkLodGlobe& _owner;
|
||||
GeodeticPatch _patch;
|
||||
bool _isVisible;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <modules/globebrowsing/meshes/trianglesoup.h>
|
||||
#include <modules/globebrowsing/meshes/grid.h>
|
||||
#include <modules/globebrowsing/other/distanceswitch.h>
|
||||
#include <modules/globebrowsing/other/patchrenderer.h>
|
||||
#include <modules/globebrowsing/rendering/patchrenderer.h>
|
||||
#include <modules/globebrowsing/globes/clipmappyramid.h>
|
||||
|
||||
namespace ghoul {
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __LATLONPATCH_H__
|
||||
#define __LATLONPATCH_H__
|
||||
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <modules/globebrowsing/geodetics/geodetic2.h>
|
||||
#include <modules/globebrowsing/geodetics/ellipsoid.h>
|
||||
#include <modules/globebrowsing/meshes/grid.h>
|
||||
#include <modules/globebrowsing/meshes/clipmapgrid.h>
|
||||
#include <modules/globebrowsing/other/frustrumculler.h>
|
||||
#include <modules/globebrowsing/other/texturetileset.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class LonLatPatch;
|
||||
class TriangleSoup;
|
||||
|
||||
using std::shared_ptr;
|
||||
using std::unique_ptr;
|
||||
using ghoul::opengl::ProgramObject;
|
||||
|
||||
class PatchRenderer {
|
||||
public:
|
||||
|
||||
PatchRenderer();
|
||||
~PatchRenderer();
|
||||
|
||||
protected:
|
||||
|
||||
unique_ptr<ProgramObject> _programObject;
|
||||
TextureTileSet _tileSet;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// PATCH RENDERER SUBCLASSES //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class LatLonPatchRenderer : public PatchRenderer {
|
||||
public:
|
||||
LatLonPatchRenderer(shared_ptr<Grid> grid);
|
||||
|
||||
void renderPatch(
|
||||
const GeodeticPatch& patch,
|
||||
const RenderData& data,
|
||||
const Ellipsoid& ellipsoid);
|
||||
|
||||
void renderPatch(
|
||||
const GeodeticPatch& patch,
|
||||
const RenderData& data,
|
||||
const Ellipsoid& ellipsoid,
|
||||
const TileIndex& ti);
|
||||
private:
|
||||
shared_ptr<Grid> _grid;
|
||||
TwmsTileProvider tileProvider;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ClipMapPatchRenderer : public PatchRenderer {
|
||||
public:
|
||||
ClipMapPatchRenderer(shared_ptr<ClipMapGrid> grid);
|
||||
|
||||
void renderPatch(
|
||||
const Geodetic2& patchSize,
|
||||
const RenderData& data,
|
||||
const Ellipsoid& ellipsoid);
|
||||
private:
|
||||
shared_ptr<ClipMapGrid> _grid;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __LATLONPATCH_H__
|
||||
@@ -68,7 +68,7 @@ namespace openspace {
|
||||
std::string fileName = _fileFutureCache.get(hashkey)->filePath;
|
||||
std::string filePath = "tiles/" + fileName;
|
||||
std::shared_ptr<Texture> texture = loadAndInitTextureDisk(filePath);
|
||||
LDEBUG("Downloaded " << fileName);
|
||||
//LDEBUG("Downloaded " << fileName);
|
||||
_tileCache.put(hashkey, texture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
****************************************************************************************/
|
||||
|
||||
|
||||
#include <modules/globebrowsing/other/frustrumculler.h>
|
||||
#include <modules/globebrowsing/rendering/frustumculler.h>
|
||||
|
||||
#include <modules/globebrowsing/geodetics/ellipsoid.h>
|
||||
|
||||
@@ -36,17 +36,17 @@ namespace openspace {
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// PATCH RENDERER //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
FrustrumCuller::FrustrumCuller()
|
||||
FrustumCuller::FrustumCuller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FrustrumCuller::~FrustrumCuller() {
|
||||
FrustumCuller::~FrustumCuller() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool FrustrumCuller::isVisible(const RenderData& data, const vec3& point, const glm::vec2& marginScreenSpace) {
|
||||
bool FrustumCuller::isVisible(const RenderData& data, const vec3& point, const glm::vec2& marginScreenSpace) {
|
||||
|
||||
mat4 modelTransform = translate(mat4(1), data.position.vec3());
|
||||
mat4 viewTransform = data.camera.combinedViewMatrix();
|
||||
@@ -58,7 +58,7 @@ namespace openspace {
|
||||
}
|
||||
|
||||
|
||||
bool FrustrumCuller::isVisible(
|
||||
bool FrustumCuller::isVisible(
|
||||
const RenderData& data,
|
||||
const GeodeticPatch& patch,
|
||||
const Ellipsoid& ellipsoid) {
|
||||
@@ -90,7 +90,7 @@ namespace openspace {
|
||||
|
||||
|
||||
|
||||
bool FrustrumCuller::testPoint(const glm::vec2& pointScreenSpace,
|
||||
bool FrustumCuller::testPoint(const glm::vec2& pointScreenSpace,
|
||||
const glm::vec2& marginScreenSpace) const
|
||||
{
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace openspace {
|
||||
}
|
||||
|
||||
|
||||
glm::vec2 FrustrumCuller::transformToScreenSpace(const vec3& point,
|
||||
glm::vec2 FrustumCuller::transformToScreenSpace(const vec3& point,
|
||||
const mat4x4& modelViewProjection) const
|
||||
{
|
||||
vec4 pointProjectionSpace = modelViewProjection * vec4(point, 1.0f);
|
||||
@@ -42,11 +42,11 @@ namespace openspace {
|
||||
using namespace glm;
|
||||
|
||||
|
||||
class FrustrumCuller {
|
||||
class FrustumCuller {
|
||||
public:
|
||||
|
||||
FrustrumCuller();
|
||||
~FrustrumCuller();
|
||||
FrustumCuller();
|
||||
~FrustumCuller();
|
||||
|
||||
/**
|
||||
Returns true if the point is inside the view frustrum defined in RenderData.
|
||||
@@ -22,7 +22,7 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/other/patchrenderer.h>
|
||||
#include <modules/globebrowsing/rendering/patchrenderer.h>
|
||||
|
||||
#include <modules/globebrowsing/meshes/clipmapgrid.h>
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <modules/globebrowsing/datastructures/latlon.h>
|
||||
#include <modules/globebrowsing/rendering/grid.h>
|
||||
#include <modules/globebrowsing/rendering/clipmapgrid.h>
|
||||
#include <modules/globebrowsing/rendering/frustrumculler.h>
|
||||
#include <modules/globebrowsing/rendering/texturetileset.h>
|
||||
#include <modules/globebrowsing/geodetics/geodetic2.h>
|
||||
#include <modules/globebrowsing/geodetics/ellipsoid.h>
|
||||
#include <modules/globebrowsing/meshes/grid.h>
|
||||
#include <modules/globebrowsing/meshes/clipmapgrid.h>
|
||||
#include <modules/globebrowsing/rendering/frustumculler.h>
|
||||
#include <modules/globebrowsing/other/texturetileset.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
@@ -47,7 +48,7 @@ namespace opengl {
|
||||
namespace openspace {
|
||||
|
||||
class LonLatPatch;
|
||||
class Geometry;
|
||||
class TriangleSoup;
|
||||
|
||||
using std::shared_ptr;
|
||||
using std::unique_ptr;
|
||||
@@ -63,7 +64,6 @@ namespace openspace {
|
||||
|
||||
unique_ptr<ProgramObject> _programObject;
|
||||
TextureTileSet _tileSet;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -76,20 +76,18 @@ namespace openspace {
|
||||
LatLonPatchRenderer(shared_ptr<Grid> grid);
|
||||
|
||||
void renderPatch(
|
||||
const LatLonPatch& patch,
|
||||
const GeodeticPatch& patch,
|
||||
const RenderData& data,
|
||||
double radius);
|
||||
const Ellipsoid& ellipsoid);
|
||||
|
||||
void renderPatch(
|
||||
const LatLonPatch& patch,
|
||||
const GeodeticPatch& patch,
|
||||
const RenderData& data,
|
||||
double radius,
|
||||
const Ellipsoid& ellipsoid,
|
||||
const TileIndex& ti);
|
||||
|
||||
private:
|
||||
TwmsTileProvider tileProvider;
|
||||
shared_ptr<Grid> _grid;
|
||||
|
||||
TwmsTileProvider tileProvider;
|
||||
};
|
||||
|
||||
|
||||
@@ -99,12 +97,13 @@ namespace openspace {
|
||||
ClipMapPatchRenderer(shared_ptr<ClipMapGrid> grid);
|
||||
|
||||
void renderPatch(
|
||||
const LatLon& patchSize,
|
||||
const Geodetic2& patchSize,
|
||||
const RenderData& data,
|
||||
double radius);
|
||||
private:
|
||||
const Ellipsoid& ellipsoid);
|
||||
private:
|
||||
shared_ptr<ClipMapGrid> _grid;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __LATLONPATCH_H__
|
||||
@@ -145,7 +145,7 @@ std::shared_ptr<DownloadManager::FileFuture> DownloadManager::downloadFile(
|
||||
FILE* fp = fopen(file.path().c_str(), "wb"); // write binary
|
||||
ghoul_assert(fp != nullptr, "Could not open/create file:\n" << file.path().c_str() << " \nerrno: " << errno);
|
||||
|
||||
LDEBUG("Start downloading file: '" << url << "' into file '" << file.path() << "'");
|
||||
//LDEBUG("Start downloading file: '" << url << "' into file '" << file.path() << "'");
|
||||
|
||||
auto downloadFunction = [url, finishedCallback, progressCallback, future, fp]() {
|
||||
CURL* curl = curl_easy_init();
|
||||
|
||||
@@ -36,15 +36,13 @@
|
||||
//#include <test_chunknode.inl>
|
||||
//#include <test_lrucache.inl>
|
||||
//#include <test_twmstileprovider.inl>
|
||||
#include <test_ellipsoid.inl>
|
||||
|
||||
|
||||
//#include <test_luaconversions.inl>
|
||||
//#include <test_powerscalecoordinates.inl>
|
||||
//#include <test_angle.inl>
|
||||
//#include <test_latlonpatch.inl>
|
||||
//#include <test_texturetileset.inl>
|
||||
//#include <test_gdalwms.inl>
|
||||
#include <test_gdalwms.inl>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
|
||||
@@ -45,7 +45,11 @@ class GdalWmsTest : public testing::Test {};
|
||||
TEST_F(GdalWmsTest, Simple) {
|
||||
GDALDataset *poDataset;
|
||||
GDALAllRegister();
|
||||
|
||||
|
||||
std::string res = GDALVersionInfo("format");
|
||||
|
||||
|
||||
std::string testFile = absPath("../data/scene/debugglobe/map_service_configs/TERRA_CR_B143_2016-04-12.wms");
|
||||
|
||||
poDataset = (GDALDataset *)GDALOpen(testFile.c_str(), GA_ReadOnly);
|
||||
|
||||
Reference in New Issue
Block a user