Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all
Unified · Split
| @@ -705,40 +705,88 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { · 704 unmodified lines | ||
| 705 | 705 | |
| 706 | 706 | |
| 707 | 707 | printf("--------- DEBUG TESTING ------------\n"); |
| 708 | − unsigned char* lastOctalCode = tree->rootNode->octalCode; | |
| 709 | 708 | //const int MAX_VOXEL_PACKET_SIZE=13; // test tight fit... |
| 710 | − unsigned char* fullOutputBuffer = new unsigned char[MAX_VOXEL_PACKET_SIZE]; | |
| 711 | − unsigned char* outputBuffer = fullOutputBuffer; | |
| 712 | − bool startedWriting = false; | |
| 709 | + unsigned char* tempOutputBuffer = new unsigned char[MAX_VOXEL_PACKET_SIZE]; | |
| 710 | + unsigned char* finalOutputBuffer = new unsigned char[MAX_VOXEL_PACKET_SIZE]; | |
| 711 | + unsigned char* finalOutputBufferAt = finalOutputBuffer; | |
| 712 | + int availableInFinal = MAX_VOXEL_PACKET_SIZE; | |
| 713 | 713 | int bytesWritten = 0; |
| 714 | + int totalBytesWritten = 0; | |
| 715 | + int totalPackets = 0; | |
| 714 | 716 | |
| 715 | 717 | VoxelNodeBag bagOfTrees; |
| 716 | 718 | |
| 717 | − bytesWritten = tree->encodeTreeBitstream(tree->rootNode, *viewFrustum, outputBuffer, MAX_VOXEL_PACKET_SIZE, bagOfTrees); | |
| 719 | + // stick a "V" in the finalOutputBuffer | |
| 720 | + finalOutputBuffer[0] = 'V'; | |
| 721 | + finalOutputBufferAt++; | |
| 722 | + availableInFinal = MAX_VOXEL_PACKET_SIZE-1; | |
| 718 | 723 | |
| 719 | − printf("--------- initial results ---- bytesWritten=%d ------------\n",bytesWritten); | |
| 720 | − outputBufferBits(fullOutputBuffer, bytesWritten, true); | |
| 721 | − printf("--------- DONE initial results ------------\n"); | |
| 724 | + //bytesWritten = tree->encodeTreeBitstream(tree->rootNode, *viewFrustum, outputBuffer, MAX_VOXEL_PACKET_SIZE, bagOfTrees); | |
| 725 | + //totalBytesWritten += bytesWritten; | |
| 726 | + //printf("--------- initial results ---- bytesWritten=%d ------------\n",bytesWritten); | |
| 727 | + //outputBufferBits(finalOutputBuffer, bytesWritten, true); | |
| 728 | + //printf("--------- DONE initial results ------------\n"); | |
| 729 | + | |
| 730 | + printf("--------- searchForColoredNodes() ------------\n"); | |
| 731 | + tree->searchForColoredNodes(tree->rootNode, *viewFrustum, bagOfTrees); | |
| 732 | + printf("--------- DONE searchForColoredNodes() ------------\n"); | |
| 722 | 733 | |
| 723 | − printf("--------- extra trees ------------\n"); | |
| 734 | + printf("--------- bag of trees ------------\n"); | |
| 724 | 735 | printf("bagOfTrees.count()=%d\n",bagOfTrees.count()); |
| 725 | 736 | |
| 726 | − int countOfExtra = 0; | |
| 737 | + int countOfTrees = 0; | |
| 738 | + bool finalOutputBufferWaiting = false; | |
| 727 | 739 | while (!bagOfTrees.isEmpty()) { |
| 728 | − countOfExtra++; | |
| 740 | + countOfTrees++; | |
| 729 | 741 | VoxelNode* extraTree = bagOfTrees.extract(); |
| 730 | − printf("processing countOfExtra=%d\n", countOfExtra); | |
| 742 | + printf("processing countOfTrees=%d\n", countOfTrees); | |
| 731 | 743 | |
| 732 | − bytesWritten = tree->encodeTreeBitstream(extraTree, *viewFrustum, outputBuffer, MAX_VOXEL_PACKET_SIZE, bagOfTrees); | |
| 744 | + // Only let this guy create at largest packets equal to the amount of space we have left in our final??? | |
| 745 | + // Or let it create the largest possible size (minus 1 for the "V") | |
| 746 | + bytesWritten = tree->encodeTreeBitstream(extraTree, *viewFrustum, tempOutputBuffer, MAX_VOXEL_PACKET_SIZE-1, bagOfTrees); | |
| 733 | 747 | |
| 734 | − | |
| 735 | − printf("--------- extra results ---- bytesWritten=%d ------------\n",bytesWritten); | |
| 736 | − outputBufferBits(fullOutputBuffer, bytesWritten, true); | |
| 737 | − printf("--------- DONE extra results ------------\n"); | |
| 748 | + printf("this tree size=%d\n", bytesWritten); | |
| 738 | 749 | |
| 750 | + // if we have room in our final packet, add this buffer to the final packet | |
| 751 | + if (availableInFinal >= bytesWritten) { | |
| 752 | + memcpy(finalOutputBufferAt, tempOutputBuffer, bytesWritten); | |
| 753 | + availableInFinal -= bytesWritten; | |
| 754 | + finalOutputBufferAt += bytesWritten; | |
| 755 | + finalOutputBufferWaiting = true; | |
| 756 | + } else { | |
| 757 | + // otherwise "send" the packet! | |
| 758 | + int sizeOfFinal = MAX_VOXEL_PACKET_SIZE - availableInFinal; | |
| 759 | + | |
| 760 | + totalBytesWritten += sizeOfFinal; | |
| 761 | + totalPackets++; | |
| 762 | + printf("---- voxel packet ---- sizeOfFinal=%d totalPackets=%d ----\n",sizeOfFinal,totalPackets); | |
| 763 | + //outputBufferBits(finalOutputBuffer, sizeOfFinal, true); | |
| 764 | + printf("---- DONE voxel packet ------------\n"); | |
| 765 | + | |
| 766 | + // reset our finalOutputBuffer (keep the 'V') | |
| 767 | + finalOutputBufferAt = &finalOutputBuffer[1]; | |
| 768 | + availableInFinal = MAX_VOXEL_PACKET_SIZE - 1; | |
| 769 | + finalOutputBufferWaiting = false; | |
| 770 | + | |
| 771 | + // we also need to stick the last created packet in here!! | |
| 772 | + memcpy(finalOutputBufferAt, tempOutputBuffer, bytesWritten); | |
| 773 | + availableInFinal -= bytesWritten; | |
| 774 | + finalOutputBufferAt += bytesWritten; | |
| 775 | + finalOutputBufferWaiting = true; | |
| 776 | + } | |
| 739 | 777 | } |
| 740 | 778 | |
| 779 | + if (finalOutputBufferWaiting) { | |
| 780 | + // otherwise "send" the packet! | |
| 781 | + int sizeOfFinal = MAX_VOXEL_PACKET_SIZE - availableInFinal; | |
| 782 | + | |
| 783 | + totalBytesWritten += sizeOfFinal; | |
| 784 | + totalPackets++; | |
| 785 | + printf("---- voxel packet ---- sizeOfFinal=%d totalPackets=%d ----\n",sizeOfFinal,totalPackets); | |
| 786 | + //outputBufferBits(finalOutputBuffer, sizeOfFinal, true); | |
| 787 | + printf("---- DONE voxel packet ------------\n"); | |
| 788 | + } | |
| 741 | 789 | |
| 742 | − | |
| 743 | − printf("--------- DONE DEBUG TESTING ------------\n"); | |
| 790 | + printf("--- DONE DEBUG TESTING --- countOfTrees=%d totalBytesWritten=%d totalPackets=%d ------\n", | |
| 791 | + countOfTrees, totalBytesWritten,totalPackets); | |
| 744 | 792 | } |