mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 16:23:16 +02:00
fixed bug in writing small SVO files
This commit is contained in:
parent
8fe74d006a
commit
e4d2f07586
3 changed files with 4 additions and 8 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue