From 6610d950cba11f01ac995991d9826d5b5c69f7d8 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 02:55:05 -0700 Subject: [PATCH] fix(editor): flyToSelected uses atan2(to.y, to.x) for correct camera yaw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Camera::getForward = (cos(yaw), sin(yaw), sin(pitch)) — to make it parallel to a direction vector we need atan2(y, x). The implementation had x and y swapped, causing Fly To to point the camera 90deg off from the target so the user often saw nothing. --- tools/editor/editor_app.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/editor/editor_app.cpp b/tools/editor/editor_app.cpp index cc143dbc..52c91898 100644 --- a/tools/editor/editor_app.cpp +++ b/tools/editor/editor_app.cpp @@ -1514,9 +1514,11 @@ void EditorApp::flyToSelected() { glm::vec3 cam = target + back * 25.0f + glm::vec3(0, 0, 15); camera_.setPosition(cam); - // Aim at target — yaw is atan2(toX, toY) in editor convention; pitch from height delta. + // Aim at target. Camera::getForward = (cos(yaw), sin(yaw), sin(pitch)), + // so to make it parallel to `to` we use atan2(to.y, to.x), not (x, y). + // The previous swap pointed the camera 90deg off from the target. glm::vec3 to = target - cam; - float yaw = glm::degrees(std::atan2(to.x, to.y)); + float yaw = glm::degrees(std::atan2(to.y, to.x)); float horiz = std::sqrt(to.x * to.x + to.y * to.y); float pitch = glm::degrees(std::atan2(to.z, horiz)); camera_.setYawPitch(yaw, pitch);