mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 14:30:08 +02:00
remove old buffer style approach to encoding
This commit is contained in:
parent
661152956a
commit
b1a0ed6480
3 changed files with 8 additions and 112 deletions
|
@ -384,10 +384,7 @@ int VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* nod
|
||||||
_myServer->getServerTree().lockForRead();
|
_myServer->getServerTree().lockForRead();
|
||||||
nodeData->stats.encodeStarted();
|
nodeData->stats.encodeStarted();
|
||||||
|
|
||||||
bytesWritten = _myServer->getServerTree().encodeTreeBitstream(subTree,
|
bytesWritten = _myServer->getServerTree().encodeTreeBitstream(subTree, &_tempPacket, nodeData->nodeBag, params);
|
||||||
_tempOutputBuffer, MAX_VOXEL_PACKET_SIZE - 1,
|
|
||||||
&_tempPacket,
|
|
||||||
nodeData->nodeBag, params);
|
|
||||||
if (bytesWritten > 0) {
|
if (bytesWritten > 0) {
|
||||||
_encodedSomething = true;
|
_encodedSomething = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1024,7 +1024,6 @@ bool VoxelTree::findCapsulePenetration(const glm::vec3& start, const glm::vec3&
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelTree::encodeTreeBitstream(VoxelNode* node,
|
int VoxelTree::encodeTreeBitstream(VoxelNode* node,
|
||||||
unsigned char* outputBuffer, int availableBytes,
|
|
||||||
VoxelPacket* packet, VoxelNodeBag& bag,
|
VoxelPacket* packet, VoxelNodeBag& bag,
|
||||||
EncodeBitstreamParams& params) {
|
EncodeBitstreamParams& params) {
|
||||||
|
|
||||||
|
@ -1053,25 +1052,14 @@ int VoxelTree::encodeTreeBitstream(VoxelNode* node,
|
||||||
roomForOctalCode = packet->startSubTree(newCode);
|
roomForOctalCode = packet->startSubTree(newCode);
|
||||||
|
|
||||||
if (newCode) {
|
if (newCode) {
|
||||||
// old way...
|
|
||||||
codeLength = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(newCode));
|
|
||||||
memcpy(outputBuffer, newCode, codeLength);
|
|
||||||
|
|
||||||
// do this!
|
|
||||||
delete newCode;
|
delete newCode;
|
||||||
} else {
|
} else {
|
||||||
codeLength = 1;
|
codeLength = 1;
|
||||||
|
|
||||||
// old way....
|
|
||||||
*outputBuffer = 0; // root
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// new way
|
// new way
|
||||||
roomForOctalCode = packet->startSubTree(node->getOctalCode());
|
roomForOctalCode = packet->startSubTree(node->getOctalCode());
|
||||||
codeLength = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(node->getOctalCode()));
|
codeLength = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(node->getOctalCode()));
|
||||||
|
|
||||||
// old way
|
|
||||||
memcpy(outputBuffer, node->getOctalCode(), codeLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the octalcode couldn't fit, then we can return, because no nodes below us will fit...
|
// If the octalcode couldn't fit, then we can return, because no nodes below us will fit...
|
||||||
|
@ -1082,10 +1070,6 @@ int VoxelTree::encodeTreeBitstream(VoxelNode* node,
|
||||||
|
|
||||||
bytesWritten += codeLength; // keep track of byte count
|
bytesWritten += codeLength; // keep track of byte count
|
||||||
|
|
||||||
// old way...
|
|
||||||
outputBuffer += codeLength; // move the pointer
|
|
||||||
availableBytes -= codeLength; // keep track or remaining space
|
|
||||||
|
|
||||||
int currentEncodeLevel = 0;
|
int currentEncodeLevel = 0;
|
||||||
|
|
||||||
// record some stats, this is the one node that we won't record below in the recursion function, so we need to
|
// record some stats, this is the one node that we won't record below in the recursion function, so we need to
|
||||||
|
@ -1094,7 +1078,7 @@ int VoxelTree::encodeTreeBitstream(VoxelNode* node,
|
||||||
params.stats->traversed(node);
|
params.stats->traversed(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
int childBytesWritten = encodeTreeBitstreamRecursion(node, outputBuffer, availableBytes, packet, bag, params, currentEncodeLevel);
|
int childBytesWritten = encodeTreeBitstreamRecursion(node, packet, bag, params, currentEncodeLevel);
|
||||||
|
|
||||||
// if childBytesWritten == 1 then something went wrong... that's not possible
|
// if childBytesWritten == 1 then something went wrong... that's not possible
|
||||||
assert(childBytesWritten != 1);
|
assert(childBytesWritten != 1);
|
||||||
|
@ -1125,7 +1109,6 @@ int VoxelTree::encodeTreeBitstream(VoxelNode* node,
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
unsigned char* outputBuffer, int availableBytes,
|
|
||||||
VoxelPacket* packet, VoxelNodeBag& bag,
|
VoxelPacket* packet, VoxelNodeBag& bag,
|
||||||
EncodeBitstreamParams& params, int& currentEncodeLevel) const {
|
EncodeBitstreamParams& params, int& currentEncodeLevel) const {
|
||||||
// How many bytes have we written so far at this level;
|
// How many bytes have we written so far at this level;
|
||||||
|
@ -1232,7 +1215,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
// If the user also asked for occlusion culling, check if this node is occluded, but only if it's not a leaf.
|
// If the user also asked for occlusion culling, check if this node is occluded, but only if it's not a leaf.
|
||||||
// leaf occlusion is handled down below when we check child nodes
|
// leaf occlusion is handled down below when we check child nodes
|
||||||
if (params.wantOcclusionCulling && !node->isLeaf()) {
|
if (params.wantOcclusionCulling && !node->isLeaf()) {
|
||||||
//node->printDebugDetails("upper section, params.wantOcclusionCulling... node=");
|
|
||||||
AABox voxelBox = node->getAABox();
|
AABox voxelBox = node->getAABox();
|
||||||
voxelBox.scale(TREE_SCALE);
|
voxelBox.scale(TREE_SCALE);
|
||||||
VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(params.viewFrustum->getProjectedPolygon(voxelBox));
|
VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(params.viewFrustum->getProjectedPolygon(voxelBox));
|
||||||
|
@ -1240,8 +1222,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
// In order to check occlusion culling, the shadow has to be "all in view" otherwise, we will ignore occlusion
|
// In order to check occlusion culling, the shadow has to be "all in view" otherwise, we will ignore occlusion
|
||||||
// culling and proceed as normal
|
// culling and proceed as normal
|
||||||
if (voxelPolygon->getAllInView()) {
|
if (voxelPolygon->getAllInView()) {
|
||||||
//node->printDebugDetails("upper section, voxelPolygon->getAllInView() node=");
|
|
||||||
|
|
||||||
CoverageMapStorageResult result = params.map->checkMap(voxelPolygon, false);
|
CoverageMapStorageResult result = params.map->checkMap(voxelPolygon, false);
|
||||||
delete voxelPolygon; // cleanup
|
delete voxelPolygon; // cleanup
|
||||||
if (result == OCCLUDED) {
|
if (result == OCCLUDED) {
|
||||||
|
@ -1267,15 +1247,9 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
unsigned char childrenExistInTreeBits = 0;
|
unsigned char childrenExistInTreeBits = 0;
|
||||||
unsigned char childrenExistInPacketBits = 0;
|
unsigned char childrenExistInPacketBits = 0;
|
||||||
unsigned char childrenColoredBits = 0;
|
unsigned char childrenColoredBits = 0;
|
||||||
|
const int BYTES_PER_COLOR = 3;
|
||||||
const int CHILD_COLOR_MASK_BYTES = sizeof(childrenColoredBits);
|
|
||||||
const int BYTES_PER_COLOR = 3;
|
|
||||||
const int CHILD_TREE_EXISTS_BYTES = sizeof(childrenExistInTreeBits) + sizeof(childrenExistInPacketBits);
|
|
||||||
const int MAX_LEVEL_BYTES = CHILD_COLOR_MASK_BYTES + NUMBER_OF_CHILDREN * BYTES_PER_COLOR + CHILD_TREE_EXISTS_BYTES;
|
|
||||||
|
|
||||||
// Make our local buffer large enough to handle writing at this level in case we need to.
|
// Make our local buffer large enough to handle writing at this level in case we need to.
|
||||||
unsigned char thisLevelBuffer[MAX_LEVEL_BYTES];
|
|
||||||
unsigned char* writeToThisLevelBuffer = &thisLevelBuffer[0];
|
|
||||||
int thisLevelKey = packet->startLevel();
|
int thisLevelKey = packet->startLevel();
|
||||||
|
|
||||||
int inViewCount = 0;
|
int inViewCount = 0;
|
||||||
|
@ -1306,11 +1280,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
|
|
||||||
if (params.wantOcclusionCulling) {
|
if (params.wantOcclusionCulling) {
|
||||||
if (childNode) {
|
if (childNode) {
|
||||||
// chance to optimize, doesn't need to be actual distance!! Could be distance squared
|
|
||||||
//float distanceSquared = childNode->distanceSquareToPoint(point);
|
|
||||||
//qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance);
|
|
||||||
//childNode->printDebugDetails("");
|
|
||||||
|
|
||||||
float distance = params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0;
|
float distance = params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0;
|
||||||
|
|
||||||
currentCount = insertIntoSortedArrays((void*)childNode, distance, i,
|
currentCount = insertIntoSortedArrays((void*)childNode, distance, i,
|
||||||
|
@ -1458,17 +1427,9 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// old way...
|
|
||||||
*writeToThisLevelBuffer = childrenColoredBits;
|
|
||||||
writeToThisLevelBuffer += sizeof(childrenColoredBits); // move the pointer
|
|
||||||
|
|
||||||
bool continueThisLevel = true;
|
bool continueThisLevel = true;
|
||||||
continueThisLevel = packet->appendBitMask(childrenColoredBits);
|
continueThisLevel = packet->appendBitMask(childrenColoredBits);
|
||||||
|
|
||||||
if (!continueThisLevel) {
|
|
||||||
//printf("packet->appendBitMask(childrenColoredBits) returned FALSE....\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (continueThisLevel) {
|
if (continueThisLevel) {
|
||||||
bytesAtThisLevel += sizeof(childrenColoredBits); // keep track of byte count
|
bytesAtThisLevel += sizeof(childrenColoredBits); // keep track of byte count
|
||||||
if (params.stats) {
|
if (params.stats) {
|
||||||
|
@ -1489,14 +1450,9 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
continueThisLevel = packet->appendColor(color);
|
continueThisLevel = packet->appendColor(color);
|
||||||
|
|
||||||
if (!continueThisLevel) {
|
if (!continueThisLevel) {
|
||||||
//printf("packet->appendColor() i=%d returned FALSE....\n", i);
|
|
||||||
break; // no point in continuing
|
break; // no point in continuing
|
||||||
}
|
}
|
||||||
|
|
||||||
// old way...
|
|
||||||
memcpy(writeToThisLevelBuffer, &childNode->getColor(), BYTES_PER_COLOR);
|
|
||||||
writeToThisLevelBuffer += BYTES_PER_COLOR; // move the pointer for color
|
|
||||||
|
|
||||||
bytesAtThisLevel += BYTES_PER_COLOR; // keep track of byte count for color
|
bytesAtThisLevel += BYTES_PER_COLOR; // keep track of byte count for color
|
||||||
|
|
||||||
// don't need to check childNode here, because we can't get here with no childNode
|
// don't need to check childNode here, because we can't get here with no childNode
|
||||||
|
@ -1511,17 +1467,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
// if the caller wants to include childExistsBits, then include them even if not in view, put them before the
|
// if the caller wants to include childExistsBits, then include them even if not in view, put them before the
|
||||||
// childrenExistInPacketBits, so that the lower code can properly repair the packet exists bits
|
// childrenExistInPacketBits, so that the lower code can properly repair the packet exists bits
|
||||||
if (continueThisLevel && params.includeExistsBits) {
|
if (continueThisLevel && params.includeExistsBits) {
|
||||||
|
|
||||||
// old way...
|
|
||||||
*writeToThisLevelBuffer = childrenExistInTreeBits;
|
|
||||||
writeToThisLevelBuffer += sizeof(childrenExistInTreeBits); // move the pointer
|
|
||||||
|
|
||||||
continueThisLevel = packet->appendBitMask(childrenExistInTreeBits);
|
continueThisLevel = packet->appendBitMask(childrenExistInTreeBits);
|
||||||
|
|
||||||
if (!continueThisLevel) {
|
|
||||||
//printf("packet->appendBitMask(childrenExistInTreeBits) returned FALSE....\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (continueThisLevel) {
|
if (continueThisLevel) {
|
||||||
bytesAtThisLevel += sizeof(childrenExistInTreeBits); // keep track of byte count
|
bytesAtThisLevel += sizeof(childrenExistInTreeBits); // keep track of byte count
|
||||||
if (params.stats) {
|
if (params.stats) {
|
||||||
|
@ -1533,10 +1479,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
// write the child exist bits
|
// write the child exist bits
|
||||||
if (continueThisLevel) {
|
if (continueThisLevel) {
|
||||||
continueThisLevel = packet->appendBitMask(childrenExistInPacketBits);
|
continueThisLevel = packet->appendBitMask(childrenExistInPacketBits);
|
||||||
|
|
||||||
// old way...
|
|
||||||
*writeToThisLevelBuffer = childrenExistInPacketBits;
|
|
||||||
|
|
||||||
if (continueThisLevel) {
|
if (continueThisLevel) {
|
||||||
bytesAtThisLevel += sizeof(childrenExistInPacketBits); // keep track of byte count
|
bytesAtThisLevel += sizeof(childrenExistInPacketBits); // keep track of byte count
|
||||||
if (params.stats) {
|
if (params.stats) {
|
||||||
|
@ -1548,13 +1490,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
// We only need to keep digging, if there is at least one child that is inView, and not a leaf.
|
// We only need to keep digging, if there is at least one child that is inView, and not a leaf.
|
||||||
keepDiggingDeeper = (inViewNotLeafCount > 0);
|
keepDiggingDeeper = (inViewNotLeafCount > 0);
|
||||||
|
|
||||||
// old way...
|
|
||||||
if (availableBytes >= bytesAtThisLevel) {
|
|
||||||
memcpy(outputBuffer, &thisLevelBuffer[0], bytesAtThisLevel);
|
|
||||||
outputBuffer += bytesAtThisLevel;
|
|
||||||
availableBytes -= bytesAtThisLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (continueThisLevel && keepDiggingDeeper) {
|
if (continueThisLevel && keepDiggingDeeper) {
|
||||||
// at this point, we need to iterate the children who are in view, even if not colored
|
// at this point, we need to iterate the children who are in view, even if not colored
|
||||||
// and we need to determine if there's a deeper tree below them that we care about.
|
// and we need to determine if there's a deeper tree below them that we care about.
|
||||||
|
@ -1567,7 +1502,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
//
|
//
|
||||||
// we know the last thing we wrote to the packet was our childrenExistInPacketBits. Let's remember where that was!
|
// we know the last thing we wrote to the packet was our childrenExistInPacketBits. Let's remember where that was!
|
||||||
int childExistsPlaceHolder = packet->getUncompressedByteOffset(sizeof(childrenExistInPacketBits));
|
int childExistsPlaceHolder = packet->getUncompressedByteOffset(sizeof(childrenExistInPacketBits));
|
||||||
unsigned char* childExistsPlaceHolderOLD = outputBuffer-sizeof(childrenExistInPacketBits);
|
|
||||||
|
|
||||||
// we are also going to recurse these child trees in "distance" sorted order, but we need to pack them in the
|
// we are also going to recurse these child trees in "distance" sorted order, but we need to pack them in the
|
||||||
// final packet in standard order. So what we're going to do is keep track of how big each subtree was in bytes,
|
// final packet in standard order. So what we're going to do is keep track of how big each subtree was in bytes,
|
||||||
|
@ -1575,9 +1509,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
// a single recursive pass in distance sorted order, but retain standard order in our encoded packet
|
// a single recursive pass in distance sorted order, but retain standard order in our encoded packet
|
||||||
int recursiveSliceSizes[NUMBER_OF_CHILDREN];
|
int recursiveSliceSizes[NUMBER_OF_CHILDREN];
|
||||||
const unsigned char* recursiveSliceStarts[NUMBER_OF_CHILDREN];
|
const unsigned char* recursiveSliceStarts[NUMBER_OF_CHILDREN];
|
||||||
const unsigned char* recursiveSliceStartsOLD[NUMBER_OF_CHILDREN];
|
|
||||||
int firstRecursiveSliceOffset = packet->getUncompressedByteOffset();
|
int firstRecursiveSliceOffset = packet->getUncompressedByteOffset();
|
||||||
unsigned char* firstRecursiveSliceOLD = outputBuffer;
|
|
||||||
int allSlicesSize = 0;
|
int allSlicesSize = 0;
|
||||||
|
|
||||||
// for each child node in Distance sorted order..., check to see if they exist, are colored, and in view, and if so
|
// for each child node in Distance sorted order..., check to see if they exist, are colored, and in view, and if so
|
||||||
|
@ -1591,12 +1523,8 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
int thisLevel = currentEncodeLevel;
|
int thisLevel = currentEncodeLevel;
|
||||||
// remember this for reshuffling
|
// remember this for reshuffling
|
||||||
recursiveSliceStarts[originalIndex] = packet->getUncompressedData() + packet->getUncompressedSize();
|
recursiveSliceStarts[originalIndex] = packet->getUncompressedData() + packet->getUncompressedSize();
|
||||||
recursiveSliceStartsOLD[originalIndex] = outputBuffer;
|
|
||||||
|
|
||||||
int childTreeBytesOut = encodeTreeBitstreamRecursion(childNode,
|
int childTreeBytesOut = encodeTreeBitstreamRecursion(childNode, packet, bag, params, thisLevel);
|
||||||
outputBuffer, availableBytes,
|
|
||||||
packet, bag,
|
|
||||||
params, thisLevel);
|
|
||||||
|
|
||||||
// remember this for reshuffling
|
// remember this for reshuffling
|
||||||
recursiveSliceSizes[originalIndex] = childTreeBytesOut;
|
recursiveSliceSizes[originalIndex] = childTreeBytesOut;
|
||||||
|
@ -1631,10 +1559,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
|
|
||||||
bytesAtThisLevel += childTreeBytesOut;
|
bytesAtThisLevel += childTreeBytesOut;
|
||||||
|
|
||||||
//old way
|
|
||||||
availableBytes -= childTreeBytesOut;
|
|
||||||
outputBuffer += childTreeBytesOut;
|
|
||||||
|
|
||||||
// If we had previously started writing, and if the child DIDN'T write any bytes,
|
// If we had previously started writing, and if the child DIDN'T write any bytes,
|
||||||
// then we want to remove their bit from the childExistsPlaceHolder bitmask
|
// then we want to remove their bit from the childExistsPlaceHolder bitmask
|
||||||
if (childTreeBytesOut == 0) {
|
if (childTreeBytesOut == 0) {
|
||||||
|
@ -1642,7 +1566,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
childrenExistInPacketBits -= (1 << (7 - originalIndex));
|
childrenExistInPacketBits -= (1 << (7 - originalIndex));
|
||||||
|
|
||||||
// repair the child exists mask
|
// repair the child exists mask
|
||||||
*childExistsPlaceHolderOLD = childrenExistInPacketBits;
|
|
||||||
continueThisLevel = packet->updatePriorBitMask(childExistsPlaceHolder, childrenExistInPacketBits);
|
continueThisLevel = packet->updatePriorBitMask(childExistsPlaceHolder, childrenExistInPacketBits);
|
||||||
|
|
||||||
// If this is the last of the child exists bits, then we're actually be rolling out the entire tree
|
// If this is the last of the child exists bits, then we're actually be rolling out the entire tree
|
||||||
|
@ -1680,25 +1603,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
|
|
||||||
// now that all slices are back in the correct order, copy them to the correct output buffer
|
// now that all slices are back in the correct order, copy them to the correct output buffer
|
||||||
continueThisLevel = packet->updatePriorBytes(firstRecursiveSliceOffset, &tempReshuffleBuffer[0], allSlicesSize);
|
continueThisLevel = packet->updatePriorBytes(firstRecursiveSliceOffset, &tempReshuffleBuffer[0], allSlicesSize);
|
||||||
|
|
||||||
// DO IT AGAIN FOR OLD WAY....
|
|
||||||
unsigned char* tempBufferToOLD = &tempReshuffleBuffer[0]; // this is our temporary destination
|
|
||||||
|
|
||||||
// iterate through our childrenExistInPacketBits, these will be the sections of the packet that we copied subTree
|
|
||||||
// details into. Unfortunately, they're in distance sorted order, not original index order. we need to put them
|
|
||||||
// back into original distance order
|
|
||||||
for (int originalIndex = 0; originalIndex < NUMBER_OF_CHILDREN; originalIndex++) {
|
|
||||||
if (oneAtBit(childrenExistInPacketBits, originalIndex)) {
|
|
||||||
int thisSliceSize = recursiveSliceSizes[originalIndex];
|
|
||||||
const unsigned char* thisSliceStartsOLD = recursiveSliceStartsOLD[originalIndex];
|
|
||||||
|
|
||||||
memcpy(tempBufferToOLD, thisSliceStartsOLD, thisSliceSize);
|
|
||||||
tempBufferToOLD += thisSliceSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now that all slices are back in the correct order, copy them to the correct output buffer
|
|
||||||
memcpy(firstRecursiveSliceOLD, &tempReshuffleBuffer[0], allSlicesSize);
|
|
||||||
}
|
}
|
||||||
} // end keepDiggingDeeper
|
} // end keepDiggingDeeper
|
||||||
|
|
||||||
|
@ -1921,7 +1825,6 @@ void VoxelTree::writeToSVOFile(const char* fileName, VoxelNode* node) {
|
||||||
nodeBag.insert(rootNode);
|
nodeBag.insert(rootNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char outputBuffer[MAX_VOXEL_PACKET_SIZE - 1]; // save on allocs by making this static
|
|
||||||
static VoxelPacket packet;
|
static VoxelPacket packet;
|
||||||
int bytesWritten = 0;
|
int bytesWritten = 0;
|
||||||
bool lastPacketWritten = false;
|
bool lastPacketWritten = false;
|
||||||
|
@ -1931,7 +1834,7 @@ void VoxelTree::writeToSVOFile(const char* fileName, VoxelNode* node) {
|
||||||
|
|
||||||
lockForRead(); // do tree locking down here so that we have shorter slices and less thread contention
|
lockForRead(); // do tree locking down here so that we have shorter slices and less thread contention
|
||||||
EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS);
|
EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS);
|
||||||
bytesWritten = encodeTreeBitstream(subTree, &outputBuffer[0], MAX_VOXEL_PACKET_SIZE - 1, &packet, nodeBag, params);
|
bytesWritten = encodeTreeBitstream(subTree, &packet, nodeBag, params);
|
||||||
unlock();
|
unlock();
|
||||||
|
|
||||||
// if bytesWritten == 0, then it means that the subTree couldn't fit, and so we should reset the packet
|
// if bytesWritten == 0, then it means that the subTree couldn't fit, and so we should reset the packet
|
||||||
|
@ -1977,7 +1880,6 @@ void VoxelTree::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinat
|
||||||
chopLevels = numberOfThreeBitSectionsInCode(startNode->getOctalCode());
|
chopLevels = numberOfThreeBitSectionsInCode(startNode->getOctalCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char outputBuffer[MAX_VOXEL_PACKET_SIZE - 1]; // save on allocs by making this static
|
|
||||||
static VoxelPacket packet;
|
static VoxelPacket packet;
|
||||||
int bytesWritten = 0;
|
int bytesWritten = 0;
|
||||||
|
|
||||||
|
@ -1988,7 +1890,7 @@ void VoxelTree::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinat
|
||||||
|
|
||||||
// ask our tree to write a bitsteam
|
// ask our tree to write a bitsteam
|
||||||
EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS, chopLevels);
|
EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS, chopLevels);
|
||||||
bytesWritten = encodeTreeBitstream(subTree, &outputBuffer[0], MAX_VOXEL_PACKET_SIZE - 1, &packet, nodeBag, params);
|
bytesWritten = encodeTreeBitstream(subTree, &packet, nodeBag, params);
|
||||||
|
|
||||||
// ask destination tree to read the bitstream
|
// ask destination tree to read the bitstream
|
||||||
ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS);
|
ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS);
|
||||||
|
@ -2009,7 +1911,6 @@ void VoxelTree::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* destin
|
||||||
// If we were given a specific node, start from there, otherwise start from root
|
// If we were given a specific node, start from there, otherwise start from root
|
||||||
nodeBag.insert(sourceTree->rootNode);
|
nodeBag.insert(sourceTree->rootNode);
|
||||||
|
|
||||||
static unsigned char outputBuffer[MAX_VOXEL_PACKET_SIZE - 1]; // save on allocs by making this static
|
|
||||||
static VoxelPacket packet;
|
static VoxelPacket packet;
|
||||||
int bytesWritten = 0;
|
int bytesWritten = 0;
|
||||||
|
|
||||||
|
@ -2020,7 +1921,7 @@ void VoxelTree::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* destin
|
||||||
|
|
||||||
// ask our tree to write a bitsteam
|
// ask our tree to write a bitsteam
|
||||||
EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS);
|
EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS);
|
||||||
bytesWritten = sourceTree->encodeTreeBitstream(subTree, &outputBuffer[0], MAX_VOXEL_PACKET_SIZE - 1, &packet, nodeBag, params);
|
bytesWritten = sourceTree->encodeTreeBitstream(subTree, &packet, nodeBag, params);
|
||||||
|
|
||||||
// ask destination tree to read the bitstream
|
// ask destination tree to read the bitstream
|
||||||
bool wantImportProgress = true;
|
bool wantImportProgress = true;
|
||||||
|
|
|
@ -164,8 +164,7 @@ public:
|
||||||
void recurseTreeWithOperationDistanceSorted(RecurseVoxelTreeOperation operation,
|
void recurseTreeWithOperationDistanceSorted(RecurseVoxelTreeOperation operation,
|
||||||
const glm::vec3& point, void* extraData=NULL);
|
const glm::vec3& point, void* extraData=NULL);
|
||||||
|
|
||||||
int encodeTreeBitstream(VoxelNode* node, unsigned char* outputBuffer, int availableBytes,
|
int encodeTreeBitstream(VoxelNode* node, VoxelPacket* packet, VoxelNodeBag& bag,
|
||||||
VoxelPacket* packet, VoxelNodeBag& bag,
|
|
||||||
EncodeBitstreamParams& params) ;
|
EncodeBitstreamParams& params) ;
|
||||||
|
|
||||||
bool isDirty() const { return _isDirty; }
|
bool isDirty() const { return _isDirty; }
|
||||||
|
@ -224,7 +223,6 @@ private:
|
||||||
void readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraData);
|
void readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraData);
|
||||||
|
|
||||||
int encodeTreeBitstreamRecursion(VoxelNode* node,
|
int encodeTreeBitstreamRecursion(VoxelNode* node,
|
||||||
unsigned char* outputBuffer, int availableBytes,
|
|
||||||
VoxelPacket* packet, VoxelNodeBag& bag,
|
VoxelPacket* packet, VoxelNodeBag& bag,
|
||||||
EncodeBitstreamParams& params, int& currentEncodeLevel) const;
|
EncodeBitstreamParams& params, int& currentEncodeLevel) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue