Allow empty slots in aiMesh::mTextureCoords.

1.Explicitly say in documentation that empty slots are allowed (it was unclear).
2.Change GetNumUVChannels() implementation to allow empty slots.
3.Revert fraction of 2da2835b29 where empty slots are detected and error logged.
pull/5636/head
Stepan Hrbek 2024-06-26 08:04:32 +02:00
parent cdf8394ccc
commit 1ccc82f2c4
2 changed files with 8 additions and 18 deletions

View File

@ -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) {

View File

@ -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;