From 7c9be4b9f5c93e3305a09ca8a03b5b30e8055d22 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 21 May 2013 11:42:13 -0700 Subject: [PATCH] cleanup code --- interface/src/VoxelSystem.cpp | 8 ++++---- libraries/shared/src/SharedUtil.h | 5 +++-- libraries/voxels/src/ViewFrustum.cpp | 2 +- libraries/voxels/src/VoxelNode.cpp | 4 ++-- voxel-server/src/main.cpp | 17 ++++++++--------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index ac8b71f66e..a610adf517 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -182,7 +182,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { if (_tree->isDirty()) { static char buffer[64] = { 0 }; if (_renderWarningsOn) { - sprintf(buffer, "newTreeToArrays() _writeRenderFullVBO=%s", (_writeRenderFullVBO ? "yes" : "no")); + sprintf(buffer, "newTreeToArrays() _writeRenderFullVBO=%s", debug::valueOf(_writeRenderFullVBO)); }; PerformanceWarning warn(_renderWarningsOn, buffer); _callsToTreesToArrays++; @@ -610,7 +610,7 @@ void VoxelSystem::updatePartialVBOs() { void VoxelSystem::updateVBOs() { static char buffer[40] = { 0 }; if (_renderWarningsOn) { - sprintf(buffer, "updateVBOs() _readRenderFullVBO=%s", (_readRenderFullVBO ? "yes" : "no")); + sprintf(buffer, "updateVBOs() _readRenderFullVBO=%s", debug::valueOf(_readRenderFullVBO)); }; PerformanceWarning warn(_renderWarningsOn, buffer); // would like to include _callsToTreesToArrays if (_voxelsDirty) { @@ -1011,7 +1011,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex if (args->hasIndexFound[nodeIndex]) { args->duplicateVBOIndex++; printLog("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, - node->isDirty() ? "yes" : "no" , node->getShouldRender() ? "yes" : "no" ); + debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender())); } else { args->hasIndexFound[nodeIndex] = true; } @@ -1040,7 +1040,7 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { args.expectedMax = _voxelsInWriteArrays; _tree->recurseTreeWithOperation(collectStatsForTreesAndVBOsOperation,&args); - printLog("_voxelsDirty=%s _voxelsInWriteArrays=%ld minDirty=%ld maxDirty=%ld \n", (_voxelsDirty ? "yes" : "no"), + printLog("_voxelsDirty=%s _voxelsInWriteArrays=%ld minDirty=%ld maxDirty=%ld \n", debug::valueOf(_voxelsDirty), _voxelsInWriteArrays, minDirty, maxDirty); printLog("stats: total %ld, leaves %ld, dirty %ld, colored %ld, shouldRender %ld, inVBO %ld\n", diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index ebaa802890..2458e1e5a2 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -80,8 +80,9 @@ int insertIntoSortedArrays(void* value, float key, int originalIndex, void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount); -class debugHelpers { +// Helper Class for debugging +class debug { public: - static const char* booleanValue(bool checkValue) { return checkValue ? "yes" : "no"; }; + static const char* valueOf(bool checkValue) { return checkValue ? "yes" : "no"; }; }; #endif /* defined(__hifi__SharedUtil__) */ diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index cce3eac76f..d03678ce42 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -243,7 +243,7 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo) const { compareTo._eyeOffsetOrientation == _eyeOffsetOrientation; if (!result && debug) { - printLog("ViewFrustum::matches()... result=%s\n", (result ? "yes" : "no")); + printLog("ViewFrustum::matches()... result=%s\n", debug::valueOf(result)); printLog("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f\n", (compareTo._position == _position ? "MATCHES " : "NO MATCH"), compareTo._position.x, compareTo._position.y, compareTo._position.z, diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index d33b7c1051..cb9558a466 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -278,8 +278,8 @@ void VoxelNode::printDebugDetails(const char* label) const { printLog("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s isDirty=%s shouldRender=%s\n children=", label, _box.getCorner().x, _box.getCorner().y, _box.getCorner().z, _box.getSize().x, - debugHelpers::booleanValue(isLeaf()), debugHelpers::booleanValue(isColored()), debugHelpers::booleanValue(isDirty()), - debugHelpers::booleanValue(getShouldRender()) ); + debug::valueOf(isLeaf()), debug::valueOf(isColored()), debug::valueOf(isDirty()), + debug::valueOf(getShouldRender()) ); outputBits(childBits,false); printLog("\n octalCode="); diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index a55e415e50..930356a7b5 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -247,9 +247,8 @@ void deepestLevelVoxelDistributor(AgentList* agentList, if (::debugVoxelSending) { printf("deepestLevelVoxelDistributor() viewFrustumChanged=%s, nodeBag.isEmpty=%s, viewSent=%s\n", - viewFrustumChanged ? "yes" : "no", - agentData->nodeBag.isEmpty() ? "yes" : "no", - agentData->getViewSent() ? "yes" : "no" + debug::valueOf(viewFrustumChanged), debug::valueOf(agentData->nodeBag.isEmpty()), + debug::valueOf(agentData->getViewSent()) ); } @@ -416,7 +415,7 @@ void *distributeVoxelsToListeners(void *args) { if (agentData) { bool viewFrustumChanged = agentData->updateCurrentViewFrustum(); if (::debugVoxelSending) { - printf("agentData->updateCurrentViewFrustum() changed=%s\n", (viewFrustumChanged ? "yes" : "no")); + printf("agentData->updateCurrentViewFrustum() changed=%s\n", debug::valueOf(viewFrustumChanged)); } if (agentData->getWantResIn()) { @@ -468,22 +467,22 @@ int main(int argc, const char * argv[]) const char* DEBUG_VOXEL_SENDING = "--debugVoxelSending"; ::debugVoxelSending = cmdOptionExists(argc, argv, DEBUG_VOXEL_SENDING); - printf("debugVoxelSending=%s\n", (::debugVoxelSending ? "yes" : "no")); + printf("debugVoxelSending=%s\n", debug::valueOf(::debugVoxelSending)); const char* WANT_ANIMATION_DEBUG = "--shouldShowAnimationDebug"; ::shouldShowAnimationDebug = cmdOptionExists(argc, argv, WANT_ANIMATION_DEBUG); - printf("shouldShowAnimationDebug=%s\n", (::shouldShowAnimationDebug ? "yes" : "no")); + printf("shouldShowAnimationDebug=%s\n", debug::valueOf(::shouldShowAnimationDebug)); const char* WANT_COLOR_RANDOMIZER = "--wantColorRandomizer"; ::wantColorRandomizer = cmdOptionExists(argc, argv, WANT_COLOR_RANDOMIZER); - printf("wantColorRandomizer=%s\n", (::wantColorRandomizer ? "yes" : "no")); + printf("wantColorRandomizer=%s\n", debug::valueOf(::wantColorRandomizer)); // By default we will voxel persist, if you want to disable this, then pass in this parameter const char* NO_VOXEL_PERSIST = "--NoVoxelPersist"; if (cmdOptionExists(argc, argv, NO_VOXEL_PERSIST)) { ::wantVoxelPersist = false; } - printf("wantVoxelPersist=%s\n", (::wantVoxelPersist ? "yes" : "no")); + printf("wantVoxelPersist=%s\n", debug::valueOf(::wantVoxelPersist)); // if we want Voxel Persistance, load the local file now... bool persistantFileRead = false; @@ -491,7 +490,7 @@ int main(int argc, const char * argv[]) printf("loading voxels from file...\n"); 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... fileRead=%s\n", persistantFileRead ? "yes" : "no" ); + printf("DONE loading voxels from file... fileRead=%s\n", debug::valueOf(persistantFileRead)); unsigned long nodeCount = ::randomTree.getVoxelCount(); printf("Nodes after loading scene %ld nodes\n", nodeCount); }