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
monroegm-disable-blank-issue-2
amzn-sean 5 years ago committed by GitHub
parent 45ebf57d3f
commit 6d2765ef42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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())

@ -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:

@ -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"
}
}
}

@ -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"
}
}
}

@ -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"
}
}
}

@ -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"
}
}
}

@ -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"
}
}
}

@ -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"
}
}
}

@ -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<AZ::Data::Asset<AZ::Data::AssetData>> 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))
{

Loading…
Cancel
Save