From 7a5ce57b4e95ff65e6f6fcab49fb66c499b513d5 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 8 May 2013 12:01:55 -0700 Subject: [PATCH 1/2] added alwaysDisplay mode to PerformanceWarnings class --- interface/src/VoxelSystem.cpp | 1 + libraries/shared/src/PerfStat.cpp | 5 +++-- libraries/shared/src/PerfStat.h | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 3920522503..3d5880c305 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -503,6 +503,7 @@ bool VoxelSystem::trueColorizeOperation(VoxelNode* node, void* extraData) { } void VoxelSystem::trueColorize() { + PerformanceWarning warn(true, "trueColorize()",true); _nodeCount = 0; _tree->recurseTreeWithOperation(trueColorizeOperation); printLog("setting true color for %d nodes\n", _nodeCount); diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index 5b4d1cc591..87998599aa 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -108,15 +108,16 @@ int PerfStat::DumpStats(char** array) { PerformanceWarning::~PerformanceWarning() { double end = usecTimestampNow(); double elapsedmsec = (end - _start) / 1000.0; - if (_renderWarningsOn && elapsedmsec > 1) { + if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) { if (elapsedmsec > 1000) { double elapsedsec = (end - _start) / 1000000.0; printLog("WARNING! %s took %lf seconds\n", _message, elapsedsec); } else { printLog("WARNING! %s took %lf milliseconds\n", _message, elapsedmsec); } + } else if (_alwaysDisplay) { + printLog("WARNING! %s took %lf milliseconds\n", _message, elapsedmsec); } - }; diff --git a/libraries/shared/src/PerfStat.h b/libraries/shared/src/PerfStat.h index 09d351a11b..8898899960 100644 --- a/libraries/shared/src/PerfStat.h +++ b/libraries/shared/src/PerfStat.h @@ -87,11 +87,13 @@ private: double _start; const char* _message; bool _renderWarningsOn; + bool _alwaysDisplay; public: - PerformanceWarning(bool renderWarnings, const char* message) : + PerformanceWarning(bool renderWarnings, const char* message, bool alwaysDisplay = false) : _start(usecTimestampNow()), _message(message), - _renderWarningsOn(renderWarnings) { }; + _renderWarningsOn(renderWarnings), + _alwaysDisplay(alwaysDisplay) { }; ~PerformanceWarning(); }; From 2f3a7f8ea89e267ed0b032cfdb6e0e7b12a3260d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 8 May 2013 12:19:27 -0700 Subject: [PATCH 2/2] use different voxel persist files for local or server mode --- libraries/voxels/src/VoxelTree.cpp | 4 +++- voxel-server/src/main.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 0c605aee62..daf2e01a72 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -933,7 +933,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEnco bool VoxelTree::readFromFileV2(const char* fileName) { std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); if(file.is_open()) { - printLog("loading file...\n"); + printLog("loading file %s...\n", fileName); // get file length.... unsigned long fileLength = file.tellg(); @@ -956,6 +956,8 @@ void VoxelTree::writeToFileV2(const char* fileName) const { std::ofstream file(fileName, std::ios::out|std::ios::binary); if(file.is_open()) { + printLog("saving to file %s...\n", fileName); + VoxelNodeBag nodeBag; nodeBag.insert(rootNode); diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index f7d4567711..50c19c2118 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -28,7 +28,8 @@ #include #endif -const char* VOXELS_PERSIST_FILE = "resources/voxels.hio2"; +const char* LOCAL_VOXELS_PERSIST_FILE = "resources/voxels.hio2"; +const char* VOXELS_PERSIST_FILE = "/etc/highfidelity/voxel-server/resources/voxels.hio2"; const int VOXEL_LISTEN_PORT = 40106; @@ -47,6 +48,8 @@ const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4; VoxelTree randomTree; bool wantVoxelPersist = true; +bool wantLocalDomain = false; + bool wantColorRandomizer = false; bool debugVoxelSending = false; @@ -207,7 +210,7 @@ void persistVoxelsWhenDirty() { // check the dirty bit and persist here... if (::wantVoxelPersist && ::randomTree.isDirty()) { printf("saving voxels to file...\n"); - randomTree.writeToFileV2(VOXELS_PERSIST_FILE); + randomTree.writeToFileV2(::wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE); randomTree.clearDirtyBit(); // tree is clean after saving printf("DONE saving voxels to file...\n"); } @@ -270,8 +273,8 @@ int main(int argc, const char * argv[]) // Handle Local Domain testing with the --local command line const char* local = "--local"; - bool wantLocalDomain = cmdOptionExists(argc, argv,local); - if (wantLocalDomain) { + ::wantLocalDomain = cmdOptionExists(argc, argv,local); + if (::wantLocalDomain) { printf("Local Domain MODE!\n"); int ip = getLocalAddress(); sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF)); @@ -302,7 +305,7 @@ int main(int argc, const char * argv[]) bool persistantFileRead = false; if (::wantVoxelPersist) { printf("loading voxels from file...\n"); - persistantFileRead = ::randomTree.readFromFileV2(VOXELS_PERSIST_FILE); + persistantFileRead = ::randomTree.readFromFileV2(::wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE); ::randomTree.clearDirtyBit(); // the tree is clean since we just loaded it printf("DONE loading voxels from file...\n"); unsigned long nodeCount = ::randomTree.getVoxelCount();