mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +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 branchStartBit = parentSections * 3;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
void printOctalCode(unsigned char * octalCode);
|
||||
int bytesRequiredForCodeLength(unsigned char threeBitCodes);
|
||||
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);
|
||||
float * firstVertexForCode(unsigned char * octalCode);
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "OctalCode.h"
|
||||
#include "VoxelTree.h"
|
||||
|
||||
const int MAX_TREE_SLICE_BYTES = 26;
|
||||
|
||||
VoxelTree::VoxelTree() {
|
||||
rootNode = new VoxelNode();
|
||||
rootNode->octalCode = new unsigned char[1];
|
||||
|
@ -46,9 +44,7 @@ int VoxelTree::levelForViewerPosition(float *position) {
|
|||
|
||||
VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode) {
|
||||
// find the appropriate branch index based on this ancestorNode
|
||||
if (*needleCode == 0) {
|
||||
return ancestorNode;
|
||||
} else {
|
||||
if (*needleCode > 0) {
|
||||
int branchForNeedle = branchIndexWithDescendant(ancestorNode->octalCode, needleCode);
|
||||
VoxelNode *childNode = ancestorNode->children[branchForNeedle];
|
||||
|
||||
|
@ -156,7 +152,8 @@ void VoxelTree::readCodeColorBufferToTree(unsigned char *codeColorBuffer) {
|
|||
|
||||
// create the node if it does not exist
|
||||
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
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "VoxelNode.h"
|
||||
|
||||
const int MAX_VOXEL_PACKET_SIZE = 1492;
|
||||
const int MAX_TREE_SLICE_BYTES = 26;
|
||||
|
||||
class VoxelTree {
|
||||
VoxelNode * nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode);
|
||||
|
|
Loading…
Reference in a new issue