From 6d2765ef4232aefcd7203919719bb375c2f41114 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Wed, 4 Aug 2021 13:10:17 +0100 Subject: [PATCH] moved default location of surfacetypemateriallibrary.physmaterial (#2786) from 'project root' to 'project root/Assets/Physics' The functionality of creating / using the default physmaterial file has only change in related to the file location, other functionality is unchanged. The following situations can occur: This will not affect have any project that uses a custom physmaterial file. This will not affect have any project that uses the default from the old location, as the configuration will still point there. New projects created will get the default physmaterial file at the new location. A Project that fails to load (or deletes) the selected physmaterial file, will get the default physmaterial file at the new location (this happens only on startup of the editor). Issue: #2765 Signed-off-by: amzn-sean 75276488+amzn-sean@users.noreply.github.com --- .../Physics/SurfaceTypeMaterialLibrary.physmaterial} | 0 .../physics/C15096740_Material_LibraryUpdatedCorrectly.py | 5 +++-- .../Gem/PythonTests/physics/Physmaterial_Editor.py | 2 +- .../C3510644_Collider_CollisionGroups.setreg_override | 5 +++-- .../Registry/C4976227_Collider_NewGroup.setreg_override | 5 +++-- ...4_Collider_SameGroupSameLayerCollision.setreg_override | 5 +++-- ...76245_PhysXCollider_CollisionLayerTest.setreg_override | 5 +++-- .../C4982593_PhysXCollider_CollisionLayer.setreg_override | 5 +++-- AutomatedTesting/Registry/physxsystemconfiguration.setreg | 5 +++-- .../Editor/Source/Components/EditorSystemComponent.cpp | 8 ++++---- 10 files changed, 26 insertions(+), 19 deletions(-) rename AutomatedTesting/{surfacetypemateriallibrary.physmaterial => Assets/Physics/SurfaceTypeMaterialLibrary.physmaterial} (100%) diff --git a/AutomatedTesting/surfacetypemateriallibrary.physmaterial b/AutomatedTesting/Assets/Physics/SurfaceTypeMaterialLibrary.physmaterial similarity index 100% rename from AutomatedTesting/surfacetypemateriallibrary.physmaterial rename to AutomatedTesting/Assets/Physics/SurfaceTypeMaterialLibrary.physmaterial diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py b/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py index 060779082c..341597e36a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py @@ -64,7 +64,8 @@ def C15096740_Material_LibraryUpdatedCorrectly(): # Constants library_property_path = "Configuration|Physics Material|Library" - default_material_path = "surfacetypemateriallibrary.physmaterial" + + default_material_path = os.path.join("assets", "physics", "surfacetypemateriallibrary.physmaterial") new_material_path = os.path.join("physicssurfaces", "default_phys_materials.physmaterial") helper.init_idle() @@ -82,7 +83,7 @@ def C15096740_Material_LibraryUpdatedCorrectly(): default_asset = Asset.find_asset_by_path(default_material_path) test_component.set_component_property_value(library_property_path, default_asset.id) default_asset.id = test_component.get_component_property_value(library_property_path) - Report.result(Tests.override_default_library, default_asset.get_path() == default_material_path) + Report.result(Tests.override_default_library, default_asset.get_path() == default_material_path.replace(os.sep, '/')) # 4) Switch it back again to the default material library. test_component.set_component_property_value(library_property_path, azasset.AssetId()) diff --git a/AutomatedTesting/Gem/PythonTests/physics/Physmaterial_Editor.py b/AutomatedTesting/Gem/PythonTests/physics/Physmaterial_Editor.py index 54ea3c7f15..cff8ae8377 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/Physmaterial_Editor.py +++ b/AutomatedTesting/Gem/PythonTests/physics/Physmaterial_Editor.py @@ -133,7 +133,7 @@ class Physmaterial_Editor: def _set_path(self): # type: (str) -> str if self.document_filename == None: - self.document_filename = os.path.join(self.project_folder, "surfacetypemateriallibrary.physmaterial") + self.document_filename = os.path.join(self.project_folder, "assets", "physics", "surfacetypemateriallibrary.physmaterial") else: for (root, directories, root_files) in os.walk(self.project_folder): for root_file in root_files: diff --git a/AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg_override b/AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg_override index 9fa5e26768..e4ea71f652 100644 --- a/AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg_override +++ b/AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg_override @@ -121,9 +121,10 @@ }, "MaterialLibrary": { "assetId": { - "guid": "{3A055A3F-8CB7-5FEE-B437-EB365FACD0D4}" + "guid": "{62446378-67F8-5E49-AC31-761DD5942695}" }, - "assetHint": "surfacetypemateriallibrary.physmaterial" + "loadBehavior": "QueueLoad", + "assetHint": "assets/physics/surfacetypemateriallibrary.physmaterial" } } } diff --git a/AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg_override b/AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg_override index afbe6a9d38..e53d3893f8 100644 --- a/AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg_override +++ b/AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg_override @@ -109,9 +109,10 @@ }, "MaterialLibrary": { "assetId": { - "guid": "{3A055A3F-8CB7-5FEE-B437-EB365FACD0D4}" + "guid": "{62446378-67F8-5E49-AC31-761DD5942695}" }, - "assetHint": "surfacetypemateriallibrary.physmaterial" + "loadBehavior": "QueueLoad", + "assetHint": "assets/physics/surfacetypemateriallibrary.physmaterial" } } } diff --git a/AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg_override b/AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg_override index 9fa5e26768..e4ea71f652 100644 --- a/AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg_override +++ b/AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg_override @@ -121,9 +121,10 @@ }, "MaterialLibrary": { "assetId": { - "guid": "{3A055A3F-8CB7-5FEE-B437-EB365FACD0D4}" + "guid": "{62446378-67F8-5E49-AC31-761DD5942695}" }, - "assetHint": "surfacetypemateriallibrary.physmaterial" + "loadBehavior": "QueueLoad", + "assetHint": "assets/physics/surfacetypemateriallibrary.physmaterial" } } } diff --git a/AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg_override b/AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg_override index 9fa5e26768..e4ea71f652 100644 --- a/AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg_override +++ b/AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg_override @@ -121,9 +121,10 @@ }, "MaterialLibrary": { "assetId": { - "guid": "{3A055A3F-8CB7-5FEE-B437-EB365FACD0D4}" + "guid": "{62446378-67F8-5E49-AC31-761DD5942695}" }, - "assetHint": "surfacetypemateriallibrary.physmaterial" + "loadBehavior": "QueueLoad", + "assetHint": "assets/physics/surfacetypemateriallibrary.physmaterial" } } } diff --git a/AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg_override b/AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg_override index 9fa5e26768..e4ea71f652 100644 --- a/AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg_override +++ b/AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg_override @@ -121,9 +121,10 @@ }, "MaterialLibrary": { "assetId": { - "guid": "{3A055A3F-8CB7-5FEE-B437-EB365FACD0D4}" + "guid": "{62446378-67F8-5E49-AC31-761DD5942695}" }, - "assetHint": "surfacetypemateriallibrary.physmaterial" + "loadBehavior": "QueueLoad", + "assetHint": "assets/physics/surfacetypemateriallibrary.physmaterial" } } } diff --git a/AutomatedTesting/Registry/physxsystemconfiguration.setreg b/AutomatedTesting/Registry/physxsystemconfiguration.setreg index 02f65b685b..83aad307a6 100644 --- a/AutomatedTesting/Registry/physxsystemconfiguration.setreg +++ b/AutomatedTesting/Registry/physxsystemconfiguration.setreg @@ -103,9 +103,10 @@ }, "MaterialLibrary": { "assetId": { - "guid": "{3A055A3F-8CB7-5FEE-B437-EB365FACD0D4}" + "guid": "{62446378-67F8-5E49-AC31-761DD5942695}" }, - "assetHint": "surfacetypemateriallibrary.physmaterial" + "loadBehavior": "QueueLoad", + "assetHint": "assets/physics/surfacetypemateriallibrary.physmaterial" } } } diff --git a/Gems/PhysX/Code/Editor/Source/Components/EditorSystemComponent.cpp b/Gems/PhysX/Code/Editor/Source/Components/EditorSystemComponent.cpp index 6dc845199a..e4c65c8667 100644 --- a/Gems/PhysX/Code/Editor/Source/Components/EditorSystemComponent.cpp +++ b/Gems/PhysX/Code/Editor/Source/Components/EditorSystemComponent.cpp @@ -24,7 +24,7 @@ namespace PhysX { - constexpr const char* DefaultAssetFilename = "SurfaceTypeMaterialLibrary"; + constexpr const char* DefaultAssetFilePath = "Physics/SurfaceTypeMaterialLibrary"; constexpr const char* TemplateAssetFilename = "PhysX/TemplateMaterialLibrary"; static AZStd::optional> GetMaterialLibraryTemplate() @@ -227,7 +227,7 @@ namespace PhysX const AZStd::string& assetExtension = assetTypeExtensions[0]; // Use the path relative to the asset root to avoid hardcoding full path in the configuration - AZStd::string relativePath = DefaultAssetFilename; + AZStd::string relativePath = DefaultAssetFilePath; AzFramework::StringFunc::Path::ReplaceExtension(relativePath, assetExtension.c_str()); // Try to find an already existing material library @@ -237,9 +237,9 @@ namespace PhysX if (!resultAssetId.IsValid()) { // No file for the default material library, create it - const char* assetRoot = AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@"); + const char* assetRoot = AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectsourceassets@"); AZStd::string fullPath; - AzFramework::StringFunc::Path::ConstructFull(assetRoot, DefaultAssetFilename, assetExtension.c_str(), fullPath); + AzFramework::StringFunc::Path::ConstructFull(assetRoot, DefaultAssetFilePath, assetExtension.c_str(), fullPath); if (auto materialLibraryOpt = CreateMaterialLibrary(fullPath, relativePath)) {