Showing the changes to interface/src/VoxelSystem.cpp (1 of 54 files). Show all
Unified · Split
| @@ -5,28 +5,31 @@ · 4 unmodified lines | ||
| 5 | 5 | // Created by Philip on 12/31/12. |
| 6 | 6 | // Copyright (c) 2012 High Fidelity, Inc. All rights reserved. |
| 7 | 7 | // |
| 8 | + | |
| 8 | 9 | #ifdef _WIN32 |
| 9 | 10 | #define _timeval_ |
| 10 | 11 | #define _USE_MATH_DEFINES |
| 11 | 12 | #endif |
| 13 | + | |
| 12 | 14 | #include <cstring> |
| 13 | 15 | #include <cmath> |
| 14 | 16 | #include <iostream> // to load voxels from file |
| 15 | 17 | #include <fstream> // to load voxels from file |
| 18 | +#include <pthread.h> | |
| 19 | + | |
| 16 | 20 | #include <glm/gtc/random.hpp> |
| 17 | −#include <SharedUtil.h> | |
| 21 | + | |
| 22 | +#include <OctalCode.h> | |
| 18 | 23 | #include <PacketHeaders.h> |
| 19 | 24 | #include <PerfStat.h> |
| 20 | −#include <OctalCode.h> | |
| 21 | −#include <pthread.h> | |
| 25 | +#include <SharedUtil.h> | |
| 26 | + | |
| 22 | 27 | #include "Application.h" |
| 23 | −#include "Log.h" | |
| 24 | −#include "VoxelConstants.h" | |
| 25 | 28 | #include "CoverageMap.h" |
| 26 | 29 | #include "CoverageMapV2.h" |
| 27 | 30 | #include "InterfaceConfig.h" |
| 28 | 31 | #include "renderer/ProgramObject.h" |
| 29 | − | |
| 32 | +#include "VoxelConstants.h" | |
| 30 | 33 | #include "VoxelSystem.h" |
| 31 | 34 | |
| 32 | 35 | float identityVertices[] = { 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1, |
| @@ -141,16 +144,16 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 108 unmodified lines | ||
| 141 | 144 | int commandLength = strlen(command); // commands are null terminated strings |
| 142 | 145 | int totalLength = 1+commandLength+1; |
| 143 | 146 | |
| 144 | − printLog("got Z message len(%d)= %s\n", numBytes, command); | |
| 147 | + qDebug("got Z message len(%d)= %s\n", numBytes, command); | |
| 145 | 148 | |
| 146 | 149 | while (totalLength <= numBytes) { |
| 147 | 150 | if (0==strcmp(command,(char*)"erase all")) { |
| 148 | − printLog("got Z message == erase all\n"); | |
| 151 | + qDebug("got Z message == erase all\n"); | |
| 149 | 152 | _tree->eraseAllVoxels(); |
| 150 | 153 | _voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this?? |
| 151 | 154 | } |
| 152 | 155 | if (0==strcmp(command,(char*)"add scene")) { |
| 153 | − printLog("got Z message == add scene - NOT SUPPORTED ON INTERFACE\n"); | |
| 156 | + qDebug("got Z message == add scene - NOT SUPPORTED ON INTERFACE\n"); | |
| 154 | 157 | } |
| 155 | 158 | totalLength += commandLength+1; |
| 156 | 159 | } |
| @@ -705,7 +708,7 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { · 548 unmodified lines | ||
| 705 | 708 | void VoxelSystem::randomizeVoxelColors() { |
| 706 | 709 | _nodeCount = 0; |
| 707 | 710 | _tree->recurseTreeWithOperation(randomColorOperation); |
| 708 | − printLog("setting randomized true color for %d nodes\n", _nodeCount); | |
| 711 | + qDebug("setting randomized true color for %d nodes\n", _nodeCount); | |
| 709 | 712 | setupNewVoxelsForDrawing(); |
| 710 | 713 | } |
| 711 | 714 | |
| @@ -719,7 +722,7 @@ bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) · 7 unmodified lines | ||
| 719 | 722 | void VoxelSystem::falseColorizeRandom() { |
| 720 | 723 | _nodeCount = 0; |
| 721 | 724 | _tree->recurseTreeWithOperation(falseColorizeRandomOperation); |
| 722 | − printLog("setting randomized false color for %d nodes\n", _nodeCount); | |
| 725 | + qDebug("setting randomized false color for %d nodes\n", _nodeCount); | |
| 723 | 726 | setupNewVoxelsForDrawing(); |
| 724 | 727 | } |
| 725 | 728 | |
| @@ -733,7 +736,7 @@ void VoxelSystem::trueColorize() { · 7 unmodified lines | ||
| 733 | 736 | PerformanceWarning warn(true, "trueColorize()",true); |
| 734 | 737 | _nodeCount = 0; |
| 735 | 738 | _tree->recurseTreeWithOperation(trueColorizeOperation); |
| 736 | − printLog("setting true color for %d nodes\n", _nodeCount); | |
| 739 | + qDebug("setting true color for %d nodes\n", _nodeCount); | |
| 737 | 740 | setupNewVoxelsForDrawing(); |
| 738 | 741 | } |
| 739 | 742 | |
| @@ -753,7 +756,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) · 13 unmodified lines | ||
| 753 | 756 | void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { |
| 754 | 757 | _nodeCount = 0; |
| 755 | 758 | _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); |
| 756 | − printLog("setting in view false color for %d nodes\n", _nodeCount); | |
| 759 | + qDebug("setting in view false color for %d nodes\n", _nodeCount); | |
| 757 | 760 | setupNewVoxelsForDrawing(); |
| 758 | 761 | } |
| 759 | 762 | |
| @@ -803,10 +806,10 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { · 43 unmodified lines | ||
| 803 | 806 | _maxDistance = 0.0; |
| 804 | 807 | _minDistance = FLT_MAX; |
| 805 | 808 | _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); |
| 806 | − printLog("determining distance range for %d nodes\n", _nodeCount); | |
| 809 | + qDebug("determining distance range for %d nodes\n", _nodeCount); | |
| 807 | 810 | _nodeCount = 0; |
| 808 | 811 | _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); |
| 809 | − printLog("setting in distance false color for %d nodes\n", _nodeCount); | |
| 812 | + qDebug("setting in distance false color for %d nodes\n", _nodeCount); | |
| 810 | 813 | setupNewVoxelsForDrawing(); |
| 811 | 814 | } |
| 812 | 815 | |
| @@ -918,7 +921,7 @@ void VoxelSystem::removeOutOfView() { · 105 unmodified lines | ||
| 918 | 921 | } |
| 919 | 922 | bool showRemoveDebugDetails = false; |
| 920 | 923 | if (showRemoveDebugDetails) { |
| 921 | − printLog("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d \n", | |
| 924 | + qDebug("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d \n", | |
| 922 | 925 | args.nodesScanned, args.nodesRemoved, args.nodesInside, |
| 923 | 926 | args.nodesIntersect, args.nodesOutside, _removedVoxels.count() |
| 924 | 927 | ); |
| @@ -984,7 +987,7 @@ bool VoxelSystem::falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* · 59 unmodified lines | ||
| 984 | 987 | void VoxelSystem::falseColorizeRandomEveryOther() { |
| 985 | 988 | falseColorizeRandomEveryOtherArgs args; |
| 986 | 989 | _tree->recurseTreeWithOperation(falseColorizeRandomEveryOtherOperation,&args); |
| 987 | − printLog("randomized false color for every other node: total %ld, colorable %ld, colored %ld\n", | |
| 990 | + qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld\n", | |
| 988 | 991 | args.totalNodes, args.colorableNodes, args.coloredNodes); |
| 989 | 992 | setupNewVoxelsForDrawing(); |
| 990 | 993 | } |
| @@ -1045,7 +1048,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex · 54 unmodified lines | ||
| 1045 | 1048 | unsigned long nodeIndex = node->getBufferIndex(); |
| 1046 | 1049 | if (args->hasIndexFound[nodeIndex]) { |
| 1047 | 1050 | args->duplicateVBOIndex++; |
| 1048 | − printLog("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, | |
| 1051 | + qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, | |
| 1049 | 1052 | debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender())); |
| 1050 | 1053 | } else { |
| 1051 | 1054 | args->hasIndexFound[nodeIndex] = true; |
| @@ -1080,13 +1083,13 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { · 28 unmodified lines | ||
| 1080 | 1083 | args.expectedMax = _voxelsInWriteArrays; |
| 1081 | 1084 | _tree->recurseTreeWithOperation(collectStatsForTreesAndVBOsOperation,&args); |
| 1082 | 1085 | |
| 1083 | − printLog("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld \n", | |
| 1086 | + qDebug("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld \n", | |
| 1084 | 1087 | args.totalNodes, args.leafNodes, args.dirtyNodes, args.coloredNodes, args.shouldRenderNodes); |
| 1085 | 1088 | |
| 1086 | − printLog(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld \n", debug::valueOf(_voxelsDirty), | |
| 1089 | + qDebug(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld \n", debug::valueOf(_voxelsDirty), | |
| 1087 | 1090 | _voxelsInWriteArrays, minDirty, maxDirty); |
| 1088 | 1091 | |
| 1089 | − printLog(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld \n", | |
| 1092 | + qDebug(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld \n", | |
| 1090 | 1093 | args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex, args.nodesInVBONotShouldRender); |
| 1091 | 1094 | |
| 1092 | 1095 | glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN; |
| @@ -1099,7 +1102,7 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { · 6 unmodified lines | ||
| 1099 | 1102 | } |
| 1100 | 1103 | } |
| 1101 | 1104 | |
| 1102 | − printLog(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld \n", | |
| 1105 | + qDebug(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld \n", | |
| 1103 | 1106 | minInVBO, maxInVBO, _voxelsInWriteArrays, _voxelsInReadArrays); |
| 1104 | 1107 | |
| 1105 | 1108 | } |
| @@ -1124,7 +1127,7 @@ void VoxelSystem::createVoxel(float x, float y, float z, float s, · 18 unmodified lines | ||
| 1124 | 1127 | unsigned char red, unsigned char green, unsigned char blue, bool destructive) { |
| 1125 | 1128 | pthread_mutex_lock(&_treeLock); |
| 1126 | 1129 | |
| 1127 | − //printLog("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); | |
| 1130 | + //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); | |
| 1128 | 1131 | _tree->createVoxel(x, y, z, s, red, green, blue, destructive); |
| 1129 | 1132 | setupNewVoxelsForDrawing(); |
| 1130 | 1133 | |
| @@ -1250,9 +1253,9 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 119 unmodified lines | ||
| 1250 | 1253 | args->occludedVoxels++; |
| 1251 | 1254 | } else if (result == STORED) { |
| 1252 | 1255 | args->notOccludedVoxels++; |
| 1253 | − //printLog("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); | |
| 1256 | + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); | |
| 1254 | 1257 | } else if (result == DOESNT_FIT) { |
| 1255 | − //printLog("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); | |
| 1258 | + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); | |
| 1256 | 1259 | } |
| 1257 | 1260 | } |
| 1258 | 1261 | return true; // keep going! |
| @@ -1285,7 +1288,7 @@ void VoxelSystem::falseColorizeOccluded() { · 26 unmodified lines | ||
| 1285 | 1288 | |
| 1286 | 1289 | _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedOperation, position, (void*)&args); |
| 1287 | 1290 | |
| 1288 | − printLog("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", | |
| 1291 | + qDebug("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", | |
| 1289 | 1292 | position.x, position.y, |
| 1290 | 1293 | args.totalVoxels, args.coloredVoxels, args.occludedVoxels, |
| 1291 | 1294 | args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, |
| @@ -1371,9 +1374,9 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD · 79 unmodified lines | ||
| 1371 | 1374 | args->occludedVoxels++; |
| 1372 | 1375 | } else if (result == V2_STORED) { |
| 1373 | 1376 | args->notOccludedVoxels++; |
| 1374 | − //printLog("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); | |
| 1377 | + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); | |
| 1375 | 1378 | } else if (result == V2_DOESNT_FIT) { |
| 1376 | − //printLog("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); | |
| 1379 | + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); | |
| 1377 | 1380 | } |
| 1378 | 1381 | delete voxelPolygon; // V2 maps don't store polygons, so we're always in charge of freeing |
| 1379 | 1382 | } |
| @@ -1410,7 +1413,7 @@ void VoxelSystem::falseColorizeOccludedV2() { · 30 unmodified lines | ||
| 1410 | 1413 | |
| 1411 | 1414 | _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedV2Operation, position, (void*)&args); |
| 1412 | 1415 | |
| 1413 | − printLog("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", | |
| 1416 | + qDebug("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", | |
| 1414 | 1417 | position.x, position.y, |
| 1415 | 1418 | args.totalVoxels, args.coloredVoxels, args.occludedVoxels, |
| 1416 | 1419 | args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, |