Fixes #2796 Collider retains phys mesh asset reference after changing to shape (#3162)

Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
This commit is contained in:
amzn-sean
2021-08-17 13:48:51 +01:00
committed by GitHub
parent 3fb903b03b
commit d9ea329cbd
2 changed files with 20 additions and 4 deletions
@@ -88,7 +88,7 @@ namespace PhysX
->EnumAttribute(Physics::ShapeType::Box, "Box")
->EnumAttribute(Physics::ShapeType::Capsule, "Capsule")
->EnumAttribute(Physics::ShapeType::PhysicsAsset, "PhysicsAsset")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnShapeTypeChanged)
// note: we do not want the user to be able to change shape types while in ComponentMode (there will
// potentially be different ComponentModes for different shape types)
->Attribute(AZ::Edit::Attributes::ReadOnly, &AzToolsFramework::ComponentModeFramework::InComponentMode)
@@ -116,6 +116,19 @@ namespace PhysX
}
}
AZ::u32 EditorProxyShapeConfig::OnShapeTypeChanged()
{
//reset the physics asset if the shape type was Physics Asset
if (m_shapeType != Physics::ShapeType::PhysicsAsset &&
m_lastShapeType == Physics::ShapeType::PhysicsAsset)
{
m_physicsAsset.m_pxAsset.Reset();
m_physicsAsset.m_configuration = Physics::PhysicsAssetShapeConfiguration();
}
m_lastShapeType = m_shapeType;
return AZ::Edit::PropertyRefreshLevels::EntireTree;
}
AZ::u32 EditorProxyShapeConfig::OnConfigurationChanged()
{
return AZ::Edit::PropertyRefreshLevels::ValuesOnly;