mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Clean up.
This commit is contained in:
parent
e37b98e0f5
commit
7e53f0b7dc
1 changed files with 2 additions and 32 deletions
|
@ -1415,34 +1415,20 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
|||
}
|
||||
|
||||
QByteArray EntityItemProperties::getPackedNormals() const {
|
||||
qDebug() << "------------PACKINGNORMALS START-----------------";
|
||||
qDebug() << "------------PACKINGNORMALS START SIZE-----------------" << getNormals().size();
|
||||
return packNormals(getNormals());
|
||||
}
|
||||
|
||||
QByteArray EntityItemProperties::packNormals(const QVector<glm::vec3>& normals) const {
|
||||
qDebug() << "------------PACKINGNORMALS-----------------";
|
||||
int normalsSize = normals.size();
|
||||
QByteArray packedNormals = QByteArray(normalsSize * 6 + 1, '0');
|
||||
// add size of the array
|
||||
packedNormals[0] = ((uint8_t)normalsSize);
|
||||
qDebug() << "------------PACKINGNORMALS START SIZE-----------------"
|
||||
<< (int)packedNormals[0]
|
||||
<< " / "
|
||||
<< ((uint8_t)normalsSize)
|
||||
<< " * "
|
||||
<< normalsSize
|
||||
<< " = "
|
||||
<< normals.count();
|
||||
|
||||
int index = 1;
|
||||
for (int i = 0; i < normalsSize; i++) {
|
||||
int numBytes = packFloatVec3ToSignedTwoByteFixed((unsigned char*)packedNormals.data() + index, normals[i], 15);
|
||||
qDebug() << "PACKINGNORMALS " << normals[i].x << " " << normals[i].y << " " << normals[i].z;
|
||||
//memcpy(packedNormals.data() + index, auxBuffer, numBytes);
|
||||
index += numBytes;
|
||||
}
|
||||
qDebug() << "----------------ENDPACKINGNORMALS--------------------";
|
||||
return packedNormals;
|
||||
}
|
||||
|
||||
|
@ -1450,7 +1436,6 @@ QByteArray EntityItemProperties::getPackedStrokeColors() const {
|
|||
return packStrokeColors(getStrokeColors());
|
||||
}
|
||||
QByteArray EntityItemProperties::packStrokeColors(const QVector<glm::vec3>& strokeColors) const {
|
||||
qDebug() << "***************PACKINGSTROKECOLORS**********************";
|
||||
int strokeColorsSize = strokeColors.size();
|
||||
QByteArray packedStrokeColors = QByteArray(strokeColorsSize * 3 + 1, '0');
|
||||
|
||||
|
@ -1468,11 +1453,7 @@ QByteArray EntityItemProperties::packStrokeColors(const QVector<glm::vec3>& stro
|
|||
packedStrokeColors[i * 3 + 1] = strokeColors[i].r * 255;
|
||||
packedStrokeColors[i * 3 + 2] = strokeColors[i].g * 255;
|
||||
packedStrokeColors[i * 3 + 3] = strokeColors[i].b * 255;
|
||||
|
||||
qDebug() << "PACKINGSTROKECOLORS" << strokeColors[i].r << " " << strokeColors[i].g << " " << strokeColors[i].b;
|
||||
}
|
||||
|
||||
qDebug() << "**************ENDPACKINGSTROKECOLORS********************";
|
||||
return packedStrokeColors;
|
||||
}
|
||||
|
||||
|
@ -1723,24 +1704,18 @@ void EntityItemProperties::setPackedNormals(const QByteArray& value) {
|
|||
}
|
||||
|
||||
QVector<glm::vec3> EntityItemProperties::unpackNormals(const QByteArray& normals) {
|
||||
qDebug() << "***************UNPACKINGNORMALS**********************";
|
||||
// the size of the vector is packed first
|
||||
QVector<glm::vec3> unpackedNormals = QVector<glm::vec3>((int)normals[0]);
|
||||
qDebug() << "UNPACKINGNORMALS SIZE TEST " << (int)normals[0] << " " << (normals.size() / 6);
|
||||
|
||||
if ((int)normals[0] == normals.size() / 6) {
|
||||
|
||||
qDebug() << "UNPACKINGNORMALS SIZE " << normals[0];
|
||||
int j = 0;
|
||||
for (int i = 1; i < normals.size();) {
|
||||
glm::vec3 aux = glm::vec3();
|
||||
i += unpackFloatVec3FromSignedTwoByteFixed((unsigned char*)normals.data() + i, aux, 15);
|
||||
unpackedNormals[j] = aux;
|
||||
qDebug() << "UNPACKINGNORMALS::" << unpackedNormals[j].x << " " << unpackedNormals[j].y << " " << unpackedNormals[j].z;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
qDebug() << "***************ENDUNPACKINGNORMALS**********************";
|
||||
return unpackedNormals;
|
||||
}
|
||||
|
||||
|
@ -1749,25 +1724,20 @@ void EntityItemProperties::setPackedStrokeColors(const QByteArray& value) {
|
|||
}
|
||||
|
||||
QVector<glm::vec3> EntityItemProperties::unpackStrokeColors(const QByteArray& strokeColors) {
|
||||
qDebug() << "------------UNPACKINGSTROKECOLORS-----------------";
|
||||
// the size of the vector is packed first
|
||||
QVector<glm::vec3> unpackedStrokeColors = QVector<glm::vec3>((int)strokeColors[0]);
|
||||
qDebug() << "UNPACKINGSTROKECOLORS SIZE TEST " << (int)strokeColors[0] << " " << (strokeColors.size() / 3);
|
||||
|
||||
|
||||
if ((int)strokeColors[0] == strokeColors.size() / 3) {
|
||||
qDebug() << "UNPACKINGSTROKECOLORS SIZE " << strokeColors[0];
|
||||
int j = 0;
|
||||
for (int i = 1; i < strokeColors.size();) {
|
||||
|
||||
float r = (uint8_t)strokeColors[i++] / 255.0f;
|
||||
float g = (uint8_t)strokeColors[i++] / 255.0f;
|
||||
float b = (uint8_t)strokeColors[i++] / 255.0f;
|
||||
qDebug() << "UNPACKINGSTROKECOLORS " << r << " " << g << " " << b;
|
||||
|
||||
unpackedStrokeColors[j++] = glmVec3(r, g, b);
|
||||
}
|
||||
}
|
||||
qDebug() << "-----------------ENDUNPACKINGSTROKECOLORS------------------";
|
||||
|
||||
return unpackedStrokeColors;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue