From 3f129c32c665ea53e1afc84f048284eed463c0ca Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 5 Sep 2024 15:13:31 -0700 Subject: [PATCH] Fix AssimpLoader collada texture coordinates (#634) Fixes UNIT_AssimpLoader_TEST with assimp 5.4.3. This should fix homebrew CI. This PR tweaks the way we checks for texture coordinates from assimp. Empty texture coordinate slots are now allowed as of assimp/assimp#5636. The new logic should be compatible with assimp 5.4.3 and prior versions Signed-off-by: Ian Chen --- graphics/src/AssimpLoader.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/graphics/src/AssimpLoader.cc b/graphics/src/AssimpLoader.cc index bcbd7096..4cf8cf33 100644 --- a/graphics/src/AssimpLoader.cc +++ b/graphics/src/AssimpLoader.cc @@ -650,14 +650,14 @@ SubMesh AssimpLoader::Implementation::CreateSubMesh( subMesh.AddVertex(vertex); subMesh.AddNormal(normal); // Iterate over sets of texture coordinates - int uvIdx = 0; - while(_assimpMesh->HasTextureCoords(uvIdx)) + for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { + if (!_assimpMesh->HasTextureCoords(i)) + continue; math::Vector3d texcoords; - texcoords.X(_assimpMesh->mTextureCoords[uvIdx][vertexIdx].x); - texcoords.Y(_assimpMesh->mTextureCoords[uvIdx][vertexIdx].y); - subMesh.AddTexCoordBySet(texcoords.X(), texcoords.Y(), uvIdx); - ++uvIdx; + texcoords.X(_assimpMesh->mTextureCoords[i][vertexIdx].x); + texcoords.Y(_assimpMesh->mTextureCoords[i][vertexIdx].y); + subMesh.AddTexCoordBySet(texcoords.X(), texcoords.Y(), i); } } for (unsigned faceIdx = 0; faceIdx < _assimpMesh->mNumFaces; ++faceIdx)