mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:52:57 +02:00
use int instead of forced 8-bit types where appropriate
This commit is contained in:
parent
9ac664dbab
commit
1abce28310
6 changed files with 13 additions and 13 deletions
|
@ -108,7 +108,7 @@ float * firstVertexForCode(unsigned char * octalCode) {
|
||||||
memset(firstVertex, 0, 3 * sizeof(float));
|
memset(firstVertex, 0, 3 * sizeof(float));
|
||||||
|
|
||||||
for (int i = 0; i < numberOfThreeBitSectionsInCode(octalCode); i++) {
|
for (int i = 0; i < numberOfThreeBitSectionsInCode(octalCode); i++) {
|
||||||
int8_t sectionIndex = sectionValue(octalCode + 1 + (3 * i / 8), (3 * i) % 8);
|
int sectionIndex = sectionValue(octalCode + 1 + (3 * i / 8), (3 * i) % 8);
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
firstVertex[j] += 0.5 * (int)oneAtBit(sectionIndex, 7 -j);
|
firstVertex[j] += 0.5 * (int)oneAtBit(sectionIndex, 7 -j);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ float randFloat () {
|
||||||
return (rand() % 10000)/10000.f;
|
return (rand() % 10000)/10000.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char randomColorValue(uint8_t miniumum) {
|
unsigned char randomColorValue(int miniumum) {
|
||||||
return miniumum + (rand() % (255 - miniumum));
|
return miniumum + (rand() % (255 - miniumum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ void outputBits(unsigned char byte) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t numberOfOnes(unsigned char byte) {
|
int numberOfOnes(unsigned char byte) {
|
||||||
return (byte >> 7)
|
return (byte >> 7)
|
||||||
+ ((byte >> 6) & 1)
|
+ ((byte >> 6) & 1)
|
||||||
+ ((byte >> 5) & 1)
|
+ ((byte >> 5) & 1)
|
||||||
|
@ -53,6 +53,6 @@ int8_t numberOfOnes(unsigned char byte) {
|
||||||
+ (byte & 1);
|
+ (byte & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool oneAtBit(unsigned char byte, int8_t bitIndex) {
|
bool oneAtBit(unsigned char byte, int bitIndex) {
|
||||||
return (byte >> (7 - bitIndex) & 1);
|
return (byte >> (7 - bitIndex) & 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,11 @@ double usecTimestamp(timeval *time);
|
||||||
double usecTimestampNow();
|
double usecTimestampNow();
|
||||||
|
|
||||||
float randFloat();
|
float randFloat();
|
||||||
unsigned char randomColorValue(uint8_t minimum);
|
unsigned char randomColorValue(int minimum);
|
||||||
bool randomBoolean();
|
bool randomBoolean();
|
||||||
|
|
||||||
void outputBits(unsigned char byte);
|
void outputBits(unsigned char byte);
|
||||||
int8_t numberOfOnes(unsigned char byte);
|
int numberOfOnes(unsigned char byte);
|
||||||
bool oneAtBit(unsigned char byte, int8_t bitIndex);
|
bool oneAtBit(unsigned char byte, int bitIndex);
|
||||||
|
|
||||||
#endif /* defined(__hifi__SharedUtil__) */
|
#endif /* defined(__hifi__SharedUtil__) */
|
||||||
|
|
|
@ -30,7 +30,7 @@ VoxelNode::~VoxelNode() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelNode::addChildAtIndex(int8_t childIndex) {
|
void VoxelNode::addChildAtIndex(int childIndex) {
|
||||||
children[childIndex] = new VoxelNode();
|
children[childIndex] = new VoxelNode();
|
||||||
|
|
||||||
// give this child its octal code
|
// give this child its octal code
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
VoxelNode();
|
VoxelNode();
|
||||||
~VoxelNode();
|
~VoxelNode();
|
||||||
|
|
||||||
void addChildAtIndex(int8_t childIndex);
|
void addChildAtIndex(int childIndex);
|
||||||
void setColorFromAverageOfChildren(int * colorArray = NULL);
|
void setColorFromAverageOfChildren(int * colorArray = NULL);
|
||||||
void setRandomColor(int minimumBrightness);
|
void setRandomColor(int minimumBrightness);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char *
|
||||||
if (*needleCode == 0) {
|
if (*needleCode == 0) {
|
||||||
return ancestorNode;
|
return ancestorNode;
|
||||||
} else if (ancestorNode->childMask != 0) {
|
} else if (ancestorNode->childMask != 0) {
|
||||||
int8_t branchForNeedle = branchIndexWithDescendant(ancestorNode->octalCode, needleCode);
|
int branchForNeedle = branchIndexWithDescendant(ancestorNode->octalCode, needleCode);
|
||||||
VoxelNode *childNode = ancestorNode->children[branchForNeedle];
|
VoxelNode *childNode = ancestorNode->children[branchForNeedle];
|
||||||
|
|
||||||
if (childNode != NULL) {
|
if (childNode != NULL) {
|
||||||
|
@ -53,7 +53,7 @@ VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char *
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelNode * VoxelTree::createMissingNode(VoxelNode *lastParentNode, unsigned char *codeToReach) {
|
VoxelNode * VoxelTree::createMissingNode(VoxelNode *lastParentNode, unsigned char *codeToReach) {
|
||||||
uint8_t indexOfNewChild = branchIndexWithDescendant(lastParentNode->octalCode, codeToReach);
|
int indexOfNewChild = branchIndexWithDescendant(lastParentNode->octalCode, codeToReach);
|
||||||
lastParentNode->addChildAtIndex(indexOfNewChild);
|
lastParentNode->addChildAtIndex(indexOfNewChild);
|
||||||
|
|
||||||
if (*lastParentNode->children[indexOfNewChild]->octalCode == *codeToReach) {
|
if (*lastParentNode->children[indexOfNewChild]->octalCode == *codeToReach) {
|
||||||
|
@ -139,7 +139,7 @@ unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
|
||||||
{
|
{
|
||||||
static unsigned char *initialBitstreamPos = bitstreamBuffer;
|
static unsigned char *initialBitstreamPos = bitstreamBuffer;
|
||||||
|
|
||||||
uint8_t firstIndexToCheck = 0;
|
int firstIndexToCheck = 0;
|
||||||
|
|
||||||
// we'll only be writing data if we're lower than
|
// we'll only be writing data if we're lower than
|
||||||
// or at the same level as the stopOctalCode
|
// or at the same level as the stopOctalCode
|
||||||
|
@ -224,7 +224,7 @@ unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelTree::printTreeForDebugging(VoxelNode *startNode) {
|
void VoxelTree::printTreeForDebugging(VoxelNode *startNode) {
|
||||||
uint8_t colorMask = 0;
|
int colorMask = 0;
|
||||||
|
|
||||||
// create the color mask
|
// create the color mask
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|
Loading…
Reference in a new issue