From f4f60e1ae7fb9cd36db1134a18dba4d410ca1c62 Mon Sep 17 00:00:00 2001 From: Areloch Date: Fri, 16 Oct 2020 17:03:30 -0500 Subject: [PATCH] Improves default suffix handling for asset importer on image assets under a material asset --- Engine/source/T3D/assets/assetImporter.cpp | 74 ++++++++++++++-------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index b36376513..95b3d1248 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -1613,7 +1613,10 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem) String imageAssetName = childAssetItem->assetName; - materialImageNoSuffix = imageAssetName.erase(imageAssetName.length() - suffix.length(), suffix.length());//cache this for later as we may need it for file association lookups + if (suffix.isEmpty()) + materialImageNoSuffix = imageAssetName; + else + materialImageNoSuffix = imageAssetName.erase(imageAssetName.length() - suffix.length(), suffix.length());//cache this for later as we may need it for file association lookups } } } @@ -1622,34 +1625,34 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem) //Now that we've checked off any existingly matched image types, process through the unmatched to look for files that associate for (S32 t = 0; t < ImageAsset::ImageTypeCount; t++) { + //This type wasn't found, so try and find a match based on suffix + String suffixList; + + switch (t) + { + case ImageAsset::Albedo: + suffixList = activeImportConfig->DiffuseTypeSuffixes; + break; + case ImageAsset::Normal: + suffixList = activeImportConfig->NormalTypeSuffixes; + break; + case ImageAsset::ORMConfig: + suffixList = activeImportConfig->PBRTypeSuffixes; + break; + case ImageAsset::Metalness: + suffixList = activeImportConfig->MetalnessTypeSuffixes; + break; + case ImageAsset::AO: + suffixList = activeImportConfig->AOTypeSuffixes; + break; + case ImageAsset::Roughness: + suffixList = activeImportConfig->RoughnessTypeSuffixes; + break; + //TODO: Glow map lookup too + } + if (!matchedImageTypes[t]) { - //This type wasn't found, so try and find a match based on suffix - String suffixList; - - switch (t) - { - case ImageAsset::Albedo: - suffixList = activeImportConfig->DiffuseTypeSuffixes; - break; - case ImageAsset::Normal: - suffixList = activeImportConfig->NormalTypeSuffixes; - break; - case ImageAsset::ORMConfig: - suffixList = activeImportConfig->PBRTypeSuffixes; - break; - case ImageAsset::Metalness: - suffixList = activeImportConfig->MetalnessTypeSuffixes; - break; - case ImageAsset::AO: - suffixList = activeImportConfig->AOTypeSuffixes; - break; - case ImageAsset::Roughness: - suffixList = activeImportConfig->RoughnessTypeSuffixes; - break; - //TODO: Glow map lookup too - } - U32 suffixCount = StringUnit::getUnitCount(suffixList.c_str(), ",;"); for (U32 i = 0; i < suffixCount; i++) { @@ -1716,6 +1719,18 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem) } } } + else + { + //just a bit of cleanup and logical testing for matches + //in the event we KNOW what the type is, but we don't have a suffix, such as a found image on a material lookup + //that doesn't have a suffix, we assume it to be the albedo, so we'll just append the suffix to avoid collisions if + //the name already matches our material name, similar to above logic + if (matchedImageTypes[t]->assetName == assetItem->assetName) + { + matchedImageTypes[t]->assetName += StringUnit::getUnit(suffixList.c_str(), 0, ",;"); + matchedImageTypes[t]->cleanAssetName = matchedImageTypes[t]->assetName; + } + } } /*for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) @@ -1904,6 +1919,11 @@ void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 m { imageAssetItem->imageSuffixType = suffixType; } + else + { + //we'll assume it's albedo + imageAssetItem->imageSuffixType = "Albedo"; + } } else {