From a60cf0f34ea74b2571d64d685644a3bb5d85cb78 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 25 Nov 2013 15:52:30 -0800 Subject: [PATCH] fix issue with copy --- interface/src/Application.cpp | 7 ++----- libraries/voxels/src/VoxelPacket.h | 2 -- libraries/voxels/src/VoxelTree.cpp | 18 +++++++++--------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 49b1d28535..6005c455b6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1524,7 +1524,6 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { SendVoxelsOperationArgs* args = (SendVoxelsOperationArgs*)extraData; if (node->isColored()) { const unsigned char* nodeOctalCode = node->getOctalCode(); - unsigned char* codeColorBuffer = NULL; int codeLength = 0; int bytesInCode = 0; @@ -1545,10 +1544,9 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { } // copy the colors over - codeColorBuffer[bytesInCode + RED_INDEX ] = node->getColor()[RED_INDEX ]; + codeColorBuffer[bytesInCode + RED_INDEX] = node->getColor()[RED_INDEX]; codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX]; - codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ]; - + codeColorBuffer[bytesInCode + BLUE_INDEX] = node->getColor()[BLUE_INDEX]; getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, codeColorBuffer, codeAndColorLength); @@ -1612,7 +1610,6 @@ void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestinati // the server as an set voxel message, this will also rebase the voxels to the new location SendVoxelsOperationArgs args; args.newBaseOctCode = octalCodeDestination; - _sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args); if (_sharedVoxelSystem.getTree() != &_clipboard) { diff --git a/libraries/voxels/src/VoxelPacket.h b/libraries/voxels/src/VoxelPacket.h index b8301cacf2..d6aafe597f 100644 --- a/libraries/voxels/src/VoxelPacket.h +++ b/libraries/voxels/src/VoxelPacket.h @@ -9,8 +9,6 @@ // * add stats tracking for number of unique colors and consecutive identical colors. // (as research for color dictionaries and RLE) // -// * copy/paste broken? -// // * further testing of compression to determine optimal configuration for performance and compression // // * improve semantics for "reshuffle" - current approach will work for now and with compression diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 857e39ca69..2b9fb98082 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -1534,12 +1534,15 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, int childTreeBytesOut = 0; // XXXBHG - Note, this seems like the correct logic here, if we included the color in this packet, then - // the LOD logic determined that the child nodes do not need to be visible... and if so, we shouldn't recurse - // them further. But... this isn't how the code has been for a while... but it's a major savings (~30%) and - // it seems to work correctly. I'd like to discuss... - // - // only recurse if we DIDN'T include colore on this level - if (!oneAtBit(childrenColoredBits, originalIndex)) { + // the LOD logic determined that the child nodes would not be visible... and if so, we shouldn't recurse + // them further. But... for some time now the code has included and recursed into these child nodes, which + // would likely still send the child content, even though the client wouldn't render it. This change is + // a major savings (~30%) and it seems to work correctly. But I want us to discuss as a group when we do + // a voxel protocol review. + // + // This only applies in the view frustum case, in other cases, like file save and copy/past where + // no viewFrustum was requested, we still want to recurse the child tree. + if (!params.viewFrustum || !oneAtBit(childrenColoredBits, originalIndex)) { childTreeBytesOut = encodeTreeBitstreamRecursion(childNode, packet, bag, params, thisLevel); } @@ -1916,13 +1919,10 @@ void VoxelTree::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinat while (!nodeBag.isEmpty()) { VoxelNode* subTree = nodeBag.extract(); - packet.reset(); // reset the packet between usage - // ask our tree to write a bitsteam EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS, chopLevels); bytesWritten = encodeTreeBitstream(subTree, &packet, nodeBag, params); - // ask destination tree to read the bitstream ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS); destinationTree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args);