Browse Source

Update ImageAsset.cpp

update getAssetIdByFilename to also check the imageFile of the asset
This helps match filenames for assets created privately such as probe bakes and targets
marauder2k7 9 months ago
parent
commit
7af992970a
1 changed files with 32 additions and 1 deletions
  1. 32 1
      Engine/source/T3D/assets/ImageAsset.cpp

+ 32 - 1
Engine/source/T3D/assets/ImageAsset.cpp

@@ -297,7 +297,38 @@ StringTableEntry ImageAsset::getAssetIdByFilename(StringTableEntry fileName)
    }
    else
    {
-      AssetPtr<ImageAsset> imageAsset = imageAssetId; //ensures the fallback is loaded
+      foundAssetcount = AssetDatabase.findAssetType(&query, "ImageAsset");
+      if (foundAssetcount != 0)
+      {
+         // loop all image assets and see if we can find one
+         // using the same image file/named target.
+         for (auto imgAsset : query.mAssetList)
+         {
+            AssetPtr<ImageAsset> temp = imgAsset;
+            if (temp.notNull())
+            {
+               if (temp->getImageFile() == fileName)
+               {
+                  return imgAsset;
+               }
+               else
+               {
+                  Torque::Path temp1 = temp->getImageFile();
+                  Torque::Path temp2 = fileName;
+
+                  if (temp1.getFileName() == temp2.getFileName())
+                  {
+                     return imgAsset;
+                  }
+               }
+               
+            }
+         }
+      }
+      else
+      {
+         AssetPtr<ImageAsset> imageAsset = imageAssetId; //ensures the fallback is loaded
+      }
    }
 
    return imageAssetId;