diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index f76e2a6d9b..50579e3979 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -381,23 +381,19 @@ bool OctreePacketData::appendValue(const glm::vec3& value) { return success; } -bool OctreePacketData::appendValue(const QVector& value){ - uint16_t qVecSize = value.size() * sizeof(glm::vec3); - QByteArray myArray; - const char* data = (const char*)value.data(); - char* sizePointer = (char*)&qVecSize; - QByteArray vecSize(sizePointer, sizeof(uint16_t)); - myArray.append(vecSize); - uint16_t arrayLength; - memcpy(&arrayLength, myArray.data(), sizeof(uint16_t)); - for(int i = 0; i < qVecSize; i++){ - myArray.append(data[i]); - } - int length = qVecSize + sizeof(uint16_t); - bool success = append((const unsigned char*)myArray.constData(), myArray.size()); +bool OctreePacketData::appendValue(const QVector& value) { + uint16_t qVecSize = value.size(); + uint16_t sizeLength = sizeof(qVecSize); + bool success = append((const unsigned char*)&qVecSize, sizeLength); + qDebug()<<"appendlength"<& result){ +int OctreePacketData::uppackDataFromBytes(const unsigned char *dataBytes, QVector& result) { uint16_t length; memcpy(&length, dataBytes, sizeof(uint16_t)); dataBytes += sizeof(length); - glm::vec3 myVec; - for(int i = 0 ; i < length; i+= sizeof(float) * 3) { - //Go through and create three floats - glm::vec3 point; - float x; - memcpy(&x, dataBytes, sizeof(float)); - point.x = x; - dataBytes += sizeof(float); - float y; - memcpy(&y, dataBytes, sizeof(float)); - point.y = y; - dataBytes += sizeof(float); - float z; - memcpy(&z, dataBytes, sizeof(float)); - point.z = z; - dataBytes += sizeof(float); - result.append(point); - } - return length + sizeof(length); -} + qDebug()<<"unpacking length"<