From c64a961a380b81edb249af2fe3a38deda365b8cf Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 8 Jul 2013 14:01:10 -0700 Subject: [PATCH] packet version handling in VoxelSystem parseData --- interface/src/VoxelSystem.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 8912762d6e..ca939bf322 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -112,32 +112,31 @@ float VoxelSystem::getVoxelsBytesReadPerSecondAverage() { int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { unsigned char command = *sourceBuffer; - unsigned char *voxelData = sourceBuffer + 1; + int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer); + unsigned char *voxelData = sourceBuffer + numBytesPacketHeader; pthread_mutex_lock(&_treeLock); switch(command) { - case PACKET_TYPE_VOXEL_DATA: - { + case PACKET_TYPE_VOXEL_DATA: { PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); // ask the VoxelTree to read the bitstream into the tree - _tree->readBitstreamToTree(voxelData, numBytes - 1, WANT_COLOR, WANT_EXISTS_BITS); + _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, WANT_COLOR, WANT_EXISTS_BITS); } - break; - case PACKET_TYPE_VOXEL_DATA_MONOCHROME: - { + break; + case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); // ask the VoxelTree to read the MONOCHROME bitstream into the tree - _tree->readBitstreamToTree(voxelData, numBytes - 1, NO_COLOR, WANT_EXISTS_BITS); + _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, NO_COLOR, WANT_EXISTS_BITS); } - break; + break; case PACKET_TYPE_Z_COMMAND: // the Z command is a special command that allows the sender to send high level semantic // requests, like erase all, or add sphere scene, different receivers may handle these // messages differently char* packetData = (char *)sourceBuffer; - char* command = &packetData[1]; // start of the command + char* command = &packetData[numBytesPacketHeader]; // start of the command int commandLength = strlen(command); // commands are null terminated strings int totalLength = 1+commandLength+1;