History

packet header changes and beginning of conversion to QByteArray

Stephen Birarda committed 12 years ago

Commit 4103cc11 parent fd34d2c121 files · +1326 −1607Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 121 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+14−13
@@ -16,7 +16,6 @@ · 15 unmodified lines
1616 #include <PerfStat.h>
1717 #include <SharedUtil.h>
1818 #include <NodeList.h>
19−#include <NodeTypes.h>
2019
2120 #include "Application.h"
2221 #include "CoverageMap.h"
@@ -550,17 +549,17 @@ bool VoxelSystem::readFromSchematicFile(const char* filename) { · 527 unmodified lines
550549 return result;
551550 }
552551
553−int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
552+int VoxelSystem::parseData(const QByteArray& packet) {
554553 bool showTimingDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
555554 PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData()",showTimingDetails);
556555
557− unsigned char command = *sourceBuffer;
558− int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer);
556+ PacketType command = packetTypeForPacket(packet);
557+ int numBytesPacketHeader = numBytesForPacketHeader(packet);
559558 switch(command) {
560− case PACKET_TYPE_VOXEL_DATA: {
561− PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PACKET_TYPE_VOXEL_DATA part...",showTimingDetails);
562−
563− unsigned char* dataAt = sourceBuffer + numBytesPacketHeader;
559+ case PacketTypeVoxelData: {
560+ PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PacketType_VOXEL_DATA part...",showTimingDetails);
561+
562+ const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader;
564563
565564 VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt));
566565 dataAt += sizeof(VOXEL_PACKET_FLAGS);
@@ -577,7 +576,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 10 unmodified lines
577576 int flightTime = arrivedAt - sentAt;
578577
579578 VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
580− int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE;
579+ int dataBytes = packet.size() - VOXEL_PACKET_HEADER_SIZE;
581580
582581 int subsection = 1;
583582 while (dataBytes > 0) {
@@ -605,7 +604,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 21 unmodified lines
605604 " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d"
606605 " subsection:%d sectionLength:%d uncompressed:%d",
607606 debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
608− sequence, flightTime, numBytes, dataBytes, subsection, sectionLength, packetData.getUncompressedSize());
607+ sequence, flightTime, packet.size(), dataBytes, subsection, sectionLength,
608+ packetData.getUncompressedSize());
609609 }
610610 _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
611611 unlockTree();
@@ -616,7 +616,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 4 unmodified lines
616616 }
617617 subsection++;
618618 }
619− break;
619+ default:
620+ break;
620621 }
621622 if (!_useFastVoxelPipeline || _writeRenderFullVBO) {
622623 setupNewVoxelsForDrawing();
@@ -624,9 +625,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 1 unmodified line
624625 setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY);
625626 }
626627
627− Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes);
628+ Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(packet.size());
628629
629− return numBytes;
630+ return packet.size();
630631 }
631632
632633 void VoxelSystem::setupNewVoxelsForDrawing() {