fixed bug in writing small SVO files

This commit is contained in:
ZappoMan 2014-05-12 12:51:45 -07:00
parent 8fe74d006a
commit e4d2f07586
3 changed files with 4 additions and 8 deletions

View file

@ -263,7 +263,7 @@ int ModelItem::readModelDataFromBuffer(const unsigned char* data, int bytesLeftT
qDebug() << "readModelDataFromBuffer()... this model didn't have animation details";
}
//printf("ModelItem::readModelDataFromBuffer()... "); debugDump();
//qDebug() << "ModelItem::readModelDataFromBuffer()... "; debugDump();
}
return bytesRead;
}
@ -417,6 +417,7 @@ void ModelItem::debugDump() const {
qDebug(" position:%f,%f,%f", _position.x, _position.y, _position.z);
qDebug(" radius:%f", getRadius());
qDebug(" color:%d,%d,%d", _color[0], _color[1], _color[2]);
qDebug() << " modelURL:" << qPrintable(getModelURL());
}
bool ModelItem::encodeModelEditMessageDetails(PacketType command, ModelItemID id, const ModelItemProperties& properties,

View file

@ -324,7 +324,7 @@ int ModelTreeElement::readElementDataFromBuffer(const unsigned char* data, int b
dataAt += sizeof(numberOfModels);
bytesLeftToRead -= (int)sizeof(numberOfModels);
bytesRead += sizeof(numberOfModels);
if (bytesLeftToRead >= (int)(numberOfModels * expectedBytesPerModel)) {
for (uint16_t i = 0; i < numberOfModels; i++) {
ModelItem tempModel;

View file

@ -335,10 +335,8 @@ void Octree::readBitstreamToTree(const unsigned char * bitstream, unsigned long
int octalCodeBytes = bytesRequiredForCodeLength(*bitstreamAt);
int theseBytesRead = 0;
theseBytesRead += octalCodeBytes;
theseBytesRead += readElementData(bitstreamRootElement, bitstreamAt + octalCodeBytes,
bufferSizeBytes - (bytesRead + octalCodeBytes), args);
// skip bitstream to new startPoint
bitstreamAt += theseBytesRead;
bytesRead += theseBytesRead;
@ -1619,7 +1617,6 @@ bool Octree::readFromSVOFile(const char* fileName) {
}
void Octree::writeToSVOFile(const char* fileName, OctreeElement* element) {
std::ofstream file(fileName, std::ios::out|std::ios::binary);
if(file.is_open()) {
@ -1642,13 +1639,12 @@ void Octree::writeToSVOFile(const char* fileName, OctreeElement* element) {
nodeBag.insert(_rootElement);
}
static OctreePacketData packetData;
OctreePacketData packetData;
int bytesWritten = 0;
bool lastPacketWritten = false;
while (!nodeBag.isEmpty()) {
OctreeElement* subTree = nodeBag.extract();
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);
bytesWritten = encodeTreeBitstream(subTree, &packetData, nodeBag, params);
@ -1670,7 +1666,6 @@ void Octree::writeToSVOFile(const char* fileName, OctreeElement* element) {
if (!lastPacketWritten) {
file.write((const char*)packetData.getFinalizedData(), packetData.getFinalizedSize());
}
}
file.close();
}