correctly handle reading models.svo files with older version

This commit is contained in:
ZappoMan 2014-05-12 11:40:15 -07:00
parent 02ca7c75eb
commit 8fe74d006a
5 changed files with 17 additions and 6 deletions

View file

@ -188,6 +188,7 @@ int ModelItem::expectedBytes() {
}
int ModelItem::readModelDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args) {
int bytesRead = 0;
if (bytesLeftToRead >= expectedBytes()) {
int clockSkew = args.sourceNode ? args.sourceNode->getClockSkewUsec() : 0;
@ -258,6 +259,8 @@ int ModelItem::readModelDataFromBuffer(const unsigned char* data, int bytesLeftT
bytesRead += animationURLLength;
qDebug() << "readModelDataFromBuffer()... animationURL=" << qPrintable(animationURLString);
} else {
qDebug() << "readModelDataFromBuffer()... this model didn't have animation details";
}
//printf("ModelItem::readModelDataFromBuffer()... "); debugDump();

View file

@ -36,6 +36,7 @@ public:
// own definition. Implement these to allow your octree based server to support editing
virtual bool getWantSVOfileVersions() const { return true; }
virtual PacketType expectedDataPacketType() const { return PacketTypeModelData; }
virtual bool canProcessVersion(PacketVersion thisVersion) const { return true; } // we support all versions
virtual bool handlesEditPacketType(PacketType packetType) const;
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode);

View file

@ -1587,14 +1587,16 @@ bool Octree::readFromSVOFile(const char* fileName) {
if (gotType == expectedType) {
dataAt += sizeof(expectedType);
dataLength -= sizeof(expectedType);
PacketVersion expectedVersion = versionForPacketType(expectedType);
gotVersion = *dataAt;
if (gotVersion == expectedVersion) {
dataAt += sizeof(expectedVersion);
dataLength -= sizeof(expectedVersion);
if (canProcessVersion(gotVersion)) {
dataAt += sizeof(gotVersion);
dataLength -= sizeof(gotVersion);
fileOk = true;
qDebug("SVO file version match. Expected: %d Got: %d",
versionForPacketType(expectedDataPacketType()), gotVersion);
} else {
qDebug("SVO file version mismatch. Expected: %d Got: %d", expectedVersion, gotVersion);
qDebug("SVO file version mismatch. Expected: %d Got: %d",
versionForPacketType(expectedDataPacketType()), gotVersion);
}
} else {
qDebug("SVO file type mismatch. Expected: %c Got: %c", expectedType, gotType);

View file

@ -203,6 +203,9 @@ public:
// own definition. Implement these to allow your octree based server to support editing
virtual bool getWantSVOfileVersions() const { return false; }
virtual PacketType expectedDataPacketType() const { return PacketTypeUnknown; }
virtual bool canProcessVersion(PacketVersion thisVersion) const {
return thisVersion == versionForPacketType(expectedDataPacketType()); }
virtual PacketVersion expectedVersion() const { return versionForPacketType(expectedDataPacketType()); }
virtual bool handlesEditPacketType(PacketType packetType) const { return false; }
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
const unsigned char* editData, int maxLength, const SharedNodePointer& sourceNode) { return 0; }
@ -306,6 +309,7 @@ public:
bool getIsViewing() const { return _isViewing; }
void setIsViewing(bool isViewing) { _isViewing = isViewing; }
signals:
void importSize(float x, float y, float z);

View file

@ -64,6 +64,7 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar
unsigned int numBytesPacketHeader = numBytesForPacketHeader(dataByteArray);
QUuid sourceUUID = uuidFromPacketHeader(dataByteArray);
PacketType expectedType = getExpectedPacketType();
PacketVersion expectedVersion = _tree->expectedVersion(); // TODO: would be better to read this from the packet!
if(command == expectedType) {
PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram expected PacketType", showTimingDetails);
@ -115,7 +116,7 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar
if (sectionLength) {
// ask the VoxelTree to read the bitstream into the tree
ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL,
sourceUUID, sourceNode);
sourceUUID, sourceNode, false, expectedVersion);
_tree->lockForWrite();
OctreePacketData packetData(packetIsCompressed);
packetData.loadFinalizedContent(dataAt, sectionLength);