Warning System Changes (polish) Redo (#4009)

* Restores the branch to the old status from old branch

Signed-off-by: aaguilea <aaguilea@amazon.com>

* Changes that didnt make it from merge manually fixed

Signed-off-by: aaguilea <aaguilea@amazon.com>

* forgot one

Signed-off-by: aaguilea <aaguilea@amazon.com>

* Added Ebus in order to remove rigidbody's dependencies

Signed-off-by: aaguilea <aaguilea@amazon.com>

* answering some of the comments in the PR

Signed-off-by: aaguilea <aaguilea@amazon.com>

* Small typo changed

Signed-off-by: aaguilea <aaguilea@amazon.com>
This commit is contained in:
AMZN-Alexandre Corcia Aguilera
2021-09-17 14:49:48 +01:00
committed by GitHub
parent c28bc7c6d8
commit 4167bb6cde
5 changed files with 58 additions and 22 deletions
@@ -395,12 +395,6 @@ namespace AzToolsFramework
AzQtComponents::CardNotification* ComponentEditor::CreateNotificationForWarningComponents(const QString& message)
{
AzQtComponents::CardNotification * notification = CreateNotification(message);
const QPushButton * featureButton = notification->addButtonFeature(tr("Continue"));
connect(featureButton, &QPushButton::clicked, this, [notification]()
{
notification->close();
});
return notification;
}
@@ -82,4 +82,18 @@ namespace PhysX
};
using EditorColliderComponentRequestBus = AZ::EBus<EditorColliderComponentRequests>;
/// <EditorColliderValidationRequests>
/// This is a Bus in order to communicate the status of the meshes of the collider and avoid dependencies with the rigidbody
/// </EditorColliderValidationRequests>
class EditorColliderValidationRequests : public AZ::ComponentBus
{
public:
/// Checks if the the mesh in the collider is correct with the current state of the Rigidbody!
virtual void ValidateRigidBodyMeshGeometryType() = 0;
};
using EditorColliderValidationRequestBus = AZ::EBus<EditorColliderValidationRequests>;
}
@@ -118,11 +118,10 @@ 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)
// reset the physics asset if the shape type was Physics Asset
if (m_shapeType != Physics::ShapeType::PhysicsAsset && m_lastShapeType == Physics::ShapeType::PhysicsAsset)
{
//clean up any reference to a physics assets, and re-initialize to an empty Pipeline::MeshAsset asset.
// clean up any reference to a physics assets, and re-initialize to an empty Pipeline::MeshAsset asset.
m_physicsAsset.m_pxAsset.Reset();
m_physicsAsset.m_pxAsset = AZ::Data::Asset<Pipeline::MeshAsset>(AZ::Data::AssetLoadBehavior::QueueLoad);
@@ -212,6 +211,7 @@ namespace PhysX
->DataElement(AZ::Edit::UIHandlers::Default, &EditorColliderComponent::m_shapeConfiguration, "Shape Configuration", "Configuration of the shape")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorColliderComponent::OnConfigurationChanged)
->Attribute(AZ::Edit::Attributes::RemoveNotify, &EditorColliderComponent::ValidateRigidBodyMeshGeometryType)
->DataElement(AZ::Edit::UIHandlers::Default, &EditorColliderComponent::m_componentModeDelegate, "Component Mode", "Collider Component Mode")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->DataElement(AZ::Edit::UIHandlers::Default, &EditorColliderComponent::m_colliderDebugDraw,
@@ -383,6 +383,7 @@ namespace PhysX
ColliderShapeRequestBus::Handler::BusConnect(GetEntityId());
AZ::Render::MeshComponentNotificationBus::Handler::BusConnect(GetEntityId());
EditorColliderComponentRequestBus::Handler::BusConnect(AZ::EntityComponentIdPair(GetEntityId(), GetId()));
EditorColliderValidationRequestBus::Handler::BusConnect(GetEntityId());
m_nonUniformScaleChangedHandler = AZ::NonUniformScaleChangedEvent::Handler(
[this](const AZ::Vector3& scale) {OnNonUniformScaleChanged(scale); });
AZ::NonUniformScaleRequestBus::Event(GetEntityId(), &AZ::NonUniformScaleRequests::RegisterScaleChangedEvent,
@@ -427,6 +428,7 @@ namespace PhysX
m_colliderDebugDraw.Disconnect();
AZ::Data::AssetBus::MultiHandler::BusDisconnect();
m_nonUniformScaleChangedHandler.Disconnect();
EditorColliderValidationRequestBus::Handler::BusDisconnect();
EditorColliderComponentRequestBus::Handler::BusDisconnect();
AZ::Render::MeshComponentNotificationBus::Handler::BusDisconnect();
ColliderShapeRequestBus::Handler::BusDisconnect();
@@ -466,6 +468,7 @@ namespace PhysX
UpdateShapeConfigurationScale();
CreateStaticEditorCollider();
ValidateRigidBodyMeshGeometryType();
m_colliderDebugDraw.ClearCachedGeometry();
@@ -768,15 +771,16 @@ namespace PhysX
{
m_componentWarnings.clear();
m_configuration.m_materialSelection.SetMaterialSlots(Physics::MaterialSelection::SlotsArray());
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(
&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree);
}
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree);
}
void EditorColliderComponent::ValidateRigidBodyMeshGeometryType()
{
const PhysX::EditorRigidBodyComponent* entityRigidbody = m_entity->FindComponent<PhysX::EditorRigidBodyComponent>();
if (m_shapeConfiguration.m_physicsAsset.m_configuration.GetShapeType() == Physics::ShapeType::PhysicsAsset && entityRigidbody)
if (m_shapeConfiguration.m_physicsAsset.m_pxAsset && (m_shapeConfiguration.m_shapeType == Physics::ShapeType::PhysicsAsset) && entityRigidbody)
{
AZStd::vector<AZStd::shared_ptr<Physics::Shape>> shapes;
Utils::GetShapesFromAsset(m_shapeConfiguration.m_physicsAsset.m_configuration, m_configuration, m_hasNonUniformScale,
@@ -784,17 +788,32 @@ namespace PhysX
if (shapes.empty())
{
m_componentWarnings.clear();
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(
&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree);
return;
}
//We grab the first shape to check if it is a triangle mesh.
auto shape = AZStd::rtti_pointer_cast<PhysX::Shape>(shapes[0]);
//We check if the shapes are triangle meshes, if any mesh is a triangle mesh we activate the warning.
bool shapeIsTriangleMesh = false;
if (shape &&
shape->GetPxShape()->getGeometryType() == physx::PxGeometryType::eTRIANGLEMESH &&
entityRigidbody->GetRigidBody() &&
entityRigidbody->GetRigidBody()->IsKinematic() == false)
for (const auto& shape : shapes)
{
auto current_shape = AZStd::rtti_pointer_cast<PhysX::Shape>(shape);
if (current_shape &&
current_shape->GetPxShape()->getGeometryType() == physx::PxGeometryType::eTRIANGLEMESH &&
entityRigidbody->GetRigidBody() &&
entityRigidbody->GetRigidBody()->IsKinematic() == false)
{
shapeIsTriangleMesh = true;
break;
}
}
if (shapeIsTriangleMesh)
{
m_componentWarnings.clear();
AZStd::string assetPath = m_shapeConfiguration.m_physicsAsset.m_configuration.m_asset.GetHint().c_str();
const size_t lastSlash = assetPath.rfind('/');
if (lastSlash != AZStd::string::npos)
@@ -816,6 +835,10 @@ namespace PhysX
{
m_componentWarnings.clear();
}
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(
&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree);
}
void EditorColliderComponent::OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset)
@@ -58,8 +58,8 @@ namespace PhysX
//! Proxy container for only displaying a specific shape configuration depending on the shapeType selected.
struct EditorProxyShapeConfig
{
AZ_CLASS_ALLOCATOR(PhysX::EditorProxyShapeConfig, AZ::SystemAllocator, 0);
AZ_RTTI(PhysX::EditorProxyShapeConfig, "{531FB42A-42A9-4234-89BA-FD349EF83D0C}");
AZ_CLASS_ALLOCATOR(EditorProxyShapeConfig, AZ::SystemAllocator, 0);
AZ_RTTI(EditorProxyShapeConfig, "{531FB42A-42A9-4234-89BA-FD349EF83D0C}");
static void Reflect(AZ::ReflectContext* context);
EditorProxyShapeConfig() = default;
@@ -106,6 +106,7 @@ namespace PhysX
, private PhysX::ColliderShapeRequestBus::Handler
, private AZ::Render::MeshComponentNotificationBus::Handler
, private PhysX::EditorColliderComponentRequestBus::Handler
, private PhysX::EditorColliderValidationRequestBus::Handler
, private AzPhysics::SimulatedBodyComponentRequestsBus::Handler
{
public:
@@ -197,6 +198,9 @@ namespace PhysX
void SetAssetScale(const AZ::Vector3& scale) override;
AZ::Vector3 GetAssetScale() override;
// PhysX::EditorColliderValidationRequestBus overrides ...
void ValidateRigidBodyMeshGeometryType() override;
AZ::Transform GetColliderLocalTransform() const;
EditorProxyShapeConfig m_shapeConfiguration;
@@ -223,8 +227,6 @@ namespace PhysX
void BuildDebugDrawMesh() const;
void ValidateRigidBodyMeshGeometryType();
AZ::ComponentDescriptor::StringWarningArray GetComponentWarnings() const { return m_componentWarnings; };
using ComponentModeDelegate = AzToolsFramework::ComponentModeFramework::ComponentModeDelegate;
@@ -286,6 +286,9 @@ namespace PhysX
}
CreateEditorWorldRigidBody();
PhysX::EditorColliderValidationRequestBus::Event(
GetEntityId(), &PhysX::EditorColliderValidationRequestBus::Events::ValidateRigidBodyMeshGeometryType);
AzPhysics::SimulatedBodyComponentRequestsBus::Handler::BusConnect(GetEntityId());
}