From 44c3908c7b5bf8f3298da8b702b765c9d8ba0957 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Mon, 22 Jun 2020 04:53:22 -0400 Subject: [PATCH] Avoid errors when the editor camera is inside the focused object Prevent the gizmo distance from being zero by MAX-ing it with CMP_EPSILON (cherry picked from commit ed2bbdbbefa190a707f4e09d9bd9c04b564f32ae) --- editor/plugins/spatial_editor_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 9ed2d3231b4..953a8b953f4 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -3196,7 +3196,7 @@ void SpatialEditorViewport::update_transform_gizmo_view() { Vector3 camz = -camera_xform.get_basis().get_axis(2).normalized(); Vector3 camy = -camera_xform.get_basis().get_axis(1).normalized(); Plane p(camera_xform.origin, camz); - float gizmo_d = Math::abs(p.distance_to(xform.origin)); + float gizmo_d = MAX(Math::abs(p.distance_to(xform.origin)), CMP_EPSILON); float d0 = camera->unproject_position(camera_xform.origin + camz * gizmo_d).y; float d1 = camera->unproject_position(camera_xform.origin + camz * gizmo_d + camy).y; float dd = Math::abs(d0 - d1);