correctly implement data types who assume all child data must be included (e.g. voxels)

This commit is contained in:
ZappoMan 2014-09-05 12:41:14 -07:00
parent a25790b350
commit e1064d8da7
4 changed files with 22 additions and 32 deletions

View file

@ -67,7 +67,7 @@ public:
virtual int minimumRequiredRootDataBytes() const { return sizeof(uint16_t); }
virtual bool suppressEmptySubtrees() const { return false; }
virtual void releaseSceneEncodeData(OctreeElementExtraEncodeData* extraEncodeData) const;
virtual void mustIncludeAllChildData() const { return false; }
virtual bool mustIncludeAllChildData() const { return false; }
virtual bool versionHasSVOfileBreaks(PacketVersion thisVersion) const
{ return thisVersion >= VERSION_ENTITIES_HAS_FILE_BREAKS; }

View file

@ -1051,10 +1051,6 @@ int Octree::encodeTreeBitstream(OctreeElement* element,
return bytesWritten;
}
qDebug() << "WROTE octalcode for element " << element->getAACube();
bytesWritten += codeLength; // keep track of byte count
int currentEncodeLevel = 0;
@ -1472,8 +1468,6 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
packetData->releaseReservedBytes(sizeof(childrenDataBits));
continueThisLevel = packetData->appendBitMask(childrenDataBits);
qDebug() << "WROTE child data bits for element " << element->getAACube();
int childDataBitsPlaceHolder = packetData->getUncompressedByteOffset(sizeof(childrenDataBits));
unsigned char actualChildrenDataBits = 0;
@ -1523,6 +1517,13 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
// Continue this level so long as some part of this child element was appended.
bool childFit = (childAppendState != OctreeElement::NONE);
// some datatypes (like Voxels) assume that all child data will fit, if it doesn't fit
// the data type wants to bail on this element level completely
if (!childFit && mustIncludeAllChildData()) {
continueThisLevel = false;
break;
}
// If the child was partially or fully appended, then mark the actualChildrenDataBits as including
// this child data
if (childFit) {
@ -1553,12 +1554,12 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
}
}
if (!continueThisLevel) {
if (!mustIncludeAllChildData() && !continueThisLevel) {
qDebug() << "WARNING UNEXPECTED CASE: reached end of child element data loop with continueThisLevel=FALSE";
qDebug() << "This is not expected!!!! -- continueThisLevel=FALSE....";
}
if (actualChildrenDataBits != childrenDataBits) {
if (continueThisLevel && actualChildrenDataBits != childrenDataBits) {
// repair the child data mask
continueThisLevel = packetData->updatePriorBitMask(childDataBitsPlaceHolder, actualChildrenDataBits);
@ -1596,7 +1597,6 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
packetData->releaseReservedBytes(sizeof(childrenExistInPacketBits));
continueThisLevel = packetData->appendBitMask(childrenExistInPacketBits);
if (continueThisLevel) {
//qDebug() << "WROTE child exists in packet bits for element " << element->getAACube();
bytesAtThisLevel += sizeof(childrenExistInPacketBits); // keep track of byte count
if (params.stats) {
params.stats->existsInPacketBitsWritten();
@ -1668,10 +1668,8 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
// Allow the datatype a chance to determine if it really wants to recurse this tree. Usually this
// will be true. But if the tree has already been encoded, we will skip this.
if (element->shouldRecurseChildTree(originalIndex, params)) {
//qDebug() << "START RECURSION child element " << childElement->getAACube();
childTreeBytesOut = encodeTreeBitstreamRecursion(childElement, packetData, bag, params,
thisLevel, nodeLocationThisView);
//qDebug() << "END RECURSION child element " << childElement->getAACube();
} else {
childTreeBytesOut = 0;
}
@ -1827,17 +1825,22 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
continueThisLevel = packetData->endLevel(thisLevelKey);
} else {
packetData->discardLevel(thisLevelKey);
qDebug() << "WARNING UNEXPECTED CASE: Something failed in attempting to pack this element";
qDebug() << "This is not expected!!!! -- continueThisLevel=FALSE....";
if (!mustIncludeAllChildData()) {
qDebug() << "WARNING UNEXPECTED CASE: Something failed in attempting to pack this element";
qDebug() << "This is not expected!!!! -- continueThisLevel=FALSE....";
}
}
// This happens if the element could not be written at all. In the case of Octree's that support partial
// element data, continueThisLevel will be true. So this only happens if the full element needs to be
// added back to the element bag.
if (!continueThisLevel) {
qDebug() << "WARNING UNEXPECTED CASE - Something failed in attempting to pack this element";
qDebug() << "IS THIS EVER EXPECTED???? -- continueThisLevel=FALSE...." ;
qDebug() << " calling bag.insert(element);.....";
if (!mustIncludeAllChildData()) {
qDebug() << "WARNING UNEXPECTED CASE - Something failed in attempting to pack this element";
qDebug() << "IS THIS EVER EXPECTED???? -- continueThisLevel=FALSE...." ;
qDebug() << " calling bag.insert(element);.....";
}
bag.insert(element);

View file

@ -238,7 +238,7 @@ public:
virtual int minimumRequiredRootDataBytes() const { return 0; }
virtual bool suppressEmptySubtrees() const { return true; }
virtual void releaseSceneEncodeData(OctreeElementExtraEncodeData* extraEncodeData) const { }
virtual void mustIncludeAllChildData() const { return true; }
virtual bool mustIncludeAllChildData() const { return true; }
/// some versions of the SVO file will include breaks with buffer lengths between each buffer chunk in the SVO
/// file. If the Octree subclass expects this for this particular version of the file, it should override this

View file

@ -66,20 +66,7 @@ void VoxelTreeElement::splitChildren() {
}
OctreeElement::AppendState VoxelTreeElement::appendElementData(OctreePacketData* packetData, EncodeBitstreamParams& params) const {
OctreeElement::AppendState appendState = packetData->appendColor(getColor()) ? OctreeElement::COMPLETED : OctreeElement::NONE;
/*
if (appendState == OctreeElement::COMPLETED) {
qDebug() << "WROTE color for element " << getAACube() << " color: "
<< getColor()[0] << ", "
<< getColor()[1] << ", "
<< getColor()[2];
} else {
qDebug() << "COULD NOT WRITE color for element " << getAACube();
}
*/
return appendState;
return packetData->appendColor(getColor()) ? OctreeElement::COMPLETED : OctreeElement::NONE;
}