Showing the changes to interface/src/VoxelSystem.cpp (1 of 5 files). Show all
Unified · Split
| @@ -595,62 +595,51 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 594 unmodified lines | |||
| 595 | 595 | ||
| 596 | unsigned char command = *sourceBuffer; | 596 | unsigned char command = *sourceBuffer; |
| 597 | int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer); | 597 | int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer); |
| 598 | unsigned char* voxelData = sourceBuffer + numBytesPacketHeader; | ||
| 599 | |||
| 600 | switch(command) { | 598 | switch(command) { |
| 601 | case PACKET_TYPE_VOXEL_DATA: { | 599 | case PACKET_TYPE_VOXEL_DATA: { |
| 602 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 600 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 603 | "readBitstreamToTree()"); | 601 | "readBitstreamToTree()"); |
| 604 | // ask the VoxelTree to read the bitstream into the tree | 602 | |
| 605 | ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID()); | 603 | unsigned char* dataAt = sourceBuffer + numBytesPacketHeader; |
| 606 | lockTree(); | 604 | |
| 607 | VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT); | 605 | VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt)); |
| 608 | int compressedSize = numBytes - numBytesPacketHeader; | 606 | dataAt += sizeof(VOXEL_PACKET_FLAGS); |
| 609 | packet.loadFinalizedContent(voxelData, compressedSize); | 607 | VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); |
| 610 | if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) { | 608 | dataAt += sizeof(VOXEL_PACKET_SEQUENCE); |
| 611 | qDebug("got packet numBytes=%d finalized size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize()); | 609 | |
| 610 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | ||
| 611 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | ||
| 612 | |||
| 613 | unsigned char* voxelData = dataAt; | ||
| 614 | |||
| 615 | bool packetIsColored = oneAtBit(flags, PACKET_IS_COLOR_BIT); | ||
| 616 | bool packetIsCompressed = oneAtBit(flags, PACKET_IS_COMPRESSED_BIT); | ||
| 617 | |||
| 618 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | ||
| 619 | int flightTime = arrivedAt - sentAt; | ||
| 620 | |||
| 621 | int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE; | ||
| 622 | if (true || Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) { | ||
| 623 | printf("Got Packet... color:%s compressed:%s sequence: %u flightTime:%d size:%d data:%d\n", | ||
| 624 | debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), | ||
| 625 | sequence, flightTime, numBytes, dataBytes); | ||
| 612 | } | 626 | } |
| 613 | _tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args); | 627 | |
| 614 | unlockTree(); | 628 | // ask the VoxelTree to read the bitstream into the tree |
| 615 | } | 629 | |
| 616 | break; | 630 | // need to check for WANT_COLOR vs NO_COLOR |
| 617 | case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { | 631 | // need to also setup packet properly with enableCompression true/false |
| 618 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 632 | ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID()); |
| 619 | "readBitstreamToTree()"); | ||
| 620 | // ask the VoxelTree to read the MONOCHROME bitstream into the tree | ||
| 621 | ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID()); | ||
| 622 | lockTree(); | 633 | lockTree(); |
| 623 | VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT); | 634 | VoxelPacketData packetData(packetIsCompressed); |
| 624 | int compressedSize = numBytes - numBytesPacketHeader; | 635 | packetData.loadFinalizedContent(voxelData, dataBytes); |
| 625 | packet.loadFinalizedContent(voxelData, compressedSize); | 636 | if (true || Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) { |
| 626 | if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) { | 637 | qDebug("got packet numBytes=%d finalized size %d uncompressed size %d\n", |
| 627 | qDebug("got packet numBytes=%d finalized size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize()); | 638 | numBytes, dataBytes, packetData.getUncompressedSize()); |
| 628 | } | 639 | } |
| 629 | _tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args); | 640 | _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args); |
| 630 | unlockTree(); | 641 | unlockTree(); |
| 631 | } | 642 | } |
| 632 | break; | ||
| 633 | case PACKET_TYPE_Z_COMMAND: | ||
| 634 | |||
| 635 | // the Z command is a special command that allows the sender to send high level semantic | ||
| 636 | // requests, like erase all, or add sphere scene, different receivers may handle these | ||
| 637 | // messages differently | ||
| 638 | char* packetData = (char *)sourceBuffer; | ||
| 639 | char* command = &packetData[numBytesPacketHeader]; // start of the command | ||
| 640 | int commandLength = strlen(command); // commands are null terminated strings | ||
| 641 | int totalLength = 1+commandLength+1; | ||
| 642 | |||
| 643 | qDebug("got Z message len(%d)= %s\n", numBytes, command); | ||
| 644 | |||
| 645 | while (totalLength <= numBytes) { | ||
| 646 | if (0==strcmp(command,(char*)"erase all")) { | ||
| 647 | qDebug("got Z message == erase all - NOT SUPPORTED ON INTERFACE\n"); | ||
| 648 | } | ||
| 649 | if (0==strcmp(command,(char*)"add scene")) { | ||
| 650 | qDebug("got Z message == add scene - NOT SUPPORTED ON INTERFACE\n"); | ||
| 651 | } | ||
| 652 | totalLength += commandLength+1; | ||
| 653 | } | ||
| 654 | break; | 643 | break; |
| 655 | } | 644 | } |
| 656 | 645 | ||