From 552f3a308d23a3f9981125ee08555e4b69fd6d31 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 16 Mar 2022 10:08:20 +0100 Subject: [PATCH] Fix nullptr dereferencing - Check if we have any texture coordinates before calculating them - closes https://github.com/assimp/assimp/issues/4445 --- code/AssetLib/MDL/MDLLoader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index 1e90c8e71..9c9cf910c 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -857,6 +857,9 @@ void MDLImporter::CalculateUVCoordinates_MDL5() { const float fHeight = (float)iHeight; aiMesh *pcMesh = this->pScene->mMeshes[0]; for (unsigned int i = 0; i < pcMesh->mNumVertices; ++i) { + if (!pcMesh->HasTextureCoords(0)) { + continue; + } pcMesh->mTextureCoords[0][i].x /= fWidth; pcMesh->mTextureCoords[0][i].y /= fHeight; pcMesh->mTextureCoords[0][i].y = 1.0f - pcMesh->mTextureCoords[0][i].y; // DX to OGL