Remove redundant API calls from EditorViewportWidget and use new WorldToScreen call (#4022)

* remove redundant API calls from EditorViewportWidget and use new WorldToScreen call

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* remove additional pre/post widget render calls that are no longer required

Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
hultonha
2021-09-13 09:36:34 +01:00
committed by GitHub
parent 51ce59e240
commit 28d45891f2
12 changed files with 42 additions and 186 deletions
@@ -11,6 +11,7 @@
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Math/VertexContainerInterface.h>
#include <AzCore/std/sort.h>
#include <AzFramework/Viewport/ViewportScreen.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
#include <AzToolsFramework/Manipulators/LinearManipulator.h>
#include <AzToolsFramework/Manipulators/ManipulatorSnapping.h>
@@ -363,9 +364,7 @@ namespace AzToolsFramework
boxSelectData.m_activeSelection = boxSelectData.m_startSelection;
}
// set the widget context before calls to ViewportWorldToScreen so we are not
// going to constantly be pushing/popping the widget context
ViewportInteraction::WidgetContextGuard widgetContextGuard(viewportId);
const AzFramework::CameraState cameraState = GetCameraState(viewportId);
// box select active (clicking and dragging)
if (editorBoxSelect.BoxRegion())
@@ -385,7 +384,7 @@ namespace AzToolsFramework
found, fixedVertices, &AZ::FixedVerticesRequestBus<Vertex>::Handler::GetVertex, vertexIndex, localVertex);
const AZ::Vector3 worldVertex = worldFromLocal.TransformPoint(AZ::AdaptVertexOut<Vertex>(localVertex));
const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, worldVertex);
const AzFramework::ScreenPoint screenPosition = AzFramework::WorldToScreen(worldVertex, cameraState);
// check if a vertex is inside the box select region
if (editorBoxSelect.BoxRegion()->contains(ViewportInteraction::QPointFromScreenPoint(screenPosition)))