From 53bb3472eac8ffb1ccb511207f19d1dc71bbeb44 Mon Sep 17 00:00:00 2001 From: hhalen Date: Mon, 8 Apr 2019 18:48:16 -0700 Subject: [PATCH] Fix skinning weight normalization. Previous code would call Normalized() on a Vec4f containing the weights. This normalizes the vector, i.e. makes the length of the vector equal to 1.0. For skinning weights what we want is the sum of the weights to be 1.0, which is a different. This commit fixes that. --- src/fbx/FbxSkinningAccess.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fbx/FbxSkinningAccess.cpp b/src/fbx/FbxSkinningAccess.cpp index f76d8ec..795cece 100644 --- a/src/fbx/FbxSkinningAccess.cpp +++ b/src/fbx/FbxSkinningAccess.cpp @@ -75,7 +75,8 @@ FbxSkinningAccess::FbxSkinningAccess(const FbxMesh* pMesh, FbxScene* pScene, Fbx } } for (int i = 0; i < controlPointCount; i++) { - vertexJointWeights[i] = vertexJointWeights[i].Normalized(); + const float weightSumRcp = 1.0 / (vertexJointWeights[i][0] + vertexJointWeights[i][1] + vertexJointWeights[i][2] + vertexJointWeights[i][3]); + vertexJointWeights[i] *= weightSumRcp; } } }