diff --git a/shared/src/VoxelTree.cpp b/shared/src/VoxelTree.cpp index 200c7f89ae..4119bd52a0 100644 --- a/shared/src/VoxelTree.cpp +++ b/shared/src/VoxelTree.cpp @@ -150,6 +150,20 @@ void VoxelTree::readBitstreamToTree(unsigned char * bitstream, int bufferSizeByt readNodeData(bitstreamRootNode, bitstream + octalCodeBytes, bufferSizeBytes - octalCodeBytes); } +void VoxelTree::readCodeColorBufferToTree(unsigned char *codeColorBuffer) { + int octalCodeBytes = bytesRequiredForCodeLength(*codeColorBuffer); + VoxelNode *lastCreatedNode = nodeForOctalCode(rootNode, codeColorBuffer); + + // create the node if it does not exist + if (*lastCreatedNode->octalCode != *codeColorBuffer) { + lastCreatedNode = createMissingNode(lastCreatedNode, codeColorBuffer); + } + + // give this node its color + memcpy(lastCreatedNode->color, codeColorBuffer + octalCodeBytes, 3); + lastCreatedNode->color[3] = 1; +} + unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer, unsigned char * stopOctalCode, VoxelNode *currentVoxelNode, diff --git a/shared/src/VoxelTree.h b/shared/src/VoxelTree.h index e69b12a910..a2215f5dd1 100644 --- a/shared/src/VoxelTree.h +++ b/shared/src/VoxelTree.h @@ -26,6 +26,7 @@ public: int levelForViewerPosition(float * position); void readBitstreamToTree(unsigned char * bitstream, int bufferSizeBytes); + void readCodeColorBufferToTree(unsigned char *codeColorBuffer); unsigned char * loadBitstreamBuffer(unsigned char *& bitstreamBuffer, unsigned char * octalCode, VoxelNode *currentVoxelNode,