mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 22:47:49 +02:00
some refactoring in for readCodeColorBufferToTree
This commit is contained in:
parent
c51b4e3311
commit
c641f12693
4 changed files with 6 additions and 8 deletions
|
@ -43,7 +43,7 @@ int bytesRequiredForCodeLength(unsigned char threeBitCodes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char branchIndexWithDescendant(unsigned char * ancestorOctalCode, unsigned char * descendantOctalCode) {
|
int branchIndexWithDescendant(unsigned char * ancestorOctalCode, unsigned char * descendantOctalCode) {
|
||||||
int parentSections = numberOfThreeBitSectionsInCode(ancestorOctalCode);
|
int parentSections = numberOfThreeBitSectionsInCode(ancestorOctalCode);
|
||||||
|
|
||||||
int branchStartBit = parentSections * 3;
|
int branchStartBit = parentSections * 3;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
void printOctalCode(unsigned char * octalCode);
|
void printOctalCode(unsigned char * octalCode);
|
||||||
int bytesRequiredForCodeLength(unsigned char threeBitCodes);
|
int bytesRequiredForCodeLength(unsigned char threeBitCodes);
|
||||||
bool isDirectParentOfChild(unsigned char *parentOctalCode, unsigned char * childOctalCode);
|
bool isDirectParentOfChild(unsigned char *parentOctalCode, unsigned char * childOctalCode);
|
||||||
char branchIndexWithDescendant(unsigned char * ancestorOctalCode, unsigned char * descendantOctalCode);
|
int branchIndexWithDescendant(unsigned char * ancestorOctalCode, unsigned char * descendantOctalCode);
|
||||||
unsigned char * childOctalCode(unsigned char * parentOctalCode, char childNumber);
|
unsigned char * childOctalCode(unsigned char * parentOctalCode, char childNumber);
|
||||||
float * firstVertexForCode(unsigned char * octalCode);
|
float * firstVertexForCode(unsigned char * octalCode);
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include "OctalCode.h"
|
#include "OctalCode.h"
|
||||||
#include "VoxelTree.h"
|
#include "VoxelTree.h"
|
||||||
|
|
||||||
const int MAX_TREE_SLICE_BYTES = 26;
|
|
||||||
|
|
||||||
VoxelTree::VoxelTree() {
|
VoxelTree::VoxelTree() {
|
||||||
rootNode = new VoxelNode();
|
rootNode = new VoxelNode();
|
||||||
rootNode->octalCode = new unsigned char[1];
|
rootNode->octalCode = new unsigned char[1];
|
||||||
|
@ -46,9 +44,7 @@ int VoxelTree::levelForViewerPosition(float *position) {
|
||||||
|
|
||||||
VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode) {
|
VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode) {
|
||||||
// find the appropriate branch index based on this ancestorNode
|
// find the appropriate branch index based on this ancestorNode
|
||||||
if (*needleCode == 0) {
|
if (*needleCode > 0) {
|
||||||
return ancestorNode;
|
|
||||||
} else {
|
|
||||||
int branchForNeedle = branchIndexWithDescendant(ancestorNode->octalCode, needleCode);
|
int branchForNeedle = branchIndexWithDescendant(ancestorNode->octalCode, needleCode);
|
||||||
VoxelNode *childNode = ancestorNode->children[branchForNeedle];
|
VoxelNode *childNode = ancestorNode->children[branchForNeedle];
|
||||||
|
|
||||||
|
@ -156,7 +152,8 @@ void VoxelTree::readCodeColorBufferToTree(unsigned char *codeColorBuffer) {
|
||||||
|
|
||||||
// create the node if it does not exist
|
// create the node if it does not exist
|
||||||
if (*lastCreatedNode->octalCode != *codeColorBuffer) {
|
if (*lastCreatedNode->octalCode != *codeColorBuffer) {
|
||||||
lastCreatedNode = createMissingNode(lastCreatedNode, codeColorBuffer);
|
VoxelNode *parentNode = createMissingNode(lastCreatedNode, codeColorBuffer);
|
||||||
|
lastCreatedNode = parentNode->children[branchIndexWithDescendant(parentNode->octalCode, codeColorBuffer)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// give this node its color
|
// give this node its color
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "VoxelNode.h"
|
#include "VoxelNode.h"
|
||||||
|
|
||||||
const int MAX_VOXEL_PACKET_SIZE = 1492;
|
const int MAX_VOXEL_PACKET_SIZE = 1492;
|
||||||
|
const int MAX_TREE_SLICE_BYTES = 26;
|
||||||
|
|
||||||
class VoxelTree {
|
class VoxelTree {
|
||||||
VoxelNode * nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode);
|
VoxelNode * nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode);
|
||||||
|
|
Loading…
Reference in a new issue