Showing the changes to interface/src/VoxelSystem.cpp (1 of 243 files). Show all
Unified · Split
| @@ -16,7 +16,6 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <PerfStat.h> |
| 17 | 17 | #include <SharedUtil.h> |
| 18 | 18 | #include <NodeList.h> |
| 19 | −#include <NodeTypes.h> | |
| 20 | 19 | |
| 21 | 20 | #include "Application.h" |
| 22 | 21 | #include "CoverageMap.h" |
| @@ -581,17 +580,17 @@ bool VoxelSystem::readFromSchematicFile(const char* filename) { · 558 unmodified lines | ||
| 581 | 580 | return result; |
| 582 | 581 | } |
| 583 | 582 | |
| 584 | −int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { | |
| 583 | +int VoxelSystem::parseData(const QByteArray& packet) { | |
| 585 | 584 | bool showTimingDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 586 | 585 | PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData()",showTimingDetails); |
| 587 | 586 | |
| 588 | − unsigned char command = *sourceBuffer; | |
| 589 | − int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer); | |
| 587 | + PacketType command = packetTypeForPacket(packet); | |
| 588 | + int numBytesPacketHeader = numBytesForPacketHeader(packet); | |
| 590 | 589 | switch(command) { |
| 591 | − case PACKET_TYPE_VOXEL_DATA: { | |
| 592 | − PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PACKET_TYPE_VOXEL_DATA part...",showTimingDetails); | |
| 593 | − | |
| 594 | − unsigned char* dataAt = sourceBuffer + numBytesPacketHeader; | |
| 590 | + case PacketTypeVoxelData: { | |
| 591 | + PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PacketType_VOXEL_DATA part...",showTimingDetails); | |
| 592 | + | |
| 593 | + const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader; | |
| 595 | 594 | |
| 596 | 595 | VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt)); |
| 597 | 596 | dataAt += sizeof(VOXEL_PACKET_FLAGS); |
| @@ -608,7 +607,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 10 unmodified lines | ||
| 608 | 607 | int flightTime = arrivedAt - sentAt; |
| 609 | 608 | |
| 610 | 609 | VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0; |
| 611 | − int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE; | |
| 610 | + int dataBytes = packet.size() - VOXEL_PACKET_HEADER_SIZE; | |
| 612 | 611 | |
| 613 | 612 | int subsection = 1; |
| 614 | 613 | while (dataBytes > 0) { |
| @@ -636,7 +635,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 21 unmodified lines | ||
| 636 | 635 | " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d" |
| 637 | 636 | " subsection:%d sectionLength:%d uncompressed:%d", |
| 638 | 637 | debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), |
| 639 | − sequence, flightTime, numBytes, dataBytes, subsection, sectionLength, packetData.getUncompressedSize()); | |
| 638 | + sequence, flightTime, packet.size(), dataBytes, subsection, sectionLength, | |
| 639 | + packetData.getUncompressedSize()); | |
| 640 | 640 | } |
| 641 | 641 | _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args); |
| 642 | 642 | unlockTree(); |
| @@ -647,7 +647,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 4 unmodified lines | ||
| 647 | 647 | } |
| 648 | 648 | subsection++; |
| 649 | 649 | } |
| 650 | − break; | |
| 650 | + default: | |
| 651 | + break; | |
| 651 | 652 | } |
| 652 | 653 | if (!_useFastVoxelPipeline || _writeRenderFullVBO) { |
| 653 | 654 | setupNewVoxelsForDrawing(); |
| @@ -655,9 +656,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 1 unmodified line | ||
| 655 | 656 | setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY); |
| 656 | 657 | } |
| 657 | 658 | |
| 658 | − Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes); | |
| 659 | + Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(packet.size()); | |
| 659 | 660 | |
| 660 | − return numBytes; | |
| 661 | + return packet.size(); | |
| 661 | 662 | } |
| 662 | 663 | |
| 663 | 664 | void VoxelSystem::setupNewVoxelsForDrawing() { |
| @@ -668,8 +669,8 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 4 unmodified lines | ||
| 668 | 669 | return; // bail early if we're not initialized |
| 669 | 670 | } |
| 670 | 671 | |
| 671 | − uint64_t start = usecTimestampNow(); | |
| 672 | − uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; | |
| 672 | + quint64 start = usecTimestampNow(); | |
| 673 | + quint64 sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; | |
| 673 | 674 | |
| 674 | 675 | bool iAmDebugging = false; // if you're debugging set this to true, so you won't get skipped for slow debugging |
| 675 | 676 | if (!iAmDebugging && sinceLastTime <= std::max((float) _setupNewVoxelsForDrawingLastElapsed, SIXTY_FPS_IN_MILLISECONDS)) { |
| @@ -729,7 +730,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 53 unmodified lines | ||
| 729 | 730 | _bufferWriteLock.unlock(); |
| 730 | 731 | } |
| 731 | 732 | |
| 732 | − uint64_t end = usecTimestampNow(); | |
| 733 | + quint64 end = usecTimestampNow(); | |
| 733 | 734 | int elapsedmsec = (end - start) / 1000; |
| 734 | 735 | _setupNewVoxelsForDrawingLastFinished = end; |
| 735 | 736 | _setupNewVoxelsForDrawingLastElapsed = elapsedmsec; |
| @@ -746,8 +747,8 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) { · 10 unmodified lines | ||
| 746 | 747 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 747 | 748 | "setupNewVoxelsForDrawingSingleNode() xxxxx"); |
| 748 | 749 | |
| 749 | − uint64_t start = usecTimestampNow(); | |
| 750 | − uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; | |
| 750 | + quint64 start = usecTimestampNow(); | |
| 751 | + quint64 sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; | |
| 751 | 752 | |
| 752 | 753 | bool iAmDebugging = false; // if you're debugging set this to true, so you won't get skipped for slow debugging |
| 753 | 754 | if (allowBailEarly && !iAmDebugging && |
| @@ -777,7 +778,7 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) { · 23 unmodified lines | ||
| 777 | 778 | |
| 778 | 779 | _bufferWriteLock.unlock(); |
| 779 | 780 | } |
| 780 | − uint64_t end = usecTimestampNow(); | |
| 781 | + quint64 end = usecTimestampNow(); | |
| 781 | 782 | int elapsedmsec = (end - start) / 1000; |
| 782 | 783 | _setupNewVoxelsForDrawingLastFinished = end; |
| 783 | 784 | _setupNewVoxelsForDrawingLastElapsed = elapsedmsec; |
| @@ -786,14 +787,14 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) { · 2 unmodified lines | ||
| 786 | 787 | void VoxelSystem::checkForCulling() { |
| 787 | 788 | |
| 788 | 789 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "checkForCulling()"); |
| 789 | − uint64_t start = usecTimestampNow(); | |
| 790 | + quint64 start = usecTimestampNow(); | |
| 790 | 791 | |
| 791 | 792 | // track how long its been since we were last moving. If we have recently moved then only use delta frustums, if |
| 792 | 793 | // it's been a long time since we last moved, then go ahead and do a full frustum cull. |
| 793 | 794 | if (isViewChanging()) { |
| 794 | 795 | _lastViewIsChanging = start; |
| 795 | 796 | } |
| 796 | − uint64_t sinceLastMoving = (start - _lastViewIsChanging) / 1000; | |
| 797 | + quint64 sinceLastMoving = (start - _lastViewIsChanging) / 1000; | |
| 797 | 798 | bool enoughTime = (sinceLastMoving >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)); |
| 798 | 799 | |
| 799 | 800 | // These has changed events will occur before we stop. So we need to remember this for when we finally have stopped |
| @@ -815,7 +816,7 @@ void VoxelSystem::checkForCulling() { · 15 unmodified lines | ||
| 815 | 816 | hideOutOfView(forceFullFrustum); |
| 816 | 817 | |
| 817 | 818 | if (forceFullFrustum) { |
| 818 | − uint64_t endViewCulling = usecTimestampNow(); | |
| 819 | + quint64 endViewCulling = usecTimestampNow(); | |
| 819 | 820 | _lastViewCullingElapsed = (endViewCulling - start) / 1000; |
| 820 | 821 | } |
| 821 | 822 | |
| @@ -824,7 +825,7 @@ void VoxelSystem::checkForCulling() { · 2 unmodified lines | ||
| 824 | 825 | // VBO reubuilding. Possibly we should do this only if our actual VBO usage crosses some lower boundary. |
| 825 | 826 | cleanupRemovedVoxels(); |
| 826 | 827 | |
| 827 | − uint64_t sinceLastAudit = (start - _lastAudit) / 1000; | |
| 828 | + quint64 sinceLastAudit = (start - _lastAudit) / 1000; | |
| 828 | 829 | |
| 829 | 830 | if (Menu::getInstance()->isOptionChecked(MenuOption::AutomaticallyAuditTree)) { |
| 830 | 831 | if (sinceLastAudit >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) { |
| @@ -1895,7 +1896,7 @@ void VoxelSystem::falseColorizeBySource() { · 1064 unmodified lines | ||
| 1895 | 1896 | // create a bunch of colors we'll use during colorization |
| 1896 | 1897 | |
| 1897 | 1898 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 1898 | − if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 1899 | + if (node->getType() == NodeType::VoxelServer) { | |
| 1899 | 1900 | uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID()); |
| 1900 | 1901 | int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS; |
| 1901 | 1902 | args.colors[nodeID] = groupColors[groupColor]; |
| @@ -2995,7 +2996,7 @@ void VoxelSystem::falseColorizeOccludedV2() { · 1093 unmodified lines | ||
| 2995 | 2996 | } |
| 2996 | 2997 | |
| 2997 | 2998 | void VoxelSystem::nodeAdded(SharedNodePointer node) { |
| 2998 | − if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 2999 | + if (node->getType() == NodeType::VoxelServer) { | |
| 2999 | 3000 | qDebug("VoxelSystem... voxel server %s added...", node->getUUID().toString().toLocal8Bit().constData()); |
| 3000 | 3001 | _voxelServerCount++; |
| 3001 | 3002 | } |
| @@ -3016,7 +3017,7 @@ bool VoxelSystem::killSourceVoxelsOperation(OctreeElement* element, void* extraD · 14 unmodified lines | ||
| 3016 | 3017 | } |
| 3017 | 3018 | |
| 3018 | 3019 | void VoxelSystem::nodeKilled(SharedNodePointer node) { |
| 3019 | − if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 3020 | + if (node->getType() == NodeType::VoxelServer) { | |
| 3020 | 3021 | _voxelServerCount--; |
| 3021 | 3022 | QUuid nodeUUID = node->getUUID(); |
| 3022 | 3023 | qDebug("VoxelSystem... voxel server %s removed...", nodeUUID.toString().toLocal8Bit().constData()); |