mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:17:35 +02:00
clened up read and write of qVec- no longer converting between qVector and qByteArray
This commit is contained in:
parent
7b08537574
commit
93c3f90c95
1 changed files with 19 additions and 37 deletions
|
@ -381,23 +381,19 @@ bool OctreePacketData::appendValue(const glm::vec3& value) {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OctreePacketData::appendValue(const QVector<glm::vec3>& value){
|
bool OctreePacketData::appendValue(const QVector<glm::vec3>& value) {
|
||||||
uint16_t qVecSize = value.size() * sizeof(glm::vec3);
|
uint16_t qVecSize = value.size();
|
||||||
QByteArray myArray;
|
uint16_t sizeLength = sizeof(qVecSize);
|
||||||
const char* data = (const char*)value.data();
|
bool success = append((const unsigned char*)&qVecSize, sizeLength);
|
||||||
char* sizePointer = (char*)&qVecSize;
|
qDebug()<<"appendlength"<<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());
|
|
||||||
if(success){
|
if(success){
|
||||||
_bytesOfValues += length;
|
_bytesOfValues += sizeLength;
|
||||||
_totalBytesOfValues += length;
|
_totalBytesOfValues += sizeLength;
|
||||||
|
}
|
||||||
|
success = append((const unsigned char*)value.constData(), qVecSize * sizeof(glm::vec3));
|
||||||
|
if(success){
|
||||||
|
_bytesOfValues += qVecSize * sizeof(glm::vec3);
|
||||||
|
_totalBytesOfValues += qVecSize * sizeof(glm::vec3);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -600,27 +596,13 @@ int OctreePacketData::uppackDataFromBytes(const unsigned char* dataBytes, xColor
|
||||||
return sizeof(rgbColor);
|
return sizeof(rgbColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OctreePacketData::uppackDataFromBytes(const unsigned char *dataBytes, QVector<glm::vec3>& result){
|
int OctreePacketData::uppackDataFromBytes(const unsigned char *dataBytes, QVector<glm::vec3>& result) {
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
memcpy(&length, dataBytes, sizeof(uint16_t));
|
memcpy(&length, dataBytes, sizeof(uint16_t));
|
||||||
dataBytes += sizeof(length);
|
dataBytes += sizeof(length);
|
||||||
glm::vec3 myVec;
|
qDebug()<<"unpacking length"<<length;
|
||||||
for(int i = 0 ; i < length; i+= sizeof(float) * 3) {
|
result.resize(length);
|
||||||
//Go through and create three floats
|
memcpy(result.data(), dataBytes, length * sizeof(glm::vec3));
|
||||||
glm::vec3 point;
|
|
||||||
float x;
|
return sizeof(uint16_t) + length * sizeof(glm::vec3);
|
||||||
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);
|
|
||||||
}
|
|
Loading…
Reference in a new issue