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
220int VoxelSystem::newTreeToArrays(VoxelNode* node) {220int VoxelSystem::newTreeToArrays(VoxelNode* node) {
221 assert(_viewFrustum); // you must set up _viewFrustum before calling this221 assert(_viewFrustum); // you must set up _viewFrustum before calling this
222 int voxelsUpdated = 0;222 int voxelsUpdated = 0;
223 float distanceToNode = node->distanceToCamera(*_viewFrustum);223 bool shouldRender = false; // assume we don't need to render it
224 float boundary = boundaryDistanceForRenderLevel(node->getLevel());224
225 float childBoundary = boundaryDistanceForRenderLevel(node->getLevel() + 1);225 // if it's colored, we might need to render it!
226 bool inBoundary = (distanceToNode <= boundary);226 if (node->isColored()) {
227 bool inChildBoundary = (distanceToNode <= childBoundary);227 float distanceToNode = node->distanceToCamera(*_viewFrustum);
228 bool shouldRender = node->isColored() && ((node->isLeaf() && inChildBoundary) || (inBoundary && !inChildBoundary));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
229 236
230 node->setShouldRender(shouldRender);237 node->setShouldRender(shouldRender);
231 // let children figure out their renderness238 // let children figure out their renderness