From e2c4c0e5e3e0b7bd4a3adf2fe0ffee6c9b454483 Mon Sep 17 00:00:00 2001 From: Roman <69218254+amzn-rhhong@users.noreply.github.com> Date: Wed, 26 Jan 2022 19:41:38 -0800 Subject: [PATCH] Atom viewport render option bugfix (#7158) * Render option bugfix Signed-off-by: rhhong * add aznumeric_cast Signed-off-by: rhhong --- .../EMotionFXAtom/Assets/Icons/Cloth.svg | 9 ++++++ .../Assets/Icons/HitDetection.svg | 12 +++++++ .../Assets/Icons/RagdollCollider.svg | 9 ++++++ .../Assets/Icons/RagdollJointLimit.svg | 8 +++++ .../EMotionFXAtom/Assets/Icons/Resources.qrc | 5 +++ .../Assets/Icons/SimulatedObjectCollider.svg | 9 ++++++ .../Code/Source/AtomActorDebugDraw.cpp | 32 +++++++++---------- .../Tools/EMStudio/AnimViewportToolBar.cpp | 17 ++++++---- .../Code/Tools/EMStudio/AnimViewportToolBar.h | 2 +- 9 files changed, 80 insertions(+), 23 deletions(-) create mode 100644 Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Cloth.svg create mode 100644 Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/HitDetection.svg create mode 100644 Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollCollider.svg create mode 100644 Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollJointLimit.svg create mode 100644 Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/SimulatedObjectCollider.svg diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Cloth.svg b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Cloth.svg new file mode 100644 index 0000000000..d19fad50ae --- /dev/null +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Cloth.svg @@ -0,0 +1,9 @@ + + + Icons / Actor / Cloth / On-2 + + + + + + diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/HitDetection.svg b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/HitDetection.svg new file mode 100644 index 0000000000..58056c2819 --- /dev/null +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/HitDetection.svg @@ -0,0 +1,12 @@ + + + Icons / Actor / Hit Detection / On-2 + + + + + + + + + diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollCollider.svg b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollCollider.svg new file mode 100644 index 0000000000..e1468f3f9d --- /dev/null +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollCollider.svg @@ -0,0 +1,9 @@ + + + Icons / Actor / Physics / On-236 + + + + + + diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollJointLimit.svg b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollJointLimit.svg new file mode 100644 index 0000000000..1a28021533 --- /dev/null +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/RagdollJointLimit.svg @@ -0,0 +1,8 @@ + + + Icons / Actor / Joint / On-2 + + + + + diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Resources.qrc b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Resources.qrc index d035b84479..cbb07c7ee0 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Resources.qrc +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/Resources.qrc @@ -1,8 +1,13 @@ Camera_category.svg + Cloth.svg + HitDetection.svg + RagdollCollider.svg + RagdollJointLimit.svg Rotate.svg Scale.svg + SimulatedObjectCollider.svg Translate.svg Visualization.svg diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/SimulatedObjectCollider.svg b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/SimulatedObjectCollider.svg new file mode 100644 index 0000000000..cd59987d4a --- /dev/null +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Assets/Icons/SimulatedObjectCollider.svg @@ -0,0 +1,9 @@ + + + Icons / Actor / Physics / On-2 + + + + + + diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp index 21f9f69f7c..deb668d12a 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorDebugDraw.cpp @@ -301,7 +301,7 @@ namespace AZ::Render RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; lineArgs.m_verts = m_auxVertices.data(); - lineArgs.m_vertCount = static_cast(m_auxVertices.size()); + lineArgs.m_vertCount = aznumeric_cast(m_auxVertices.size()); lineArgs.m_colors = m_auxColors.data(); lineArgs.m_colorCount = lineArgs.m_vertCount; lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; @@ -393,9 +393,9 @@ namespace AZ::Render RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; lineArgs.m_verts = m_auxVertices.data(); - lineArgs.m_vertCount = static_cast(m_auxVertices.size()); + lineArgs.m_vertCount = aznumeric_cast(m_auxVertices.size()); lineArgs.m_colors = m_auxColors.data(); - lineArgs.m_colorCount = static_cast(m_auxColors.size()); + lineArgs.m_colorCount = aznumeric_cast(m_auxColors.size()); lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; auxGeom->DrawLines(lineArgs); } @@ -464,15 +464,15 @@ namespace AZ::Render m_auxVertices.emplace_back(normalPos); m_auxVertices.emplace_back(normalPos + (normalDir * faceNormalsScale * scaleMultiplier)); } - } - RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; - lineArgs.m_verts = m_auxVertices.data(); - lineArgs.m_vertCount = static_cast(m_auxVertices.size()); - lineArgs.m_colors = &faceNormalsColor; - lineArgs.m_colorCount = 1; - lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; - auxGeom->DrawLines(lineArgs); + RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; + lineArgs.m_verts = m_auxVertices.data(); + lineArgs.m_vertCount = aznumeric_cast(m_auxVertices.size()); + lineArgs.m_colors = &faceNormalsColor; + lineArgs.m_colorCount = 1; + lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; + auxGeom->DrawLines(lineArgs); + } } // render vertex normals @@ -501,7 +501,7 @@ namespace AZ::Render RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; lineArgs.m_verts = m_auxVertices.data(); - lineArgs.m_vertCount = static_cast(m_auxVertices.size()); + lineArgs.m_vertCount = aznumeric_cast(m_auxVertices.size()); lineArgs.m_colors = &vertexNormalsColor; lineArgs.m_colorCount = 1; lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; @@ -589,9 +589,9 @@ namespace AZ::Render RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; lineArgs.m_verts = m_auxVertices.data(); - lineArgs.m_vertCount = static_cast(m_auxVertices.size()); + lineArgs.m_vertCount = aznumeric_cast(m_auxVertices.size()); lineArgs.m_colors = m_auxColors.data(); - lineArgs.m_colorCount = static_cast(m_auxColors.size()); + lineArgs.m_colorCount = aznumeric_cast(m_auxColors.size()); lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; auxGeom->DrawLines(lineArgs); } @@ -649,7 +649,7 @@ namespace AZ::Render RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs; lineArgs.m_verts = m_auxVertices.data(); - lineArgs.m_vertCount = static_cast(m_auxVertices.size()); + lineArgs.m_vertCount = aznumeric_cast(m_auxVertices.size()); lineArgs.m_colors = &wireframeColor; lineArgs.m_colorCount = 1; lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off; @@ -688,7 +688,7 @@ namespace AZ::Render m_drawParams.m_drawViewportId = viewportContext->GetId(); AzFramework::WindowSize viewportSize = viewportContext->GetViewportSize(); - m_drawParams.m_position = AZ::Vector3(static_cast(viewportSize.m_width), 0.0f, 1.0f) + + m_drawParams.m_position = AZ::Vector3(aznumeric_cast(viewportSize.m_width), 0.0f, 1.0f) + TopRightBorderPadding * viewportContext->GetDpiScalingFactor(); m_drawParams.m_scale = AZ::Vector2(BaseFontSize); m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right; diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp index 455c587818..d9de41f54b 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp @@ -79,11 +79,16 @@ namespace EMStudio // [EMFX-TODO] Add those option once implemented. // CreateViewOptionEntry(contextMenu, "Actor Bind Pose", EMotionFX::ActorRenderFlag::RENDER_ACTORBINDPOSE); contextMenu->addSeparator(); - CreateViewOptionEntry(contextMenu, "Hit Detection Colliders", EMotionFX::ActorRenderFlag::RENDER_HITDETECTION_COLLIDERS); - CreateViewOptionEntry(contextMenu, "Ragdoll Colliders", EMotionFX::ActorRenderFlag::RENDER_RAGDOLL_COLLIDERS); - CreateViewOptionEntry(contextMenu, "Ragdoll Joint Limits", EMotionFX::ActorRenderFlag::RENDER_RAGDOLL_JOINTLIMITS); - CreateViewOptionEntry(contextMenu, "Cloth Colliders", EMotionFX::ActorRenderFlag::RENDER_CLOTH_COLLIDERS); - CreateViewOptionEntry(contextMenu, "Simulated Object Colliders", EMotionFX::ActorRenderFlag::RENDER_SIMULATEDOBJECT_COLLIDERS); + CreateViewOptionEntry(contextMenu, "Hit Detection Colliders", EMotionFX::ActorRenderFlag::RENDER_HITDETECTION_COLLIDERS, true, + ":/EMotionFXAtom/HitDetection.svg"); + CreateViewOptionEntry(contextMenu, "Ragdoll Colliders", EMotionFX::ActorRenderFlag::RENDER_RAGDOLL_COLLIDERS, true, + ":/EMotionFXAtom/RagdollCollider.svg"); + CreateViewOptionEntry(contextMenu, "Ragdoll Joint Limits", EMotionFX::ActorRenderFlag::RENDER_RAGDOLL_JOINTLIMITS, true, + ":/EMotionFXAtom/RagdollJointLimit.svg"); + CreateViewOptionEntry(contextMenu, "Cloth Colliders", EMotionFX::ActorRenderFlag::RENDER_CLOTH_COLLIDERS, true, + ":/EMotionFXAtom/Cloth.svg"); + CreateViewOptionEntry(contextMenu, "Simulated Object Colliders", EMotionFX::ActorRenderFlag::RENDER_SIMULATEDOBJECT_COLLIDERS, true, + ":/EMotionFXAtom/SimulatedObjectCollider.svg"); CreateViewOptionEntry(contextMenu, "Simulated Joints", EMotionFX::ActorRenderFlag::RENDER_SIMULATEJOINTS); } @@ -153,7 +158,7 @@ namespace EMStudio } void AnimViewportToolBar::CreateViewOptionEntry( - QMenu* menu, const char* menuEntryName, uint32_t actionIndex, bool visible, char* iconFileName) + QMenu* menu, const char* menuEntryName, uint32_t actionIndex, bool visible, const char* iconFileName) { QAction* action = menu->addAction( menuEntryName, diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.h index 30f2c6b80c..f516b9df28 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.h @@ -30,7 +30,7 @@ namespace EMStudio private: void CreateViewOptionEntry( - QMenu* menu, const char* menuEntryName, uint32_t actionIndex, bool visible = true, char* iconFileName = nullptr); + QMenu* menu, const char* menuEntryName, uint32_t actionIndex, bool visible = true, const char* iconFileName = nullptr); AtomRenderPlugin* m_plugin = nullptr; QAction* m_manipulatorActions[RenderOptions::ManipulatorMode::NUM_MODES] = { nullptr };