mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
make sure material IDs are de-duplicated
This commit is contained in:
parent
88b8fb4c5e
commit
c445d914d7
2 changed files with 6 additions and 6 deletions
|
@ -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,
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue