mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 12:44:03 +02:00
Merge pull request #656 from ZappoMan/bug_fixes
fix hungergames circle bug, and improve performance of isLeafOrLOD logic
This commit is contained in:
commit
be59035ede
1 changed files with 5 additions and 25 deletions
|
@ -1346,33 +1346,13 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
|
||||||
|
|
||||||
// There are two types of nodes for which we want to send colors:
|
// There are two types of nodes for which we want to send colors:
|
||||||
// 1) Leaves - obviously
|
// 1) Leaves - obviously
|
||||||
// 2) Non-leaves who's children would be visible and beyond our LOD.
|
// 2) Non-leaves who's children would be visible but are beyond our LOD.
|
||||||
// NOTE: This code works, but it's pretty expensive, because we're calculating distances for all the grand
|
|
||||||
// children, which we'll end up doing again later in the next level of recursion. We need to optimize this
|
|
||||||
// in the future.
|
|
||||||
bool isLeafOrLOD = childNode->isLeaf();
|
bool isLeafOrLOD = childNode->isLeaf();
|
||||||
if (params.viewFrustum && childNode->isColored() && !childNode->isLeaf()) {
|
if (params.viewFrustum && childNode->isColored() && !childNode->isLeaf()) {
|
||||||
int grandChildrenInView = 0;
|
int childLevel = childNode->getLevel();
|
||||||
int grandChildrenInLOD = 0;
|
float childBoundary = boundaryDistanceForRenderLevel(childLevel + params.boundaryLevelAdjust);
|
||||||
float grandChildBoundaryDistance = boundaryDistanceForRenderLevel(childNode->getLevel() +
|
float grandChildBoundary = boundaryDistanceForRenderLevel(childLevel + 1 + params.boundaryLevelAdjust);
|
||||||
1 + params.boundaryLevelAdjust);
|
isLeafOrLOD = ((distance <= childBoundary) && !(distance <= grandChildBoundary));
|
||||||
for (int grandChildIndex = 0; grandChildIndex < NUMBER_OF_CHILDREN; grandChildIndex++) {
|
|
||||||
VoxelNode* grandChild = childNode->getChildAtIndex(grandChildIndex);
|
|
||||||
|
|
||||||
if (grandChild && grandChild->isColored() && grandChild->isInView(*params.viewFrustum)) {
|
|
||||||
grandChildrenInView++;
|
|
||||||
|
|
||||||
float grandChildDistance = grandChild->distanceToCamera(*params.viewFrustum);
|
|
||||||
if (grandChildDistance < grandChildBoundaryDistance) {
|
|
||||||
grandChildrenInLOD++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if any of our grandchildren ARE in view, then we don't want to include our color. If none are, then
|
|
||||||
// we do want to include our color
|
|
||||||
if (grandChildrenInView > 0 && grandChildrenInLOD == 0) {
|
|
||||||
isLeafOrLOD = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// track children with actual color, only if the child wasn't previously in view!
|
// track children with actual color, only if the child wasn't previously in view!
|
||||||
|
|
Loading…
Reference in a new issue