Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all
Unified · Split
| @@ -390,14 +390,29 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 389 unmodified lines | |||
| 390 | bool shouldRender = false; // assume we don't need to render it | 390 | bool shouldRender = false; // assume we don't need to render it |
| 391 | // if it's colored, we might need to render it! | 391 | // if it's colored, we might need to render it! |
| 392 | shouldRender = node->calculateShouldRender(Application::getInstance()->getViewFrustum()); | 392 | shouldRender = node->calculateShouldRender(Application::getInstance()->getViewFrustum()); |
| 393 | |||
| 393 | node->setShouldRender(shouldRender); | 394 | node->setShouldRender(shouldRender); |
| 394 | // let children figure out their renderness | 395 | // let children figure out their renderness |
| 395 | if (!node->isLeaf()) { | 396 | if (!node->isLeaf()) { |
| 397 | |||
| 398 | // As we check our children, see if any of them went from shouldRender to NOT shouldRender | ||
| 399 | // then we probably dropped LOD and if we don't have color, we want to average our children | ||
| 400 | // for a new color. | ||
| 401 | int childrenGotHiddenCount = 0; | ||
| 396 | for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { | 402 | for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { |
| 397 | if (node->getChildAtIndex(i)) { | 403 | VoxelNode* childNode = node->getChildAtIndex(i); |
| 398 | voxelsUpdated += newTreeToArrays(node->getChildAtIndex(i)); | 404 | if (childNode) { |
| 405 | bool wasShouldRender = childNode->getShouldRender(); | ||
| 406 | voxelsUpdated += newTreeToArrays(childNode); | ||
| 407 | bool isShouldRender = childNode->getShouldRender(); | ||
| 408 | if (wasShouldRender && !isShouldRender) { | ||
| 409 | childrenGotHiddenCount++; | ||
| 410 | } | ||
| 399 | } | 411 | } |
| 400 | } | 412 | } |
| 413 | if (childrenGotHiddenCount > 0) { | ||
| 414 | node->setColorFromAverageOfChildren(); | ||
| 415 | } | ||
| 401 | } | 416 | } |
| 402 | if (_writeRenderFullVBO) { | 417 | if (_writeRenderFullVBO) { |
| 403 | voxelsUpdated += updateNodeInArraysAsFullVBO(node); | 418 | voxelsUpdated += updateNodeInArraysAsFullVBO(node); |