diff --git a/code/AssetLib/Collada/ColladaLoader.cpp b/code/AssetLib/Collada/ColladaLoader.cpp index 2574fd2ea..6d7085b35 100644 --- a/code/AssetLib/Collada/ColladaLoader.cpp +++ b/code/AssetLib/Collada/ColladaLoader.cpp @@ -625,16 +625,14 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc } // same for texture coords, as many as we have - // empty slots are not allowed, need to pack and adjust UV indexes accordingly - for (size_t a = 0, real = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { + for (size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { if (pSrcMesh->mTexCoords[a].size() >= pStartVertex + numVertices) { - dstMesh->mTextureCoords[real] = new aiVector3D[numVertices]; + dstMesh->mTextureCoords[a] = new aiVector3D[numVertices]; for (size_t b = 0; b < numVertices; ++b) { - dstMesh->mTextureCoords[real][b] = pSrcMesh->mTexCoords[a][pStartVertex + b]; + dstMesh->mTextureCoords[a][b] = pSrcMesh->mTexCoords[a][pStartVertex + b]; } - dstMesh->mNumUVComponents[real] = pSrcMesh->mNumUVComponents[a]; - ++real; + dstMesh->mNumUVComponents[a] = pSrcMesh->mNumUVComponents[a]; } } diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index 1dd5d436a..8441b48be 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -371,20 +371,7 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh) { ReportWarning("There are unreferenced vertices"); } - // texture channel 2 may not be set if channel 1 is zero ... - { - unsigned int i = 0; - for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { - if (!pMesh->HasTextureCoords(i)) break; - } - for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) - if (pMesh->HasTextureCoords(i)) { - ReportError("Texture coordinate channel %i exists " - "although the previous channel was nullptr.", - i); - } - } - // the same for the vertex colors + // vertex color channel 2 may not be set if channel 1 is zero ... { unsigned int i = 0; for (; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) { diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index ed9a8faf9..da81cc24c 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -729,8 +729,9 @@ struct aiMesh { /** * @brief Vertex texture coordinates, also known as UV channels. * - * A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per - * vertex. nullptr if not present. The array is mNumVertices in size. + * A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS channels per + * vertex. Used and unused (nullptr) channels may go in any order. + * The array is mNumVertices in size. */ C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; @@ -950,8 +951,10 @@ struct aiMesh { //! @return the number of stored uv-channels. unsigned int GetNumUVChannels() const { unsigned int n(0); - while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) { - ++n; + for (unsigned i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) { + if (mTextureCoords[i]) { + ++n; + } } return n;