use int instead of forced 8-bit types where appropriate

This commit is contained in:
Stephen Birarda 2013-03-20 13:44:09 -07:00
parent 9ac664dbab
commit 1abce28310
6 changed files with 13 additions and 13 deletions

View file

@ -108,7 +108,7 @@ float * firstVertexForCode(unsigned char * octalCode) {
memset(firstVertex, 0, 3 * sizeof(float));
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++) {
firstVertex[j] += 0.5 * (int)oneAtBit(sectionIndex, 7 -j);
}

View file

@ -24,7 +24,7 @@ float randFloat () {
return (rand() % 10000)/10000.f;
}
unsigned char randomColorValue(uint8_t miniumum) {
unsigned char randomColorValue(int miniumum) {
return miniumum + (rand() % (255 - miniumum));
}
@ -42,7 +42,7 @@ void outputBits(unsigned char byte) {
printf("\n");
}
int8_t numberOfOnes(unsigned char byte) {
int numberOfOnes(unsigned char byte) {
return (byte >> 7)
+ ((byte >> 6) & 1)
+ ((byte >> 5) & 1)
@ -53,6 +53,6 @@ int8_t numberOfOnes(unsigned char byte) {
+ (byte & 1);
}
bool oneAtBit(unsigned char byte, int8_t bitIndex) {
bool oneAtBit(unsigned char byte, int bitIndex) {
return (byte >> (7 - bitIndex) & 1);
}

View file

@ -22,11 +22,11 @@ double usecTimestamp(timeval *time);
double usecTimestampNow();
float randFloat();
unsigned char randomColorValue(uint8_t minimum);
unsigned char randomColorValue(int minimum);
bool randomBoolean();
void outputBits(unsigned char byte);
int8_t numberOfOnes(unsigned char byte);
bool oneAtBit(unsigned char byte, int8_t bitIndex);
int numberOfOnes(unsigned char byte);
bool oneAtBit(unsigned char byte, int bitIndex);
#endif /* defined(__hifi__SharedUtil__) */

View file

@ -30,7 +30,7 @@ VoxelNode::~VoxelNode() {
}
}
void VoxelNode::addChildAtIndex(int8_t childIndex) {
void VoxelNode::addChildAtIndex(int childIndex) {
children[childIndex] = new VoxelNode();
// give this child its octal code

View file

@ -16,7 +16,7 @@ public:
VoxelNode();
~VoxelNode();
void addChildAtIndex(int8_t childIndex);
void addChildAtIndex(int childIndex);
void setColorFromAverageOfChildren(int * colorArray = NULL);
void setRandomColor(int minimumBrightness);

View file

@ -31,7 +31,7 @@ VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char *
if (*needleCode == 0) {
return ancestorNode;
} else if (ancestorNode->childMask != 0) {
int8_t branchForNeedle = branchIndexWithDescendant(ancestorNode->octalCode, needleCode);
int branchForNeedle = branchIndexWithDescendant(ancestorNode->octalCode, needleCode);
VoxelNode *childNode = ancestorNode->children[branchForNeedle];
if (childNode != NULL) {
@ -53,7 +53,7 @@ VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char *
}
VoxelNode * VoxelTree::createMissingNode(VoxelNode *lastParentNode, unsigned char *codeToReach) {
uint8_t indexOfNewChild = branchIndexWithDescendant(lastParentNode->octalCode, codeToReach);
int indexOfNewChild = branchIndexWithDescendant(lastParentNode->octalCode, codeToReach);
lastParentNode->addChildAtIndex(indexOfNewChild);
if (*lastParentNode->children[indexOfNewChild]->octalCode == *codeToReach) {
@ -139,7 +139,7 @@ unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
{
static unsigned char *initialBitstreamPos = bitstreamBuffer;
uint8_t firstIndexToCheck = 0;
int firstIndexToCheck = 0;
// we'll only be writing data if we're lower than
// or at the same level as the stopOctalCode
@ -224,7 +224,7 @@ unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
}
void VoxelTree::printTreeForDebugging(VoxelNode *startNode) {
uint8_t colorMask = 0;
int colorMask = 0;
// create the color mask
for (int i = 0; i < 8; i++) {