mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-22 21:06:27 +02:00
add method to repair child masks after adding randomly placed voxels
This commit is contained in:
parent
c641f12693
commit
f435a09673
2 changed files with 26 additions and 0 deletions
|
@ -159,6 +159,31 @@ void VoxelTree::readCodeColorBufferToTree(unsigned char *codeColorBuffer) {
|
||||||
// give this node its color
|
// give this node its color
|
||||||
memcpy(lastCreatedNode->color, codeColorBuffer + octalCodeBytes, 3);
|
memcpy(lastCreatedNode->color, codeColorBuffer + octalCodeBytes, 3);
|
||||||
lastCreatedNode->color[3] = 1;
|
lastCreatedNode->color[3] = 1;
|
||||||
|
|
||||||
|
repairChildMasks(rootNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelTree::repairChildMasks(VoxelNode *currentNode) {
|
||||||
|
|
||||||
|
currentNode->childMask = 0;
|
||||||
|
int grandChildren = 0;
|
||||||
|
int thisNodeGrandChildren = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|
||||||
|
if (currentNode->children[i] != NULL) {
|
||||||
|
thisNodeGrandChildren = repairChildMasks(currentNode->children[i]);
|
||||||
|
|
||||||
|
if (thisNodeGrandChildren > 0) {
|
||||||
|
currentNode->childMask += (1 << (7 - i));
|
||||||
|
}
|
||||||
|
|
||||||
|
thisNodeGrandChildren += grandChildren;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return grandChildren;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
|
unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
int levelForViewerPosition(float * position);
|
int levelForViewerPosition(float * position);
|
||||||
void readBitstreamToTree(unsigned char * bitstream, int bufferSizeBytes);
|
void readBitstreamToTree(unsigned char * bitstream, int bufferSizeBytes);
|
||||||
void readCodeColorBufferToTree(unsigned char *codeColorBuffer);
|
void readCodeColorBufferToTree(unsigned char *codeColorBuffer);
|
||||||
|
int repairChildMasks(VoxelNode *currentNode);
|
||||||
unsigned char * loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
|
unsigned char * loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
|
||||||
unsigned char * octalCode,
|
unsigned char * octalCode,
|
||||||
VoxelNode *currentVoxelNode,
|
VoxelNode *currentVoxelNode,
|
||||||
|
|
Loading…
Reference in a new issue