Merge branch 'master' into integrate-tinyusdz-br-rendermesh-refactor

pull/5628/head
Steve M 2024-07-10 16:57:01 -07:00
commit 4916202fa2
3 changed files with 12 additions and 24 deletions

View File

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

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;