A Chunk not visible to the camera wants to get merged. Cleaned up ChunkRender render signature

This commit is contained in:
Erik Broberg
2016-05-13 18:31:44 -04:00
parent ac24890195
commit f48400523c
4 changed files with 21 additions and 35 deletions
+2 -3
View File
@@ -90,8 +90,6 @@ namespace openspace {
const Ellipsoid& ellipsoid = _owner->ellipsoid();
const int maxHeight = 8700; // should be read from gdal dataset or mod file
@@ -100,11 +98,12 @@ namespace openspace {
_isVisible &= FrustumCuller::isVisible(myRenderData, _surfacePatch, ellipsoid, maxHeight);
}
if (_owner->doHorizonCulling) {
_isVisible &= HorizonCuller::isVisible(myRenderData, _surfacePatch, ellipsoid, maxHeight);
}
if (!_isVisible) return WANT_MERGE;
Vec3 cameraPosition = myRenderData.camera.position().dvec3();
Geodetic2 pointOnPatch = _surfacePatch.closestPoint(
+5 -5
View File
@@ -96,10 +96,11 @@ bool ChunkNode::internalUpdateChunkTree(const RenderData& data) {
}
// check if all children requested merge
if (requestedMergeMask == 0xf) {
if (requestedMergeMask == 0xf && _chunk.update(data)) {
merge();
// re-run this method on this, now that this is a leaf node
// re-run internalUpdateChunkTree on this, now that this is a leaf node
// OBS, this may currently cause a split() again ...
return internalUpdateChunkTree(data);
}
return false;
@@ -111,8 +112,7 @@ void ChunkNode::internalRender(const RenderData& data) {
if (isLeaf()) {
if (_chunk.isVisible()) {
ChunkRenderer& patchRenderer = _chunk.owner()->getPatchRenderer();
patchRenderer.renderChunk(_chunk, _chunk.owner()->ellipsoid(), data);
//patchRenderer.renderPatch(_chunk.surfacePatch, data, _chunk.owner->ellipsoid(), _chunk.index);
patchRenderer.renderChunk(_chunk, data);
ChunkNode::renderedPatches++;
}
}
@@ -126,7 +126,6 @@ void ChunkNode::internalRender(const RenderData& data) {
void ChunkNode::split(int depth) {
if (depth > 0 && isLeaf()) {
for (size_t i = 0; i < 4; i++) {
Chunk chunk(_chunk.owner(), _chunk.index().child((Quad)i), _chunk.owner()->initChunkVisible);
_children[i] = std::unique_ptr<ChunkNode>(new ChunkNode(chunk, this));
}
@@ -146,6 +145,7 @@ void ChunkNode::merge() {
}
_children[i] = nullptr;
}
ghoul_assert(isLeaf(), "ChunkNode must be leaf after merge");
}
@@ -24,6 +24,7 @@
#include <modules/globebrowsing/rendering/patchrenderer.h>
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
#include <modules/globebrowsing/meshes/clipmapgrid.h>
// open space includes
@@ -37,6 +38,7 @@
#include <ghoul/opengl/textureunit.h>
#define _USE_MATH_DEFINES
#include <math.h>
@@ -108,24 +110,16 @@ namespace openspace {
_programObjectLocalRendering->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
}
void ChunkRenderer::renderChunk(
const Chunk& chunk,
const Ellipsoid& ellipsoid,
const RenderData& data)
{
void ChunkRenderer::renderChunk(const Chunk& chunk, const RenderData& data) {
if (chunk.index().level < 9) {
renderChunkGlobally(chunk, ellipsoid, data);
renderChunkGlobally(chunk, data);
}
else {
renderChunkLocally(chunk, ellipsoid, data);
renderChunkLocally(chunk, data);
}
}
void ChunkRenderer::renderChunkGlobally(
const Chunk& chunk,
const Ellipsoid& ellipsoid,
const RenderData& data)
{
void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& data){
using namespace glm;
// TODO : Model transform should be fetched as a matrix directly.
@@ -176,6 +170,7 @@ namespace openspace {
Geodetic2 swCorner = chunk.surfacePatch().southWestCorner();
auto patchSize = chunk.surfacePatch().size();
const Ellipsoid& ellipsoid = chunk.owner()->ellipsoid();
_programObjectGlobalRendering->setUniform("modelViewProjectionTransform", modelViewProjectionTransform);
_programObjectGlobalRendering->setUniform("minLatLon", vec2(swCorner.toLonLatVec2()));
_programObjectGlobalRendering->setUniform("lonLatScalingFactor", vec2(patchSize.toLonLatVec2()));
@@ -193,11 +188,7 @@ namespace openspace {
}
void ChunkRenderer::renderChunkLocally(
const Chunk& chunk,
const Ellipsoid& ellipsoid,
const RenderData& data)
{
void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& data){
using namespace glm;
// TODO : Model transform should be fetched as a matrix directly.
@@ -248,6 +239,8 @@ namespace openspace {
Geodetic2 nw = chunk.surfacePatch().northWestCorner();
Geodetic2 ne = chunk.surfacePatch().northEastCorner();
const Ellipsoid& ellipsoid = chunk.owner()->ellipsoid();
// Get model space positions of the four control points
Vec3 patchSwModelSpace = ellipsoid.cartesianSurfacePosition(sw);
Vec3 patchSeModelSpace = ellipsoid.cartesianSurfacePosition(se);
@@ -83,19 +83,13 @@ namespace openspace {
ChunkRenderer(shared_ptr<Grid> grid,
shared_ptr<TileProviderManager> tileProviderManager);
void ChunkRenderer::renderChunk(
const Chunk& chunk,
const Ellipsoid& ellipsoid,
const RenderData& data);
void ChunkRenderer::renderChunk(const Chunk& chunk, const RenderData& data);
private:
void ChunkRenderer::renderChunkGlobally(
const Chunk& chunk,
const Ellipsoid& ellipsoid,
const RenderData& data);
const Chunk& chunk, const RenderData& data);
void ChunkRenderer::renderChunkLocally(
const Chunk& chunk,
const Ellipsoid& ellipsoid,
const RenderData& data);
const Chunk& chunk, const RenderData& data);
shared_ptr<Grid> _grid;
};