Showing the changes to interface/src/VoxelSystem.cpp (1 of 7 files). Show all
Unified · Split
| @@ -592,14 +592,15 @@ float VoxelSystem::getVoxelsBytesReadPerSecondAverage() { · 591 unmodified lines | ||
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { |
| 595 | + bool showTimingDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 596 | + PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData()",showTimingDetails); | |
| 595 | 597 | |
| 596 | 598 | unsigned char command = *sourceBuffer; |
| 597 | 599 | int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer); |
| 598 | 600 | switch(command) { |
| 599 | 601 | case PACKET_TYPE_VOXEL_DATA: { |
| 600 | − PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 601 | − "readBitstreamToTree()"); | |
| 602 | − | |
| 602 | + PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PACKET_TYPE_VOXEL_DATA part...",showTimingDetails); | |
| 603 | + | |
| 603 | 604 | unsigned char* dataAt = sourceBuffer + numBytesPacketHeader; |
| 604 | 605 | |
| 605 | 606 | VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt)); |
| @@ -641,7 +642,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 35 unmodified lines | ||
| 641 | 642 | VoxelPacketData packetData(packetIsCompressed); |
| 642 | 643 | packetData.loadFinalizedContent(dataAt, sectionLength); |
| 643 | 644 | if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) { |
| 644 | − qDebug("Got Packet color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d" | |
| 645 | + qDebug("VoxelSystem::parseData() ... Got Packet Section" | |
| 646 | + " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d" | |
| 645 | 647 | " subsection:%d sectionLength:%d uncompressed:%d\n", |
| 646 | 648 | debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), |
| 647 | 649 | sequence, flightTime, numBytes, dataBytes, subsection, sectionLength, packetData.getUncompressedSize()); |
| @@ -657,12 +659,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 9 unmodified lines | ||
| 657 | 659 | } |
| 658 | 660 | break; |
| 659 | 661 | } |
| 660 | − | |
| 661 | − | |
| 662 | 662 | if (!_useFastVoxelPipeline || _writeRenderFullVBO) { |
| 663 | 663 | setupNewVoxelsForDrawing(); |
| 664 | 664 | } else { |
| 665 | − checkForCulling(); | |
| 666 | 665 | setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY); |
| 667 | 666 | } |
| 668 | 667 | |
| @@ -689,8 +688,6 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 20 unmodified lines | ||
| 689 | 688 | |
| 690 | 689 | _inSetupNewVoxelsForDrawing = true; |
| 691 | 690 | |
| 692 | − checkForCulling(); // check for out of view and deleted voxels... | |
| 693 | − | |
| 694 | 691 | bool didWriteFullVBO = _writeRenderFullVBO; |
| 695 | 692 | if (_tree->isDirty()) { |
| 696 | 693 | static char buffer[64] = { 0 }; |
| @@ -776,68 +773,44 @@ void VoxelSystem::checkForCulling() { · 79 unmodified lines | ||
| 776 | 773 | |
| 777 | 774 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "checkForCulling()"); |
| 778 | 775 | uint64_t start = usecTimestampNow(); |
| 779 | − uint64_t sinceLastViewCulling = (start - _lastViewCulling) / 1000; | |
| 780 | 776 | |
| 781 | − // These items used to be menu options, we are not defaulting to and only supporting these modes. | |
| 782 | − bool constantCulling = true; | |
| 783 | − bool performHideOutOfViewLogic = true; | |
| 784 | − bool performRemoveOutOfViewLogic = false; | |
| 785 | 777 | |
| 786 | − // If the view frustum is no longer changing, but has changed, since last time, then remove nodes that are out of view | |
| 787 | − if (constantCulling || ( | |
| 788 | − (sinceLastViewCulling >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) | |
| 789 | − && !isViewChanging() | |
| 790 | − ) | |
| 791 | − ) { | |
| 792 | − // When we call removeOutOfView() voxels, we don't actually remove the voxels from the VBOs, but we do remove | |
| 793 | − // them from tree, this makes our tree caclulations faster, but doesn't require us to fully rebuild the VBOs (which | |
| 794 | − // can be expensive). | |
| 795 | − if (performHideOutOfViewLogic) { | |
| 796 | − | |
| 797 | − // track how long its been since we were last moving. If we have recently moved then only use delta frustums, if | |
| 798 | − // it's been a long time since we last moved, then go ahead and do a full frustum cull. | |
| 799 | − if (isViewChanging()) { | |
| 800 | − _lastViewIsChanging = start; | |
| 801 | − } | |
| 802 | − uint64_t sinceLastMoving = (start - _lastViewIsChanging) / 1000; | |
| 778 | + // track how long its been since we were last moving. If we have recently moved then only use delta frustums, if | |
| 779 | + // it's been a long time since we last moved, then go ahead and do a full frustum cull. | |
| 780 | + if (isViewChanging()) { | |
| 781 | + _lastViewIsChanging = start; | |
| 782 | + } | |
| 783 | + uint64_t sinceLastMoving = (start - _lastViewIsChanging) / 1000; | |
| 803 | 784 | |
| 804 | − bool enoughTime = (sinceLastMoving >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)); | |
| 785 | + bool enoughTime = (sinceLastMoving >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)); | |
| 805 | 786 | |
| 806 | − // These has changed events will occur before we stop. So we need to remember this for when we finally have stopped | |
| 807 | − // moving long enough to be enoughTime | |
| 808 | − if (hasViewChanged()) { | |
| 809 | − _hasRecentlyChanged = true; | |
| 810 | − } | |
| 811 | − | |
| 812 | − // If we have recently changed, but it's been enough time since we last moved, then we will do a full frustum | |
| 813 | − // hide/show culling pass | |
| 814 | − bool forceFullFrustum = enoughTime && _hasRecentlyChanged; | |
| 815 | − | |
| 816 | − // in hide mode, we only track the full frustum culls, because we don't care about the partials. | |
| 817 | − if (forceFullFrustum) { | |
| 818 | − _lastViewCulling = start; | |
| 819 | − _hasRecentlyChanged = false; | |
| 820 | − } | |
| 821 | − | |
| 822 | − hideOutOfView(forceFullFrustum); | |
| 787 | + // These has changed events will occur before we stop. So we need to remember this for when we finally have stopped | |
| 788 | + // moving long enough to be enoughTime | |
| 789 | + if (hasViewChanged()) { | |
| 790 | + _hasRecentlyChanged = true; | |
| 791 | + } | |
| 823 | 792 | |
| 824 | − if (forceFullFrustum) { | |
| 825 | − uint64_t endViewCulling = usecTimestampNow(); | |
| 826 | − _lastViewCullingElapsed = (endViewCulling - start) / 1000; | |
| 827 | − } | |
| 793 | + // If we have recently changed, but it's been enough time since we last moved, then we will do a full frustum | |
| 794 | + // hide/show culling pass | |
| 795 | + bool forceFullFrustum = enoughTime && _hasRecentlyChanged; | |
| 828 | 796 | |
| 829 | − } else if (performRemoveOutOfViewLogic) { | |
| 830 | − _lastViewCulling = start; | |
| 831 | − removeOutOfView(); | |
| 832 | − uint64_t endViewCulling = usecTimestampNow(); | |
| 833 | − _lastViewCullingElapsed = (endViewCulling - start) / 1000; | |
| 834 | − } | |
| 835 | − | |
| 836 | − // Once we call cleanupRemovedVoxels() we do need to rebuild our VBOs (if anything was actually removed). So, | |
| 837 | − // we should consider putting this someplace else... as this might be able to occur less frequently, and save us on | |
| 838 | − // VBO reubuilding. Possibly we should do this only if our actual VBO usage crosses some lower boundary. | |
| 839 | − cleanupRemovedVoxels(); | |
| 797 | + // in hide mode, we only track the full frustum culls, because we don't care about the partials. | |
| 798 | + if (forceFullFrustum) { | |
| 799 | + _lastViewCulling = start; | |
| 800 | + _hasRecentlyChanged = false; | |
| 840 | 801 | } |
| 802 | + | |
| 803 | + hideOutOfView(forceFullFrustum); | |
| 804 | + | |
| 805 | + if (forceFullFrustum) { | |
| 806 | + uint64_t endViewCulling = usecTimestampNow(); | |
| 807 | + _lastViewCullingElapsed = (endViewCulling - start) / 1000; | |
| 808 | + } | |
| 809 | + | |
| 810 | + // Once we call cleanupRemovedVoxels() we do need to rebuild our VBOs (if anything was actually removed). So, | |
| 811 | + // we should consider putting this someplace else... as this might be able to occur less frequently, and save us on | |
| 812 | + // VBO reubuilding. Possibly we should do this only if our actual VBO usage crosses some lower boundary. | |
| 813 | + cleanupRemovedVoxels(); | |
| 841 | 814 | |
| 842 | 815 | uint64_t sinceLastAudit = (start - _lastAudit) / 1000; |
| 843 | 816 | |