Fixed bug introduced in commit f484005... due to enum Chunk::Status was implicitely casted to bool. Changed enum to class

This commit is contained in:
Erik Broberg
2016-05-17 13:22:45 -04:00
parent a9d34d4d25
commit 974fff33fd
3 changed files with 14 additions and 15 deletions

View File

@@ -102,8 +102,9 @@ namespace openspace {
_isVisible &= HorizonCuller::isVisible(myRenderData, _surfacePatch, ellipsoid, maxHeight);
}
if(!_isVisible && owner()->mergeInvisible)
return WANT_MERGE;
if (!_isVisible && owner()->mergeInvisible) {
return Status::WANT_MERGE;
}
Vec3 cameraPosition = myRenderData.camera.position().dvec3();
@@ -125,9 +126,9 @@ namespace openspace {
// clamp level
desiredLevel = glm::clamp(desiredLevel, _owner->minSplitDepth, _owner->maxSplitDepth);
if (desiredLevel < _index.level) return WANT_MERGE;
else if (_index.level < desiredLevel) return WANT_SPLIT;
else return DO_NOTHING;
if (desiredLevel < _index.level) return Status::WANT_MERGE;
else if (_index.level < desiredLevel) return Status::WANT_SPLIT;
else return Status::DO_NOTHING;
}
void Chunk::render(const RenderData& data) const {

View File

@@ -44,7 +44,7 @@ namespace openspace {
class Chunk {
public:
enum Status{
enum class Status{
DO_NOTHING,
WANT_MERGE,
WANT_SPLIT,

View File

@@ -74,13 +74,12 @@ bool ChunkNode::updateChunkTree(const RenderData& data) {
if (isLeaf()) {
Chunk::Status status = _chunk.update(data);
if (status == Chunk::WANT_SPLIT) {
if (status == Chunk::Status::WANT_SPLIT) {
split();
}
return status == Chunk::WANT_MERGE;
return status == Chunk::Status::WANT_MERGE;
}
else {
char requestedMergeMask = 0;
for (int i = 0; i < 4; ++i) {
if (_children[i]->updateChunkTree(data)) {
@@ -88,14 +87,13 @@ bool ChunkNode::updateChunkTree(const RenderData& data) {
}
}
// check if all children requested merge
if (requestedMergeMask == 0xf && _chunk.update(data)) {
merge();
bool allChildrenWantsMerge = requestedMergeMask == 0xf;
bool thisChunkWantsSplit = _chunk.update(data) == Chunk::Status::WANT_SPLIT;
// re-run updateChunkTree on this, now that this is a leaf node
// OBS, this may currently cause a split() again ...
return updateChunkTree(data);
if (allChildrenWantsMerge && !thisChunkWantsSplit) {
merge();
}
return false;
}
}