Address QA comments.

This commit is contained in:
Daniela 2017-09-26 17:44:46 +01:00
parent d054c6dc36
commit 179a426389
5 changed files with 30 additions and 26 deletions

View file

@ -205,7 +205,6 @@ std::vector<PolyLineEntityRenderer::Vertex> PolyLineEntityRenderer::updateVertic
float uCoord = 0.0f;
int finalIndex = size - 1;
glm::vec3 binormal;
//
float accumulatedDistance = 0.0f;
float distanceToLastPoint = 0.0f;
float accumulatedStrokeWidth = 0.0f;
@ -213,8 +212,8 @@ std::vector<PolyLineEntityRenderer::Vertex> PolyLineEntityRenderer::updateVertic
bool doesStrokeWidthVary = false;
for (int i = 0; i < strokeWidths.size(); i++) {
if (i > 1 && strokeWidths[i] != strokeWidths[i - 1]) {
for (int i = 1; i < strokeWidths.size(); i++) {
if (strokeWidths[i] != strokeWidths[i - 1]) {
doesStrokeWidthVary = true;
break;
}
@ -227,9 +226,8 @@ std::vector<PolyLineEntityRenderer::Vertex> PolyLineEntityRenderer::updateVertic
const auto& color = strokeColors.size() == normals.size() ? strokeColors.at(i) : strokeColors.at(0);
int vertexIndex = i * 2;
//if (!isUVModeStretch && vertexIndex >= 2) {
if (!isUVModeStretch && i >= 1) {
//distanceToLastPoint = glm::distance(points.at(vertexIndex), points.at(vertexIndex - 2));
distanceToLastPoint = glm::distance(points.at(i), points.at(i - 1));
accumulatedDistance += distanceToLastPoint;
strokeWidth = 2 * strokeWidths[i];
@ -238,13 +236,17 @@ std::vector<PolyLineEntityRenderer::Vertex> PolyLineEntityRenderer::updateVertic
//If the stroke varies along the line the texture will stretch more or less depending on the speed
//because it looks better than using the same method as below
accumulatedStrokeWidth += strokeWidth;
float newUcoord = glm::ceil((textureAspectRatio * accumulatedDistance) / (accumulatedStrokeWidth / i));
float increaseValue = newUcoord - uCoord;
float increaseValue = 1;
if (accumulatedStrokeWidth != 0) {
float newUcoord = glm::ceil(((1.0f / textureAspectRatio) * accumulatedDistance) / (accumulatedStrokeWidth / i));
increaseValue = newUcoord - uCoord;
}
increaseValue = increaseValue > 0 ? increaseValue : 1;
uCoord += increaseValue;
} else {
//If the stroke width is constant then the textures should keep the aspect ratio along the line
uCoord = (textureAspectRatio * accumulatedDistance) / strokeWidth;
uCoord = ((1.0f / textureAspectRatio) * accumulatedDistance) / strokeWidth;
}
} else if (vertexIndex >= 2) {
uCoord += uCoordInc;
@ -261,10 +263,6 @@ std::vector<PolyLineEntityRenderer::Vertex> PolyLineEntityRenderer::updateVertic
}
}
//const auto v1 = point + binormal;
//const auto v2 = point - binormal;
const auto v1 = points.at(i) + binormal;
const auto v2 = points.at(i) - binormal;
vertices.emplace_back(v1, normal, vec2(uCoord, 0.0f), color);
@ -296,9 +294,7 @@ void PolyLineEntityRenderer::doRender(RenderArgs* args) {
float textureWidth = (float)_texture->getOriginalWidth();
float textureHeight = (float)_texture->getOriginalHeight();
if (textureWidth != 0 && textureHeight != 0) {
_textureAspectRatio = textureWidth < textureHeight
? textureWidth / textureHeight
: textureHeight / textureWidth;
_textureAspectRatio = textureWidth / textureHeight;
}
batch.setInputFormat(polylineFormat);

View file

@ -70,7 +70,6 @@ protected:
bool _empty{ true };
NetworkTexturePointer _texture;
float _textureAspectRatio { 1.0f };
QVector<glm::vec3> _vertices;
};

View file

@ -1710,6 +1710,9 @@ QVector<glm::vec3> EntityItemProperties::unpackNormals(const QByteArray& normals
unpackedNormals[j] = aux;
j++;
}
} else {
qCDebug(entities) << "WARNING - Expected received size for normals does not match. Expected: " << (int)normals[0]
<< " Received: " << (normals.size() / 6);
}
return unpackedNormals;
}
@ -1731,6 +1734,9 @@ QVector<glm::vec3> EntityItemProperties::unpackStrokeColors(const QByteArray& st
float b = (uint8_t)strokeColors[i++] / 255.0f;
unpackedStrokeColors[j++] = glmVec3(r, g, b);
}
} else {
qCDebug(entities) << "WARNING - Expected received size for stroke colors does not match. Expected: "
<< (int)strokeColors[0] << " Received: " << (strokeColors.size() / 3);
}
return unpackedStrokeColors;
@ -2250,6 +2256,10 @@ QList<QString> EntityItemProperties::listChangedProperties() {
out += "strokeColors";
}
if (isUVModeStretchChanged()) {
out += "isUVModeStretch";
}
getAnimation().listChangedProperties(out);
getKeyLight().listChangedProperties(out);
getSkybox().listChangedProperties(out);

View file

@ -31,7 +31,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
case PacketType::EntityData:
return VERSION_ENTITIES_STROKE_COLOR_PROPERTY;
case PacketType::EntityPhysics:
return VERSION_ENTITIES_UV_MODE_PROPERTY;
return VERSION_ENTITIES_ANIMATION_ALLOW_TRANSLATION_PROPERTIES;
case PacketType::EntityQuery:
return static_cast<PacketVersion>(EntityQueryPacketVersion::JSONFilterWithFamilyTree);
case PacketType::AvatarIdentity:

View file

@ -108,7 +108,6 @@
//Undo related logic
function setUndoState(disabled) {
//document.getElementById("message").innerHTML = "message received!";
if (!disabled) {
document.getElementById("undoButton").removeAttribute("disabled");
} else {