History

short circuit shouldRender logic in treeToArrays()

ZappoMan committed 13 years ago

Commit af6f5151 parent 2c8c6a21 file · +13 −6Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+13−6
@@ -220,12 +220,19 @@ void VoxelSystem::copyWrittenDataToReadArrays() { · 219 unmodified lines
220220 int VoxelSystem::newTreeToArrays(VoxelNode* node) {
221221 assert(_viewFrustum); // you must set up _viewFrustum before calling this
222222 int voxelsUpdated = 0;
223− float distanceToNode = node->distanceToCamera(*_viewFrustum);
224− float boundary = boundaryDistanceForRenderLevel(node->getLevel());
225− float childBoundary = boundaryDistanceForRenderLevel(node->getLevel() + 1);
226− bool inBoundary = (distanceToNode <= boundary);
227− bool inChildBoundary = (distanceToNode <= childBoundary);
228− bool shouldRender = node->isColored() && ((node->isLeaf() && inChildBoundary) || (inBoundary && !inChildBoundary));
223+ bool shouldRender = false; // assume we don't need to render it
224+
225+ // if it's colored, we might need to render it!
226+ if (node->isColored()) {
227+ float distanceToNode = node->distanceToCamera(*_viewFrustum);
228+ float boundary = boundaryDistanceForRenderLevel(node->getLevel());
229+ float childBoundary = boundaryDistanceForRenderLevel(node->getLevel() + 1);
230+ bool inBoundary = (distanceToNode <= boundary);
231+ bool inChildBoundary = (distanceToNode <= childBoundary);
232+
233+ shouldRender = (node->isLeaf() && inChildBoundary) || (inBoundary && !inChildBoundary);
234+ }
235+
229236
230237 node->setShouldRender(shouldRender);
231238 // let children figure out their renderness