mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:28:03 +02:00
better packing of qvector of quats
This commit is contained in:
parent
3026415f03
commit
69839b4b16
1 changed files with 15 additions and 6 deletions
|
@ -395,13 +395,17 @@ bool OctreePacketData::appendValue(const QVector<glm::vec3>& value) {
|
||||||
bool OctreePacketData::appendValue(const QVector<glm::quat>& value) {
|
bool OctreePacketData::appendValue(const QVector<glm::quat>& value) {
|
||||||
uint16_t qVecSize = value.size();
|
uint16_t qVecSize = value.size();
|
||||||
bool success = appendValue(qVecSize);
|
bool success = appendValue(qVecSize);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
success = append((const unsigned char*)value.constData(), qVecSize * sizeof(glm::quat));
|
QByteArray dataByteArray(udt::MAX_PACKET_SIZE, 0);
|
||||||
if (success) {
|
unsigned char* start = reinterpret_cast<unsigned char*>(dataByteArray.data());
|
||||||
_bytesOfValues += qVecSize * sizeof(glm::quat);
|
unsigned char* destinationBuffer = start;
|
||||||
_totalBytesOfValues += qVecSize * sizeof(glm::quat);
|
for (int index = 0; index < value.size(); index++) {
|
||||||
|
destinationBuffer += packOrientationQuatToBytes(destinationBuffer, value[index]);
|
||||||
}
|
}
|
||||||
|
success = append(start, destinationBuffer - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,11 +653,16 @@ int OctreePacketData::unpackDataFromBytes(const unsigned char *dataBytes, QVecto
|
||||||
|
|
||||||
int OctreePacketData::unpackDataFromBytes(const unsigned char *dataBytes, QVector<glm::quat>& result) {
|
int OctreePacketData::unpackDataFromBytes(const unsigned char *dataBytes, QVector<glm::quat>& result) {
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
|
const unsigned char *start = dataBytes;
|
||||||
memcpy(&length, dataBytes, sizeof(uint16_t));
|
memcpy(&length, dataBytes, sizeof(uint16_t));
|
||||||
dataBytes += sizeof(length);
|
dataBytes += sizeof(length);
|
||||||
result.resize(length);
|
result.resize(length);
|
||||||
memcpy(result.data(), dataBytes, length * sizeof(glm::quat));
|
|
||||||
return sizeof(uint16_t) + length * sizeof(glm::quat);
|
for (int i = 0; i < length; i++) {
|
||||||
|
dataBytes += unpackOrientationQuatFromBytes(dataBytes, result[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataBytes - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QVector<float>& result) {
|
int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QVector<float>& result) {
|
||||||
|
|
Loading…
Reference in a new issue