diff options
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 6 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 17 | ||||
-rw-r--r-- | tools/editor/plugins/tile_map_editor_plugin.cpp | 27 | ||||
-rw-r--r-- | tools/editor/plugins/tile_map_editor_plugin.h | 2 |
4 files changed, 28 insertions, 24 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 62fb271930..2b70cec3fa 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -8119,6 +8119,9 @@ void RasterizerGLES2::_draw_textured_quad(const Rect2& p_rect, const Rect2& p_sr (p_src_region.pos.y+p_src_region.size.height)/p_tex_size.height) }; + if (p_transpose) { + SWAP( texcoords[1], texcoords[3] ); + } if (p_h_flip) { SWAP( texcoords[0], texcoords[1] ); SWAP( texcoords[2], texcoords[3] ); @@ -8127,9 +8130,6 @@ void RasterizerGLES2::_draw_textured_quad(const Rect2& p_rect, const Rect2& p_sr SWAP( texcoords[1], texcoords[2] ); SWAP( texcoords[0], texcoords[3] ); } - if (p_transpose) { - SWAP( texcoords[1], texcoords[3] ); - } Vector2 coords[4]= { Vector2( p_rect.pos.x, p_rect.pos.y ), diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 0b123bfa1c..93005ed1e3 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -242,19 +242,22 @@ void TileMap::_update_dirty_quadrants() { Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id); Matrix32 xform; xform.set_origin(offset.floor()); + if (c.transpose) { + SWAP(xform.elements[0].x, xform.elements[0].y); + SWAP(xform.elements[1].x, xform.elements[1].y); + SWAP(shape_ofs.x, shape_ofs.y); + SWAP(s.x, s.y); + } if (c.flip_h) { - xform.elements[0]=-xform.elements[0]; + xform.elements[0].x=-xform.elements[0].x; + xform.elements[1].x=-xform.elements[1].x; shape_ofs.x=s.x-shape_ofs.x; } if (c.flip_v) { - xform.elements[1]=-xform.elements[1]; + xform.elements[0].y=-xform.elements[0].y; + xform.elements[1].y=-xform.elements[1].y; shape_ofs.y=s.y-shape_ofs.y; } - if (c.transpose) { - SWAP(xform.elements[0].x, xform.elements[0].y); - SWAP(xform.elements[1].x, xform.elements[1].y); - SWAP(shape_ofs.x, shape_ofs.y); - } xform.elements[2].x+=shape_ofs.x; xform.elements[2].y+=shape_ofs.y; diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 1dcf948505..47727a00c2 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -42,9 +42,9 @@ void TileMapEditor::_notification(int p_what) { case NOTIFICATION_READY: { + transpose->set_icon( get_icon("Transpose","EditorIcons")); mirror_x->set_icon( get_icon("MirrorX","EditorIcons")); mirror_y->set_icon( get_icon("MirrorY","EditorIcons")); - transpose->set_icon( get_icon("Transpose","EditorIcons")); rotate_0->set_icon( get_icon("Rotate0","EditorIcons")); rotate_90->set_icon( get_icon("Rotate90","EditorIcons")); rotate_180->set_icon( get_icon("Rotate180","EditorIcons")); @@ -90,6 +90,7 @@ void TileMapEditor::set_selected_tile(int p_tile) { } } +// Wrapper to workaround five arg limit of undo/redo methods void TileMapEditor::_set_cell_shortened(const Point2& p_pos,int p_value,bool p_flip_h, bool p_flip_v, bool p_transpose) { ERR_FAIL_COND(!node); node->set_cell(floor(p_pos.x), floor(p_pos.y), p_value, p_flip_h, p_flip_v, p_transpose); @@ -757,8 +758,8 @@ void TileMapEditor::_update_transform_buttons(Object *p_button) { transpose->set_pressed(false); } else if (b == rotate_90) { - mirror_x->set_pressed(false); - mirror_y->set_pressed(true); + mirror_x->set_pressed(true); + mirror_y->set_pressed(false); transpose->set_pressed(true); } else if (b == rotate_180) { @@ -767,15 +768,15 @@ void TileMapEditor::_update_transform_buttons(Object *p_button) { transpose->set_pressed(false); } else if (b == rotate_270) { - mirror_x->set_pressed(true); - mirror_y->set_pressed(false); + mirror_x->set_pressed(false); + mirror_y->set_pressed(true); transpose->set_pressed(true); } rotate_0->set_pressed(!mirror_x->is_pressed() && !mirror_y->is_pressed() && !transpose->is_pressed()); - rotate_90->set_pressed(!mirror_x->is_pressed() && mirror_y->is_pressed() && transpose->is_pressed()); + rotate_90->set_pressed(mirror_x->is_pressed() && !mirror_y->is_pressed() && transpose->is_pressed()); rotate_180->set_pressed(mirror_x->is_pressed() && mirror_y->is_pressed() && !transpose->is_pressed()); - rotate_270->set_pressed(mirror_x->is_pressed() && !mirror_y->is_pressed() && transpose->is_pressed()); + rotate_270->set_pressed(!mirror_x->is_pressed() && mirror_y->is_pressed() && transpose->is_pressed()); mirror_x->set_block_signals(false); mirror_y->set_block_signals(false); @@ -807,6 +808,12 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { canvas_item_editor_hb = memnew( HBoxContainer ); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(canvas_item_editor_hb); canvas_item_editor_hb->add_child( memnew( VSeparator )); + transpose = memnew( ToolButton ); + transpose->set_toggle_mode(true); + transpose->set_tooltip("Transpose"); + transpose->set_focus_mode(FOCUS_NONE); + transpose->connect("pressed", this, "_update_transform_buttons", make_binds(transpose)); + canvas_item_editor_hb->add_child(transpose); mirror_x = memnew( ToolButton ); mirror_x->set_toggle_mode(true); mirror_x->set_tooltip("Mirror X (A)"); @@ -819,12 +826,6 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { mirror_y->set_focus_mode(FOCUS_NONE); mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y)); canvas_item_editor_hb->add_child(mirror_y); - transpose = memnew( ToolButton ); - transpose->set_toggle_mode(true); - transpose->set_tooltip("Transpose"); - transpose->set_focus_mode(FOCUS_NONE); - transpose->connect("pressed", this, "_update_transform_buttons", make_binds(transpose)); - canvas_item_editor_hb->add_child(transpose); canvas_item_editor_hb->add_child(memnew(VSeparator)); rotate_0 = memnew( ToolButton ); rotate_0->set_toggle_mode(true); diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h index 525315a8f1..367e687d77 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.h +++ b/tools/editor/plugins/tile_map_editor_plugin.h @@ -71,9 +71,9 @@ class TileMapEditor : public VBoxContainer { bool mouse_over; Label *mirror_label; + ToolButton *transpose; ToolButton *mirror_x; ToolButton *mirror_y; - ToolButton *transpose; ToolButton *rotate_0; ToolButton *rotate_90; ToolButton *rotate_180; |