UX Workflow improvements for Physics Materials (#1237)

- Added button to PhysX Collider Component in PhysX Mesh's field to open FBX Settings.
- Added button Material Selection to open the physics material library in Asset Editor.
- Default Material in PhysX configuration is read only and consistent with the text in combo boxes.
- Material configuration field "Surface Type" renamed to "Name"
- Fixed bug in EditorColliderComponent where the material selection was not updated when changing the library.
- Fixed bug where the materials selection was not set to default when a physics material from the asset was not found in the library.
- Added attributes 'BrowseButtonEnabled' and 'BrowseButtonVisible' to PropertyAssetCtrl.
- Updated physx configuration setreg files of AutomatedTesting project.
This commit is contained in:
Aaron Ruiz Mora
2021-06-10 16:36:38 +01:00
committed by GitHub
parent 2ede3c3dc3
commit 7a053d82e1
22 changed files with 127 additions and 37 deletions
@@ -58,10 +58,12 @@ namespace PhysX
{
editContext->Class<EditorProxyAssetShapeConfig>("EditorProxyShapeConfig", "PhysX Base shape collider")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &EditorProxyAssetShapeConfig::m_pxAsset, "PhysX Mesh", "PhysX mesh collider asset")
->Attribute(AZ_CRC_CE("EditButton"), "")
->Attribute(AZ_CRC_CE("EditDescription"), "Open in FBX Settings")
->DataElement(AZ::Edit::UIHandlers::Default, &EditorProxyAssetShapeConfig::m_configuration, "Configuration", "Configuration of asset shape")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
}
}
}
@@ -356,6 +358,7 @@ namespace PhysX
[this](const AZ::Data::AssetId& defaultMaterialLibrary)
{
m_configuration.m_materialSelection.OnMaterialLibraryChanged(defaultMaterialLibrary);
UpdateMaterialSlotsFromMeshAsset();
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestRefresh,
AzToolsFramework::PropertyModificationRefreshLevel::Refresh_AttributesAndValues);
+1
View File
@@ -441,6 +441,7 @@ namespace PhysX
"UpdateMaterialSelectionFromPhysicsAsset: Physics material '%s' not found in the material library. Mesh material '%s' will use the default physics material.",
physicsMaterialNameFromPhysicsAsset.c_str(),
meshAsset->m_assetData.m_materialNames[slotIndex].c_str());
materialSelection.SetMaterialId(Physics::MaterialId(), slotIndex);
}
}
}
@@ -17,6 +17,7 @@
#include <AzCore/IO/GenericStreams.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Serialization/Utils.h>
#include <AzCore/Serialization/EditContext.h>
#include <PhysX/MeshAsset.h>
#include <PhysX/SystemComponentBus.h>
#include <Source/Pipeline/MeshAssetHandler.h>
@@ -158,6 +159,27 @@ namespace PhysX
}
}
void MeshAsset::Reflect(AZ::ReflectContext* context)
{
MeshAssetData::Reflect(context);
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<MeshAsset>()
->Field("MeshAssetData", &MeshAsset::m_assetData)
;
// Note: This class needs to have edit context reflection so PropertyAssetCtrl::OnEditButtonClicked
// can open the asset with the preferred asset editor (FBX Settings).
if (auto* editContext = serializeContext->GetEditContext())
{
editContext->Class<MeshAsset>("PhysX Mesh Asset", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
;
}
}
}
void AssetColliderConfiguration::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
@@ -311,7 +311,7 @@ namespace PhysX
AZStd::string materialName = DefaultMaterialName;
if (!localFbxMaterialsList.empty())
{
int materialId = nodeMesh->GetFaceMaterialId(faceIndex);
const int materialId = nodeMesh->GetFaceMaterialId(faceIndex);
if (materialId >= localFbxMaterialsList.size())
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow,
@@ -332,7 +332,7 @@ namespace PhysX
}
}
AZ::u16 materialIndex = InsertMaterialIndexByName(materialName, assetMaterialData);
const AZ::u16 materialIndex = InsertMaterialIndexByName(materialName, assetMaterialData);
assetMaterialData.m_nodesToPerFaceMaterialIndices[nodeName][faceIndex] = materialIndex;
}
}
@@ -729,7 +729,7 @@ namespace PhysX
{
// Gather material data from asset for the mesh group
AZStd::optional<Utils::AssetMaterialsData> assetMaterialData = Utils::GatherMaterialsFromMeshGroup(pxMeshGroup, graph);
if (!assetMaterialData)
if (!assetMaterialData.has_value())
{
return SceneEvents::ProcessingResult::Failure;
}
+1 -1
View File
@@ -94,7 +94,7 @@ namespace PhysX
void SystemComponent::Reflect(AZ::ReflectContext* context)
{
D6JointLimitConfiguration::Reflect(context);
Pipeline::MeshAssetData::Reflect(context);
Pipeline::MeshAsset::Reflect(context);
PhysX::ReflectionUtils::ReflectPhysXOnlyApi(context);