mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:58:59 +02:00
code review cleanup
This commit is contained in:
parent
622a078d24
commit
bf3b014743
2 changed files with 18 additions and 14 deletions
|
@ -54,7 +54,7 @@ bool randomBoolean() {
|
||||||
|
|
||||||
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
|
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
outputBits(buffer[i],false);
|
outputBits(buffer[i], false);
|
||||||
}
|
}
|
||||||
if (withNewLine) {
|
if (withNewLine) {
|
||||||
printLog("\n");
|
printLog("\n");
|
||||||
|
@ -377,28 +377,30 @@ void printVoxelCode(unsigned char* voxelCode) {
|
||||||
// the second array is a sorted key for the value, the third array is the index for the value in it original
|
// the second array is a sorted key for the value, the third array is the index for the value in it original
|
||||||
// non-sorted array
|
// non-sorted array
|
||||||
// returns -1 if size exceeded
|
// returns -1 if size exceeded
|
||||||
int insertIntoSortedArrays(void* value, float key, int originalIndex,
|
int insertIntoSortedArrays(
|
||||||
void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount) {
|
void* value, float key, int originalIndex,
|
||||||
|
void** valueArray, float* keyArray, int* originalIndexArray,
|
||||||
|
int currentCount, int maxCount) {
|
||||||
|
|
||||||
if (currentCount < maxCount) {
|
if (currentCount < maxCount) {
|
||||||
int i=0;
|
int i = 0;
|
||||||
if (currentCount > 0) {
|
if (currentCount > 0) {
|
||||||
while (i<currentCount && key > keyArray[i]) {
|
while (i < currentCount && key > keyArray[i]) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
// i is our desired location
|
// i is our desired location
|
||||||
// shift array elements to the right
|
// shift array elements to the right
|
||||||
if (i < currentCount && i+1 < maxCount) {
|
if (i < currentCount && i+1 < maxCount) {
|
||||||
memcpy(&valueArray[i+1],&valueArray[i],sizeof(void*) * (currentCount-i));
|
memcpy(&valueArray[i + 1], &valueArray[i], sizeof(void*) * (currentCount - i));
|
||||||
memcpy(&keyArray[i+1],&keyArray[i],sizeof(float) * (currentCount-i));
|
memcpy(&keyArray[i + 1], &keyArray[i], sizeof(float) * (currentCount - i));
|
||||||
memcpy(&originalIndexArray[i+1],&originalIndexArray[i],sizeof(int) * (currentCount-i));
|
memcpy(&originalIndexArray[i + 1], &originalIndexArray[i], sizeof(int) * (currentCount - i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// place new element at i
|
// place new element at i
|
||||||
valueArray[i]=value;
|
valueArray[i] = value;
|
||||||
keyArray[i]=key;
|
keyArray[i] = key;
|
||||||
originalIndexArray[i]=originalIndex;
|
originalIndexArray[i] = originalIndex;
|
||||||
return currentCount+1;
|
return currentCount + 1;
|
||||||
}
|
}
|
||||||
return -1; // error case
|
return -1; // error case
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,9 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
|
||||||
void usleep(int waitTime);
|
void usleep(int waitTime);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int insertIntoSortedArrays(void* value, float key, int originalIndex,
|
int insertIntoSortedArrays(
|
||||||
void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount);
|
void* value, float key, int originalIndex,
|
||||||
|
void** valueArray, float* keyArray, int* originalIndexArray,
|
||||||
|
int currentCount, int maxCount);
|
||||||
|
|
||||||
#endif /* defined(__hifi__SharedUtil__) */
|
#endif /* defined(__hifi__SharedUtil__) */
|
||||||
|
|
Loading…
Reference in a new issue