{LYN-4996} Asset Processor is not reprocessing STL files after settings are edited/updated (#2095)
* add asset importer file extension Signed-off-by: sharmajs <sharmajs@amazon.com> * add new test setreg file Signed-off-by: sharmajs <sharmajs@amazon.com> * removed an unnecessary namespace Signed-off-by: sharmajs <sharmajs@amazon.com> * addressed feedback Signed-off-by: sharmajs <sharmajs@amazon.com> * addressed feedback Signed-off-by: sharmajs <sharmajs@amazon.com> * remove unnecessay method Signed-off-by: sharmajs <sharmajs@amazon.com> * add file Signed-off-by: sharmajs <sharmajs@amazon.com> * reduce waiting time in block until idle Signed-off-by: sharmajs <sharmajs@amazon.com>
This commit is contained in:
@@ -17,6 +17,9 @@ class QString;
|
||||
|
||||
namespace AzToolsFramework::AssetUtils
|
||||
{
|
||||
static constexpr const char* AssetImporterSettingsKey{ "/O3DE/SceneAPI/AssetImporter" };
|
||||
static constexpr const char* AssetImporterSupportedFileTypeKey{ "SupportedFileTypeExtensions" };
|
||||
|
||||
//! Reads the "/Amazon/AssetProcessor/Settings/Platforms" entry from the settings registry
|
||||
//! to retrieve all enabled platforms
|
||||
void ReadEnabledPlatformsFromSettingsRegistry(AZ::SettingsRegistryInterface& settingsRegistry,
|
||||
|
||||
@@ -238,6 +238,14 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
OUTPUT_SUBDIRECTORY
|
||||
testdata/DummyProject
|
||||
)
|
||||
ly_add_target_files(
|
||||
TARGETS
|
||||
AssetProcessor.Tests
|
||||
FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_metadata/AssetProcessorPlatformConfig.setreg
|
||||
OUTPUT_SUBDIRECTORY
|
||||
testdata/config_metadata
|
||||
)
|
||||
|
||||
# Have the AssetProcessorTest use the LY_CMAKE_TARGET define of AssetProcessorBatch for the purpose
|
||||
# of looking up the generated cmake build dependencies settings registry .setreg file
|
||||
|
||||
@@ -12,6 +12,7 @@ set(FILES
|
||||
testdata/config_broken_noscans/AssetProcessorPlatformConfig.setreg
|
||||
testdata/config_broken_recognizers/AssetProcessorPlatformConfig.setreg
|
||||
testdata/config_regular/AssetProcessorPlatformConfig.setreg
|
||||
testdata/config_metadata/AssetProcessorPlatformConfig.setreg
|
||||
testdata/config_regular_platform_scanfolder/AssetProcessorPlatformConfig.setreg
|
||||
testdata/EmptyDummyProject/AssetProcessorGamePlatformConfig.setreg
|
||||
testdata/DummyProject/AssetProcessorGamePlatformConfig.setreg
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
friend class GTEST_TEST_CLASS_NAME_(ModtimeScanningTest, ModtimeSkipping_ModifyMetadataFile);
|
||||
friend class GTEST_TEST_CLASS_NAME_(ModtimeScanningTest, ModtimeSkipping_DeleteFile);
|
||||
friend class GTEST_TEST_CLASS_NAME_(DeleteTest, DeleteFolderSharedAcrossTwoScanFolders_CorrectFileAndFolderAreDeletedFromCache);
|
||||
friend class GTEST_TEST_CLASS_NAME_(MetadataFileTest, MetadataFile_SourceFileExtensionDifferentCase);
|
||||
|
||||
friend class AssetProcessorManagerTest;
|
||||
friend struct ModtimeScanningTest;
|
||||
@@ -5241,3 +5242,59 @@ void DuplicateProcessTest::SetUp()
|
||||
m_sharedConnection = m_assetProcessorManager->m_stateData.get();
|
||||
ASSERT_TRUE(m_sharedConnection);
|
||||
}
|
||||
|
||||
void MetadataFileTest::SetUp()
|
||||
{
|
||||
AssetProcessorManagerTest::SetUp();
|
||||
m_config->AddMetaDataType("foo", "txt");
|
||||
}
|
||||
|
||||
TEST_F(MetadataFileTest, MetadataFile_SourceFileExtensionDifferentCase)
|
||||
{
|
||||
|
||||
using namespace AzToolsFramework::AssetSystem;
|
||||
using namespace AssetProcessor;
|
||||
|
||||
QDir tempPath(m_tempDir.path());
|
||||
|
||||
QString relFileName("Dummy.TXT");
|
||||
QString absPath(tempPath.absoluteFilePath("subfolder1/Dummy.TXT"));
|
||||
QString watchFolder = tempPath.absoluteFilePath("subfolder1");
|
||||
UnitTestUtils::CreateDummyFile(absPath, "dummy");
|
||||
|
||||
JobEntry entry;
|
||||
entry.m_watchFolderPath = watchFolder;
|
||||
entry.m_databaseSourceName = entry.m_pathRelativeToWatchFolder = relFileName;
|
||||
entry.m_jobKey = "txt";
|
||||
entry.m_platformInfo = { "pc", {"host", "renderer", "desktop"} };
|
||||
entry.m_jobRunKey = 1;
|
||||
|
||||
QString productPath(m_normalizedCacheRootDir.absoluteFilePath("outputfile.TXT"));
|
||||
UnitTestUtils::CreateDummyFile(productPath);
|
||||
|
||||
AssetBuilderSDK::ProcessJobResponse jobResponse;
|
||||
jobResponse.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success;
|
||||
jobResponse.m_outputProducts.push_back(AssetBuilderSDK::JobProduct(productPath.toUtf8().data()));
|
||||
|
||||
QMetaObject::invokeMethod(m_assetProcessorManager.get(), "AssetProcessed", Qt::QueuedConnection, Q_ARG(JobEntry, entry), Q_ARG(AssetBuilderSDK::ProcessJobResponse, jobResponse));
|
||||
|
||||
ASSERT_TRUE(BlockUntilIdle(5000));
|
||||
|
||||
// Creating a metadata file for the source assets
|
||||
// APM should process the source asset if a metadafile is detected
|
||||
// We are intentionally having a source file with a different file extension casing than the one specified in the metadata rule.
|
||||
QString metadataFile(tempPath.absoluteFilePath("subfolder1/Dummy.foo"));
|
||||
UnitTestUtils::CreateDummyFile(metadataFile, "dummy");
|
||||
|
||||
// Capture the job details as the APM inspects the file.
|
||||
JobDetails jobDetails;
|
||||
auto connection = QObject::connect(m_assetProcessorManager.get(), &AssetProcessorManager::AssetToProcess, [&jobDetails](JobDetails job)
|
||||
{
|
||||
jobDetails = job;
|
||||
});
|
||||
|
||||
m_assetProcessorManager->AssessAddedFile(tempPath.absoluteFilePath(metadataFile));
|
||||
|
||||
ASSERT_TRUE(BlockUntilIdle(5000));
|
||||
ASSERT_EQ(jobDetails.m_jobEntry.m_pathRelativeToWatchFolder, relFileName);
|
||||
}
|
||||
|
||||
@@ -179,6 +179,13 @@ struct ModtimeScanningTest
|
||||
AZStd::unique_ptr<StaticData> m_data;
|
||||
};
|
||||
|
||||
|
||||
struct MetadataFileTest
|
||||
: public AssetProcessorManagerTest
|
||||
{
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
struct FingerprintTest
|
||||
: public AssetProcessorManagerTest
|
||||
{
|
||||
|
||||
+22
@@ -21,6 +21,7 @@ class UnitTestPlatformConfiguration : public AssetProcessor::PlatformConfigurati
|
||||
{
|
||||
friend class GTEST_TEST_CLASS_NAME_(PlatformConfigurationUnitTests, Test_GemHandling);
|
||||
friend class GTEST_TEST_CLASS_NAME_(PlatformConfigurationUnitTests, Test_MetaFileTypes);
|
||||
friend class GTEST_TEST_CLASS_NAME_(PlatformConfigurationUnitTests, Test_MetaFileTypes_AssetImporterExtensions);
|
||||
protected:
|
||||
};
|
||||
|
||||
@@ -665,3 +666,24 @@ TEST_F(PlatformConfigurationUnitTests, PlatformConfigFile_IsPresent_Found)
|
||||
ASSERT_TRUE(config.AddPlatformConfigFilePaths(platformConfigList));
|
||||
ASSERT_EQ(platformConfigList.size(), 1);
|
||||
}
|
||||
|
||||
TEST_F(PlatformConfigurationUnitTests, Test_MetaFileTypes_AssetImporterExtensions)
|
||||
{
|
||||
using namespace AssetProcessor;
|
||||
|
||||
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
|
||||
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_metadata");
|
||||
ASSERT_TRUE(configRoot);
|
||||
UnitTestPlatformConfiguration config;
|
||||
m_absorber.Clear();
|
||||
ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
|
||||
ASSERT_GT(m_absorber.m_numErrorsAbsorbed, 0);
|
||||
ASSERT_TRUE(config.MetaDataFileTypesCount() == 2);
|
||||
|
||||
QStringList entriesToTest{ "aaa", "bbb" };
|
||||
for (int idx = 0; idx < entriesToTest.size(); idx++)
|
||||
{
|
||||
ASSERT_EQ(config.GetMetaDataFileTypeAt(idx).first, QString("%1.assetinfo").arg(entriesToTest[idx]));
|
||||
ASSERT_EQ(config.GetMetaDataFileTypeAt(idx).second, QString("%1").arg(entriesToTest[idx]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/Gem/GemInfo.h>
|
||||
#include <AzToolsFramework/Asset/AssetUtils.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -23,6 +24,21 @@ namespace
|
||||
|
||||
namespace AssetProcessor
|
||||
{
|
||||
|
||||
void AssetImporterPathsVisitor::Visit([[maybe_unused]] AZStd::string_view path, AZStd::string_view, AZ::SettingsRegistryInterface::Type,
|
||||
AZStd::string_view value)
|
||||
{
|
||||
auto found = value.find('.');
|
||||
if (found != AZStd::string::npos)
|
||||
{
|
||||
m_supportedFileExtensions.emplace_back(value.substr(found + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_supportedFileExtensions.emplace_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
struct PlatformsInfoVisitor
|
||||
: AZ::SettingsRegistryInterface::Visitor
|
||||
{
|
||||
@@ -1126,6 +1142,17 @@ namespace AssetProcessor
|
||||
|
||||
MetaDataTypesVisitor visitor;
|
||||
settingsRegistry->Visit(visitor, AZ::SettingsRegistryInterface::FixedValueString(AssetProcessorSettingsKey) + "/MetaDataTypes");
|
||||
|
||||
using namespace AzToolsFramework::AssetUtils;
|
||||
AZStd::vector<AZStd::string> supportedFileExtensions;
|
||||
AssetImporterPathsVisitor assetImporterVisitor{ settingsRegistry, supportedFileExtensions };
|
||||
settingsRegistry->Visit(assetImporterVisitor, AZ::SettingsRegistryInterface::FixedValueString(AssetImporterSettingsKey) + "/" + AssetImporterSupportedFileTypeKey);
|
||||
|
||||
for (auto& entry : assetImporterVisitor.m_supportedFileExtensions)
|
||||
{
|
||||
visitor.m_metaDataTypes.push_back({ AZStd::string::format("%s.assetinfo", entry.c_str()), entry });
|
||||
}
|
||||
|
||||
for (const auto& metaDataType : visitor.m_metaDataTypes)
|
||||
{
|
||||
QString fileType = AssetUtilities::NormalizeFilePath(QString::fromUtf8(metaDataType.m_fileType.c_str(),
|
||||
|
||||
@@ -40,6 +40,21 @@ namespace AssetProcessor
|
||||
extern const char AssetConfigPlatformDir[];
|
||||
extern const char AssetProcessorPlatformConfigFileName[];
|
||||
|
||||
struct AssetImporterPathsVisitor
|
||||
: AZ::SettingsRegistryInterface::Visitor
|
||||
{
|
||||
AssetImporterPathsVisitor(AZ::SettingsRegistryInterface* settingsRegistry, AZStd::vector<AZStd::string>& supportedExtension)
|
||||
: m_settingsRegistry(settingsRegistry)
|
||||
, m_supportedFileExtensions(supportedExtension)
|
||||
{
|
||||
}
|
||||
|
||||
void Visit(AZStd::string_view path, AZStd::string_view, AZ::SettingsRegistryInterface::Type, AZStd::string_view value) override;
|
||||
|
||||
AZ::SettingsRegistryInterface* m_settingsRegistry;
|
||||
AZStd::vector<AZStd::string> m_supportedFileExtensions;
|
||||
};
|
||||
|
||||
//! Information for a given recognizer, on a specific platform
|
||||
//! essentially a plain data holder, but with helper funcs
|
||||
class AssetPlatformSpec
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"O3DE":
|
||||
{
|
||||
"SceneAPI":
|
||||
{
|
||||
"AssetImporter":
|
||||
{
|
||||
"SupportedFileTypeExtensions":
|
||||
[
|
||||
".aaa",
|
||||
".bbb"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
#include <AzToolsFramework/Asset/AssetUtils.h>
|
||||
#include <SceneAPI/SceneBuilder/SceneImportRequestHandler.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Scene.h>
|
||||
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
|
||||
@@ -23,19 +24,21 @@ namespace AZ
|
||||
{
|
||||
void SceneImporterSettings::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
using namespace AzToolsFramework::AssetUtils;
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context); serializeContext)
|
||||
{
|
||||
serializeContext->Class<SceneImporterSettings>()
|
||||
->Version(2)
|
||||
->Field("SupportedFileTypeExtensions", &SceneImporterSettings::m_supportedFileTypeExtensions);
|
||||
->Field(AssetImporterSupportedFileTypeKey, &SceneImporterSettings::m_supportedFileTypeExtensions);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneImportRequestHandler::Activate()
|
||||
{
|
||||
using namespace AzToolsFramework::AssetUtils;
|
||||
if (auto* settingsRegistry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
settingsRegistry->GetObject(m_settings, "/O3DE/SceneAPI/AssetImporter");
|
||||
settingsRegistry->GetObject(m_settings, AssetImporterSettingsKey);
|
||||
}
|
||||
|
||||
BusConnect();
|
||||
|
||||
Reference in New Issue
Block a user