History

fixed LOD disappear on backing up

ZappoMan committed 13 years ago

Commit 2c962961 parent a5459f81 file · +17 −2Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all

Unified · Split

interface/src/VoxelSystem.cpp+17−2
@@ -390,14 +390,29 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 389 unmodified lines
390390 bool shouldRender = false; // assume we don't need to render it
391391 // if it's colored, we might need to render it!
392392 shouldRender = node->calculateShouldRender(Application::getInstance()->getViewFrustum());
393+
393394 node->setShouldRender(shouldRender);
394395 // let children figure out their renderness
395396 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;
396402 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
397− if (node->getChildAtIndex(i)) {
398− voxelsUpdated += newTreeToArrays(node->getChildAtIndex(i));
403+ VoxelNode* childNode = 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+ }
399411 }
400412 }
413+ if (childrenGotHiddenCount > 0) {
414+ node->setColorFromAverageOfChildren();
415+ }
401416 }
402417 if (_writeRenderFullVBO) {
403418 voxelsUpdated += updateNodeInArraysAsFullVBO(node);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t