From 145f0d84a1bab642a53e7198f21ba26eb7e8e365 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Tue, 7 Nov 2017 13:59:13 -0800 Subject: [PATCH] Minor normal/tangent cleanup. --- src/Fbx2Raw.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Fbx2Raw.cpp b/src/Fbx2Raw.cpp index 2d694aa..61f8e57 100644 --- a/src/Fbx2Raw.cpp +++ b/src/Fbx2Raw.cpp @@ -784,16 +784,14 @@ static void ReadMesh(RawModel &raw, FbxScene *pScene, FbxNode *pNode, const std: const FbxVector4 &shapePosition = transform.MultNormalize(targetShape->positions[controlPointIndex]); blendVertex.position = toVec3f(shapePosition - fbxPosition); if (targetShape->normals.LayerPresent()) { - FbxVector4 normal = targetShape->normals.GetElement( + const FbxVector4 &normal = targetShape->normals.GetElement( polygonIndex, polygonVertexIndex, controlPointIndex, FbxVector4(0.0f, 0.0f, 0.0f, 0.0f), inverseTransposeTransform, true); - normal -= fbxNormal; - blendVertex.normal = toVec3f(normal); + blendVertex.normal = toVec3f(normal - fbxNormal); } if (targetShape->tangents.LayerPresent()) { - FbxVector4 tangent = targetShape->tangents.GetElement( + const FbxVector4 &tangent = targetShape->tangents.GetElement( polygonIndex, polygonVertexIndex, controlPointIndex, FbxVector4(0.0f, 0.0f, 0.0f, 0.0f), inverseTransposeTransform, true); - tangent -= fbxTangent; - blendVertex.tangent = toVec4f(tangent); + blendVertex.tangent = toVec4f(tangent - fbxTangent); } vertex.blends.push_back(blendVertex); }