mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 22:56:29 +02:00
type squish
This commit is contained in:
parent
6fff53a2dc
commit
afcf6dd3e0
2 changed files with 16 additions and 16 deletions
|
@ -16,7 +16,7 @@
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
#include "OctalCode.h"
|
#include "OctalCode.h"
|
||||||
|
|
||||||
int numberOfThreeBitSectionsInCode(const unsigned char * octalCode) {
|
int numberOfThreeBitSectionsInCode(const unsigned char* octalCode) {
|
||||||
assert(octalCode);
|
assert(octalCode);
|
||||||
if (*octalCode == 255) {
|
if (*octalCode == 255) {
|
||||||
return *octalCode + numberOfThreeBitSectionsInCode(octalCode + 1);
|
return *octalCode + numberOfThreeBitSectionsInCode(octalCode + 1);
|
||||||
|
@ -25,18 +25,18 @@ int numberOfThreeBitSectionsInCode(const unsigned char * octalCode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printOctalCode(const unsigned char * octalCode) {
|
void printOctalCode(const unsigned char* octalCode) {
|
||||||
if (!octalCode) {
|
if (!octalCode) {
|
||||||
qDebug("NULL\n");
|
qDebug("NULL\n");
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) {
|
for (int i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) {
|
||||||
outputBits(octalCode[i],false);
|
outputBits(octalCode[i],false);
|
||||||
}
|
}
|
||||||
qDebug("\n");
|
qDebug("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char sectionValue(const unsigned char * startByte, char startIndexInByte) {
|
char sectionValue(const unsigned char* startByte, char startIndexInByte) {
|
||||||
char rightShift = 8 - startIndexInByte - 3;
|
char rightShift = 8 - startIndexInByte - 3;
|
||||||
|
|
||||||
if (rightShift < 0) {
|
if (rightShift < 0) {
|
||||||
|
@ -54,14 +54,14 @@ int bytesRequiredForCodeLength(unsigned char threeBitCodes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int branchIndexWithDescendant(const unsigned char * ancestorOctalCode, const unsigned char * descendantOctalCode) {
|
int branchIndexWithDescendant(const unsigned char* ancestorOctalCode, const unsigned char* descendantOctalCode) {
|
||||||
int parentSections = numberOfThreeBitSectionsInCode(ancestorOctalCode);
|
int parentSections = numberOfThreeBitSectionsInCode(ancestorOctalCode);
|
||||||
|
|
||||||
int branchStartBit = parentSections * 3;
|
int branchStartBit = parentSections * 3;
|
||||||
return sectionValue(descendantOctalCode + 1 + (branchStartBit / 8), branchStartBit % 8);
|
return sectionValue(descendantOctalCode + 1 + (branchStartBit / 8), branchStartBit % 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char * childOctalCode(const unsigned char * parentOctalCode, char childNumber) {
|
unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNumber) {
|
||||||
|
|
||||||
// find the length (in number of three bit code sequences)
|
// find the length (in number of three bit code sequences)
|
||||||
// in the parent
|
// in the parent
|
||||||
|
@ -76,7 +76,7 @@ unsigned char * childOctalCode(const unsigned char * parentOctalCode, char child
|
||||||
int childCodeBytes = bytesRequiredForCodeLength(parentCodeSections + 1);
|
int childCodeBytes = bytesRequiredForCodeLength(parentCodeSections + 1);
|
||||||
|
|
||||||
// create a new buffer to hold the new octal code
|
// create a new buffer to hold the new octal code
|
||||||
unsigned char *newCode = new unsigned char[childCodeBytes];
|
unsigned char* newCode = new unsigned char[childCodeBytes];
|
||||||
|
|
||||||
// copy the parent code to the child
|
// copy the parent code to the child
|
||||||
if (parentOctalCode != NULL) {
|
if (parentOctalCode != NULL) {
|
||||||
|
@ -115,7 +115,7 @@ unsigned char * childOctalCode(const unsigned char * parentOctalCode, char child
|
||||||
return newCode;
|
return newCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void voxelDetailsForCode(const unsigned char * octalCode, VoxelPositionSize& voxelPositionSize) {
|
void voxelDetailsForCode(const unsigned char* octalCode, VoxelPositionSize& voxelPositionSize) {
|
||||||
float output[3];
|
float output[3];
|
||||||
memset(&output[0], 0, 3 * sizeof(float));
|
memset(&output[0], 0, 3 * sizeof(float));
|
||||||
float currentScale = 1.0;
|
float currentScale = 1.0;
|
||||||
|
@ -138,7 +138,7 @@ void voxelDetailsForCode(const unsigned char * octalCode, VoxelPositionSize& vox
|
||||||
voxelPositionSize.s = currentScale;
|
voxelPositionSize.s = currentScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyFirstVertexForCode(const unsigned char * octalCode, float* output) {
|
void copyFirstVertexForCode(const unsigned char* octalCode, float* output) {
|
||||||
memset(output, 0, 3 * sizeof(float));
|
memset(output, 0, 3 * sizeof(float));
|
||||||
|
|
||||||
float currentScale = 0.5;
|
float currentScale = 0.5;
|
||||||
|
@ -154,7 +154,7 @@ void copyFirstVertexForCode(const unsigned char * octalCode, float* output) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float * firstVertexForCode(const unsigned char * octalCode) {
|
float * firstVertexForCode(const unsigned char* octalCode) {
|
||||||
float * firstVertex = new float[3];
|
float * firstVertex = new float[3];
|
||||||
copyFirstVertexForCode(octalCode, firstVertex);
|
copyFirstVertexForCode(octalCode, firstVertex);
|
||||||
return firstVertex;
|
return firstVertex;
|
||||||
|
|
|
@ -20,11 +20,11 @@ const int RED_INDEX = 0;
|
||||||
const int GREEN_INDEX = 1;
|
const int GREEN_INDEX = 1;
|
||||||
const int BLUE_INDEX = 2;
|
const int BLUE_INDEX = 2;
|
||||||
|
|
||||||
void printOctalCode(const unsigned char * octalCode);
|
void printOctalCode(const unsigned char* octalCode);
|
||||||
int bytesRequiredForCodeLength(unsigned char threeBitCodes);
|
int bytesRequiredForCodeLength(unsigned char threeBitCodes);
|
||||||
int branchIndexWithDescendant(const unsigned char * ancestorOctalCode, const unsigned char * descendantOctalCode);
|
int branchIndexWithDescendant(const unsigned char* ancestorOctalCode, const unsigned char* descendantOctalCode);
|
||||||
unsigned char * childOctalCode(const unsigned char * parentOctalCode, char childNumber);
|
unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNumber);
|
||||||
int numberOfThreeBitSectionsInCode(const unsigned char * octalCode);
|
int numberOfThreeBitSectionsInCode(const unsigned char* octalCode);
|
||||||
unsigned char* chopOctalCode(const unsigned char* originalOctalCode, int chopLevels);
|
unsigned char* chopOctalCode(const unsigned char* originalOctalCode, int chopLevels);
|
||||||
unsigned char* rebaseOctalCode(const unsigned char* originalOctalCode, const unsigned char* newParentOctalCode,
|
unsigned char* rebaseOctalCode(const unsigned char* originalOctalCode, const unsigned char* newParentOctalCode,
|
||||||
bool includeColorSpace = false);
|
bool includeColorSpace = false);
|
||||||
|
@ -35,8 +35,8 @@ bool isAncestorOf(const unsigned char* possibleAncestor, const unsigned char* po
|
||||||
|
|
||||||
// Note: copyFirstVertexForCode() is preferred because it doesn't allocate memory for the return
|
// Note: copyFirstVertexForCode() is preferred because it doesn't allocate memory for the return
|
||||||
// but other than that these do the same thing.
|
// but other than that these do the same thing.
|
||||||
float * firstVertexForCode(const unsigned char * octalCode);
|
float * firstVertexForCode(const unsigned char* octalCode);
|
||||||
void copyFirstVertexForCode(const unsigned char * octalCode, float* output);
|
void copyFirstVertexForCode(const unsigned char* octalCode, float* output);
|
||||||
|
|
||||||
struct VoxelPositionSize {
|
struct VoxelPositionSize {
|
||||||
float x, y, z, s;
|
float x, y, z, s;
|
||||||
|
|
Loading…
Reference in a new issue