Showing the changes to interface/src/VoxelSystem.cpp (1 of 28 files). Show all
Unified · Split
| @@ -28,6 +28,7 @@ · 27 unmodified lines | |||
| 28 | #include "CoverageMap.h" | 28 | #include "CoverageMap.h" |
| 29 | #include "CoverageMapV2.h" | 29 | #include "CoverageMapV2.h" |
| 30 | #include "InterfaceConfig.h" | 30 | #include "InterfaceConfig.h" |
| 31 | #include "Menu.h" | ||
| 31 | #include "renderer/ProgramObject.h" | 32 | #include "renderer/ProgramObject.h" |
| 32 | #include "VoxelConstants.h" | 33 | #include "VoxelConstants.h" |
| 33 | #include "VoxelSystem.h" | 34 | #include "VoxelSystem.h" |
| @@ -189,14 +190,16 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 155 unmodified lines | |||
| 189 | 190 | ||
| 190 | switch(command) { | 191 | switch(command) { |
| 191 | case PACKET_TYPE_VOXEL_DATA: { | 192 | case PACKET_TYPE_VOXEL_DATA: { |
| 192 | PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); | 193 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 194 | "readBitstreamToTree()"); | ||
| 193 | // ask the VoxelTree to read the bitstream into the tree | 195 | // ask the VoxelTree to read the bitstream into the tree |
| 194 | ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); | 196 | ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); |
| 195 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); | 197 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); |
| 196 | } | 198 | } |
| 197 | break; | 199 | break; |
| 198 | case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { | 200 | case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { |
| 199 | PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); | 201 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 202 | "readBitstreamToTree()"); | ||
| 200 | // ask the VoxelTree to read the MONOCHROME bitstream into the tree | 203 | // ask the VoxelTree to read the MONOCHROME bitstream into the tree |
| 201 | ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); | 204 | ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); |
| 202 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); | 205 | _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); |
| @@ -238,7 +241,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 35 unmodified lines | |||
| 238 | } | 241 | } |
| 239 | 242 | ||
| 240 | void VoxelSystem::setupNewVoxelsForDrawing() { | 243 | void VoxelSystem::setupNewVoxelsForDrawing() { |
| 241 | PerformanceWarning warn(_renderWarningsOn, "setupNewVoxelsForDrawing()"); // would like to include _voxelsInArrays, _voxelsUpdated | 244 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 245 | "setupNewVoxelsForDrawing()"); // would like to include _voxelsInArrays, _voxelsUpdated | ||
| 242 | uint64_t start = usecTimestampNow(); | 246 | uint64_t start = usecTimestampNow(); |
| 243 | uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; | 247 | uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; |
| 244 | 248 | ||
| @@ -273,10 +277,10 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 28 unmodified lines | |||
| 273 | bool didWriteFullVBO = _writeRenderFullVBO; | 277 | bool didWriteFullVBO = _writeRenderFullVBO; |
| 274 | if (_tree->isDirty()) { | 278 | if (_tree->isDirty()) { |
| 275 | static char buffer[64] = { 0 }; | 279 | static char buffer[64] = { 0 }; |
| 276 | if (_renderWarningsOn) { | 280 | if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) { |
| 277 | sprintf(buffer, "newTreeToArrays() _writeRenderFullVBO=%s", debug::valueOf(_writeRenderFullVBO)); | 281 | sprintf(buffer, "newTreeToArrays() _writeRenderFullVBO=%s", debug::valueOf(_writeRenderFullVBO)); |
| 278 | }; | 282 | }; |
| 279 | PerformanceWarning warn(_renderWarningsOn, buffer); | 283 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), buffer); |
| 280 | _callsToTreesToArrays++; | 284 | _callsToTreesToArrays++; |
| 281 | if (_writeRenderFullVBO) { | 285 | if (_writeRenderFullVBO) { |
| 282 | _voxelsInWriteArrays = 0; // reset our VBO | 286 | _voxelsInWriteArrays = 0; // reset our VBO |
| @@ -315,7 +319,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 32 unmodified lines | |||
| 315 | } | 319 | } |
| 316 | 320 | ||
| 317 | void VoxelSystem::cleanupRemovedVoxels() { | 321 | void VoxelSystem::cleanupRemovedVoxels() { |
| 318 | PerformanceWarning warn(_renderWarningsOn, "cleanupRemovedVoxels()"); | 322 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "cleanupRemovedVoxels()"); |
| 319 | // This handles cleanup of voxels that were culled as part of our regular out of view culling operation | 323 | // This handles cleanup of voxels that were culled as part of our regular out of view culling operation |
| 320 | if (!_removedVoxels.isEmpty()) { | 324 | if (!_removedVoxels.isEmpty()) { |
| 321 | while (!_removedVoxels.isEmpty()) { | 325 | while (!_removedVoxels.isEmpty()) { |
| @@ -391,7 +395,8 @@ void VoxelSystem::copyWrittenDataSegmentToReadArrays(glBufferIndex segmentStart, · 69 unmodified lines | |||
| 391 | } | 395 | } |
| 392 | 396 | ||
| 393 | void VoxelSystem::copyWrittenDataToReadArrays(bool fullVBOs) { | 397 | void VoxelSystem::copyWrittenDataToReadArrays(bool fullVBOs) { |
| 394 | PerformanceWarning warn(_renderWarningsOn, "copyWrittenDataToReadArrays()"); | 398 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 399 | "copyWrittenDataToReadArrays()"); | ||
| 395 | if (_voxelsDirty && _voxelsUpdated) { | 400 | if (_voxelsDirty && _voxelsUpdated) { |
| 396 | if (fullVBOs) { | 401 | if (fullVBOs) { |
| 397 | copyWrittenDataToReadArraysFullVBOs(); | 402 | copyWrittenDataToReadArraysFullVBOs(); |
| @@ -525,8 +530,6 @@ glm::vec3 VoxelSystem::computeVoxelVertex(const glm::vec3& startVertex, float vo · 127 unmodified lines | |||
| 525 | ProgramObject* VoxelSystem::_perlinModulateProgram = 0; | 530 | ProgramObject* VoxelSystem::_perlinModulateProgram = 0; |
| 526 | 531 | ||
| 527 | void VoxelSystem::init() { | 532 | void VoxelSystem::init() { |
| 528 | |||
| 529 | _renderWarningsOn = false; | ||
| 530 | _callsToTreesToArrays = 0; | 533 | _callsToTreesToArrays = 0; |
| 531 | _setupNewVoxelsForDrawingLastFinished = 0; | 534 | _setupNewVoxelsForDrawingLastFinished = 0; |
| 532 | _setupNewVoxelsForDrawingLastElapsed = 0; | 535 | _setupNewVoxelsForDrawingLastElapsed = 0; |
| @@ -657,10 +660,11 @@ void VoxelSystem::updatePartialVBOs() { · 124 unmodified lines | |||
| 657 | 660 | ||
| 658 | void VoxelSystem::updateVBOs() { | 661 | void VoxelSystem::updateVBOs() { |
| 659 | static char buffer[40] = { 0 }; | 662 | static char buffer[40] = { 0 }; |
| 660 | if (_renderWarningsOn) { | 663 | if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) { |
| 661 | sprintf(buffer, "updateVBOs() _readRenderFullVBO=%s", debug::valueOf(_readRenderFullVBO)); | 664 | sprintf(buffer, "updateVBOs() _readRenderFullVBO=%s", debug::valueOf(_readRenderFullVBO)); |
| 662 | }; | 665 | }; |
| 663 | PerformanceWarning warn(_renderWarningsOn, buffer); // would like to include _callsToTreesToArrays | 666 | // would like to include _callsToTreesToArrays |
| 667 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), buffer); | ||
| 664 | if (_voxelsDirty) { | 668 | if (_voxelsDirty) { |
| 665 | if (_readRenderFullVBO) { | 669 | if (_readRenderFullVBO) { |
| 666 | updateFullVBOs(); | 670 | updateFullVBOs(); |
| @@ -688,7 +692,7 @@ void VoxelSystem::updateVBOSegment(glBufferIndex segmentStart, glBufferIndex seg · 21 unmodified lines | |||
| 688 | } | 692 | } |
| 689 | 693 | ||
| 690 | void VoxelSystem::render(bool texture) { | 694 | void VoxelSystem::render(bool texture) { |
| 691 | PerformanceWarning warn(_renderWarningsOn, "render()"); | 695 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "render()"); |
| 692 | 696 | ||
| 693 | // get the lock so that the update thread won't change anything | 697 | // get the lock so that the update thread won't change anything |
| 694 | pthread_mutex_lock(&_bufferWriteLock); | 698 | pthread_mutex_lock(&_bufferWriteLock); |
| @@ -824,7 +828,9 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) · 129 unmodified lines | |||
| 824 | return true; // keep going! | 828 | return true; // keep going! |
| 825 | } | 829 | } |
| 826 | 830 | ||
| 827 | void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { | 831 | void VoxelSystem::falseColorizeInView() { |
| 832 | ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum(); | ||
| 833 | |||
| 828 | _nodeCount = 0; | 834 | _nodeCount = 0; |
| 829 | _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); | 835 | _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); |
| 830 | qDebug("setting in view false color for %d nodes\n", _nodeCount); | 836 | qDebug("setting in view false color for %d nodes\n", _nodeCount); |
| @@ -951,14 +957,16 @@ bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, void* extra · 120 unmodified lines | |||
| 951 | return true; // keep going! | 957 | return true; // keep going! |
| 952 | } | 958 | } |
| 953 | 959 | ||
| 954 | void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { | 960 | void VoxelSystem::falseColorizeDistanceFromView() { |
| 961 | ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum(); | ||
| 962 | |||
| 955 | _nodeCount = 0; | 963 | _nodeCount = 0; |
| 956 | _maxDistance = 0.0; | 964 | _maxDistance = 0.0; |
| 957 | _minDistance = FLT_MAX; | 965 | _minDistance = FLT_MAX; |
| 958 | _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); | 966 | _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) viewFrustum); |
| 959 | qDebug("determining distance range for %d nodes\n", _nodeCount); | 967 | qDebug("determining distance range for %d nodes\n", _nodeCount); |
| 960 | _nodeCount = 0; | 968 | _nodeCount = 0; |
| 961 | _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); | 969 | _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) viewFrustum); |
| 962 | qDebug("setting in distance false color for %d nodes\n", _nodeCount); | 970 | qDebug("setting in distance false color for %d nodes\n", _nodeCount); |
| 963 | _tree->setDirtyBit(); | 971 | _tree->setDirtyBit(); |
| 964 | setupNewVoxelsForDrawing(); | 972 | setupNewVoxelsForDrawing(); |
| @@ -1063,7 +1071,7 @@ bool VoxelSystem::hasViewChanged() { · 98 unmodified lines | |||
| 1063 | } | 1071 | } |
| 1064 | 1072 | ||
| 1065 | void VoxelSystem::removeOutOfView() { | 1073 | void VoxelSystem::removeOutOfView() { |
| 1066 | PerformanceWarning warn(_renderWarningsOn, "removeOutOfView()"); | 1074 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "removeOutOfView()"); |
| 1067 | removeOutOfViewArgs args(this); | 1075 | removeOutOfViewArgs args(this); |
| 1068 | _tree->recurseTreeWithOperation(removeOutOfViewOperation,(void*)&args); | 1076 | _tree->recurseTreeWithOperation(removeOutOfViewOperation,(void*)&args); |
| 1069 | 1077 | ||