Merge pull request #59443 from rcorre/blender-xform-local-space

Disable local space for blender transforms.
This commit is contained in:
Rémi Verschelde 2023-03-07 12:00:17 +01:00
commit e404a7a8ee
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -1110,6 +1110,7 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {
_edit.click_ray = _get_ray(p_point); _edit.click_ray = _get_ray(p_point);
_edit.click_ray_pos = _get_ray_pos(p_point); _edit.click_ray_pos = _get_ray_pos(p_point);
_edit.plane = TRANSFORM_VIEW; _edit.plane = TRANSFORM_VIEW;
spatial_editor->set_local_coords_enabled(false);
spatial_editor->update_transform_gizmo(); spatial_editor->update_transform_gizmo();
_edit.center = spatial_editor->get_gizmo_transform().origin; _edit.center = spatial_editor->get_gizmo_transform().origin;
@ -3693,6 +3694,7 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
return; return;
} }
bool show_gizmo = spatial_editor->is_gizmo_visible() && !_edit.instant;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
Transform3D axis_angle; Transform3D axis_angle;
if (xform.basis.get_column(i).normalized().dot(xform.basis.get_column((i + 1) % 3).normalized()) < 1.0) { if (xform.basis.get_column(i).normalized().dot(xform.basis.get_column((i + 1) % 3).normalized()) < 1.0) {
@ -3701,15 +3703,15 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
axis_angle.basis.scale(scale); axis_angle.basis.scale(scale);
axis_angle.origin = xform.origin; axis_angle.origin = xform.origin;
RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], axis_angle);
RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], show_gizmo && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE));
RenderingServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], axis_angle);
RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], show_gizmo && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE));
RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], axis_angle);
RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)); RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], show_gizmo && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE));
RenderingServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], axis_angle);
RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], show_gizmo && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE));
RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], axis_angle);
RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], show_gizmo && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE));
RenderingServer::get_singleton()->instance_set_transform(axis_gizmo_instance[i], xform); RenderingServer::get_singleton()->instance_set_transform(axis_gizmo_instance[i], xform);
} }
@ -4477,6 +4479,7 @@ void Node3DEditorViewport::begin_transform(TransformMode p_mode, bool instant) {
_compute_edit(_edit.mouse_pos); _compute_edit(_edit.mouse_pos);
_edit.instant = instant; _edit.instant = instant;
_edit.snap = spatial_editor->is_snap_enabled(); _edit.snap = spatial_editor->is_snap_enabled();
update_transform_gizmo_view();
} }
} }