small improvements to triangle mesh rigid body warning

Signed-off-by: greerdv <greerdv@amazon.com>
monroegm-disable-blank-issue-2
greerdv 4 years ago
parent 6be8c9d622
commit c562f0a807

@ -33,6 +33,9 @@ namespace AzQtComponents
titleLabel->setObjectName("Title"); titleLabel->setObjectName("Title");
titleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); titleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
titleLabel->setWordWrap(true); titleLabel->setWordWrap(true);
titleLabel->setTextFormat(Qt::RichText);
titleLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
titleLabel->setOpenExternalLinks(true);
QHBoxLayout* headerLayout = new QHBoxLayout(headerFrame); QHBoxLayout* headerLayout = new QHBoxLayout(headerFrame);
headerLayout->setSizeConstraint(QLayout::SetMinimumSize); headerLayout->setSizeConstraint(QLayout::SetMinimumSize);

@ -17,6 +17,7 @@
#include <AzFramework/Physics/Configuration/StaticRigidBodyConfiguration.h> #include <AzFramework/Physics/Configuration/StaticRigidBodyConfiguration.h>
#include <AzFramework/Viewport/ViewportColors.h> #include <AzFramework/Viewport/ViewportColors.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h> #include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <AzToolsFramework/API/EntityPropertyEditorRequestsBus.h>
#include <AzToolsFramework/ComponentModes/BoxComponentMode.h> #include <AzToolsFramework/ComponentModes/BoxComponentMode.h>
#include <AzToolsFramework/Maths/TransformUtils.h> #include <AzToolsFramework/Maths/TransformUtils.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h> #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
@ -791,6 +792,7 @@ namespace PhysX
if (shapes.empty()) if (shapes.empty())
{ {
m_componentWarnings.clear(); m_componentWarnings.clear();
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast( AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(
&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree); &AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree);
return; return;
@ -824,9 +826,16 @@ namespace PhysX
} }
m_componentWarnings.push_back(AZStd::string::format( m_componentWarnings.push_back(AZStd::string::format(
"The Physics Asset \"%s\" is a Triangle Mesh, it is not compatible with a Dynamic Rigidbody, either:\n" "The asset \"%s\" contains one or more triangle meshes, which are not compatible with non-kinematic dynamic "
"Change the PhysicsAsset to Convex Mesh or set the Rigidbody to kinematic.", "rigid bodies. To make the collider compatible, you can export the asset as a primitive or convex mesh, use mesh "
"decomposition when exporting the asset, or set the rigid body to kinematic. Learn more about "
"<a href=\"https://o3de.org/docs/user-guide/components/reference/physx/collider/\">colliders</a>.",
assetPath.c_str())); assetPath.c_str()));
// make sure the entity inspector scrolls so the warning is visible by marking this component as having
// new content
AzToolsFramework::EntityPropertyEditorRequestBus::Broadcast(
&AzToolsFramework::EntityPropertyEditorRequests::SetNewComponentId, GetId());
} }
else else
{ {
@ -839,8 +848,8 @@ namespace PhysX
} }
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast( AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(
&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree); &AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay,
m_componentWarnings.empty() ? AzToolsFramework::Refresh_EntireTree : AzToolsFramework::Refresh_EntireTree_NewContent);
} }
void EditorColliderComponent::OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset) void EditorColliderComponent::OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset)

@ -103,7 +103,6 @@ namespace PhysX
} }
} // namespace Internal } // namespace Internal
void EditorRigidBodyConfiguration::Reflect(AZ::ReflectContext* context) void EditorRigidBodyConfiguration::Reflect(AZ::ReflectContext* context)
{ {
auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context); auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
@ -310,6 +309,15 @@ namespace PhysX
} }
} }
void EditorRigidBodyComponent::OnConfigurationChanged()
{
CreateEditorWorldRigidBody();
// required in case the kinematic setting has changed
PhysX::EditorColliderValidationRequestBus::Event(
GetEntityId(), &PhysX::EditorColliderValidationRequestBus::Events::ValidateRigidBodyMeshGeometryType);
}
void EditorRigidBodyComponent::Reflect(AZ::ReflectContext* context) void EditorRigidBodyComponent::Reflect(AZ::ReflectContext* context)
{ {
EditorRigidBodyConfiguration::Reflect(context); EditorRigidBodyConfiguration::Reflect(context);
@ -336,7 +344,7 @@ namespace PhysX
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/physx/rigid-body-physics/") ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/physx/rigid-body-physics/")
->DataElement(0, &EditorRigidBodyComponent::m_config, "Configuration", "Configuration for rigid body physics.") ->DataElement(0, &EditorRigidBodyComponent::m_config, "Configuration", "Configuration for rigid body physics.")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly) ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorRigidBodyComponent::CreateEditorWorldRigidBody) ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorRigidBodyComponent::OnConfigurationChanged)
; ;
} }
} }

@ -120,6 +120,8 @@ namespace PhysX
void InitPhysicsTickHandler(); void InitPhysicsTickHandler();
void PrePhysicsTick(); void PrePhysicsTick();
void OnConfigurationChanged();
Debug::DebugDisplayDataChangedEvent::Handler m_debugDisplayDataChangeHandler; Debug::DebugDisplayDataChangedEvent::Handler m_debugDisplayDataChangeHandler;
EditorRigidBodyConfiguration m_config; EditorRigidBodyConfiguration m_config;

Loading…
Cancel
Save