Skip to content

Commit 44f5d36

Browse files
committed
Improve logged transform part name
1 parent 0df4316 commit 44f5d36

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

editor/viewport/editor_transform_gizmo_nd.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,34 @@ Ref<RectND> EditorTransformGizmoND::_get_rect_bounds_of_selection(const Ref<Tran
340340
return bounds;
341341
}
342342

343-
VectorN _origin_axis_aligned_biplane_raycast(const VectorN &p_ray_origin, const VectorN &p_ray_direction, const VectorN &p_axis1, const VectorN &p_axis2) {
343+
String EditorTransformGizmoND::_get_transform_part_simple_action_name(const TransformPart p_part) {
344+
switch (p_part) {
345+
case TRANSFORM_NONE: {
346+
return "Transform";
347+
} break;
348+
case TRANSFORM_MOVE_AXIS:
349+
case TRANSFORM_MOVE_PLANE: {
350+
return "Move";
351+
} break;
352+
case TRANSFORM_ROTATE: {
353+
return "Rotate";
354+
} break;
355+
case TRANSFORM_SCALE_AXIS:
356+
case TRANSFORM_SCALE_PLANE: {
357+
return "Scale";
358+
} break;
359+
case TRANSFORM_STRETCH_POS:
360+
case TRANSFORM_STRETCH_NEG: {
361+
return "Stretch";
362+
} break;
363+
case TRANSFORM_MAX: {
364+
return "Transform";
365+
} break;
366+
}
367+
return "Transform";
368+
}
369+
370+
VectorN EditorTransformGizmoND::_origin_axis_aligned_biplane_raycast(const VectorN &p_ray_origin, const VectorN &p_ray_direction, const VectorN &p_axis1, const VectorN &p_axis2) {
344371
VectorN plane_normal = VectorND::slide(p_ray_direction, p_axis1);
345372
plane_normal = VectorND::slide(plane_normal, p_axis2);
346373
Ref<PlaneND> plane = PlaneND::from_normal_distance(VectorND::normalized(plane_normal), 0.0);
@@ -512,19 +539,14 @@ void EditorTransformGizmoND::_end_transformation() {
512539
return;
513540
}
514541
// Create an undo/redo action for the transformation.
515-
const bool is_move_only = _current_transformation == TRANSFORM_MOVE_AXIS || _current_transformation == TRANSFORM_MOVE_PLANE;
516-
_undo_redo->create_action(is_move_only ? String("Move ND nodes with gizmo") : String("Transform ND nodes with gizmo"));
542+
const String action = _get_transform_part_simple_action_name(_current_transformation);
543+
_undo_redo->create_action(action + String(" 4D nodes with gizmo"));
517544
const int size = _selected_top_nodes.size();
518545
for (int i = 0; i < size; i++) {
519546
NodeND *node_nd = Object::cast_to<NodeND>(_selected_top_nodes[i]);
520547
if (node_nd != nullptr) {
521-
if (is_move_only) {
522-
_undo_redo->add_do_property(node_nd, StringName("global_position"), node_nd->get_global_position());
523-
_undo_redo->add_undo_property(node_nd, StringName("global_position"), _selected_top_node_old_transforms[i]->get_origin());
524-
} else {
525-
_undo_redo->add_do_property(node_nd, StringName("global_transform"), node_nd->get_global_transform());
526-
_undo_redo->add_undo_property(node_nd, StringName("global_transform"), _selected_top_node_old_transforms[i]);
527-
}
548+
_undo_redo->add_do_property(node_nd, StringName("global_transform"), node_nd->get_global_transform());
549+
_undo_redo->add_undo_property(node_nd, StringName("global_transform"), _selected_top_node_old_transforms[i]);
528550
}
529551
}
530552
_undo_redo->commit_action(false);

editor/viewport/editor_transform_gizmo_nd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class EditorTransformGizmoND : public NodeND {
8181
void _update_gizmo_transform();
8282
void _update_gizmo_mesh_transform(const CameraND *p_camera);
8383
Ref<RectND> _get_rect_bounds_of_selection(const Ref<TransformND> &p_inv_relative_to) const;
84+
static String _get_transform_part_simple_action_name(const TransformPart p_part);
85+
static VectorN _origin_axis_aligned_biplane_raycast(const VectorN &p_ray_origin, const VectorN &p_ray_direction, const VectorN &p_axis1, const VectorN &p_axis2);
8486

8587
// Highlighting functions, used when not transforming.
8688
TransformPart _check_for_best_hit(const VectorN &p_local_ray_origin, const VectorN &p_local_ray_direction, int &r_primary_axis, int &r_secondary_axis) const;

0 commit comments

Comments
 (0)