MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / onCursorPos

Method onCursorPos

engine/source/editor/source/editor_input_manager.cpp:188–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186 }
187
188 void EditorInputManager::onCursorPos(double xpos, double ypos)
189 {
190 if (!g_is_editor_mode)
191 return;
192
193 float angularVelocity =
194 180.0f / Math::max(m_engine_window_size.x, m_engine_window_size.y); // 180 degrees while moving full screen
195 if (m_mouse_x >= 0.0f && m_mouse_y >= 0.0f)
196 {
197 if (g_editor_global_context.m_window_system->isMouseButtonDown(GLFW_MOUSE_BUTTON_RIGHT))
198 {
199 glfwSetInputMode(
200 g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
201 g_editor_global_context.m_scene_manager->getEditorCamera()->rotate(
202 Vector2(ypos - m_mouse_y, xpos - m_mouse_x) * angularVelocity);
203 }
204 else if (g_editor_global_context.m_window_system->isMouseButtonDown(GLFW_MOUSE_BUTTON_LEFT))
205 {
206 g_editor_global_context.m_scene_manager->moveEntity(
207 xpos,
208 ypos,
209 m_mouse_x,
210 m_mouse_y,
211 m_engine_window_pos,
212 m_engine_window_size,
213 m_cursor_on_axis,
214 g_editor_global_context.m_scene_manager->getSelectedObjectMatrix());
215 glfwSetInputMode(g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
216 }
217 else
218 {
219 glfwSetInputMode(g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
220
221 if (isCursorInRect(m_engine_window_pos, m_engine_window_size))
222 {
223 Vector2 cursor_uv = Vector2((m_mouse_x - m_engine_window_pos.x) / m_engine_window_size.x,
224 (m_mouse_y - m_engine_window_pos.y) / m_engine_window_size.y);
225 updateCursorOnAxis(cursor_uv);
226 }
227 }
228 }
229 m_mouse_x = xpos;
230 m_mouse_y = ypos;
231 }
232
233 void EditorInputManager::onCursorEnter(int entered)
234 {

Callers

nothing calls this directly

Calls 8

glfwSetInputModeFunction · 0.85
isMouseButtonDownMethod · 0.80
getWindowMethod · 0.80
getEditorCameraMethod · 0.80
moveEntityMethod · 0.80
Vector2Class · 0.50
rotateMethod · 0.45

Tested by

no test coverage detected