------------------------------------------------------------------------------------------------
| 488 | |
| 489 | // ------------------------------------------------------------------------------------------------ |
| 490 | void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial *pMaterial, |
| 491 | aiTextureType type) { |
| 492 | const char *szType = aiTextureTypeToString(type); |
| 493 | |
| 494 | // **************************************************************************** |
| 495 | // Search all keys of the material ... |
| 496 | // textures must be specified with ascending indices |
| 497 | // (e.g. diffuse #2 may not be specified if diffuse #1 is not there ...) |
| 498 | // **************************************************************************** |
| 499 | |
| 500 | int iNumIndices = 0; |
| 501 | int iIndex = -1; |
| 502 | for (unsigned int i = 0; i < pMaterial->mNumProperties; ++i) { |
| 503 | aiMaterialProperty *prop = pMaterial->mProperties[i]; |
| 504 | ai_assert(nullptr != prop); |
| 505 | if (!::strcmp(prop->mKey.data, "$tex.file") && prop->mSemantic == static_cast<unsigned int>(type)) { |
| 506 | iIndex = std::max(iIndex, (int)prop->mIndex); |
| 507 | ++iNumIndices; |
| 508 | |
| 509 | if (aiPTI_String != prop->mType) { |
| 510 | ReportError("Material property %s is expected to be a string", prop->mKey.data); |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | if (iIndex + 1 != iNumIndices) { |
| 515 | ReportError("%s #%i is set, but there are only %i %s textures", |
| 516 | szType, iIndex, iNumIndices, szType); |
| 517 | } |
| 518 | if (!iNumIndices) { |
| 519 | return; |
| 520 | } |
| 521 | std::vector<aiTextureMapping> mappings(iNumIndices); |
| 522 | |
| 523 | // Now check whether all UV indices are valid ... |
| 524 | bool bNoSpecified = true; |
| 525 | for (unsigned int i = 0; i < pMaterial->mNumProperties; ++i) { |
| 526 | aiMaterialProperty *prop = pMaterial->mProperties[i]; |
| 527 | if (static_cast<aiTextureType>(prop->mSemantic) != type) { |
| 528 | continue; |
| 529 | } |
| 530 | |
| 531 | if ((int)prop->mIndex >= iNumIndices) { |
| 532 | ReportError("Found texture property with index %i, although there " |
| 533 | "are only %i textures of type %s", |
| 534 | prop->mIndex, iNumIndices, szType); |
| 535 | } |
| 536 | |
| 537 | if (!::strcmp(prop->mKey.data, "$tex.mapping")) { |
| 538 | if (aiPTI_Integer != prop->mType || prop->mDataLength < sizeof(aiTextureMapping)) { |
| 539 | ReportError("Material property %s%i is expected to be an integer (size is %i)", |
| 540 | prop->mKey.data, prop->mIndex, prop->mDataLength); |
| 541 | } |
| 542 | mappings[prop->mIndex] = *((aiTextureMapping *)prop->mData); |
| 543 | } else if (!::strcmp(prop->mKey.data, "$tex.uvtrafo")) { |
| 544 | if (aiPTI_Float != prop->mType || prop->mDataLength < sizeof(aiUVTransform)) { |
| 545 | ReportError("Material property %s%i is expected to be 5 floats large (size is %i)", |
| 546 | prop->mKey.data, prop->mIndex, prop->mDataLength); |
| 547 | } |
nothing calls this directly
no test coverage detected