Merge pull request #33589 from JFonS/fix_scaled_gizmos

Fix broken gizmo interaction when Node is scaled
This commit is contained in:
Rémi Verschelde 2019-11-13 13:43:57 +01:00 committed by GitHub
commit a439c55eff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -490,7 +490,6 @@ bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point,
if (r_gizmo_handle && !hidden) { if (r_gizmo_handle && !hidden) {
Transform t = spatial_node->get_global_transform(); Transform t = spatial_node->get_global_transform();
t.orthonormalize();
if (billboard_handle) { if (billboard_handle) {
t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
} }
@ -551,7 +550,6 @@ bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point,
if (selectable_icon_size > 0.0f) { if (selectable_icon_size > 0.0f) {
Transform t = spatial_node->get_global_transform(); Transform t = spatial_node->get_global_transform();
t.orthonormalize();
Vector3 camera_position = p_camera->get_camera_transform().origin; Vector3 camera_position = p_camera->get_camera_transform().origin;
if (camera_position.distance_squared_to(t.origin) > 0.01) { if (camera_position.distance_squared_to(t.origin) > 0.01) {
t.set_look_at(t.origin, camera_position, Vector3(0, 1, 0)); t.set_look_at(t.origin, camera_position, Vector3(0, 1, 0));
@ -861,7 +859,6 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx,
Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node()); Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
Transform gt = light->get_global_transform(); Transform gt = light->get_global_transform();
gt.orthonormalize();
Transform gi = gt.affine_inverse(); Transform gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
@ -1106,7 +1103,6 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_giz
AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
Transform gt = player->get_global_transform(); Transform gt = player->get_global_transform();
gt.orthonormalize();
Transform gi = gt.affine_inverse(); Transform gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
@ -1266,7 +1262,6 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx
Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node()); Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
Transform gt = camera->get_global_transform(); Transform gt = camera->get_global_transform();
gt.orthonormalize();
Transform gi = gt.affine_inverse(); Transform gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);
@ -3234,7 +3229,6 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
return; return;
Transform gt = cs->get_global_transform(); Transform gt = cs->get_global_transform();
gt.orthonormalize();
Transform gi = gt.affine_inverse(); Transform gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_from = p_camera->project_ray_origin(p_point);