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
16#include <PerfStat.h>16#include <PerfStat.h>
17#include <SharedUtil.h>17#include <SharedUtil.h>
18#include <NodeList.h>18#include <NodeList.h>
19#include <NodeTypes.h>
20 19
21#include "Application.h"20#include "Application.h"
22#include "CoverageMap.h"21#include "CoverageMap.h"
@@ -550,17 +549,17 @@ bool VoxelSystem::readFromSchematicFile(const char* filename) { · 527 unmodified lines
550 return result;549 return result;
551}550}
552 551
553int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {552int VoxelSystem::parseData(const QByteArray& packet) {
554 bool showTimingDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);553 bool showTimingDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
555 PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData()",showTimingDetails);554 PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData()",showTimingDetails);
556 555
557 unsigned char command = *sourceBuffer;556 PacketType command = packetTypeForPacket(packet);
558 int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer);557 int numBytesPacketHeader = numBytesForPacketHeader(packet);
559 switch(command) {558 switch(command) {
560 case PACKET_TYPE_VOXEL_DATA: {559 case PacketTypeVoxelData: {
561 PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PACKET_TYPE_VOXEL_DATA part...",showTimingDetails);560 PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() PacketType_VOXEL_DATA part...",showTimingDetails);
562 561
563 unsigned char* dataAt = sourceBuffer + numBytesPacketHeader;562 const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader;
564 563
565 VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt));564 VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt));
566 dataAt += sizeof(VOXEL_PACKET_FLAGS);565 dataAt += sizeof(VOXEL_PACKET_FLAGS);
@@ -577,7 +576,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 10 unmodified lines
577 int flightTime = arrivedAt - sentAt;576 int flightTime = arrivedAt - sentAt;
578 577
579 VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;578 VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
580 int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE;579 int dataBytes = packet.size() - VOXEL_PACKET_HEADER_SIZE;
581 580
582 int subsection = 1;581 int subsection = 1;
583 while (dataBytes > 0) {582 while (dataBytes > 0) {
@@ -605,7 +604,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 21 unmodified lines
605 " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d"604 " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d"
606 " subsection:%d sectionLength:%d uncompressed:%d",605 " subsection:%d sectionLength:%d uncompressed:%d",
607 debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),606 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());
609 }609 }
610 _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);610 _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
611 unlockTree();611 unlockTree();
@@ -616,7 +616,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 4 unmodified lines
616 }616 }
617 subsection++;617 subsection++;
618 }618 }
619 break;619 default:
620 break;
620 }621 }
621 if (!_useFastVoxelPipeline || _writeRenderFullVBO) {622 if (!_useFastVoxelPipeline || _writeRenderFullVBO) {
622 setupNewVoxelsForDrawing();623 setupNewVoxelsForDrawing();
@@ -624,9 +625,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 1 unmodified line
624 setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY);625 setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY);
625 }626 }
626 627
627 Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes);628 Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(packet.size());
628 629
629 return numBytes;630 return packet.size();
630}631}
631 632
632void VoxelSystem::setupNewVoxelsForDrawing() {633void VoxelSystem::setupNewVoxelsForDrawing() {