Showing the changes to interface/src/VoxelSystem.cpp (1 of 4 files). Show all
Unified · Split
| @@ -610,25 +610,32 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 609 unmodified lines | |||
| 610 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | 610 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); |
| 611 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | 611 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); |
| 612 | 612 | ||
| 613 | unsigned char* voxelData = dataAt; | ||
| 614 | |||
| 615 | bool packetIsColored = oneAtBit(flags, PACKET_IS_COLOR_BIT); | 613 | bool packetIsColored = oneAtBit(flags, PACKET_IS_COLOR_BIT); |
| 616 | bool packetIsCompressed = oneAtBit(flags, PACKET_IS_COMPRESSED_BIT); | 614 | bool packetIsCompressed = oneAtBit(flags, PACKET_IS_COMPRESSED_BIT); |
| 617 | 615 | ||
| 618 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | 616 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); |
| 619 | int flightTime = arrivedAt - sentAt; | 617 | int flightTime = arrivedAt - sentAt; |
| 620 | 618 | ||
| 619 | VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0; | ||
| 621 | int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE; | 620 | int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE; |
| 621 | |||
| 622 | if (packetIsCompressed && dataBytes > sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE)) { | ||
| 623 | sectionLength = (*(VOXEL_PACKET_INTERNAL_SECTION_SIZE*)dataAt); | ||
| 624 | dataAt += sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE); | ||
| 625 | } else { | ||
| 626 | sectionLength = dataBytes; | ||
| 627 | } | ||
| 628 | unsigned char* voxelData = dataAt; | ||
| 622 | 629 | ||
| 623 | // ask the VoxelTree to read the bitstream into the tree | 630 | // ask the VoxelTree to read the bitstream into the tree |
| 624 | ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID()); | 631 | ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID()); |
| 625 | lockTree(); | 632 | lockTree(); |
| 626 | VoxelPacketData packetData(packetIsCompressed); | 633 | VoxelPacketData packetData(packetIsCompressed); |
| 627 | packetData.loadFinalizedContent(voxelData, dataBytes); | 634 | packetData.loadFinalizedContent(voxelData, sectionLength); |
| 628 | if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) { | 635 | if (true || Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) { |
| 629 | qDebug("Got Packet color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d uncompressed:%d\n", | 636 | qDebug("Got Packet color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d sectionLength:%d uncompressed:%d\n", |
| 630 | debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), | 637 | debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), |
| 631 | sequence, flightTime, numBytes, dataBytes, packetData.getUncompressedSize()); | 638 | sequence, flightTime, numBytes, dataBytes, sectionLength, packetData.getUncompressedSize()); |
| 632 | } | 639 | } |
| 633 | _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args); | 640 | _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args); |
| 634 | unlockTree(); | 641 | unlockTree(); |