From e9d71c9406f29c0abdbdb2807da1b84de0d75afd Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 12 Apr 2013 15:06:51 -0700 Subject: [PATCH 1/5] add dependency to shared library from voxel library --- libraries/voxels/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 376d652d00..71c538162d 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -18,5 +18,6 @@ file(GLOB HIFI_VOXELS_SRCS src/*.h src/*.cpp) # create a library and set the property so it can be referenced later add_library(${TARGET_NAME} ${HIFI_VOXELS_SRCS}) -include_directories(${TARGET_NAME} ../shared/src) +add_dependencies(${TARGET_NAME} shared) + set(HIFI_VOXELS_LIBRARY ${TARGET_NAME}) \ No newline at end of file From 9b73d2559dd416acadaef0d3fb2ee071f8ae148a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 12 Apr 2013 15:15:19 -0700 Subject: [PATCH 2/5] Revert "add dependency to shared library from voxel library" This reverts commit e9d71c9406f29c0abdbdb2807da1b84de0d75afd. --- libraries/voxels/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 71c538162d..376d652d00 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -18,6 +18,5 @@ file(GLOB HIFI_VOXELS_SRCS src/*.h src/*.cpp) # create a library and set the property so it can be referenced later add_library(${TARGET_NAME} ${HIFI_VOXELS_SRCS}) -add_dependencies(${TARGET_NAME} shared) - +include_directories(${TARGET_NAME} ../shared/src) set(HIFI_VOXELS_LIBRARY ${TARGET_NAME}) \ No newline at end of file From 83ee4507596382c984c903a43d52272d5280f283 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 12 Apr 2013 15:18:04 -0700 Subject: [PATCH 3/5] change long int to long in CounterStats --- libraries/shared/src/CounterStats.cpp | 12 ++-- libraries/shared/src/CounterStats.h | 82 +++++++++++++-------------- 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/libraries/shared/src/CounterStats.cpp b/libraries/shared/src/CounterStats.cpp index 7dbab0add6..050ee6159b 100644 --- a/libraries/shared/src/CounterStats.cpp +++ b/libraries/shared/src/CounterStats.cpp @@ -33,17 +33,17 @@ // int sampleAt; -void CounterStatHistory::recordSample(long int thisCount) { +void CounterStatHistory::recordSample(long thisCount) { timeval now; gettimeofday(&now,NULL); double nowSeconds = (now.tv_usec/1000000.0)+(now.tv_sec); this->recordSample(nowSeconds,thisCount); } -void CounterStatHistory::recordSample(double thisTime, long int thisCount) { +void CounterStatHistory::recordSample(double thisTime, long thisCount) { // how much did we change since last sample? - long int thisDelta = thisCount - this->lastCount; + long thisDelta = thisCount - this->lastCount; double elapsed = thisTime - this->lastTime; // record the latest values @@ -74,12 +74,12 @@ void CounterStatHistory::recordSample(double thisTime, long int thisCount) { } -long int CounterStatHistory::getRunningAverage() { +long CounterStatHistory::getRunningAverage() { // before we calculate our running average, always "reset" the current count, with the current time // this will flush out old data, if we haven't been adding any new data. this->recordSample(this->currentCount); - long int runningTotal = 0; + long runningTotal = 0; double minTime = this->timeSamples[0]; double maxTime = this->timeSamples[0]; @@ -90,6 +90,6 @@ long int CounterStatHistory::getRunningAverage() { } double elapsedTime = maxTime-minTime; - long int runningAverage = runningTotal/elapsedTime; + long runningAverage = runningTotal/elapsedTime; return runningAverage; } diff --git a/libraries/shared/src/CounterStats.h b/libraries/shared/src/CounterStats.h index 29481461b6..36b91c6937 100644 --- a/libraries/shared/src/CounterStats.h +++ b/libraries/shared/src/CounterStats.h @@ -22,58 +22,56 @@ #define COUNTETSTATS_TIME_FRAME (COUNTETSTATS_SAMPLES_TO_KEEP*COUNTETSTATS_TIME_BETWEEN_SAMPLES) class CounterStatHistory { - +public: + std::string name; + + CounterStatHistory(std::string myName): + currentCount(0), currentDelta(0),currentTime(0.0), + lastCount(0),lastTime(0.0), + totalTime(0.0), + sampleAt(-1), sampleCount(0), name(myName) {}; + + CounterStatHistory(): + currentCount(0), currentDelta(0),currentTime(0.0), + lastCount(0),lastTime(0.0), + totalTime(0.0), + sampleAt(-1), sampleCount(0) {}; + + CounterStatHistory(std::string myName, double initialTime, long int initialCount) : + currentCount(initialCount), currentDelta(0), currentTime(initialTime), + lastCount(initialCount),lastTime(initialTime), + totalTime(initialTime), + sampleAt(-1), sampleCount(0), name(myName) {}; + + void recordSample(long thisCount); + void recordSample(double thisTime, long thisCount); + long getRunningAverage(); + + long getAverage() { + return currentCount/totalTime; + }; + + double getTotalTime() { + return totalTime; + }; + long getCount() { + return currentCount; + }; private: - long int currentCount; - long int currentDelta; + long currentCount; + long currentDelta; double currentTime; - long int lastCount; + long lastCount; double lastTime; double totalTime; - long int countSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; - long int deltaSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; + long countSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; + long deltaSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; double timeSamples[COUNTETSTATS_SAMPLES_TO_KEEP]; int sampleAt; int sampleCount; - -public: - std::string name; - - CounterStatHistory(std::string myName): - currentCount(0), currentDelta(0),currentTime(0.0), - lastCount(0),lastTime(0.0), - totalTime(0.0), - sampleAt(-1),sampleCount(0), name(myName) {}; - - CounterStatHistory(): - currentCount(0), currentDelta(0),currentTime(0.0), - lastCount(0),lastTime(0.0), - totalTime(0.0), - sampleAt(-1),sampleCount(0) {}; - - CounterStatHistory(std::string myName, double initialTime, long int initialCount) : - currentCount(initialCount), currentDelta(0), currentTime(initialTime), - lastCount(initialCount),lastTime(initialTime), - totalTime(initialTime), - sampleAt(-1), sampleCount(0), name(myName) {}; - - void recordSample(long int thisCount); - void recordSample(double thisTime, long int thisCount); - long int getRunningAverage(); - - long int getAverage() { - return currentCount/totalTime; - }; - - double getTotalTime() { - return totalTime; - }; - long int getCount() { - return currentCount; - }; }; #endif /* defined(__hifi__CounterStat__) */ From d30512e273c9a31afdc6353f458a3fade6229ea5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 12 Apr 2013 15:25:41 -0700 Subject: [PATCH 4/5] remove another long int --- libraries/shared/src/CounterStats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/CounterStats.h b/libraries/shared/src/CounterStats.h index 36b91c6937..7d698d0970 100644 --- a/libraries/shared/src/CounterStats.h +++ b/libraries/shared/src/CounterStats.h @@ -37,7 +37,7 @@ public: totalTime(0.0), sampleAt(-1), sampleCount(0) {}; - CounterStatHistory(std::string myName, double initialTime, long int initialCount) : + CounterStatHistory(std::string myName, double initialTime, long initialCount) : currentCount(initialCount), currentDelta(0), currentTime(initialTime), lastCount(initialCount),lastTime(initialTime), totalTime(initialTime), From f6adac139902eba94bab1268dd5503d8af2f886a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 12 Apr 2013 15:35:06 -0700 Subject: [PATCH 5/5] change a couple more long ints --- libraries/voxels/src/VoxelTree.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/voxels/src/VoxelTree.h b/libraries/voxels/src/VoxelTree.h index 486d560be8..618a3710ae 100644 --- a/libraries/voxels/src/VoxelTree.h +++ b/libraries/voxels/src/VoxelTree.h @@ -19,15 +19,10 @@ const int MAX_TREE_SLICE_BYTES = 26; const int TREE_SCALE = 10; class VoxelTree { - VoxelNode * nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode, VoxelNode** parentOfFoundNode); - VoxelNode * createMissingNode(VoxelNode *lastParentNode, unsigned char *deepestCodeToCreate); - int readNodeData(VoxelNode *destinationNode, unsigned char * nodeData, int bufferSizeBytes); - - public: - long int voxelsCreated; - long int voxelsColored; - long int voxelsBytesRead; + long voxelsCreated; + long voxelsColored; + long voxelsBytesRead; CounterStatHistory voxelsCreatedStats; CounterStatHistory voxelsColoredStats; @@ -56,6 +51,10 @@ public: void loadVoxelsFile(const char* fileName, bool wantColorRandomizer); void createSphere(float r,float xc, float yc, float zc, float s, bool solid, bool wantColorRandomizer); +private: + VoxelNode * nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode, VoxelNode** parentOfFoundNode); + VoxelNode * createMissingNode(VoxelNode *lastParentNode, unsigned char *deepestCodeToCreate); + int readNodeData(VoxelNode *destinationNode, unsigned char * nodeData, int bufferSizeBytes); }; int boundaryDistanceForRenderLevel(unsigned int renderLevel);