From c445d914d7d4704edd7bcbad2716b7144bdbbfce Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 12 Sep 2017 21:59:46 -0700 Subject: [PATCH] make sure material IDs are de-duplicated --- libraries/baking/src/FBXBaker.cpp | 6 +++--- libraries/fbx/src/FBXReader_Mesh.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/baking/src/FBXBaker.cpp b/libraries/baking/src/FBXBaker.cpp index 52c63c26d0..271a25e9dd 100644 --- a/libraries/baking/src/FBXBaker.cpp +++ b/libraries/baking/src/FBXBaker.cpp @@ -349,7 +349,7 @@ void FBXBaker::rewriteAndBakeSceneModels() { if (hasPerFaceMaterials) { faceMaterialAttributeID = meshBuilder.AddAttribute( (draco::GeometryAttribute::Type)DRACO_ATTRIBUTE_MATERIAL_ID, - 2, draco::DT_INT64); + 1, draco::DT_UINT16); } @@ -357,7 +357,6 @@ void FBXBaker::rewriteAndBakeSceneModels() { draco::FaceIndex face; for (auto& part : mesh.parts) { const auto matTex = extractedMesh.partMaterialTextures[partIndex]; - const int64_t matTexData[2] = { matTex.first, matTex.second }; auto addFace = [&](QVector& indices, int index, draco::FaceIndex face) { auto idx0 = indices[index]; @@ -365,7 +364,8 @@ void FBXBaker::rewriteAndBakeSceneModels() { auto idx2 = indices[index + 2]; if (hasPerFaceMaterials) { - meshBuilder.SetPerFaceAttributeValueForFace(faceMaterialAttributeID, face, &matTexData); + uint16_t materialID = matTex.first; + meshBuilder.SetPerFaceAttributeValueForFace(faceMaterialAttributeID, face, &materialID); } meshBuilder.SetAttributeValuesForFace(positionAttributeID, face, diff --git a/libraries/fbx/src/FBXReader_Mesh.cpp b/libraries/fbx/src/FBXReader_Mesh.cpp index f1524b1a81..323ecac37b 100644 --- a/libraries/fbx/src/FBXReader_Mesh.cpp +++ b/libraries/fbx/src/FBXReader_Mesh.cpp @@ -415,16 +415,16 @@ ExtractedMesh FBXReader::extractMesh(const FBXNode& object, unsigned int& meshIn // grab the material ID and texture ID for this face, if we have it auto firstCorner = dracoMesh->face(draco::FaceIndex(i))[0]; - int64_t matTexValue[2] = { 0, 0 }; + uint16_t materialID { 0 }; if (matTexAttribute) { // read material ID and texture ID mappings into materials and texture vectors auto mappedIndex = matTexAttribute->mapped_index(firstCorner); - matTexAttribute->ConvertValue(mappedIndex, &matTexValue[0]); + matTexAttribute->ConvertValue(mappedIndex, &materialID); } - QPair materialTexture(matTexValue[0], matTexValue[1]); + QPair materialTexture(materialID, 0); // grab or setup the FBXMeshPart for the part this face belongs to int& partIndexPlusOne = materialTextureParts[materialTexture];