From 80bb8bbcc303be104c0a90da247ad0df3c797ad4 Mon Sep 17 00:00:00 2001 From: aaronp64 Date: Tue, 21 Jan 2025 12:19:53 -0500 Subject: [PATCH] Fix Camera3D gizmo representation for aspect ratio > 1 For cameras using perspective projection mode, when the camera's viewport aspect ratio was greater than 1 (width > height), the camera gizmo would not correctly scale its depth, causing its appearance in editor to not match what it would show in preview/runtime. For aspect ratio <= 1, only the x axis had to be scaled by the ratio. For aspect ratio > 1, we use the inverse, and were only applying it to the y axis. To keep the same ratio and FOV as multiplying the x axis, both y and z should be multiplied by the inverse. Updated to multiply depth by size_factor.y (1 for aspect ratio <= 1, inverse of ratio for ratio > 1). --- editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp index 257db67410b..964eaac72ac 100644 --- a/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp @@ -180,7 +180,7 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { const float hsize = Math::sin(Math::deg_to_rad(fov)); const float depth = -Math::cos(Math::deg_to_rad(fov)); - Vector3 side = Vector3(hsize * size_factor.x, 0, depth); + Vector3 side = Vector3(hsize * size_factor.x, 0, depth * size_factor.y); Vector3 nside = Vector3(-side.x, side.y, side.z); Vector3 up = Vector3(0, hsize * size_factor.y, 0);