glTF2: Make handling of embedded textures safer.

Previous code does not check whether the embedded texture exists.
pull/3946/head
Hill Ma 2021-06-08 12:53:18 -07:00
parent c58fe0c98f
commit ef739c1703
1 changed files with 7 additions and 8 deletions

View File

@ -515,9 +515,8 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTe
std::string imgId = mAsset->FindUniqueID("", "image");
texture->source = mAsset->images.Create(imgId);
if (path[0] == '*') { // embedded
aiTexture* curTex = mScene->mTextures[atoi(&path[1])];
const aiTexture* curTex = mScene->GetEmbeddedTexture(path.c_str());
if (curTex != nullptr) { // embedded
texture->source->name = curTex->mFilename.C_Str();
//basisu: embedded ktx2, bu