@@ -38,19 +38,22 @@ void OvEditor::Panels::SceneView::Update(float p_deltaTime)
3838
3939 using namespace OvWindowing ::Inputs;
4040
41- if (EDITOR_CONTEXT (inputManager)-> IsKeyPressed (EKey::KEY_Z ))
41+ if (IsFocused () && !m_cameraController. IsRightMousePressed ( ))
4242 {
43- m_currentOperation = OvEditor::Core::EGizmoOperation::TRANSLATION;
44- }
43+ if (EDITOR_CONTEXT (inputManager)->IsKeyPressed (EKey::KEY_W))
44+ {
45+ m_currentOperation = OvEditor::Core::EGizmoOperation::TRANSLATE;
46+ }
4547
46- if (EDITOR_CONTEXT (inputManager)->IsKeyPressed (EKey::KEY_X ))
47- {
48- m_currentOperation = OvEditor::Core::EGizmoOperation::ROTATION ;
49- }
48+ if (EDITOR_CONTEXT (inputManager)->IsKeyPressed (EKey::KEY_E ))
49+ {
50+ m_currentOperation = OvEditor::Core::EGizmoOperation::ROTATE ;
51+ }
5052
51- if (EDITOR_CONTEXT (inputManager)->IsKeyPressed (EKey::KEY_C))
52- {
53- m_currentOperation = OvEditor::Core::EGizmoOperation::SCALE;
53+ if (EDITOR_CONTEXT (inputManager)->IsKeyPressed (EKey::KEY_R))
54+ {
55+ m_currentOperation = OvEditor::Core::EGizmoOperation::SCALE;
56+ }
5457 }
5558}
5659
@@ -122,75 +125,54 @@ void OvEditor::Panels::SceneView::RenderSceneForActorPicking()
122125 m_actorPickingFramebuffer.Unbind ();
123126}
124127
125- void OvEditor::Panels::SceneView::HandleActorPicking ()
128+ bool IsResizing ()
126129{
127- using namespace OvWindowing ::Inputs;
128-
129130 auto cursor = ImGui::GetMouseCursor ();
130131
131- bool isResizing =
132+ return
132133 cursor == ImGuiMouseCursor_ResizeEW ||
133134 cursor == ImGuiMouseCursor_ResizeNS ||
134135 cursor == ImGuiMouseCursor_ResizeNWSE ||
135136 cursor == ImGuiMouseCursor_ResizeNESW ||
136- cursor == ImGuiMouseCursor_ResizeAll;
137+ cursor == ImGuiMouseCursor_ResizeAll;;
138+ }
137139
138- if (EDITOR_CONTEXT (inputManager)->IsMouseButtonReleased (EMouseButton::MOUSE_BUTTON_LEFT))
140+ void OvEditor::Panels::SceneView::HandleActorPicking ()
141+ {
142+ using namespace OvWindowing ::Inputs;
143+
144+ auto & inputManager = *EDITOR_CONTEXT (inputManager);
145+
146+ if (inputManager.IsMouseButtonReleased (EMouseButton::MOUSE_BUTTON_LEFT))
139147 {
140148 m_gizmoOperations.StopPicking ();
141149 }
142150
143- bool mouseClicked = EDITOR_CONTEXT (inputManager)->IsMouseButtonPressed (EMouseButton::MOUSE_BUTTON_LEFT);
144-
145- bool enableActorPickingDebugDraw = EDITOR_CONTEXT (inputManager)->GetKeyState (EKey::KEY_G) == EKeyState::KEY_DOWN;
146-
147- if (mouseClicked || enableActorPickingDebugDraw)
151+ if (IsHovered () && !IsResizing () && inputManager.IsMouseButtonPressed (EMouseButton::MOUSE_BUTTON_LEFT) && !m_cameraController.IsRightMousePressed ())
148152 {
149153 RenderSceneForActorPicking ();
150- }
151154
152- if (IsHovered () && !isResizing && mouseClicked)
153- {
154155 // Look actor under mouse
155- auto mousePosition = EDITOR_CONTEXT (inputManager)->GetMousePosition ();
156- auto mouseX = static_cast <uint16_t >(mousePosition.first );
157- auto mouseY = static_cast <uint16_t >(mousePosition.second );
158- mouseX -= static_cast <uint16_t >(m_position.x );
159- mouseY -= static_cast <uint16_t >(m_position.y );
156+ auto [mouseX, mouseY] = inputManager.GetMousePosition ();
157+ mouseX -= m_position.x ;
158+ mouseY -= m_position.y ;
160159 mouseY = GetSafeSize ().second - mouseY + 25 ;
161160
162161 m_actorPickingFramebuffer.Bind ();
163- uint8_t pixels [3 ];
164- glReadPixels (static_cast <int >(mouseX), static_cast <int >(mouseY), 1 , 1 , GL_RGB, GL_UNSIGNED_BYTE, pixels );
162+ uint8_t pixel [3 ];
163+ glReadPixels (static_cast <int >(mouseX), static_cast <int >(mouseY), 1 , 1 , GL_RGB, GL_UNSIGNED_BYTE, pixel );
165164 m_actorPickingFramebuffer.Unbind ();
166165
167166 /* Gizmo picking */
168- if (EDITOR_EXEC (IsAnyActorSelected ()) && pixels [0 ] == 255 && pixels [1 ] == 255 && pixels [2 ] >= 252 && pixels [2 ] <= 254 )
167+ if (EDITOR_EXEC (IsAnyActorSelected ()) && pixel [0 ] == 255 && pixel [1 ] == 255 && pixel [2 ] >= 252 && pixel [2 ] <= 254 )
169168 {
170- auto & actor = EDITOR_EXEC (GetSelectedActor ());
171-
172- switch (pixels[2 ])
173- {
174- /* Gizmo X */
175- case 252 :
176- m_gizmoOperations.StartPicking (actor, m_cameraPosition, m_currentOperation, OvEditor::Core::GizmoBehaviour::EDirection::X);
177- break ;
178-
179- /* Gizmo Y */
180- case 253 :
181- m_gizmoOperations.StartPicking (actor, m_cameraPosition, m_currentOperation, OvEditor::Core::GizmoBehaviour::EDirection::Y);
182- break ;
183-
184- /* Gizmo Z */
185- case 254 :
186- m_gizmoOperations.StartPicking (actor, m_cameraPosition, m_currentOperation, OvEditor::Core::GizmoBehaviour::EDirection::Z);
187- break ;
188- }
169+ auto direction = static_cast <OvEditor::Core::GizmoBehaviour::EDirection>(pixel[2 ] - 252 );
170+ m_gizmoOperations.StartPicking (EDITOR_EXEC (GetSelectedActor ()), m_cameraPosition, m_currentOperation, direction);
189171 }
190172 /* Actor picking */
191173 else
192174 {
193- uint32_t actorID = (0 << 24 ) | (pixels [2 ] << 16 ) | (pixels [1 ] << 8 ) | (pixels [0 ] << 0 );
175+ uint32_t actorID = (0 << 24 ) | (pixel [2 ] << 16 ) | (pixel [1 ] << 8 ) | (pixel [0 ] << 0 );
194176
195177 if (auto actor = EDITOR_CONTEXT (sceneManager).GetCurrentScene ()->FindActorByID (actorID))
196178 {
@@ -203,8 +185,6 @@ void OvEditor::Panels::SceneView::HandleActorPicking()
203185 }
204186 }
205187
206- m_image->textureID .d = enableActorPickingDebugDraw ? m_actorPickingFramebuffer.GetTextureID () : m_fbo.GetTextureID ();
207-
208188 if (m_gizmoOperations.IsPicking ())
209189 {
210190 auto mousePosition = EDITOR_CONTEXT (inputManager)->GetMousePosition ();
0 commit comments