And more changes for better syntax and less useless stuff

This commit is contained in:
sam gateau 2018-10-02 13:09:04 -07:00
parent e5df356774
commit 5d0f2e3035
3 changed files with 13 additions and 27 deletions

View file

@ -355,7 +355,7 @@ void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, bool isWireframe
bool isDeformed = _isBlendShaped || _isSkinned;
if (isWireframe) {
isTranslucent = hasTangents = hasLightmap = isDeformed = false;
isTranslucent = hasTangents = hasLightmap = false;
}
ShapeKey::Builder builder;

View file

@ -1614,33 +1614,22 @@ public:
using packBlendshapeOffsetTo = void(glm::uvec4& packed, const BlendshapeOffsetUnpacked& unpacked);
void packBlendshapeOffsetTo_Pos_F32_3xSN10_Nor_3xSN10_Tan_3xSN10(glm::uvec4& packed, const BlendshapeOffsetUnpacked& unpacked) {
float len = glm::compMax(glm::abs(unpacked.positionOffsetAndSpare));
glm::vec3 normalizedPos(unpacked.positionOffsetAndSpare);
float len = glm::compMax(glm::abs(unpacked.positionOffset));
glm::vec3 normalizedPos(unpacked.positionOffset);
if (len > 1.0f) {
normalizedPos /= len;
}
else {
} else {
len = 1.0f;
}
packed = glm::uvec4(
glm::floatBitsToUint(len),
glm::packSnorm3x10_1x2(glm::vec4(normalizedPos, 0.0f)),
glm::packSnorm3x10_1x2(glm::vec4(unpacked.normalOffsetAndSpare, 0.0f)),
glm::packSnorm3x10_1x2(glm::vec4(unpacked.tangentOffsetAndSpare, 0.0f))
glm::packSnorm3x10_1x2(glm::vec4(unpacked.normalOffset, 0.0f)),
glm::packSnorm3x10_1x2(glm::vec4(unpacked.tangentOffset, 0.0f))
);
}
void packBlendshapeOffsetTo_Pos_3xF16_Nor_3xSN10_Tan_3xSN10(glm::uvec4& packed, const BlendshapeOffsetUnpacked& unpacked) {
packed = glm::uvec4(
glm::packHalf2x16(glm::vec2(unpacked.positionOffsetAndSpare)),
glm::packHalf2x16(glm::vec2(unpacked.positionOffsetAndSpare.z, 0.0f)),
glm::packSnorm3x10_1x2(glm::vec4(unpacked.normalOffsetAndSpare, 0.0f)),
glm::packSnorm3x10_1x2(glm::vec4(unpacked.tangentOffsetAndSpare, 0.0f))
);
}
class Blender : public QRunnable {
public:
@ -1691,20 +1680,17 @@ void Blender::run() {
float normalCoefficient = vertexCoefficient * NORMAL_COEFFICIENT_SCALE;
const FBXBlendshape& blendshape = mesh.blendshapes.at(i);
bool doTangent = (mesh.tangents.size()) && (blendshape.tangents.size());
tbb::parallel_for(tbb::blocked_range<int>(0, blendshape.indices.size()), [&](const tbb::blocked_range<int>& range) {
for (auto j = range.begin(); j < range.end(); j++) {
int index = blendshape.indices.at(j);
auto& currentBlendshapeOffset = unpackedBlendshapeOffsets[index];
currentBlendshapeOffset.positionOffsetAndSpare += blendshape.vertices.at(j) * vertexCoefficient;
currentBlendshapeOffset.positionOffset += blendshape.vertices.at(j) * vertexCoefficient;
currentBlendshapeOffset.normalOffsetAndSpare += blendshape.normals.at(j) * normalCoefficient;
if (doTangent) {
if ((int)j < blendshape.tangents.size()) {
currentBlendshapeOffset.tangentOffsetAndSpare += blendshape.tangents.at(j) * normalCoefficient;
}
currentBlendshapeOffset.normalOffset += blendshape.normals.at(j) * normalCoefficient;
if (j < blendshape.tangents.size()) {
currentBlendshapeOffset.tangentOffset += blendshape.tangents.at(j) * normalCoefficient;
}
}
});

View file

@ -80,9 +80,9 @@ struct BlendshapeOffsetPacked {
};
struct BlendshapeOffsetUnpacked {
glm::vec3 positionOffsetAndSpare;
glm::vec3 normalOffsetAndSpare;
glm::vec3 tangentOffsetAndSpare;
glm::vec3 positionOffset;
glm::vec3 normalOffset;
glm::vec3 tangentOffset;
};
using BlendshapeOffset = BlendshapeOffsetPacked;