Update intersect behavior for positioning entities in the viewport (#5906)
* update intersect behavior for positioning entities in the viewport and restore SurfaceManipulator Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * tests for surface manipulator from EditorTransformComponentSelection Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * update comments in tests and remove #pragma optimize('', off)@ Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * add new file for FindClosestPickIntersection tests Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * add remaining tests for surface manipulator and snap fixes Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * some small updates and polish before PR Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * small updates following PR feedback Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
75d6cb2527
commit
6908a3e945
@@ -472,7 +472,7 @@ void EditorViewportWidget::Update()
|
||||
{
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
m_entityVisibilityQuery.UpdateVisibility(GetCameraState());
|
||||
m_entityVisibilityQuery.UpdateVisibility(m_renderViewport->GetCameraState());
|
||||
|
||||
if (ed_visibility_logTiming)
|
||||
{
|
||||
@@ -714,7 +714,7 @@ void EditorViewportWidget::RenderAll()
|
||||
|
||||
m_debugDisplay->DepthTestOff();
|
||||
m_manipulatorManager->DrawManipulators(
|
||||
*m_debugDisplay, GetCameraState(),
|
||||
*m_debugDisplay, m_renderViewport->GetCameraState(),
|
||||
BuildMouseInteractionInternal(
|
||||
AztfVi::MouseButtons(AztfVi::TranslateMouseButtons(QGuiApplication::mouseButtons())), keyboardModifiers,
|
||||
BuildMousePick(WidgetToViewport(mapFromGlobal(QCursor::pos())))));
|
||||
@@ -878,31 +878,11 @@ void EditorViewportWidget::OnMenuSelectCurrentCamera()
|
||||
}
|
||||
}
|
||||
|
||||
AzFramework::CameraState EditorViewportWidget::GetCameraState()
|
||||
{
|
||||
return m_renderViewport->GetCameraState();
|
||||
}
|
||||
|
||||
AZ::Vector3 EditorViewportWidget::PickTerrain(const AzFramework::ScreenPoint& point)
|
||||
{
|
||||
return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true));
|
||||
}
|
||||
|
||||
float EditorViewportWidget::TerrainHeight(const AZ::Vector2& position)
|
||||
{
|
||||
return GetIEditor()->GetTerrainElevation(position.GetX(), position.GetY());
|
||||
}
|
||||
|
||||
void EditorViewportWidget::FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut)
|
||||
{
|
||||
visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End());
|
||||
}
|
||||
|
||||
AzFramework::ScreenPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
|
||||
{
|
||||
return m_renderViewport->ViewportWorldToScreen(worldPosition);
|
||||
}
|
||||
|
||||
QWidget* EditorViewportWidget::GetWidgetForViewportContextMenu()
|
||||
{
|
||||
return this;
|
||||
@@ -2132,7 +2112,7 @@ bool EditorViewportWidget::GetActiveCameraState(AzFramework::CameraState& camera
|
||||
{
|
||||
if (m_pPrimaryViewport == this)
|
||||
{
|
||||
cameraState = GetCameraState();
|
||||
cameraState = m_renderViewport->GetCameraState();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,6 @@ private:
|
||||
void* GetSystemCursorConstraintWindow() const override;
|
||||
|
||||
// AzToolsFramework::MainEditorViewportInteractionRequestBus overrides ...
|
||||
AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override;
|
||||
float TerrainHeight(const AZ::Vector2& position) override;
|
||||
bool ShowingWorldSpace() override;
|
||||
QWidget* GetWidgetForViewportContextMenu() override;
|
||||
|
||||
@@ -293,9 +291,6 @@ private:
|
||||
// This switches the active camera to the next one in the list of (default, all custom cams).
|
||||
void CycleCamera();
|
||||
|
||||
AzFramework::CameraState GetCameraState();
|
||||
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
|
||||
|
||||
QPoint WidgetToViewport(const QPoint& point) const;
|
||||
QPoint ViewportToWidget(const QPoint& point) const;
|
||||
QSize WidgetToViewport(const QSize& size) const;
|
||||
|
||||
@@ -1396,7 +1396,7 @@ void SandboxIntegrationManager::ContextMenu_NewEntity()
|
||||
{
|
||||
worldPosition = AzToolsFramework::FindClosestPickIntersection(
|
||||
view->GetViewportId(), AzFramework::ScreenPointFromVector2(m_contextMenuViewPoint), AzToolsFramework::EditorPickRayLength,
|
||||
GetDefaultEntityPlacementDistance());
|
||||
AzToolsFramework::GetDefaultEntityPlacementDistance());
|
||||
}
|
||||
|
||||
CreateNewEntityAtPosition(worldPosition);
|
||||
|
||||
@@ -14,14 +14,11 @@
|
||||
// Qt
|
||||
#include <QPainter>
|
||||
|
||||
// AzCore
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
|
||||
// AzQtComponents
|
||||
#include <AzQtComponents/DragAndDrop/ViewportDragAndDrop.h>
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
|
||||
@@ -41,19 +38,6 @@
|
||||
#undef LoadCursor
|
||||
#endif
|
||||
|
||||
AZ_CVAR(
|
||||
float,
|
||||
ed_defaultEntityPlacementDistance,
|
||||
10.0f,
|
||||
nullptr,
|
||||
AZ::ConsoleFunctorFlags::Null,
|
||||
"The default distance to place an entity from the camera if no intersection is found");
|
||||
|
||||
float GetDefaultEntityPlacementDistance()
|
||||
{
|
||||
return ed_defaultEntityPlacementDistance;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Viewport drag and drop support
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -63,7 +47,7 @@ void QtViewport::BuildDragDropContext(
|
||||
{
|
||||
context.m_hitLocation = AzToolsFramework::FindClosestPickIntersection(
|
||||
viewportId, AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(point), AzToolsFramework::EditorPickRayLength,
|
||||
GetDefaultEntityPlacementDistance());
|
||||
AzToolsFramework::GetDefaultEntityPlacementDistance());
|
||||
}
|
||||
|
||||
void QtViewport::dragEnterEvent(QDragEnterEvent* event)
|
||||
|
||||
@@ -87,9 +87,6 @@ enum EStdCursor
|
||||
STD_CURSOR_LAST,
|
||||
};
|
||||
|
||||
//! The default distance an entity is placed from the camera if there is no intersection
|
||||
SANDBOX_API float GetDefaultEntityPlacementDistance();
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
class SANDBOX_API CViewport
|
||||
: public IDisplayViewport
|
||||
|
||||
Reference in New Issue
Block a user