File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -351,7 +351,10 @@ namespace our {
351351 if (mat->GetTextureCount (type) == 0 ) return nullptr ;
352352 if (mat->GetTexture (type, 0 , &path) != AI_SUCCESS ) return nullptr ;
353353
354- Texture2D* texture = nullptr ;
354+ std::string cacheKey = this ->name + " _" + path.C_Str ();
355+ Texture2D* texture = AssetLoader<Texture2D>::get (cacheKey);
356+ if (texture) return texture;
357+
355358 if (path.length > 0 && path.data [0 ] == ' *' ) {
356359 // this is an embedded texture, we can load it directly from memory
357360 const aiTexture* embeddedTexture = scene->GetEmbeddedTexture (path.C_Str ());
@@ -387,7 +390,7 @@ namespace our {
387390 glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR );
388391 texture->unbind ();
389392
390- AssetLoader<Texture2D>::add (path. C_Str () , texture);
393+ AssetLoader<Texture2D>::add (cacheKey , texture);
391394 return texture;
392395 }
393396
You can’t perform that action at this time.
0 commit comments