diff options
author | Yuri Sizov <11782833+YuriSizov@users.noreply.github.com> | 2022-08-23 15:34:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 15:34:04 +0300 |
commit | 249517f1325c9d3960dab20daaa0834b7d6a237c (patch) | |
tree | dbf257609adc02a17f5b3d8a99c1d2e804627f13 | |
parent | 14f8a54a3371df91327dbe2fc52c42a3616fcab0 (diff) | |
parent | 3541200f2b6c14d3c72b6da4ed4c54525edd93f3 (diff) |
Merge pull request #61493 from Calinou/editor-align-transform-rotate-decal
Rotate Decal nodes when using Align Transform/Rotation With View
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 2798f3d93e..30eb85709a 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -46,6 +46,7 @@ #include "editor/scene_tree_dock.h" #include "scene/3d/camera_3d.h" #include "scene/3d/collision_shape_3d.h" +#include "scene/3d/decal.h" #include "scene/3d/light_3d.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/physics_body_3d.h" @@ -2972,6 +2973,13 @@ void Node3DEditorViewport::_menu_option(int p_option) { xform.scale_basis(sp->get_scale()); } + if (Object::cast_to<Decal>(E)) { + // Adjust rotation to match Decal's default orientation. + // This makes the decal "look" in the same direction as the camera, + // rather than pointing down relative to the camera orientation. + xform.basis.rotate_local(Vector3(1, 0, 0), Math_TAU * 0.25); + } + undo_redo->add_do_method(sp, "set_global_transform", xform); undo_redo->add_undo_method(sp, "set_global_transform", sp->get_global_gizmo_transform()); } @@ -2999,7 +3007,16 @@ void Node3DEditorViewport::_menu_option(int p_option) { continue; } - undo_redo->add_do_method(sp, "set_rotation", camera_transform.basis.get_euler_normalized()); + Basis basis = camera_transform.basis; + + if (Object::cast_to<Decal>(E)) { + // Adjust rotation to match Decal's default orientation. + // This makes the decal "look" in the same direction as the camera, + // rather than pointing down relative to the camera orientation. + basis.rotate_local(Vector3(1, 0, 0), Math_TAU * 0.25); + } + + undo_redo->add_do_method(sp, "set_rotation", basis.get_euler_normalized()); undo_redo->add_undo_method(sp, "set_rotation", sp->get_rotation()); } undo_redo->commit_action(); |