From c08dfc90c3a661024eb78db0faa63397afcedf42 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 2 May 2014 17:46:11 -0700 Subject: [PATCH] Add a hack to fix normals on Makehuman exports. --- libraries/fbx/src/FBXReader.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 385f45e323..0bf203be02 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -760,6 +760,7 @@ ExtractedMesh extractMesh(const FBXNode& object) { } else if (child.name == "LayerElementNormal") { data.normalsByVertex = false; + bool indexToDirect = false; foreach (const FBXNode& subdata, child.children) { if (subdata.name == "Normals") { data.normals = createVec3Vector(getDoubleVector(subdata)); @@ -767,11 +768,17 @@ ExtractedMesh extractMesh(const FBXNode& object) { } else if (subdata.name == "NormalsIndex") { data.normalIndices = getIntVector(subdata); - } else if (subdata.name == "MappingInformationType" && - subdata.properties.at(0) == "ByVertice") { + } else if (subdata.name == "MappingInformationType" && subdata.properties.at(0) == "ByVertice") { data.normalsByVertex = true; + + } else if (subdata.name == "ReferenceInformationType" && subdata.properties.at(0) == "IndexToDirect") { + indexToDirect = true; } } + if (indexToDirect && data.normalIndices.isEmpty()) { + // hack to work around wacky Makehuman exports + data.normalsByVertex = true; + } } else if (child.name == "LayerElementUV" && child.properties.at(0).toInt() == 0) { foreach (const FBXNode& subdata, child.children) { if (subdata.name == "UV") {