support for models in root element

This commit is contained in:
ZappoMan 2014-05-20 15:20:27 -07:00
parent 1278470a91
commit e7425a8128
4 changed files with 28 additions and 4 deletions

View file

@ -41,6 +41,7 @@ public:
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode);
virtual bool rootElementHasData() const { return true; }
virtual void update();
void storeModel(const ModelItem& model, const SharedNodePointer& senderNode = SharedNodePointer());

View file

@ -53,8 +53,6 @@ PacketVersion versionForPacketType(PacketType type) {
return 1;
case PacketTypeEnvironmentData:
return 1;
case PacketTypeParticleData:
return 1;
case PacketTypeDomainList:
case PacketTypeDomainListRequest:
return 3;
@ -66,8 +64,10 @@ PacketVersion versionForPacketType(PacketType type) {
return 1;
case PacketTypeOctreeStats:
return 1;
case PacketTypeParticleData:
return 1;
case PacketTypeModelData:
return 1;
return 2;
default:
return 0;
}

View file

@ -301,6 +301,13 @@ int Octree::readElementData(OctreeElement* destinationElement, const unsigned ch
}
}
}
// if this is the root, and there is more data to read, allow it to read it's element data...
if (destinationElement == _rootElement && rootElementHasData() && (bytesLeftToRead - bytesRead) > 0) {
// tell the element to read the subsequent data
bytesRead += _rootElement->readElementDataFromBuffer(nodeData + bytesRead, bytesLeftToRead - bytesRead, args);
}
return bytesRead;
}
@ -1524,7 +1531,22 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
}
} // end keepDiggingDeeper
// At this point all our BitMasks are complete... so let's output them to see how they compare...
// If we made it this far, then we've written all of our child data... if this element is the root
// element, then we also allow the root element to write out it's data...
if (continueThisLevel && element == _rootElement && rootElementHasData()) {
int bytesBeforeChild = packetData->getUncompressedSize();
continueThisLevel = element->appendElementData(packetData, params);
int bytesAfterChild = packetData->getUncompressedSize();
if (continueThisLevel) {
bytesAtThisLevel += (bytesAfterChild - bytesBeforeChild); // keep track of byte count for this child
if (params.stats) {
params.stats->colorSent(element);
}
}
}
// if we were unable to fit this level in our packet, then rewind and add it to the element bag for
// sending later...
if (continueThisLevel) {

View file

@ -211,6 +211,7 @@ public:
const unsigned char* editData, int maxLength, const SharedNodePointer& sourceNode) { return 0; }
virtual bool recurseChildrenWithData() const { return true; }
virtual bool rootElementHasData() const { return false; }
virtual void update() { }; // nothing to do by default