From e651f255772b11d01f1210178e6f567981dba36c Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Mon, 2 Aug 2021 13:17:34 +0200 Subject: [PATCH] Ported the render plugin, render update callback and render widget Signed-off-by: Benjamin Jillich --- .../Rendering/Common/RotateManipulator.h | 2 +- .../Rendering/Common/TranslateManipulator.h | 2 +- .../Source/BlendTreeRotationMath2Node.cpp | 1 - .../Source/RenderPlugin/RenderPlugin.cpp | 2 +- .../RenderPlugin/RenderUpdateCallback.cpp | 7 +++---- .../Source/RenderPlugin/RenderWidget.cpp | 18 ++++++++---------- .../Source/RenderPlugin/RenderWidget.h | 12 ++++-------- 7 files changed, 18 insertions(+), 26 deletions(-) diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RotateManipulator.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RotateManipulator.h index c6d719ae7c..5443bad219 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RotateManipulator.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RotateManipulator.h @@ -8,7 +8,7 @@ #pragma once -// include the Core system +#include #include #include #include diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h index 362f6c19be..7bc0bacfe0 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h @@ -9,7 +9,7 @@ #ifndef __MCOMMON_TRANSLATEMANIPULATOR_H #define __MCOMMON_TRANSLATEMANIPULATOR_H -// include the Core system +#include #include #include #include "MCommonConfig.h" diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeRotationMath2Node.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeRotationMath2Node.cpp index d01a6e5f0d..1f15333561 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeRotationMath2Node.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeRotationMath2Node.cpp @@ -105,7 +105,6 @@ namespace EMotionFX } // If both x and y inputs have connections - //MCore::Quaternion x = MCore::AzQuatToEmfxQuat(m_defaultValue); AZ::Quaternion x = m_defaultValue; AZ::Quaternion y = x; if (mConnections.size() == 2) diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderPlugin.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderPlugin.cpp index ab219b2b92..e4663750ce 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderPlugin.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderPlugin.cpp @@ -915,7 +915,7 @@ namespace EMStudio } // get the mesh based AABB - AZ::Aabb aabb; + AZ::Aabb aabb = AZ::Aabb::CreateNull(); actorInstance->CalcMeshBasedAabb(0, &aabb); // get the node based AABB diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.cpp index 4c032cb2ea..fed309d2e5 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.cpp @@ -170,9 +170,8 @@ namespace EMStudio settings.mNodeBasedColor = renderOptions->GetNodeAABBColor(); settings.mStaticBasedColor = renderOptions->GetStaticAABBColor(); settings.mMeshBasedColor = renderOptions->GetMeshAABBColor(); - settings.mCollisionMeshBasedColor = renderOptions->GetCollisionMeshAABBColor(); - renderUtil->RenderAABBs(actorInstance, settings); + renderUtil->RenderAabbs(actorInstance, settings); } if (widget->GetRenderFlag(RenderViewWidget::RENDER_OBB)) @@ -260,8 +259,8 @@ namespace EMStudio // render the selection if (renderOptions->GetRenderSelectionBox() && EMotionFX::GetActorManager().GetNumActorInstances() != 1 && mPlugin->GetCurrentSelection()->CheckIfHasActorInstance(actorInstance)) { - MCore::AABB aabb = actorInstance->GetAABB(); - aabb.Widen(aabb.CalcRadius() * 0.005f); + AZ::Aabb aabb = actorInstance->GetAabb(); + aabb.Expand(aabb.GetExtents() * 0.005f); renderUtil->RenderSelection(aabb, renderOptions->GetSelectionColor()); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.cpp index c74f693765..fb0ce4fdbf 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.cpp @@ -72,9 +72,8 @@ namespace EMStudio } // start view closeup flight - void RenderWidget::ViewCloseup(const MCore::AABB& aabb, float flightTime, uint32 viewCloseupWaiting) + void RenderWidget::ViewCloseup(const AZ::Aabb& aabb, float flightTime, uint32 viewCloseupWaiting) { - //LogError("ViewCloseup: AABB: Pos=(%.3f, %.3f, %.3f), Width=%.3f, Height=%.3f, Depth=%.3f", aabb.CalcMiddle().x, aabb.CalcMiddle().y, aabb.CalcMiddle().z, aabb.CalcWidth(), aabb.CalcHeight(), aabb.CalcDepth()); mViewCloseupWaiting = viewCloseupWaiting; mViewCloseupAABB = aabb; mViewCloseupFlightTime = flightTime; @@ -82,9 +81,8 @@ namespace EMStudio void RenderWidget::ViewCloseup(bool selectedInstancesOnly, float flightTime, uint32 viewCloseupWaiting) { - //LogError("ViewCloseup: AABB: Pos=(%.3f, %.3f, %.3f), Width=%.3f, Height=%.3f, Depth=%.3f", aabb.CalcMiddle().x, aabb.CalcMiddle().y, aabb.CalcMiddle().z, aabb.CalcWidth(), aabb.CalcHeight(), aabb.CalcDepth()); mViewCloseupWaiting = viewCloseupWaiting; - mViewCloseupAABB = mPlugin->GetSceneAABB(selectedInstancesOnly); + mViewCloseupAABB = mPlugin->GetSceneAabb(selectedInstancesOnly); mViewCloseupFlightTime = flightTime; } @@ -603,14 +601,15 @@ namespace EMStudio if (actor->CheckIfHasMeshes(actorInstance->GetLODLevel()) == false) { // calculate the node based AABB - MCore::AABB box; - actorInstance->CalcNodeBasedAABB(&box); + AZ::Aabb box; + actorInstance->CalcNodeBasedAabb(&box); // render the aabb - if (box.CheckIfIsValid()) + if (box.IsValid()) { + const MCore::AABB mcoreAabb(box.GetMin(), box.GetMax()); AZ::Vector3 ii, n; - if (ray.Intersects(box, &ii, &n)) + if (ray.Intersects(mcoreAabb, &ii, &n)) { selectedActorInstance = actorInstance; oldIntersectionPoint = ii; @@ -1169,8 +1168,7 @@ namespace EMStudio mViewCloseupWaiting--; if (mViewCloseupWaiting == 0) { - mCamera->ViewCloseup(mViewCloseupAABB, mViewCloseupFlightTime); - //mViewCloseupWaiting = 0; + mCamera->ViewCloseup(MCore::AABB(mViewCloseupAABB.GetMin(), mViewCloseupAABB.GetMax()), mViewCloseupFlightTime); } } diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.h index b6776d43a4..10722f744a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderWidget.h @@ -6,11 +6,10 @@ * */ -#ifndef __EMSTUDIO_RENDERWIDGET_H -#define __EMSTUDIO_RENDERWIDGET_H +#pragma once -// #if !defined(Q_MOC_RUN) +#include #include #include "../EMStudioConfig.h" #include @@ -117,7 +116,7 @@ namespace EMStudio MCORE_INLINE MCommon::Camera* GetCamera() const { return mCamera; } MCORE_INLINE CameraMode GetCameraMode() const { return mCameraMode; } MCORE_INLINE void SetSkipFollowCalcs(bool skipFollowCalcs) { mSkipFollowCalcs = skipFollowCalcs; } - void ViewCloseup(const MCore::AABB& aabb, float flightTime, uint32 viewCloseupWaiting = 5); + void ViewCloseup(const AZ::Aabb& aabb, float flightTime, uint32 viewCloseupWaiting = 5); void ViewCloseup(bool selectedInstancesOnly, float flightTime, uint32 viewCloseupWaiting = 5); void SwitchCamera(CameraMode mode); @@ -161,7 +160,7 @@ namespace EMStudio // used for closeup camera flights uint32 mViewCloseupWaiting; - MCore::AABB mViewCloseupAABB; + AZ::Aabb mViewCloseupAABB; float mViewCloseupFlightTime; // manipulator helper data @@ -175,6 +174,3 @@ namespace EMStudio int32 mPixelsMovedSinceRightClick; }; } // namespace EMStudio - - -#endif