History

added dirty bit support to VoxelTree, use it to determine when to call treeToArrays

ZappoMan committed 13 years ago

Commit 5a14c711 parent c353c1d4 files · +35 −7Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+7−2
@@ -149,7 +149,12 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 148 unmodified lines
149149
150150 void VoxelSystem::setupNewVoxelsForDrawing() {
151151 double start = usecTimestampNow();
152− _voxelsUpdated = newTreeToArrays(_tree->rootNode);
152+ if (_tree->isDirty()) {
153+ _voxelsUpdated = newTreeToArrays(_tree->rootNode);
154+ _tree->clearDirtyBit(); // after we pull the trees into the array, we can consider the tree clean
155+ } else {
156+ _voxelsUpdated = 0;
157+ }
153158 if (_voxelsUpdated) {
154159 _voxelsDirty=true;
155160 }
@@ -248,8 +253,8 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 92 unmodified lines
248253 _voxelsInArrays++; // our know vertices in the arrays
249254 }
250255 voxelsUpdated++;
251− node->clearDirtyBit();
252256 }
257+ node->clearDirtyBit(); // always clear the dirty bit, even if it doesn't need to be rendered
253258 return voxelsUpdated;
254259 }
255260