make sure material IDs are de-duplicated

This commit is contained in:
Stephen Birarda 2017-09-12 21:59:46 -07:00
parent 88b8fb4c5e
commit c445d914d7
2 changed files with 6 additions and 6 deletions

View file

@ -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<int>& 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,

View file

@ -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<int64_t, 2>(mappedIndex, &matTexValue[0]);
matTexAttribute->ConvertValue<uint16_t, 1>(mappedIndex, &materialID);
}
QPair<int, int> materialTexture(matTexValue[0], matTexValue[1]);
QPair<int, int> materialTexture(materialID, 0);
// grab or setup the FBXMeshPart for the part this face belongs to
int& partIndexPlusOne = materialTextureParts[materialTexture];