Fix nullptr dereferencing

- Check if we have any texture coordinates before calculating them
- closes https://github.com/assimp/assimp/issues/4445
pull/4446/head
Kim Kulling 2022-03-16 10:08:20 +01:00 committed by GitHub
parent 784d9615f5
commit 552f3a308d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -857,6 +857,9 @@ void MDLImporter::CalculateUVCoordinates_MDL5() {
const float fHeight = (float)iHeight; const float fHeight = (float)iHeight;
aiMesh *pcMesh = this->pScene->mMeshes[0]; aiMesh *pcMesh = this->pScene->mMeshes[0];
for (unsigned int i = 0; i < pcMesh->mNumVertices; ++i) { for (unsigned int i = 0; i < pcMesh->mNumVertices; ++i) {
if (!pcMesh->HasTextureCoords(0)) {
continue;
}
pcMesh->mTextureCoords[0][i].x /= fWidth; pcMesh->mTextureCoords[0][i].x /= fWidth;
pcMesh->mTextureCoords[0][i].y /= fHeight; pcMesh->mTextureCoords[0][i].y /= fHeight;
pcMesh->mTextureCoords[0][i].y = 1.0f - pcMesh->mTextureCoords[0][i].y; // DX to OGL pcMesh->mTextureCoords[0][i].y = 1.0f - pcMesh->mTextureCoords[0][i].y; // DX to OGL