From f85abe53efa4015e1895fe593a062b5b1c001c21 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 28 Mar 2013 16:22:37 -0700 Subject: [PATCH] add a method to VoxelTree to reaverage the voxel colors --- shared/src/VoxelTree.cpp | 15 +++++++++++++++ shared/src/VoxelTree.h | 1 + 2 files changed, 16 insertions(+) diff --git a/shared/src/VoxelTree.cpp b/shared/src/VoxelTree.cpp index 728e2e6d08..085315ad86 100644 --- a/shared/src/VoxelTree.cpp +++ b/shared/src/VoxelTree.cpp @@ -384,6 +384,21 @@ void VoxelTree::printTreeForDebugging(VoxelNode *startNode) { } } +void VoxelTree::reaverageVoxelColors(VoxelNode *startNode) { + bool hasChildren; + + for (int i = 0; i < 8; i++) { + if (startNode->children[i] != NULL) { + reaverageVoxelColors(startNode->children[i]); + hasChildren = true; + } + } + + if (hasChildren) { + startNode->setColorFromAverageOfChildren(); + } + +} ////////////////////////////////////////////////////////////////////////////////////////// // Method: VoxelTree::loadVoxelsFile() // Description: Loads HiFidelity encoded Voxels from a binary file. The current file diff --git a/shared/src/VoxelTree.h b/shared/src/VoxelTree.h index 0a76ff49b4..6b0da733e2 100644 --- a/shared/src/VoxelTree.h +++ b/shared/src/VoxelTree.h @@ -30,6 +30,7 @@ public: void readBitstreamToTree(unsigned char * bitstream, int bufferSizeBytes); void readCodeColorBufferToTree(unsigned char *codeColorBuffer); void printTreeForDebugging(VoxelNode *startNode); + void reaverageVoxelColors(VoxelNode *startNode); unsigned char * loadBitstreamBuffer(unsigned char *& bitstreamBuffer, VoxelNode *currentVoxelNode, MarkerNode *currentMarkerNode,