mirror of https://github.com/godotengine/godot
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).
This commit is contained in:
parent
7b1ed520bd
commit
80bb8bbcc3
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue