@@ -94,96 +94,45 @@ void GridMapEditor::_menu_option(int p_option) {
9494 update_grid ();
9595
9696 } break ;
97- case MENU_OPTION_CURSOR_ROTATE_Y: {
98- Basis r;
99- if (input_action == INPUT_PASTE) {
100- r = node->get_basis_with_orthogonal_index (paste_indicator.orientation );
101- r.rotate (Vector3 (0 , 1 , 0 ), -Math::PI / 2.0 );
102- paste_indicator.orientation = node->get_orthogonal_index_from_basis (r);
103- _update_paste_indicator ();
104- break ;
105- }
106-
107- r = node->get_basis_with_orthogonal_index (cursor_rot);
108- r.rotate (Vector3 (0 , 1 , 0 ), -Math::PI / 2.0 );
109- cursor_rot = node->get_orthogonal_index_from_basis (r);
110- _update_cursor_transform ();
111- } break ;
112- case MENU_OPTION_CURSOR_ROTATE_X: {
113- Basis r;
114- if (input_action == INPUT_PASTE) {
115- r = node->get_basis_with_orthogonal_index (paste_indicator.orientation );
116- r.rotate (Vector3 (1 , 0 , 0 ), -Math::PI / 2.0 );
117- paste_indicator.orientation = node->get_orthogonal_index_from_basis (r);
118- _update_paste_indicator ();
119- break ;
120- }
121-
122- r = node->get_basis_with_orthogonal_index (cursor_rot);
123- r.rotate (Vector3 (1 , 0 , 0 ), -Math::PI / 2.0 );
124- cursor_rot = node->get_orthogonal_index_from_basis (r);
125- _update_cursor_transform ();
126- } break ;
127- case MENU_OPTION_CURSOR_ROTATE_Z: {
128- Basis r;
129- if (input_action == INPUT_PASTE) {
130- r = node->get_basis_with_orthogonal_index (paste_indicator.orientation );
131- r.rotate (Vector3 (0 , 0 , 1 ), -Math::PI / 2.0 );
132- paste_indicator.orientation = node->get_orthogonal_index_from_basis (r);
133- _update_paste_indicator ();
134- break ;
135- }
13697
137- r = node->get_basis_with_orthogonal_index (cursor_rot);
138- r.rotate (Vector3 (0 , 0 , 1 ), -Math::PI / 2.0 );
139- cursor_rot = node->get_orthogonal_index_from_basis (r);
140- _update_cursor_transform ();
141- } break ;
142- case MENU_OPTION_CURSOR_BACK_ROTATE_Y: {
143- Basis r;
144- if (input_action == INPUT_PASTE) {
145- r = node->get_basis_with_orthogonal_index (paste_indicator.orientation );
146- r.rotate (Vector3 (0 , 1 , 0 ), Math::PI / 2.0 );
147- paste_indicator.orientation = node->get_orthogonal_index_from_basis (r);
148- _update_paste_indicator ();
149- break ;
98+ case MENU_OPTION_CURSOR_ROTATE_X:
99+ case MENU_OPTION_CURSOR_ROTATE_Y:
100+ case MENU_OPTION_CURSOR_ROTATE_Z:
101+ case MENU_OPTION_CURSOR_BACK_ROTATE_X:
102+ case MENU_OPTION_CURSOR_BACK_ROTATE_Y:
103+ case MENU_OPTION_CURSOR_BACK_ROTATE_Z: {
104+ Vector3 rotation_axis;
105+ float rotation_angle = -Math::PI / 2.0 ;
106+ if (p_option == MENU_OPTION_CURSOR_ROTATE_X || p_option == MENU_OPTION_CURSOR_BACK_ROTATE_X) {
107+ rotation_axis.x = (p_option == MENU_OPTION_CURSOR_ROTATE_X) ? 1 : -1 ;
108+ } else if (p_option == MENU_OPTION_CURSOR_ROTATE_Y || p_option == MENU_OPTION_CURSOR_BACK_ROTATE_Y) {
109+ rotation_axis.y = (p_option == MENU_OPTION_CURSOR_ROTATE_Y) ? 1 : -1 ;
110+ } else if (p_option == MENU_OPTION_CURSOR_ROTATE_Z || p_option == MENU_OPTION_CURSOR_BACK_ROTATE_Z) {
111+ rotation_axis.z = (p_option == MENU_OPTION_CURSOR_ROTATE_Z) ? 1 : -1 ;
150112 }
151113
152- r = node->get_basis_with_orthogonal_index (cursor_rot);
153- r.rotate (Vector3 (0 , 1 , 0 ), Math::PI / 2.0 );
154- cursor_rot = node->get_orthogonal_index_from_basis (r);
155- _update_cursor_transform ();
156- } break ;
157- case MENU_OPTION_CURSOR_BACK_ROTATE_X: {
158114 Basis r;
159115 if (input_action == INPUT_PASTE) {
160116 r = node->get_basis_with_orthogonal_index (paste_indicator.orientation );
161- r.rotate (Vector3 ( 1 , 0 , 0 ), Math::PI / 2.0 );
117+ r.rotate (rotation_axis, rotation_angle );
162118 paste_indicator.orientation = node->get_orthogonal_index_from_basis (r);
163119 _update_paste_indicator ();
164- break ;
120+ } else if (_has_selection ()) {
121+ Array cells = _get_selected_cells ();
122+ for (int i = 0 ; i < cells.size (); i++) {
123+ Vector3i cell = cells[i];
124+ r = node->get_basis_with_orthogonal_index (node->get_cell_item_orientation (cell));
125+ r.rotate (rotation_axis, rotation_angle);
126+ node->set_cell_item (cell, node->get_cell_item (cell), node->get_orthogonal_index_from_basis (r));
127+ }
128+ } else {
129+ r = node->get_basis_with_orthogonal_index (cursor_rot);
130+ r.rotate (rotation_axis, rotation_angle);
131+ cursor_rot = node->get_orthogonal_index_from_basis (r);
132+ _update_cursor_transform ();
165133 }
166-
167- r = node->get_basis_with_orthogonal_index (cursor_rot);
168- r.rotate (Vector3 (1 , 0 , 0 ), Math::PI / 2.0 );
169- cursor_rot = node->get_orthogonal_index_from_basis (r);
170- _update_cursor_transform ();
171134 } break ;
172- case MENU_OPTION_CURSOR_BACK_ROTATE_Z: {
173- Basis r;
174- if (input_action == INPUT_PASTE) {
175- r = node->get_basis_with_orthogonal_index (paste_indicator.orientation );
176- r.rotate (Vector3 (0 , 0 , 1 ), Math::PI / 2.0 );
177- paste_indicator.orientation = node->get_orthogonal_index_from_basis (r);
178- _update_paste_indicator ();
179- break ;
180- }
181135
182- r = node->get_basis_with_orthogonal_index (cursor_rot);
183- r.rotate (Vector3 (0 , 0 , 1 ), Math::PI / 2.0 );
184- cursor_rot = node->get_orthogonal_index_from_basis (r);
185- _update_cursor_transform ();
186- } break ;
187136 case MENU_OPTION_CURSOR_CLEAR_ROTATION: {
188137 if (input_action == INPUT_PASTE) {
189138 paste_indicator.orientation = 0 ;
@@ -249,6 +198,10 @@ void GridMapEditor::_update_cursor_transform() {
249198 cursor_transform = node->get_global_transform () * cursor_transform;
250199
251200 if (mode_buttons_group->get_pressed_button () == paint_mode_button) {
201+ // Auto-deselect the selection when painting.
202+ if (selection.active ) {
203+ _set_selection (false );
204+ }
252205 // Rotation is only applied in paint mode, we don't want the cursor box to rotate otherwise.
253206 cursor_transform.basis = node->get_basis_with_orthogonal_index (cursor_rot);
254207 if (selected_palette >= 0 && node && node->get_mesh_library ().is_valid ()) {
0 commit comments