From ef93275aff2dd77d18b04a18c927be8a54b53a85 Mon Sep 17 00:00:00 2001 From: Erik Broberg Date: Mon, 25 Apr 2016 18:02:45 -0400 Subject: [PATCH 1/4] ChunkNodes that are not visible are not rendered --- modules/globebrowsing/globes/chunknode.cpp | 254 +++++++++--------- modules/globebrowsing/globes/chunknode.h | 77 +++--- .../globebrowsing/globes/renderableglobe.cpp | 2 +- modules/globebrowsing/other/patchrenderer.h | 88 +++--- .../globebrowsing/other/twmstileprovider.cpp | 2 +- src/engine/downloadmanager.cpp | 2 +- 6 files changed, 216 insertions(+), 209 deletions(-) diff --git a/modules/globebrowsing/globes/chunknode.cpp b/modules/globebrowsing/globes/chunknode.cpp index 7896b15282..2e9d711c6f 100644 --- a/modules/globebrowsing/globes/chunknode.cpp +++ b/modules/globebrowsing/globes/chunknode.cpp @@ -34,7 +34,7 @@ namespace { - const std::string _loggerCat = "ChunkNode"; + const std::string _loggerCat = "ChunkNode"; } namespace openspace { @@ -46,186 +46,188 @@ 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 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 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.globeRadius, ti); - ChunkNode::renderedPatches++; - - } - else { - std::vector childIndices = traverseData.childIndices(); - for (int i = 0; i < 4; ++i) { - _children[i]->internalRender(data, childIndices[i]); - } - } + patchRenderer.renderPatch(_patch, data, _owner.globeRadius, ti); + ChunkNode::renderedPatches++; + } + } + else { + std::vector childIndices = traverseData.childIndices(); + for (int i = 0; i < 4; ++i) { + _children[i]->internalRender(data, childIndices[i]); + } + } } -int ChunkNode::calculateDesiredLevel(const RenderData& data, const ChunkIndex& traverseData) { +int ChunkNode::calculateDesiredLevelAndUpdateIsVisible(const RenderData& data, const ChunkIndex& traverseData) { + _isVisible = true; + Vec3 globePosition = data.position.dvec3(); + Vec3 patchNormal = _patch.center().asUnitCartesian(); + Vec3 patchPosition = globePosition + _owner.globeRadius * patchNormal; + + Vec3 cameraPosition = data.camera.position().dvec3(); + Vec3 cameraDirection = Vec3(data.camera.viewDirection()); + Vec3 cameraToChunk = patchPosition - cameraPosition; - Vec3 globePosition = data.position.dvec3(); - Vec3 patchNormal = _patch.center().asUnitCartesian(); - Vec3 patchPosition = globePosition + _owner.globeRadius * patchNormal; + // 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 cameraPosition = data.camera.position().dvec3(); - Vec3 cameraDirection = Vec3(data.camera.viewDirection()); - Vec3 cameraToChunk = patchPosition - cameraPosition; + Vec3 globeToCamera = cameraPosition - globePosition; + + Geodetic2 cameraPositionOnGlobe = Geodetic2::fromCartesian(globeToCamera); + Geodetic2 closestPatchPoint = _patch.closestPoint(cameraPositionOnGlobe); + + Vec3 normalOfClosestPatchPoint = closestPatchPoint.asUnitCartesian(); + Scalar cosPatchNormalNormalizedGlobeToCamera = glm::dot(normalOfClosestPatchPoint, glm::normalize(globeToCamera)); + + //LDEBUG(cosPatchNormalCameraDirection); + + double cosAngleToHorizon = _owner.globeRadius / glm::length(globeToCamera); + + if (cosPatchNormalNormalizedGlobeToCamera < cosAngleToHorizon) { + _isVisible = false; + return traverseData.level - 1; + } - // 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); + // Do frustrum culling + FrustrumCuller& culler = _owner.getFrustrumCuller(); - Vec3 globeToCamera = cameraPosition - globePosition; + if (!culler.isVisible(data, _patch, _owner.globeRadius)) { + _isVisible = false; + return traverseData.level - 1; + } - Geodetic2 cameraPositionOnGlobe = Geodetic2::fromCartesian(globeToCamera); - Geodetic2 closestPatchPoint = _patch.closestPoint(cameraPositionOnGlobe); + // Calculate desired level based on distance + Scalar distance = glm::length(cameraToChunk); + _owner.minDistToCamera = fmin(_owner.minDistToCamera, distance); - Vec3 normalOfClosestPatchPoint = closestPatchPoint.asUnitCartesian(); - Scalar cosPatchNormalNormalizedGlobeToCamera = glm::dot(normalOfClosestPatchPoint, glm::normalize(globeToCamera)); - - //LDEBUG(cosPatchNormalCameraDirection); - - double cosAngleToHorizon = _owner.globeRadius / glm::length(globeToCamera); - - if (cosPatchNormalNormalizedGlobeToCamera < cosAngleToHorizon) { - return traverseData.level - 1; - } - - - // Do frustrum culling - FrustrumCuller& culler = _owner.getFrustrumCuller(); - - if (!culler.isVisible(data, _patch, _owner.globeRadius)) { - return traverseData.level - 1; - } - - // Calculate desired level based on distance - Scalar distance = glm::length(cameraToChunk); - _owner.minDistToCamera = fmin(_owner.minDistToCamera, distance); - - Scalar scaleFactor = 100 * _owner.globeRadius; - Scalar projectedScaleFactor = scaleFactor / distance; - int desiredLevel = floor( log2(projectedScaleFactor) ); - return desiredLevel; + Scalar scaleFactor = 100 * _owner.globeRadius; + Scalar projectedScaleFactor = scaleFactor / distance; + int desiredLevel = floor( log2(projectedScaleFactor) ); + return desiredLevel; } 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(new ChunkNode(_owner, nwBounds, this)); - _children[Quad::NORTH_EAST] = std::unique_ptr(new ChunkNode(_owner, neBounds, this)); - _children[Quad::SOUTH_WEST] = std::unique_ptr(new ChunkNode(_owner, swBounds, this)); - _children[Quad::SOUTH_EAST] = std::unique_ptr(new ChunkNode(_owner, seBounds, this)); - } + // Create new chunk nodes + _children[Quad::NORTH_WEST] = std::unique_ptr(new ChunkNode(_owner, nwBounds, this)); + _children[Quad::NORTH_EAST] = std::unique_ptr(new ChunkNode(_owner, neBounds, this)); + _children[Quad::SOUTH_WEST] = std::unique_ptr(new ChunkNode(_owner, swBounds, this)); + _children[Quad::SOUTH_EAST] = std::unique_ptr(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]; } diff --git a/modules/globebrowsing/globes/chunknode.h b/modules/globebrowsing/globes/chunknode.h index 26c2261e74..306450e01b 100644 --- a/modules/globebrowsing/globes/chunknode.h +++ b/modules/globebrowsing/globes/chunknode.h @@ -37,70 +37,75 @@ // 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 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 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&); - int calculateDesiredLevel(const RenderData& data, const ChunkIndex&); - - - ChunkNode* _parent; - std::unique_ptr _children[4]; + void internalRender(const RenderData& data, ChunkIndex&); + bool internalUpdateChunkTree(const RenderData& data, ChunkIndex&); - ChunkLodGlobe& _owner; - GeodeticPatch _patch; - + int calculateDesiredLevelAndUpdateIsVisible(const RenderData& data, const ChunkIndex&); + + + ChunkNode* _parent; + std::unique_ptr _children[4]; + + ChunkLodGlobe& _owner; + + GeodeticPatch _patch; + bool _isVisible; + + + }; } // namespace openspace diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index 6686bf8fc4..364dd2efc7 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -66,7 +66,7 @@ namespace openspace { // Mainly for debugging purposes @AA addProperty(_rotation); - addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e7); + //addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e7); addSwitchValue(std::shared_ptr(new ChunkLodGlobe(dictionary)), 1e9); addSwitchValue(std::shared_ptr(new GlobeMesh(dictionary)), 1e10); diff --git a/modules/globebrowsing/other/patchrenderer.h b/modules/globebrowsing/other/patchrenderer.h index 97da5f93a4..0a1a2f0a28 100644 --- a/modules/globebrowsing/other/patchrenderer.h +++ b/modules/globebrowsing/other/patchrenderer.h @@ -46,62 +46,62 @@ namespace opengl { namespace openspace { - class LonLatPatch; - class TriangleSoup; - - using std::shared_ptr; - using std::unique_ptr; - using ghoul::opengl::ProgramObject; + class LonLatPatch; + class TriangleSoup; + + using std::shared_ptr; + using std::unique_ptr; + using ghoul::opengl::ProgramObject; - class PatchRenderer { - public: - - PatchRenderer(); - ~PatchRenderer(); + class PatchRenderer { + public: + + PatchRenderer(); + ~PatchRenderer(); - protected: + protected: - unique_ptr _programObject; - TextureTileSet _tileSet; - }; + unique_ptr _programObject; + TextureTileSet _tileSet; + }; - ////////////////////////////////////////////////////////////////////////////////////// - // PATCH RENDERER SUBCLASSES // - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // PATCH RENDERER SUBCLASSES // + ////////////////////////////////////////////////////////////////////////////////////// - class LatLonPatchRenderer : public PatchRenderer { - public: - LatLonPatchRenderer(shared_ptr grid); + class LatLonPatchRenderer : public PatchRenderer { + public: + LatLonPatchRenderer(shared_ptr grid); - void renderPatch( - const GeodeticPatch& patch, - const RenderData& data, - double radius); + void renderPatch( + const GeodeticPatch& patch, + const RenderData& data, + double radius); - void renderPatch( - const GeodeticPatch& patch, - const RenderData& data, - double radius, - const TileIndex& ti); - private: - shared_ptr _grid; - TwmsTileProvider tileProvider; - }; + void renderPatch( + const GeodeticPatch& patch, + const RenderData& data, + double radius, + const TileIndex& ti); + private: + shared_ptr _grid; + TwmsTileProvider tileProvider; + }; - class ClipMapPatchRenderer : public PatchRenderer { - public: - ClipMapPatchRenderer(shared_ptr grid); + class ClipMapPatchRenderer : public PatchRenderer { + public: + ClipMapPatchRenderer(shared_ptr grid); - void renderPatch( - const Geodetic2& patchSize, - const RenderData& data, - double radius); - private: - shared_ptr _grid; - }; + void renderPatch( + const Geodetic2& patchSize, + const RenderData& data, + double radius); + private: + shared_ptr _grid; + }; } // namespace openspace diff --git a/modules/globebrowsing/other/twmstileprovider.cpp b/modules/globebrowsing/other/twmstileprovider.cpp index ea6974abcc..79f65c6761 100644 --- a/modules/globebrowsing/other/twmstileprovider.cpp +++ b/modules/globebrowsing/other/twmstileprovider.cpp @@ -68,7 +68,7 @@ namespace openspace { std::string fileName = _fileFutureCache.get(hashkey)->filePath; std::string filePath = "tiles/" + fileName; std::shared_ptr texture = loadAndInitTextureDisk(filePath); - LDEBUG("Downloaded " << fileName); + //LDEBUG("Downloaded " << fileName); _tileCache.put(hashkey, texture); } } diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 5b6b9c79bc..2f2048d97d 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -145,7 +145,7 @@ std::shared_ptr 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(); From dbf9293a31daec6242e2b138274734aef28047e1 Mon Sep 17 00:00:00 2001 From: Erik Broberg Date: Wed, 27 Apr 2016 12:13:33 -0400 Subject: [PATCH 2/4] Moved patchrenderer and frustumculler to folder rendering --- modules/globebrowsing/CMakeLists.txt | 10 +- modules/globebrowsing/globes/chunklodglobe.h | 2 +- modules/globebrowsing/globes/chunknode.cpp | 1 - modules/globebrowsing/globes/chunknode.h | 2 +- modules/globebrowsing/globes/clipmapglobe.h | 2 +- .../globebrowsing/globes/renderableglobe.cpp | 2 +- .../frustumculler.cpp} | 2 +- .../frustumculler.h} | 0 .../globebrowsing/rendering/patchrenderer.cpp | 254 ++++++++++++++++++ .../globebrowsing/rendering/patchrenderer.h | 24 +- .../patchrenderer_tmp.h} | 24 +- tests/main.cpp | 8 +- tests/test_gdalwms.inl | 4 + 13 files changed, 297 insertions(+), 38 deletions(-) rename modules/globebrowsing/{other/frustrumculler.cpp => rendering/frustumculler.cpp} (98%) rename modules/globebrowsing/{other/frustrumculler.h => rendering/frustumculler.h} (100%) create mode 100644 modules/globebrowsing/rendering/patchrenderer.cpp rename modules/globebrowsing/{other/patchrenderer.h => rendering/patchrenderer_tmp.h} (89%) diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index a288bbebca..b61a71c33c 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -41,9 +41,10 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/geodetic2.h ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/angle.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 @@ -67,9 +68,10 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/geodetic2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/angle.inl + ${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 diff --git a/modules/globebrowsing/globes/chunklodglobe.h b/modules/globebrowsing/globes/chunklodglobe.h index fe05305d5e..72a33174da 100644 --- a/modules/globebrowsing/globes/chunklodglobe.h +++ b/modules/globebrowsing/globes/chunklodglobe.h @@ -40,7 +40,7 @@ #include -#include +#include #include namespace ghoul { diff --git a/modules/globebrowsing/globes/chunknode.cpp b/modules/globebrowsing/globes/chunknode.cpp index 2e9d711c6f..0c0717708c 100644 --- a/modules/globebrowsing/globes/chunknode.cpp +++ b/modules/globebrowsing/globes/chunknode.cpp @@ -32,7 +32,6 @@ #include - namespace { const std::string _loggerCat = "ChunkNode"; } diff --git a/modules/globebrowsing/globes/chunknode.h b/modules/globebrowsing/globes/chunknode.h index 306450e01b..4cee16ea9f 100644 --- a/modules/globebrowsing/globes/chunknode.h +++ b/modules/globebrowsing/globes/chunknode.h @@ -31,7 +31,7 @@ #include #include -#include +#include diff --git a/modules/globebrowsing/globes/clipmapglobe.h b/modules/globebrowsing/globes/clipmapglobe.h index b1770555f2..3ec7ab150b 100644 --- a/modules/globebrowsing/globes/clipmapglobe.h +++ b/modules/globebrowsing/globes/clipmapglobe.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include namespace ghoul { diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index 364dd2efc7..6686bf8fc4 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -66,7 +66,7 @@ namespace openspace { // Mainly for debugging purposes @AA addProperty(_rotation); - //addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e7); + addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e7); addSwitchValue(std::shared_ptr(new ChunkLodGlobe(dictionary)), 1e9); addSwitchValue(std::shared_ptr(new GlobeMesh(dictionary)), 1e10); diff --git a/modules/globebrowsing/other/frustrumculler.cpp b/modules/globebrowsing/rendering/frustumculler.cpp similarity index 98% rename from modules/globebrowsing/other/frustrumculler.cpp rename to modules/globebrowsing/rendering/frustumculler.cpp index 87dd03a06e..7ffb6ba138 100644 --- a/modules/globebrowsing/other/frustrumculler.cpp +++ b/modules/globebrowsing/rendering/frustumculler.cpp @@ -23,7 +23,7 @@ ****************************************************************************************/ -#include +#include namespace { const std::string _loggerCat = "FrustrumCuller"; diff --git a/modules/globebrowsing/other/frustrumculler.h b/modules/globebrowsing/rendering/frustumculler.h similarity index 100% rename from modules/globebrowsing/other/frustrumculler.h rename to modules/globebrowsing/rendering/frustumculler.h diff --git a/modules/globebrowsing/rendering/patchrenderer.cpp b/modules/globebrowsing/rendering/patchrenderer.cpp new file mode 100644 index 0000000000..77e9340fd1 --- /dev/null +++ b/modules/globebrowsing/rendering/patchrenderer.cpp @@ -0,0 +1,254 @@ +/***************************************************************************************** +* * +* 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 + +#include + +// open space includes +#include +#include +#include + +// ghoul includes +#include +#include +#include + + +#define _USE_MATH_DEFINES +#include + +namespace { + const std::string _loggerCat = "PatchRenderer"; + + const std::string keyFrame = "Frame"; + const std::string keyGeometry = "Geometry"; + const std::string keyShading = "PerformShading"; + + const std::string keyBody = "Body"; +} + +namespace openspace { + + ////////////////////////////////////////////////////////////////////////////////////// + // PATCH RENDERER // + ////////////////////////////////////////////////////////////////////////////////////// + PatchRenderer::PatchRenderer() + : _tileSet(Geodetic2(M_PI, M_PI * 2), Geodetic2(M_PI / 2, -M_PI), 0) + { + + } + + PatchRenderer::~PatchRenderer() { + if (_programObject) { + RenderEngine& renderEngine = OsEng.renderEngine(); + renderEngine.removeRenderProgram(_programObject); + _programObject = nullptr; + } + } + + + + ////////////////////////////////////////////////////////////////////////////////////// + // LATLON PATCH RENDERER // + ////////////////////////////////////////////////////////////////////////////////////// + LatLonPatchRenderer::LatLonPatchRenderer(shared_ptr grid) + : PatchRenderer() + , _grid(grid) + { + _programObject = OsEng.renderEngine().buildRenderProgram( + "LatLonSphereMappingProgram", + "${MODULE_GLOBEBROWSING}/shaders/latlonpatch_spheremapping_vs.glsl", + "${MODULE_GLOBEBROWSING}/shaders/simple_fs.glsl"); + ghoul_assert(_programObject != nullptr, "Failed to initialize programObject!"); + + using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError; + _programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes); + } + + void LatLonPatchRenderer::renderPatch( + const GeodeticPatch& patch, const RenderData& data, double radius) + { + + // Get the textures that should be used for rendering + TileIndex ti = _tileSet.getTileIndex(patch); + + renderPatch(patch, data, radius, ti); + } + + void LatLonPatchRenderer::renderPatch(const GeodeticPatch& patch,const RenderData& data, + double radius, const TileIndex& tileIndex) + { + + using namespace glm; + + + + + + // TODO : Model transform should be fetched as a matrix directly. + mat4 modelTransform = translate(mat4(1), data.position.vec3()); + mat4 viewTransform = data.camera.combinedViewMatrix(); + mat4 modelViewProjectionTransform = data.camera.projectionMatrix() + * viewTransform * modelTransform; + + + // activate shader + _programObject->activate(); + + // Get the textures that should be used for rendering + std::shared_ptr tile00; + bool usingTile = true; + TileIndex ti; + ti.level =tileIndex.level; + ti.x = tileIndex.y; + ti.y = tileIndex.x; + tile00 = tileProvider.getTile(ti); + + if (tile00 == nullptr) { + tile00 = _tileSet.getTile(tileIndex); + usingTile = false; + } + + glm::mat3 uvTransform = usingTile ? glm::mat3(1) : _tileSet.getUvTransformationPatchToTile(patch, tileIndex); + + // Bind and use the texture + ghoul::opengl::TextureUnit texUnit; + texUnit.activate(); + tile00->bind(); + _programObject->setUniform("textureSampler", texUnit); + _programObject->setUniform("uvTransformPatchToTile", uvTransform); + + Geodetic2 swCorner = patch.southWestCorner(); + _programObject->setUniform("segmentsPerPatch", _grid->xSegments()); + _programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform); + _programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2())); + _programObject->setUniform("lonLatScalingFactor", vec2(patch.size().toLonLatVec2())); + _programObject->setUniform("globeRadius", float(radius)); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + + // render + _grid->geometry().drawUsingActiveProgram(); + + // disable shader + _programObject->deactivate(); + } + + + + ////////////////////////////////////////////////////////////////////////////////////// + // CLIPMAP PATCH RENDERER // + ////////////////////////////////////////////////////////////////////////////////////// + ClipMapPatchRenderer::ClipMapPatchRenderer(shared_ptr grid) + : PatchRenderer() + , _grid(grid) + { + _programObject = OsEng.renderEngine().buildRenderProgram( + "LatLonSphereMappingProgram", + "${MODULE_GLOBEBROWSING}/shaders/clipmappatch_spheremapping_vs.glsl", + "${MODULE_GLOBEBROWSING}/shaders/simple_fs.glsl"); + ghoul_assert(_programObject != nullptr, "Failed to initialize programObject!"); + + using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError; + _programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes); + } + + void ClipMapPatchRenderer::renderPatch( + const Geodetic2& patchSize, + const RenderData& data, + double radius) + { + // activate shader + _programObject->activate(); + using namespace glm; + + mat4 viewTransform = data.camera.combinedViewMatrix(); + + // TODO : Model transform should be fetched as a matrix directly. + mat4 modelTransform = translate(mat4(1), data.position.vec3()); + + // Snap patch position + int segmentsPerPatch = _grid->segments(); + Geodetic2 stepSize = Geodetic2( + patchSize.lat / segmentsPerPatch, + patchSize.lon / segmentsPerPatch); + ivec2 patchesToCoverGlobe = ivec2( + M_PI / patchSize.lat + 0.5, + M_PI * 2 / patchSize.lon + 0.5); + Geodetic2 cameraPosLatLon = Geodetic2::fromCartesian(data.camera.position().dvec3()); + ivec2 intSnapCoord = ivec2( + cameraPosLatLon.lat / (M_PI * 2) * segmentsPerPatch * patchesToCoverGlobe.y, + cameraPosLatLon.lon / (M_PI) * segmentsPerPatch * patchesToCoverGlobe.x); + Geodetic2 newPatchCenter = Geodetic2( + stepSize.lat * intSnapCoord.x, + stepSize.lon * intSnapCoord.y); + GeodeticPatch newPatch( + newPatchCenter, + Geodetic2(patchSize.lat / 2, patchSize.lon / 2)); + + ivec2 contraction = ivec2(intSnapCoord.y % 2, intSnapCoord.x % 2); + + //LDEBUG("patch.center = [ " << patch.center.lat << " , " << patch.center.lon << " ]"); + //LDEBUG("intSnapCoord = [ " << intSnapCoord.x << " , " << intSnapCoord.y << " ]"); + //LDEBUG("contraction = [ " << contraction.x << " , " << contraction.y << " ]"); + + + // Get the textures that should be used for rendering + TileIndex tileIndex = _tileSet.getTileIndex(newPatch); + GeodeticPatch tilePatch = _tileSet.getTilePositionAndScale(tileIndex); + std::shared_ptr tile00 = _tileSet.getTile(tileIndex); + glm::mat3 uvTransform = _tileSet.getUvTransformationPatchToTile(newPatch, tileIndex); + + // Bind and use the texture + ghoul::opengl::TextureUnit texUnit; + texUnit.activate(); + tile00->bind(); + _programObject->setUniform("textureSampler", texUnit); + _programObject->setUniform("uvTransformPatchToTile", mat3(uvTransform)); + + _programObject->setUniform( + "modelViewProjectionTransform", + data.camera.projectionMatrix() * viewTransform * modelTransform); + _programObject->setUniform("segmentsPerPatch", segmentsPerPatch); + _programObject->setUniform("minLatLon", vec2(newPatch.southWestCorner().toLonLatVec2())); + _programObject->setUniform("lonLatScalingFactor", vec2(patchSize.toLonLatVec2())); + _programObject->setUniform("globeRadius", float(radius)); + _programObject->setUniform("contraction", contraction); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + + // render + _grid->geometry().drawUsingActiveProgram(); + + // disable shader + _programObject->deactivate(); + } + +} // namespace openspace diff --git a/modules/globebrowsing/rendering/patchrenderer.h b/modules/globebrowsing/rendering/patchrenderer.h index feeda0bb6c..ddf45f513b 100644 --- a/modules/globebrowsing/rendering/patchrenderer.h +++ b/modules/globebrowsing/rendering/patchrenderer.h @@ -31,11 +31,11 @@ // open space includes #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ghoul { namespace opengl { @@ -47,7 +47,7 @@ namespace opengl { namespace openspace { class LonLatPatch; - class Geometry; + class TriangleSoup; using std::shared_ptr; using std::unique_ptr; @@ -63,7 +63,6 @@ namespace openspace { unique_ptr _programObject; TextureTileSet _tileSet; - }; @@ -76,20 +75,18 @@ namespace openspace { LatLonPatchRenderer(shared_ptr grid); void renderPatch( - const LatLonPatch& patch, + const GeodeticPatch& patch, const RenderData& data, double radius); void renderPatch( - const LatLonPatch& patch, + const GeodeticPatch& patch, const RenderData& data, double radius, const TileIndex& ti); - private: - TwmsTileProvider tileProvider; shared_ptr _grid; - + TwmsTileProvider tileProvider; }; @@ -99,12 +96,13 @@ namespace openspace { ClipMapPatchRenderer(shared_ptr grid); void renderPatch( - const LatLon& patchSize, + const Geodetic2& patchSize, const RenderData& data, double radius); private: shared_ptr _grid; }; + } // namespace openspace #endif // __LATLONPATCH_H__ \ No newline at end of file diff --git a/modules/globebrowsing/other/patchrenderer.h b/modules/globebrowsing/rendering/patchrenderer_tmp.h similarity index 89% rename from modules/globebrowsing/other/patchrenderer.h rename to modules/globebrowsing/rendering/patchrenderer_tmp.h index 0a1a2f0a28..feeda0bb6c 100644 --- a/modules/globebrowsing/other/patchrenderer.h +++ b/modules/globebrowsing/rendering/patchrenderer_tmp.h @@ -31,11 +31,11 @@ // open space includes #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ghoul { namespace opengl { @@ -47,7 +47,7 @@ namespace opengl { namespace openspace { class LonLatPatch; - class TriangleSoup; + class Geometry; using std::shared_ptr; using std::unique_ptr; @@ -63,6 +63,7 @@ namespace openspace { unique_ptr _programObject; TextureTileSet _tileSet; + }; @@ -75,18 +76,20 @@ namespace openspace { LatLonPatchRenderer(shared_ptr grid); void renderPatch( - const GeodeticPatch& patch, + const LatLonPatch& patch, const RenderData& data, double radius); void renderPatch( - const GeodeticPatch& patch, + const LatLonPatch& patch, const RenderData& data, double radius, const TileIndex& ti); + private: - shared_ptr _grid; TwmsTileProvider tileProvider; + shared_ptr _grid; + }; @@ -96,13 +99,12 @@ namespace openspace { ClipMapPatchRenderer(shared_ptr grid); void renderPatch( - const Geodetic2& patchSize, + const LatLon& patchSize, const RenderData& data, double radius); private: shared_ptr _grid; }; - } // namespace openspace #endif // __LATLONPATCH_H__ \ No newline at end of file diff --git a/tests/main.cpp b/tests/main.cpp index 3ca71a4a53..95e1200112 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -33,16 +33,16 @@ //#include //#include //#include -#include -#include -#include +//#include +//#include +//#include //#include //#include //#include //#include //#include -//#include +#include #include #include diff --git a/tests/test_gdalwms.inl b/tests/test_gdalwms.inl index b7561bbf55..80d522a963 100644 --- a/tests/test_gdalwms.inl +++ b/tests/test_gdalwms.inl @@ -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); From 958c8a7828c95af8ec174f97434f7e8484902105 Mon Sep 17 00:00:00 2001 From: Erik Broberg Date: Wed, 27 Apr 2016 12:19:38 -0400 Subject: [PATCH 3/4] removed old file --- .../rendering/patchrenderer_tmp.h | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 modules/globebrowsing/rendering/patchrenderer_tmp.h diff --git a/modules/globebrowsing/rendering/patchrenderer_tmp.h b/modules/globebrowsing/rendering/patchrenderer_tmp.h deleted file mode 100644 index feeda0bb6c..0000000000 --- a/modules/globebrowsing/rendering/patchrenderer_tmp.h +++ /dev/null @@ -1,110 +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 -#include - -// open space includes -#include - -#include -#include -#include -#include -#include - -namespace ghoul { -namespace opengl { - class ProgramObject; -} -} - - -namespace openspace { - - class LonLatPatch; - class Geometry; - - using std::shared_ptr; - using std::unique_ptr; - using ghoul::opengl::ProgramObject; - - class PatchRenderer { - public: - - PatchRenderer(); - ~PatchRenderer(); - - protected: - - unique_ptr _programObject; - TextureTileSet _tileSet; - - }; - - - ////////////////////////////////////////////////////////////////////////////////////// - // PATCH RENDERER SUBCLASSES // - ////////////////////////////////////////////////////////////////////////////////////// - - class LatLonPatchRenderer : public PatchRenderer { - public: - LatLonPatchRenderer(shared_ptr grid); - - void renderPatch( - const LatLonPatch& patch, - const RenderData& data, - double radius); - - void renderPatch( - const LatLonPatch& patch, - const RenderData& data, - double radius, - const TileIndex& ti); - - private: - TwmsTileProvider tileProvider; - shared_ptr _grid; - - }; - - - - class ClipMapPatchRenderer : public PatchRenderer { - public: - ClipMapPatchRenderer(shared_ptr grid); - - void renderPatch( - const LatLon& patchSize, - const RenderData& data, - double radius); - private: - shared_ptr _grid; - }; -} // namespace openspace - -#endif // __LATLONPATCH_H__ \ No newline at end of file From 25d96cb17df5f61daeba274807b5d0607cacd463 Mon Sep 17 00:00:00 2001 From: Erik Broberg Date: Wed, 27 Apr 2016 12:22:29 -0400 Subject: [PATCH 4/4] Changed FrustrumCuller to FrustumCuller --- modules/globebrowsing/globes/chunklodglobe.cpp | 6 +++--- modules/globebrowsing/globes/chunklodglobe.h | 4 ++-- modules/globebrowsing/globes/chunknode.cpp | 2 +- modules/globebrowsing/rendering/frustumculler.cpp | 12 ++++++------ modules/globebrowsing/rendering/frustumculler.h | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/globebrowsing/globes/chunklodglobe.cpp b/modules/globebrowsing/globes/chunklodglobe.cpp index 1b562b91bc..1f5a696cab 100644 --- a/modules/globebrowsing/globes/chunklodglobe.cpp +++ b/modules/globebrowsing/globes/chunklodglobe.cpp @@ -91,7 +91,7 @@ namespace openspace { _patchRenderer.reset(new LatLonPatchRenderer(geometry)); - _frustrumCuller = std::shared_ptr(new FrustrumCuller()); + _frustumCuller = std::shared_ptr(new FrustumCuller()); } @@ -116,8 +116,8 @@ namespace openspace { return *_patchRenderer; } - FrustrumCuller& ChunkLodGlobe::getFrustrumCuller() { - return *_frustrumCuller; + FrustumCuller& ChunkLodGlobe::getFrustumCuller() { + return *_frustumCuller; } diff --git a/modules/globebrowsing/globes/chunklodglobe.h b/modules/globebrowsing/globes/chunklodglobe.h index 72a33174da..f8bf71068c 100644 --- a/modules/globebrowsing/globes/chunklodglobe.h +++ b/modules/globebrowsing/globes/chunklodglobe.h @@ -58,7 +58,7 @@ namespace openspace { ~ChunkLodGlobe(); LatLonPatchRenderer& getPatchRenderer(); - FrustrumCuller& getFrustrumCuller(); + FrustumCuller& getFrustumCuller(); bool initialize() override; bool deinitialize() override; @@ -84,7 +84,7 @@ namespace openspace { std::unique_ptr _rightRoot; // Frustrum culler - std::shared_ptr _frustrumCuller; + std::shared_ptr _frustumCuller; // the patch used for actual rendering std::unique_ptr _patchRenderer; diff --git a/modules/globebrowsing/globes/chunknode.cpp b/modules/globebrowsing/globes/chunknode.cpp index 0c0717708c..2a08eda788 100644 --- a/modules/globebrowsing/globes/chunknode.cpp +++ b/modules/globebrowsing/globes/chunknode.cpp @@ -169,7 +169,7 @@ int ChunkNode::calculateDesiredLevelAndUpdateIsVisible(const RenderData& data, c // Do frustrum culling - FrustrumCuller& culler = _owner.getFrustrumCuller(); + FrustumCuller& culler = _owner.getFrustumCuller(); if (!culler.isVisible(data, _patch, _owner.globeRadius)) { _isVisible = false; diff --git a/modules/globebrowsing/rendering/frustumculler.cpp b/modules/globebrowsing/rendering/frustumculler.cpp index 7ffb6ba138..afd9d2634c 100644 --- a/modules/globebrowsing/rendering/frustumculler.cpp +++ b/modules/globebrowsing/rendering/frustumculler.cpp @@ -34,17 +34,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(); @@ -56,7 +56,7 @@ namespace openspace { } - bool FrustrumCuller::isVisible(const RenderData& data, const GeodeticPatch& patch, double radius) { + bool FrustumCuller::isVisible(const RenderData& data, const GeodeticPatch& patch, double radius) { // An axis aligned bounding box based on the patch's minimum boudning sphere is // used for testnig @@ -85,7 +85,7 @@ namespace openspace { - bool FrustrumCuller::testPoint(const glm::vec2& pointScreenSpace, + bool FrustumCuller::testPoint(const glm::vec2& pointScreenSpace, const glm::vec2& marginScreenSpace) const { @@ -97,7 +97,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); diff --git a/modules/globebrowsing/rendering/frustumculler.h b/modules/globebrowsing/rendering/frustumculler.h index 583c1c073a..c51b147905 100644 --- a/modules/globebrowsing/rendering/frustumculler.h +++ b/modules/globebrowsing/rendering/frustumculler.h @@ -41,11 +41,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.