Skip to content

Commit e9445b4

Browse files
authored
Fixed picking pass to only draw when the scene view is hovered (#578)
* Fixed picking pass to only draw when teh scene view is hovered * Also made gizmo arrows always higlighted during an operation
1 parent f82c351 commit e9445b4

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

Sources/Overload/OvEditor/include/OvEditor/Core/CameraController.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ namespace OvEditor::Core
8383
*/
8484
bool IsRightMousePressed() const;
8585

86+
/**
87+
* Returns true if the camera controller is currently operating
88+
*/
89+
bool IsOperating() const;
90+
8691
/**
8792
* Lock the target actor to the given actor.
8893
* @note Usefull to force orbital camera or camera focus to target a specific actor

Sources/Overload/OvEditor/src/OvEditor/Core/CameraController.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ bool OvEditor::Core::CameraController::IsRightMousePressed() const
258258
return m_rightMousePressed;
259259
}
260260

261+
bool OvEditor::Core::CameraController::IsOperating() const
262+
{
263+
return m_rightMousePressed || m_middleMousePressed;
264+
}
265+
261266
void OvEditor::Core::CameraController::LockTargetActor(OvCore::ECS::Actor& p_actor)
262267
{
263268
m_lockedActor = p_actor;

Sources/Overload/OvEditor/src/OvEditor/Panels/SceneView.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ OvCore::Rendering::SceneRenderer::SceneDescriptor OvEditor::Panels::SceneView::C
156156

157157
void OvEditor::Panels::SceneView::DrawFrame()
158158
{
159+
auto& pickingPass = m_renderer->GetPass<OvEditor::Rendering::PickingRenderPass>("Picking");
160+
161+
// Enable picking pass only when the scene view is hovered, not picking, and not operating the camera
162+
pickingPass.SetEnabled(
163+
IsHovered() &&
164+
!m_gizmoOperations.IsPicking() &&
165+
!m_cameraController.IsOperating()
166+
);
167+
159168
OvEditor::Panels::AViewControllable::DrawFrame();
160169
HandleActorPicking();
161170
}
@@ -183,7 +192,7 @@ void OvEditor::Panels::SceneView::HandleActorPicking()
183192
m_gizmoOperations.StopPicking();
184193
}
185194

186-
if (IsHovered() && !IsResizing())
195+
if (!m_gizmoOperations.IsPicking() && IsHovered() && !IsResizing())
187196
{
188197
const auto pickingResult = GetPickingResult();
189198

@@ -241,6 +250,7 @@ void OvEditor::Panels::SceneView::HandleActorPicking()
241250

242251
m_gizmoOperations.SetCurrentMouse({ static_cast<float>(mousePosition.first - m_position.x), static_cast<float>(mousePosition.second - m_position.y) });
243252
m_gizmoOperations.ApplyOperation(m_camera.GetViewMatrix(), m_camera.GetProjectionMatrix(), m_camera.GetPosition(), { static_cast<float>(winWidth), static_cast<float>(winHeight) });
253+
m_highlightedGizmoDirection = m_gizmoOperations.GetDirection();
244254
}
245255
}
246256

Sources/Overload/OvEditor/src/OvEditor/Rendering/PickingRenderPass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ OvEditor::Rendering::PickingRenderPass::PickingResult OvEditor::Rendering::Picki
102102

103103
void OvEditor::Rendering::PickingRenderPass::Draw(OvRendering::Data::PipelineState p_pso)
104104
{
105-
// TODO: Make sure we only renderer when the view is hovered and not being resized
106105
ZoneScoped;
107106
TracyGpuZone("PickingRenderPass");
108107

0 commit comments

Comments
 (0)