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
This commit is contained in:
Aaron Franke 2020-06-22 04:53:22 -04:00
parent 10d2fa4210
commit ed2bbdbbef
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
1 changed files with 1 additions and 1 deletions

View File

@ -3208,7 +3208,7 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
Vector3 camz = -camera_xform.get_basis().get_axis(2).normalized(); Vector3 camz = -camera_xform.get_basis().get_axis(2).normalized();
Vector3 camy = -camera_xform.get_basis().get_axis(1).normalized(); Vector3 camy = -camera_xform.get_basis().get_axis(1).normalized();
Plane p(camera_xform.origin, camz); 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 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 d1 = camera->unproject_position(camera_xform.origin + camz * gizmo_d + camy).y;
float dd = Math::abs(d0 - d1); float dd = Math::abs(d0 - d1);