From 31f72107daf7000ab2f54bb214e7e0288bdc7633 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 23 Jan 2015 09:26:48 -0800 Subject: [PATCH] remove support for old pre-entity svo files --- libraries/entities/src/EntityTree.h | 3 +- libraries/entities/src/ModelEntityItem.cpp | 127 --------------------- libraries/entities/src/ModelEntityItem.h | 3 - 3 files changed, 2 insertions(+), 131 deletions(-) diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index e8c8a93165..405cbecd99 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -60,7 +60,8 @@ 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 PacketTypeEntityData; } - virtual bool canProcessVersion(PacketVersion thisVersion) const { return true; } // we support all versions + virtual bool canProcessVersion(PacketVersion thisVersion) const + { return thisVersion >= VERSION_ENTITIES_SUPPORT_SPLIT_MTU; } // we support all versions with split mtu 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); diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 4cdec0f29a..2c3dcd0600 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -81,17 +81,6 @@ bool ModelEntityItem::setProperties(const EntityItemProperties& properties) { return somethingChanged; } - - -int ModelEntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args) { - if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU) { - return oldVersionReadEntityDataFromBuffer(data, bytesLeftToRead, args); - } - - // let our base class do most of the work... it will call us back for our porition... - return EntityItem::readEntityDataFromBuffer(data, bytesLeftToRead, args); -} - int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args, EntityPropertyFlags& propertyFlags, bool overwriteLocalData) { @@ -131,122 +120,6 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, return bytesRead; } -int ModelEntityItem::oldVersionReadEntityDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args) { - - int bytesRead = 0; - if (bytesLeftToRead >= expectedBytes()) { - int clockSkew = args.sourceNode ? args.sourceNode->getClockSkewUsec() : 0; - - const unsigned char* dataAt = data; - - // id - // this old bitstream format had 32bit IDs. They are obsolete and need to be replaced with our new UUID - // format. We can simply read and ignore the old ID since they should not be repeated. This code should only - // run on loading from an old file. - quint32 oldID; - memcpy(&oldID, dataAt, sizeof(oldID)); - dataAt += sizeof(oldID); - bytesRead += sizeof(oldID); - _id = QUuid::createUuid(); - - // _lastUpdated - memcpy(&_lastUpdated, dataAt, sizeof(_lastUpdated)); - dataAt += sizeof(_lastUpdated); - bytesRead += sizeof(_lastUpdated); - _lastUpdated -= clockSkew; - - // _lastEdited - memcpy(&_lastEdited, dataAt, sizeof(_lastEdited)); - dataAt += sizeof(_lastEdited); - bytesRead += sizeof(_lastEdited); - _lastEdited -= clockSkew; - _created = _lastEdited; // NOTE: old models didn't have age or created time, assume their last edit was a create - - QString ageAsString = formatSecondsElapsed(getAge()); - qDebug() << "Loading old model file, _created = _lastEdited =" << _created - << " age=" << getAge() << "seconds - " << ageAsString - << "old ID=" << oldID << "new ID=" << _id; - - // radius - float radius; - memcpy(&radius, dataAt, sizeof(radius)); - dataAt += sizeof(radius); - bytesRead += sizeof(radius); - setRadius(radius); - - // position - memcpy(&_position, dataAt, sizeof(_position)); - dataAt += sizeof(_position); - bytesRead += sizeof(_position); - - // color - memcpy(&_color, dataAt, sizeof(_color)); - dataAt += sizeof(_color); - bytesRead += sizeof(_color); - - // TODO: how to handle this? Presumable, this would only ever be true if the model file was saved with - // a model being in a shouldBeDeleted state. Which seems unlikely. But if it happens, maybe we should delete the entity after loading? - // shouldBeDeleted - bool shouldBeDeleted = false; - memcpy(&shouldBeDeleted, dataAt, sizeof(shouldBeDeleted)); - dataAt += sizeof(shouldBeDeleted); - bytesRead += sizeof(shouldBeDeleted); - if (shouldBeDeleted) { - qDebug() << "UNEXPECTED - read shouldBeDeleted=TRUE from an old format file"; - } - - // modelURL - uint16_t modelURLLength; - memcpy(&modelURLLength, dataAt, sizeof(modelURLLength)); - dataAt += sizeof(modelURLLength); - bytesRead += sizeof(modelURLLength); - QString modelURLString((const char*)dataAt); - setModelURL(modelURLString); - dataAt += modelURLLength; - bytesRead += modelURLLength; - - // rotation - int bytes = unpackOrientationQuatFromBytes(dataAt, _rotation); - dataAt += bytes; - bytesRead += bytes; - - if (args.bitstreamVersion >= VERSION_ENTITIES_HAVE_ANIMATION) { - // animationURL - uint16_t animationURLLength; - memcpy(&animationURLLength, dataAt, sizeof(animationURLLength)); - dataAt += sizeof(animationURLLength); - bytesRead += sizeof(animationURLLength); - QString animationURLString((const char*)dataAt); - setAnimationURL(animationURLString); - dataAt += animationURLLength; - bytesRead += animationURLLength; - - // animationIsPlaying - bool animationIsPlaying; - memcpy(&animationIsPlaying, dataAt, sizeof(animationIsPlaying)); - dataAt += sizeof(animationIsPlaying); - bytesRead += sizeof(animationIsPlaying); - setAnimationIsPlaying(animationIsPlaying); - - // animationFrameIndex - float animationFrameIndex; - memcpy(&animationFrameIndex, dataAt, sizeof(animationFrameIndex)); - dataAt += sizeof(animationFrameIndex); - bytesRead += sizeof(animationFrameIndex); - setAnimationFrameIndex(animationFrameIndex); - - // animationFPS - float animationFPS; - memcpy(&animationFPS, dataAt, sizeof(animationFPS)); - dataAt += sizeof(animationFPS); - bytesRead += sizeof(animationFPS); - setAnimationFPS(animationFPS); - } - } - return bytesRead; -} - - // TODO: eventually only include properties changed since the params.lastViewFrustumSent time EntityPropertyFlags ModelEntityItem::getEntityProperties(EncodeBitstreamParams& params) const { EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params); diff --git a/libraries/entities/src/ModelEntityItem.h b/libraries/entities/src/ModelEntityItem.h index dc236644b7..a607745475 100644 --- a/libraries/entities/src/ModelEntityItem.h +++ b/libraries/entities/src/ModelEntityItem.h @@ -40,7 +40,6 @@ public: OctreeElement::AppendState& appendState) const; - virtual int readEntityDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args); virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args, EntityPropertyFlags& propertyFlags, bool overwriteLocalData); @@ -116,8 +115,6 @@ public: protected: - /// For reading models from pre V3 bitstreams - int oldVersionReadEntityDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args); bool isAnimatingSomething() const; rgbColor _color;