diff options
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 51 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 102 | ||||
-rw-r--r-- | editor/plugins/collision_polygon_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/mesh_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/particles_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 42 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 185 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 6 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 184 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 19 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 2 |
13 files changed, 437 insertions, 174 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index d2e7feb6e1..b63352389e 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -47,9 +47,9 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co for (int i = 0; i < 5; i++) { if (i < p_rating) - stars[i]->set_texture(get_icon("RatingStar", "EditorIcons")); + stars[i]->set_texture(get_icon("Favorites", "EditorIcons")); else - stars[i]->set_texture(get_icon("RatingNoStar", "EditorIcons")); + stars[i]->set_texture(get_icon("NonFavorite", "EditorIcons")); } } @@ -273,15 +273,15 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { HBoxContainer *hbox = memnew(HBoxContainer); vbox->add_child(hbox); - vbox->add_constant_override("separation", 15); + vbox->add_constant_override("separation", 15 * EDSCALE); VBoxContainer *desc_vbox = memnew(VBoxContainer); hbox->add_child(desc_vbox); - hbox->add_constant_override("separation", 15); + hbox->add_constant_override("separation", 15 * EDSCALE); item = memnew(EditorAssetLibraryItem); desc_vbox->add_child(item); - desc_vbox->set_custom_minimum_size(Size2(300, 0)); + desc_vbox->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); desc_bg = memnew(PanelContainer); desc_vbox->add_child(desc_bg); @@ -292,12 +292,12 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { desc_bg->add_child(description); preview = memnew(TextureRect); - preview->set_custom_minimum_size(Size2(640, 345)); + preview->set_custom_minimum_size(Size2(640 * EDSCALE, 345 * EDSCALE)); hbox->add_child(preview); previews_bg = memnew(PanelContainer); vbox->add_child(previews_bg); - previews_bg->set_custom_minimum_size(Size2(0, 85)); + previews_bg->set_custom_minimum_size(Size2(0, 101 * EDSCALE)); previews = memnew(ScrollContainer); previews_bg->add_child(previews); @@ -445,7 +445,7 @@ void EditorAssetLibraryItemDownload::_install() { void EditorAssetLibraryItemDownload::_make_request() { download->cancel_request(); - download->set_download_file(EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("tmp_asset_" + itos(asset_id)) + ".zip"); + download->set_download_file(EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_asset_" + itos(asset_id)) + ".zip"); Error err = download->request(host); if (err != OK) { @@ -680,7 +680,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt PoolByteArray image_data = p_data; if (use_cache) { - String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); FileAccess *file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ); @@ -702,15 +702,28 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt Ref<Image> image = Ref<Image>(memnew(Image(r.ptr(), len))); if (!image->empty()) { - float max_height = 10000; switch (image_queue[p_queue_id].image_type) { - case IMAGE_QUEUE_ICON: max_height = 80; break; - case IMAGE_QUEUE_THUMBNAIL: max_height = 80; break; - case IMAGE_QUEUE_SCREENSHOT: max_height = 345; break; - } - float scale_ratio = max_height / image->get_height(); - if (scale_ratio < 1) { - image->resize(image->get_width() * scale_ratio, image->get_height() * scale_ratio, Image::INTERPOLATE_CUBIC); + case IMAGE_QUEUE_ICON: + + image->resize(80 * EDSCALE, 80 * EDSCALE, Image::INTERPOLATE_CUBIC); + + break; + case IMAGE_QUEUE_THUMBNAIL: { + float max_height = 85 * EDSCALE; + + float scale_ratio = max_height / (image->get_height() * EDSCALE); + if (scale_ratio < 1) { + image->resize(image->get_width() * EDSCALE * scale_ratio, image->get_height() * EDSCALE * scale_ratio, Image::INTERPOLATE_CUBIC); + } + } break; + case IMAGE_QUEUE_SCREENSHOT: { + float max_height = 397 * EDSCALE; + + float scale_ratio = max_height / (image->get_height() * EDSCALE); + if (scale_ratio < 1) { + image->resize(image->get_width() * EDSCALE * scale_ratio, image->get_height() * EDSCALE * scale_ratio, Image::INTERPOLATE_CUBIC); + } + } break; } Ref<ImageTexture> tex; @@ -738,7 +751,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) { for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("ETag:") == 0) { // Save etag - String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); String new_etag = headers[i].substr(headers[i].find(":") + 1, headers[i].length()).strip_edges(); FileAccess *file; @@ -786,7 +799,7 @@ void EditorAssetLibrary::_update_image_queue() { for (Map<int, ImageQueue>::Element *E = image_queue.front(); E; E = E->next()) { if (!E->get().active && current_images < max_images) { - String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + E->get().image_url.md5_text()); + String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + E->get().image_url.md5_text()); Vector<String> headers; if (FileAccess::exists(cache_filename_base + ".etag") && FileAccess::exists(cache_filename_base + ".data")) { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 38467369db..b6ba09fb58 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -176,9 +176,9 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Node2D *n2d = Object::cast_to<Node2D>(E->get()); - if (n2d && n2d->edit_has_pivot()) { + if (n2d && n2d->_edit_use_pivot()) { - Vector2 offset = n2d->edit_get_pivot(); + Vector2 offset = n2d->_edit_get_pivot(); Vector2 gpos = n2d->get_global_position(); Vector2 local_mouse_pos = n2d->get_canvas_transform().affine_inverse().xform(mouse_pos); @@ -186,9 +186,9 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) { Vector2 motion_ofs = gpos - local_mouse_pos; undo_redo->add_do_method(n2d, "set_global_position", local_mouse_pos); - undo_redo->add_do_method(n2d, "edit_set_pivot", offset + n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs)); + undo_redo->add_do_method(n2d, "_edit_set_pivot", offset + n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs)); undo_redo->add_undo_method(n2d, "set_global_position", gpos); - undo_redo->add_undo_method(n2d, "edit_set_pivot", offset); + undo_redo->add_undo_method(n2d, "_edit_set_pivot", offset); for (int i = 0; i < n2d->get_child_count(); i++) { Node2D *n2dc = Object::cast_to<Node2D>(n2d->get_child(i)); if (!n2dc) @@ -249,8 +249,8 @@ void CanvasItemEditor::_snap_other_nodes(Point2 p_value, Point2 &r_current_snap, Transform2D ci_transform = canvas_item->get_global_transform_with_canvas(); Transform2D to_snap_transform = p_to_snap ? p_to_snap->get_global_transform_with_canvas() : Transform2D(); if (fmod(ci_transform.get_rotation() - to_snap_transform.get_rotation(), (real_t)360.0) == 0.0) { - Point2 begin = ci_transform.xform(canvas_item->get_item_rect().get_position()); - Point2 end = ci_transform.xform(canvas_item->get_item_rect().get_position() + canvas_item->get_item_rect().get_size()); + Point2 begin = ci_transform.xform(canvas_item->_edit_get_rect().get_position()); + Point2 end = ci_transform.xform(canvas_item->_edit_get_rect().get_position() + canvas_item->_edit_get_rect().get_size()); _snap_if_closer_point(p_value, begin, r_current_snap, r_snapped, ci_transform.get_rotation()); _snap_if_closer_point(p_value, end, r_current_snap, r_snapped, ci_transform.get_rotation()); @@ -282,8 +282,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, const end = p_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(1, 1))); can_snap = true; } else if (const CanvasItem *parent_ci = Object::cast_to<CanvasItem>(p_canvas_item->get_parent())) { - begin = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->get_item_rect().get_position()); - end = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->get_item_rect().get_position() + parent_ci->get_item_rect().get_size()); + begin = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->_edit_get_rect().get_position()); + end = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->_edit_get_rect().get_position() + parent_ci->_edit_get_rect().get_size()); can_snap = true; } @@ -306,8 +306,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, const // Self sides (for anchors) if ((snap_active && snap_node_sides && (p_modes & SNAP_NODE_SIDES)) || (p_forced_modes & SNAP_NODE_SIDES)) { - begin = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->get_item_rect().get_position()); - end = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->get_item_rect().get_position() + p_canvas_item->get_item_rect().get_size()); + begin = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->_edit_get_rect().get_position()); + end = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->_edit_get_rect().get_position() + p_canvas_item->_edit_get_rect().get_size()); _snap_if_closer_point(p_target, begin, output, snapped, rotation); _snap_if_closer_point(p_target, end, output, snapped, rotation); } @@ -629,7 +629,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) { - Rect2 rect = c->get_item_rect(); + Rect2 rect = c->_edit_get_rect(); Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos); if (rect.has_point(local_pos)) { @@ -675,7 +675,7 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) { - Rect2 rect = c->get_item_rect(); + Rect2 rect = c->_edit_get_rect(); Transform2D xform = p_parent_xform * p_canvas_xform * c->get_transform(); if (p_rect.has_point(xform.xform(rect.position)) && @@ -767,15 +767,15 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE if (p_snap) drag *= grid_step * Math::pow(2.0, grid_step_multiplier); - undo_redo->add_undo_method(canvas_item, "edit_set_state", canvas_item->edit_get_state()); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); if (p_move_mode == MOVE_VIEW_BASE) { // drag = transform.affine_inverse().basis_xform(p_dir); // zoom sensitive drag = canvas_item->get_global_transform_with_canvas().affine_inverse().basis_xform(drag); - Rect2 local_rect = canvas_item->get_item_rect(); + Rect2 local_rect = canvas_item->_edit_get_rect(); local_rect.position += drag; - undo_redo->add_do_method(canvas_item, "edit_set_rect", local_rect); + undo_redo->add_do_method(canvas_item, "_edit_set_rect", local_rect); } else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT @@ -816,7 +816,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() { if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) continue; - Rect2 rect = canvas_item->get_item_rect(); + Rect2 rect = canvas_item->_edit_get_rect(); Transform2D xform = canvas_item->get_global_transform_with_canvas(); r2.expand_to(xform.xform(rect.position)); @@ -877,7 +877,7 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_resize_handle_drag_type(const ERR_FAIL_COND_V(!canvas_item, DRAG_NONE); - Rect2 rect = canvas_item->get_item_rect(); + Rect2 rect = canvas_item->_edit_get_rect(); Transform2D xforml = canvas_item->get_global_transform_with_canvas(); Transform2D xform = transform * xforml; @@ -1011,14 +1011,14 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) { if (!se) continue; - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); if (Object::cast_to<Node2D>(canvas_item)) - se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); + se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->_edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); } if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0]) && bone_ik_list.size() == 0) { @@ -1500,7 +1500,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { // Cancel a drag if (bone_ik_list.size()) { for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) { - E->get().node->edit_set_state(E->get().orig_state); + E->get().node->_edit_set_state(E->get().orig_state); } bone_ik_list.clear(); @@ -1519,9 +1519,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if (!se) continue; - canvas_item->edit_set_state(se->undo_state); + canvas_item->_edit_set_state(se->undo_state); if (Object::cast_to<Node2D>(canvas_item)) - Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot); + Object::cast_to<Node2D>(canvas_item)->_edit_set_pivot(se->undo_pivot); if (Object::cast_to<Control>(canvas_item)) Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot); } @@ -1574,8 +1574,8 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) { - undo_redo->add_do_method(E->get().node, "edit_set_state", E->get().node->edit_get_state()); - undo_redo->add_undo_method(E->get().node, "edit_set_state", E->get().orig_state); + undo_redo->add_do_method(E->get().node, "_edit_set_state", E->get().node->_edit_get_state()); + undo_redo->add_undo_method(E->get().node, "_edit_set_state", E->get().orig_state); } undo_redo->add_do_method(viewport, "update"); @@ -1601,14 +1601,14 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if (!se) continue; - Variant state = canvas_item->edit_get_state(); - undo_redo->add_do_method(canvas_item, "edit_set_state", state); - undo_redo->add_undo_method(canvas_item, "edit_set_state", se->undo_state); + Variant state = canvas_item->_edit_get_state(); + undo_redo->add_do_method(canvas_item, "_edit_set_state", state); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); { Node2D *pvt = Object::cast_to<Node2D>(canvas_item); - if (pvt && pvt->edit_has_pivot()) { - undo_redo->add_do_method(canvas_item, "edit_set_pivot", pvt->edit_get_pivot()); - undo_redo->add_undo_method(canvas_item, "edit_set_pivot", se->undo_pivot); + if (pvt && pvt->_edit_use_pivot()) { + undo_redo->add_do_method(canvas_item, "_edit_set_pivot", pvt->_edit_get_pivot()); + undo_redo->add_undo_method(canvas_item, "_edit_set_pivot", se->undo_pivot); } Control *cnt = Object::cast_to<Control>(canvas_item); @@ -1709,7 +1709,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { BoneIK bik; bik.node = b; bik.len = len; - bik.orig_state = b->edit_get_state(); + bik.orig_state = b->_edit_get_state(); bone_ik_list.push_back(bik); @@ -1741,13 +1741,13 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if ((b->get_control() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) { drag = DRAG_ROTATE; drag_from = transform.affine_inverse().xform(click); - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); if (Object::cast_to<Node2D>(canvas_item)) - se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); + se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->_edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); return; } @@ -1764,13 +1764,13 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { drag = _get_resize_handle_drag_type(click, drag_point_from); if (drag != DRAG_NONE) { drag_from = transform.affine_inverse().xform(click); - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); if (Object::cast_to<Node2D>(canvas_item)) - se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); + se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->_edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); return; } @@ -1780,9 +1780,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { drag = _get_anchor_handle_drag_type(click, drag_point_from); if (drag != DRAG_NONE) { drag_from = transform.affine_inverse().xform(click); - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); return; } } @@ -1890,9 +1890,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { bool dragging_bone = drag == DRAG_ALL && selection.size() == 1 && bone_ik_list.size(); if (!dragging_bone) { - canvas_item->edit_set_state(se->undo_state); //reset state and reapply + canvas_item->_edit_set_state(se->undo_state); //reset state and reapply if (Object::cast_to<Node2D>(canvas_item)) - Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot); + Object::cast_to<Node2D>(canvas_item)->_edit_set_pivot(se->undo_pivot); if (Object::cast_to<Control>(canvas_item)) Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot); } @@ -2003,10 +2003,10 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dto) - canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dfrom); - Rect2 local_rect = canvas_item->get_item_rect(); + Rect2 local_rect = canvas_item->_edit_get_rect(); Vector2 begin = local_rect.position; Vector2 end = local_rect.position + local_rect.size; - Vector2 minsize = canvas_item->edit_get_minimum_size(); + Vector2 minsize = canvas_item->_edit_get_minimum_size(); if (uniform) { // Keep the height/width ratio of the item @@ -2084,7 +2084,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if (Object::cast_to<Node2D>(canvas_item)) { Node2D *n2d = Object::cast_to<Node2D>(canvas_item); - n2d->edit_set_pivot(se->undo_pivot + drag_vector); + n2d->_edit_set_pivot(se->undo_pivot + drag_vector); } if (Object::cast_to<Control>(canvas_item)) { Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot + drag_vector); @@ -2103,7 +2103,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { local_rect.position = begin; local_rect.size = end - begin; - canvas_item->edit_set_rect(local_rect); + canvas_item->_edit_set_rect(local_rect); } else { //ok, all that had to be done was done, now solve IK @@ -2454,7 +2454,7 @@ void CanvasItemEditor::_draw_selection() { if (!se) continue; - Rect2 rect = canvas_item->get_item_rect(); + Rect2 rect = canvas_item->_edit_get_rect(); if (show_helpers && drag != DRAG_NONE && drag != DRAG_PIVOT) { const Transform2D pre_drag_xform = transform * se->pre_drag_xform; @@ -2496,7 +2496,7 @@ void CanvasItemEditor::_draw_selection() { Node2D *node2d = Object::cast_to<Node2D>(canvas_item); if (node2d) { - if (node2d->edit_has_pivot()) { + if (node2d->_edit_use_pivot()) { viewport->draw_texture(pivot_icon, xform.get_origin() + (-pivot_icon->get_size() / 2).floor()); can_move_pivot = true; pivot_found = true; @@ -2868,7 +2868,7 @@ void CanvasItemEditor::_get_encompassing_rect(Node *p_node, Rect2 &r_rect, const CanvasItem *c = Object::cast_to<CanvasItem>(p_node); if (c && c->is_visible_in_tree()) { - Rect2 rect = c->get_item_rect(); + Rect2 rect = c->_edit_get_rect(); Transform2D xform = p_xform * c->get_transform(); r_rect.expand_to(xform.xform(rect.position)); r_rect.expand_to(xform.xform(rect.position + Point2(rect.size.x, 0))); @@ -2963,7 +2963,7 @@ void CanvasItemEditor::_notification(int p_what) { if (!se) continue; - Rect2 r = canvas_item->get_item_rect(); + Rect2 r = canvas_item->_edit_get_rect(); Transform2D xform = canvas_item->get_transform(); if (r != se->prev_rect || xform != se->prev_xform) { @@ -3899,7 +3899,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { //if (!canvas_item->is_visible_in_tree()) continue; ++count; - Rect2 item_rect = canvas_item->get_item_rect(); + Rect2 item_rect = canvas_item->_edit_get_rect(); Vector2 pos = canvas_item->get_global_transform().get_origin(); Vector2 scale = canvas_item->get_global_transform().get_scale(); diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 24c4813771..0818c8975e 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -389,7 +389,7 @@ void CollisionPolygonEditor::_polygon_draw() { rect = rect.grow(1); - Rect3 r; + AABB r; r.position.x = rect.position.x; r.position.y = rect.position.y; r.position.z = depth; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 5f73d0b465..ed04c90cc5 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -184,7 +184,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from) { Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path) { - String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); + String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); @@ -790,13 +790,13 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) { VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; Transform xform; xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125); xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis; - Rect3 rot_aabb = xform.xform(aabb); + AABB rot_aabb = xform.xform(aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) return Ref<Texture>(); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 74618aecc2..60e8858b2d 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -95,7 +95,7 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) { rot_y = 0; _update_rotation(); - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); print_line("aabb: " + aabb); Vector3 ofs = aabb.position + aabb.size * 0.5; float m = aabb.get_longest_axis_size(); diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 10834b74ff..f4a9960087 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -153,15 +153,15 @@ void ParticlesEditor::_generate_aabb() { EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time)); - Rect3 rect; + AABB rect; while (running < time) { uint64_t ticks = OS::get_singleton()->get_ticks_usec(); ep.step("Generating..", int(running), true); OS::get_singleton()->delay_usec(1000); - Rect3 capture = node->capture_aabb(); - if (rect == Rect3()) + AABB capture = node->capture_aabb(); + if (rect == AABB()) rect = capture; else rect.merge_with(capture); @@ -247,7 +247,7 @@ void ParticlesEditor::_generate_emission_points() { PoolVector<Face3>::Read r = geometry.read(); - Rect3 aabb; + AABB aabb; for (int i = 0; i < gcount; i++) { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 607ccaa4e7..32ec9b2ba9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -586,6 +586,32 @@ void ScriptEditor::_close_docs_tab() { } } +void ScriptEditor::_close_other_tabs() { + + int child_count = tab_container->get_child_count(); + int current_idx = tab_container->get_current_tab(); + for (int i = child_count - 1; i >= 0; i--) { + + if (i == current_idx) { + continue; + } + + tab_container->set_current_tab(i); + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); + + if (se) { + + // Maybe there are unsaved changes + if (se->is_unsaved()) { + _ask_close_current_unsaved_tab(se); + continue; + } + } + + _close_current_tab(); + } +} + void ScriptEditor::_close_all_tabs() { int child_count = tab_container->get_child_count(); @@ -855,7 +881,7 @@ void ScriptEditor::_menu_option(int p_option) { file_dialog_option = FILE_SAVE_THEME_AS; file_dialog->clear_filters(); file_dialog->add_filter("*.tet"); - file_dialog->set_current_path(EditorSettings::get_singleton()->get_settings_path() + "/text_editor_themes/" + EditorSettings::get_singleton()->get("text_editor/theme/color_theme")); + file_dialog->set_current_path(EditorSettings::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); file_dialog->popup_centered_ratio(); file_dialog->set_title(TTR("Save Theme As..")); } break; @@ -1003,6 +1029,9 @@ void ScriptEditor::_menu_option(int p_option) { case CLOSE_DOCS: { _close_docs_tab(); } break; + case CLOSE_OTHER_TABS: { + _close_other_tabs(); + } break; case CLOSE_ALL: { _close_all_tabs(); } break; @@ -1078,6 +1107,9 @@ void ScriptEditor::_menu_option(int p_option) { case CLOSE_DOCS: { _close_docs_tab(); } break; + case CLOSE_OTHER_TABS: { + _close_other_tabs(); + } break; case CLOSE_ALL: { _close_all_tabs(); } break; @@ -1119,6 +1151,7 @@ void ScriptEditor::_notification(int p_what) { editor->connect("script_add_function_request", this, "_add_callback"); editor->connect("resource_saved", this, "_res_saved_callback"); script_list->connect("item_selected", this, "_script_selected"); + members_overview->connect("item_selected", this, "_members_overview_selected"); help_overview->connect("item_selected", this, "_help_overview_selected"); script_split->connect("dragged", this, "_script_split_dragged"); @@ -1583,7 +1616,7 @@ void ScriptEditor::_update_script_names() { } } - if (_sort_list_on_update) { + if (_sort_list_on_update && !sedata.empty()) { sedata.sort(); // change actual order of tab_container so that the order can be rearranged by user @@ -2139,6 +2172,8 @@ void ScriptEditor::_make_script_list_context_menu() { context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/save"), FILE_SAVE); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/save_as"), FILE_SAVE_AS); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_file"), FILE_CLOSE); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_all"), CLOSE_ALL); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_other_tabs"), CLOSE_OTHER_TABS); context_menu->add_separator(); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT); @@ -2458,6 +2493,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_close_discard_current_tab", &ScriptEditor::_close_discard_current_tab); ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab); ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs); + ClassDB::bind_method("_close_other_tabs", &ScriptEditor::_close_other_tabs); ClassDB::bind_method("_open_recent_script", &ScriptEditor::_open_recent_script); ClassDB::bind_method("_editor_play", &ScriptEditor::_editor_play); ClassDB::bind_method("_editor_pause", &ScriptEditor::_editor_pause); @@ -2539,7 +2575,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { script_list->set_v_size_flags(SIZE_EXPAND_FILL); script_split->set_split_offset(140); //list_split->set_split_offset(500); - _sort_list_on_update = true; script_list->connect("gui_input", this, "_script_list_gui_input"); script_list->set_allow_rmb_select(true); @@ -2604,6 +2639,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_other_tabs", TTR("Close Other Tabs")), CLOSE_OTHER_TABS); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/run_file", TTR("Run"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_X), FILE_RUN); file_menu->get_popup()->add_separator(); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index b8317f9e86..77ca4bc9d9 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -135,6 +135,7 @@ class ScriptEditor : public PanelContainer { FILE_CLOSE, CLOSE_DOCS, CLOSE_ALL, + CLOSE_OTHER_TABS, TOGGLE_SCRIPTS_PANEL, FILE_TOOL_RELOAD, FILE_TOOL_RELOAD_SOFT, @@ -251,6 +252,7 @@ class ScriptEditor : public PanelContainer { void _close_current_tab(); void _close_discard_current_tab(const String &p_str); void _close_docs_tab(); + void _close_other_tabs(); void _close_all_tabs(); void _ask_close_current_unsaved_tab(ScriptEditorBase *current); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 6b945157e8..214f24b386 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -201,7 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { text_edit->add_keyword_color("Rect2", basetype_color); text_edit->add_keyword_color("Transform2D", basetype_color); text_edit->add_keyword_color("Vector3", basetype_color); - text_edit->add_keyword_color("Rect3", basetype_color); + text_edit->add_keyword_color("AABB", basetype_color); text_edit->add_keyword_color("Basis", basetype_color); text_edit->add_keyword_color("Plane", basetype_color); text_edit->add_keyword_color("Transform", basetype_color); @@ -518,7 +518,9 @@ void ScriptTextEditor::tag_saved_version() { } void ScriptTextEditor::goto_line(int p_line, bool p_with_error) { - code_editor->get_text_edit()->call_deferred("cursor_set_line", p_line); + TextEdit *tx = code_editor->get_text_edit(); + tx->unfold_line(p_line); + tx->call_deferred("cursor_set_line", p_line); } void ScriptTextEditor::ensure_focus() { @@ -712,15 +714,6 @@ void ScriptTextEditor::_breakpoint_toggled(int p_row) { ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row)); } -static void swap_lines(TextEdit *tx, int line1, int line2) { - String tmp = tx->get_line(line1); - String tmp2 = tx->get_line(line2); - tx->set_line(line2, tmp); - tx->set_line(line1, tmp2); - - tx->cursor_set_line(line2); -} - void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_column) { Node *base = get_tree()->get_edited_scene_root(); @@ -799,39 +792,41 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c void ScriptTextEditor::_edit_option(int p_op) { + TextEdit *tx = code_editor->get_text_edit(); + switch (p_op) { case EDIT_UNDO: { - code_editor->get_text_edit()->undo(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + + tx->undo(); + tx->call_deferred("grab_focus"); } break; case EDIT_REDO: { - code_editor->get_text_edit()->redo(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + + tx->redo(); + tx->call_deferred("grab_focus"); } break; case EDIT_CUT: { - code_editor->get_text_edit()->cut(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + tx->cut(); + tx->call_deferred("grab_focus"); } break; case EDIT_COPY: { - code_editor->get_text_edit()->copy(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + tx->copy(); + tx->call_deferred("grab_focus"); } break; case EDIT_PASTE: { - code_editor->get_text_edit()->paste(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + tx->paste(); + tx->call_deferred("grab_focus"); } break; case EDIT_SELECT_ALL: { - code_editor->get_text_edit()->select_all(); - code_editor->get_text_edit()->call_deferred("grab_focus"); - + tx->select_all(); + tx->call_deferred("grab_focus"); } break; case EDIT_MOVE_LINE_UP: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = script; if (scr.is_null()) return; @@ -850,6 +845,9 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == 0 || next_id < 0) return; + tx->unfold_line(line_id); + tx->unfold_line(next_id); + tx->swap_lines(line_id, next_id); tx->cursor_set_line(next_id); } @@ -863,16 +861,17 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == 0 || next_id < 0) return; + tx->unfold_line(line_id); + tx->unfold_line(next_id); + tx->swap_lines(line_id, next_id); tx->cursor_set_line(next_id); } tx->end_complex_operation(); tx->update(); - } break; case EDIT_MOVE_LINE_DOWN: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -891,6 +890,9 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count()) return; + tx->unfold_line(line_id); + tx->unfold_line(next_id); + tx->swap_lines(line_id, next_id); tx->cursor_set_line(next_id); } @@ -904,6 +906,9 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count()) return; + tx->unfold_line(line_id); + tx->unfold_line(next_id); + tx->swap_lines(line_id, next_id); tx->cursor_set_line(next_id); } @@ -913,7 +918,6 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case EDIT_INDENT_LEFT: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -938,11 +942,9 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); //tx->deselect(); - } break; case EDIT_INDENT_RIGHT: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -959,11 +961,9 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); //tx->deselect(); - } break; case EDIT_DELETE_LINE: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -972,13 +972,12 @@ void ScriptTextEditor::_edit_option(int p_op) { int line = tx->cursor_get_line(); tx->set_line(tx->cursor_get_line(), ""); tx->backspace_at_cursor(); + tx->unfold_line(line); tx->cursor_set_line(line); tx->end_complex_operation(); - } break; case EDIT_CLONE_DOWN: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -997,6 +996,7 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->begin_complex_operation(); for (int i = from_line; i <= to_line; i++) { + tx->unfold_line(i); if (i >= tx->get_line_count() - 1) { tx->set_line(i, tx->get_line(i) + "\n"); } @@ -1012,11 +1012,29 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); + } break; + case EDIT_FOLD_LINE: { + + tx->fold_line(tx->cursor_get_line()); + tx->update(); + } break; + case EDIT_UNFOLD_LINE: { + + tx->unfold_line(tx->cursor_get_line()); + tx->update(); + } break; + case EDIT_FOLD_ALL_LINES: { + + tx->fold_all_lines(); + tx->update(); + } break; + case EDIT_UNFOLD_ALL_LINES: { + tx->unhide_all_lines(); + tx->update(); } break; case EDIT_TOGGLE_COMMENT: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -1065,62 +1083,65 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); //tx->deselect(); - } break; case EDIT_COMPLETE: { - code_editor->get_text_edit()->query_code_comple(); - + tx->query_code_comple(); } break; case EDIT_AUTO_INDENT: { - TextEdit *te = code_editor->get_text_edit(); - String text = te->get_text(); + String text = tx->get_text(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; - te->begin_complex_operation(); + tx->begin_complex_operation(); int begin, end; - if (te->is_selection_active()) { - begin = te->get_selection_from_line(); - end = te->get_selection_to_line(); + if (tx->is_selection_active()) { + begin = tx->get_selection_from_line(); + end = tx->get_selection_to_line(); // ignore if the cursor is not past the first column - if (te->get_selection_to_column() == 0) { + if (tx->get_selection_to_column() == 0) { end--; } } else { begin = 0; - end = te->get_line_count() - 1; + end = tx->get_line_count() - 1; } scr->get_language()->auto_indent_code(text, begin, end); Vector<String> lines = text.split("\n"); for (int i = begin; i <= end; ++i) { - te->set_line(i, lines[i]); + tx->set_line(i, lines[i]); } - te->end_complex_operation(); - + tx->end_complex_operation(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { + trim_trailing_whitespace(); } break; case EDIT_CONVERT_INDENT_TO_SPACES: { + convert_indent_to_spaces(); } break; case EDIT_CONVERT_INDENT_TO_TABS: { + convert_indent_to_tabs(); } break; case EDIT_PICK_COLOR: { + color_panel->popup(); } break; case EDIT_TO_UPPERCASE: { + _convert_case(UPPER); } break; case EDIT_TO_LOWERCASE: { + _convert_case(LOWER); } break; case EDIT_CAPITALIZE: { + _convert_case(CAPITALIZE); } break; case SEARCH_FIND: { @@ -1145,41 +1166,47 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(code_editor->get_text_edit()); + goto_line_dialog->popup_find_line(tx); } break; case DEBUG_TOGGLE_BREAKPOINT: { - int line = code_editor->get_text_edit()->cursor_get_line(); - bool dobreak = !code_editor->get_text_edit()->is_line_set_as_breakpoint(line); - code_editor->get_text_edit()->set_line_as_breakpoint(line, dobreak); + + int line = tx->cursor_get_line(); + bool dobreak = !tx->is_line_set_as_breakpoint(line); + tx->set_line_as_breakpoint(line, dobreak); ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak); } break; case DEBUG_REMOVE_ALL_BREAKPOINTS: { + List<int> bpoints; - code_editor->get_text_edit()->get_breakpoints(&bpoints); + tx->get_breakpoints(&bpoints); for (List<int>::Element *E = bpoints.front(); E; E = E->next()) { int line = E->get(); - bool dobreak = !code_editor->get_text_edit()->is_line_set_as_breakpoint(line); - code_editor->get_text_edit()->set_line_as_breakpoint(line, dobreak); + bool dobreak = !tx->is_line_set_as_breakpoint(line); + tx->set_line_as_breakpoint(line, dobreak); ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak); } } case DEBUG_GOTO_NEXT_BREAKPOINT: { + List<int> bpoints; - code_editor->get_text_edit()->get_breakpoints(&bpoints); + tx->get_breakpoints(&bpoints); if (bpoints.size() <= 0) { return; } - int line = code_editor->get_text_edit()->cursor_get_line(); + int line = tx->cursor_get_line(); + // wrap around if (line >= bpoints[bpoints.size() - 1]) { - code_editor->get_text_edit()->cursor_set_line(bpoints[0]); + tx->unfold_line(bpoints[0]); + tx->cursor_set_line(bpoints[0]); } else { for (List<int>::Element *E = bpoints.front(); E; E = E->next()) { int bline = E->get(); if (bline > line) { - code_editor->get_text_edit()->cursor_set_line(bline); + tx->unfold_line(bline); + tx->cursor_set_line(bline); return; } } @@ -1187,21 +1214,24 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case DEBUG_GOTO_PREV_BREAKPOINT: { + List<int> bpoints; - code_editor->get_text_edit()->get_breakpoints(&bpoints); + tx->get_breakpoints(&bpoints); if (bpoints.size() <= 0) { return; } - int line = code_editor->get_text_edit()->cursor_get_line(); + int line = tx->cursor_get_line(); // wrap around if (line <= bpoints[0]) { - code_editor->get_text_edit()->cursor_set_line(bpoints[bpoints.size() - 1]); + tx->unfold_line(bpoints[bpoints.size() - 1]); + tx->cursor_set_line(bpoints[bpoints.size() - 1]); } else { for (List<int>::Element *E = bpoints.back(); E; E = E->prev()) { int bline = E->get(); if (bline < line) { - code_editor->get_text_edit()->cursor_set_line(bline); + tx->unfold_line(bline); + tx->cursor_set_line(bline); return; } } @@ -1210,9 +1240,10 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case HELP_CONTEXTUAL: { - String text = code_editor->get_text_edit()->get_selection_text(); + + String text = tx->get_selection_text(); if (text == "") - text = code_editor->get_text_edit()->get_word_under_cursor(); + text = tx->get_word_under_cursor(); if (text != "") { emit_signal("request_help_search", text); } @@ -1398,6 +1429,9 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { Vector2 mpos = mb->get_global_position() - tx->get_global_position(); bool have_selection = (tx->get_selection_text().length() > 0); bool have_color = (tx->get_word_at_pos(mpos) == "Color"); + int fold_state = 0; + bool can_fold = tx->can_fold(row); + bool is_folded = tx->is_folded(row); if (have_color) { String line = tx->get_line(row); @@ -1428,7 +1462,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { have_color = false; } } - _make_context_menu(have_selection, have_color); + _make_context_menu(have_selection, have_color, can_fold, is_folded); } } } @@ -1447,7 +1481,7 @@ void ScriptTextEditor::_color_changed(const Color &p_color) { code_editor->get_text_edit()->set_line(color_line, new_line); } -void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { +void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_can_fold, bool p_is_folded) { context_menu->clear(); if (p_selection) { @@ -1467,6 +1501,13 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); } + if (p_can_fold) { + // can fold + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_line"), EDIT_FOLD_LINE); + } else if (p_is_folded) { + // can unfold + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_line"), EDIT_UNFOLD_LINE); + } if (p_color) { context_menu->add_separator(); context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR); @@ -1530,6 +1571,10 @@ ScriptTextEditor::ScriptTextEditor() { edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_line"), EDIT_FOLD_LINE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_all_lines"), EDIT_FOLD_ALL_LINES); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_line"), EDIT_UNFOLD_LINE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES); edit_menu->get_popup()->add_separator(); #ifdef OSX_ENABLED edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/complete_symbol"), EDIT_COMPLETE); @@ -1607,6 +1652,10 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), 0); ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD | KEY_K); ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD | KEY_B); + ED_SHORTCUT("script_text_editor/fold_line", TTR("Fold Line"), KEY_MASK_ALT | KEY_LEFT); + ED_SHORTCUT("script_text_editor/unfold_line", TTR("Unfold Line"), KEY_MASK_ALT | KEY_RIGHT); + ED_SHORTCUT("script_text_editor/fold_all_lines", TTR("Fold All Lines"), 0); + ED_SHORTCUT("script_text_editor/unfold_all_lines", TTR("Unfold All Lines"), 0); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CTRL | KEY_SPACE); #else diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 83f3ea57c0..722015ef3e 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -91,6 +91,10 @@ class ScriptTextEditor : public ScriptEditorBase { EDIT_TO_UPPERCASE, EDIT_TO_LOWERCASE, EDIT_CAPITALIZE, + EDIT_FOLD_LINE, + EDIT_UNFOLD_LINE, + EDIT_FOLD_ALL_LINES, + EDIT_UNFOLD_ALL_LINES, SEARCH_FIND, SEARCH_FIND_NEXT, SEARCH_FIND_PREV, @@ -118,7 +122,7 @@ protected: static void _bind_methods(); void _edit_option(int p_op); - void _make_context_menu(bool p_selection, bool p_color); + void _make_context_menu(bool p_selection, bool p_color, bool p_can_fold, bool p_is_folded); void _text_edit_gui_input(const Ref<InputEvent> &ev); void _color_changed(const Color &p_color); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index ca80908ab5..b3d3d5e13a 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -758,17 +758,49 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig } } + bool is_plane_scale = false; + // plane select + if (col_axis == -1) { + col_d = 1e20; + + for (int i = 0; i < 3; i++) { + + Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized(); + Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized(); + + Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gs * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST); + + Vector3 r; + Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); + + if (plane.intersects_ray(ray_pos, ray, &r)) { + + float dist = r.distance_to(grabber_pos); + if (dist < (gs * GIZMO_PLANE_SIZE)) { + + float d = ray_pos.distance_to(r); + if (d < col_d) { + col_d = d; + col_axis = i; + + is_plane_scale = true; + } + } + } + } + } + if (col_axis != -1) { if (p_highlight_only) { - spatial_editor->select_gizmo_highlight_axis(col_axis + 9); + spatial_editor->select_gizmo_highlight_axis(col_axis + (is_plane_scale ? 12 : 9)); } else { //handle scale _edit.mode = TRANSFORM_SCALE; _compute_edit(Point2(p_screenpos.x, p_screenpos.y)); - _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis); + _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis + (is_plane_scale ? 3 : 0)); } return true; } @@ -1255,6 +1287,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 motion_mask; Plane plane; + bool plane_mv = false; switch (_edit.plane) { case TRANSFORM_VIEW: @@ -1273,6 +1306,21 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2); plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); break; + case TRANSFORM_YZ: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0)); + plane_mv = true; + break; + case TRANSFORM_XZ: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(0); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1)); + plane_mv = true; + break; + case TRANSFORM_XY: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0) + spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2)); + plane_mv = true; + break; } Vector3 intersection; @@ -1284,8 +1332,19 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; Vector3 motion = intersection - click; - if (motion_mask != Vector3()) { - motion = motion_mask.dot(motion) * motion_mask; + if (_edit.plane != TRANSFORM_VIEW) { + + if (!plane_mv) { + + motion = motion_mask.dot(motion) * motion_mask; + + } else { + + // Alternative planar scaling mode + if (_get_key_modifier(m) != KEY_SHIFT) { + motion = motion_mask.dot(motion) * motion_mask; + } + } } else { float center_click_dist = click.distance_to(_edit.center); @@ -1379,7 +1438,6 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { switch (_edit.plane) { case TRANSFORM_VIEW: - motion_mask = Vector3(0, 0, 0); plane = Plane(_edit.center, _get_camera_normal()); break; case TRANSFORM_X_AXIS: @@ -1417,7 +1475,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; Vector3 motion = intersection - click; - if (motion_mask != Vector3()) { + if (_edit.plane != TRANSFORM_VIEW) { if (!plane_mv) { motion = motion_mask.dot(motion) * motion_mask; } @@ -2011,7 +2069,7 @@ void SpatialEditorViewport::_notification(int p_what) { if (se->aabb.has_no_surface()) { - se->aabb = vi ? vi->get_aabb() : Rect3(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); + se->aabb = vi ? vi->get_aabb() : AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); } Transform t = sp->get_global_transform(); @@ -2099,6 +2157,29 @@ void SpatialEditorViewport::_notification(int p_what) { } } + // FPS Counter. + bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FPS)); + if (show_fps != fps->is_visible()) { + if (show_fps) + fps->show(); + else + fps->hide(); + } + + if (show_fps) { + String text; + const float temp_fps = Engine::get_singleton()->get_frames_per_second(); + text += TTR("FPS") + ": " + itos(temp_fps) + " (" + String::num(1000.0f / temp_fps, 2) + " ms)"; + + if (fps_label->get_text() != text || surface->get_size() != prev_size) { + fps_label->set_text(text); + Size2 ms = fps->get_size(); + Size2 size = surface->get_size(); + size.y = ms.y + 20; + fps->set_position(size - ms - Vector2(20, 0) * EDSCALE); + } + } + prev_size = surface->get_size(); } @@ -2109,6 +2190,7 @@ void SpatialEditorViewport::_notification(int p_what) { surface->connect("mouse_entered", this, "_smouseenter"); surface->connect("mouse_exited", this, "_smouseexit"); info->add_style_override("panel", get_stylebox("panel", "Panel")); + fps->add_style_override("panel", get_stylebox("panel", "Panel")); preview_camera->set_icon(get_icon("Camera", "EditorIcons")); _init_gizmo_instance(index); } @@ -2431,6 +2513,13 @@ void SpatialEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(idx, !current); } break; + case VIEW_FPS: { + + int idx = view_menu->get_popup()->get_item_index(VIEW_FPS); + bool current = view_menu->get_popup()->is_item_checked(idx); + view_menu->get_popup()->set_item_checked(idx, !current); + + } break; case VIEW_DISPLAY_NORMAL: { viewport->set_debug_draw(Viewport::DEBUG_DRAW_DISABLED); @@ -2516,6 +2605,14 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) { //VS::get_singleton()->instance_geometry_set_flag(scale_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); VS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer); + + scale_plane_gizmo_instance[i] = VS::get_singleton()->instance_create(); + VS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid()); + VS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + VS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); + //VS::get_singleton()->instance_geometry_set_flag(scale_plane_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true); + VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); + VS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer); } } @@ -2526,6 +2623,7 @@ void SpatialEditorViewport::_finish_gizmo_instances() { VS::get_singleton()->free(move_plane_gizmo_instance[i]); VS::get_singleton()->free(rotate_gizmo_instance[i]); VS::get_singleton()->free(scale_gizmo_instance[i]); + VS::get_singleton()->free(scale_plane_gizmo_instance[i]); } } void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { @@ -2622,6 +2720,8 @@ void SpatialEditorViewport::update_transform_gizmo_view() { VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE)); VisualServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE)); + VisualServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform); + VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE)); } } @@ -2756,7 +2856,7 @@ void SpatialEditorViewport::focus_selection() { cursor.pos = center; } -void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, Rect3 *p_preview_bounds, AcceptDialog *p_accept) { +void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) { preview_node = p_preview_node; preview_bounds = p_preview_bounds; accept = p_accept; @@ -2819,14 +2919,14 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const return point + offset; } -Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) { - Rect3 bounds = p_bounds; +AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds) { + AABB bounds = p_bounds; for (int i = 0; i < p_parent->get_child_count(); i++) { Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i)); if (child) { MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(child); if (mesh_instance) { - Rect3 mesh_instance_bounds = mesh_instance->get_aabb(); + AABB mesh_instance_bounds = mesh_instance->get_aabb(); mesh_instance_bounds.position += mesh_instance->get_global_transform().origin - p_parent->get_global_transform().origin; bounds.merge_with(mesh_instance_bounds); } @@ -2858,7 +2958,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const { editor->get_scene_root()->add_child(preview_node); } } - *preview_bounds = _calculate_spatial_bounds(preview_node, Rect3()); + *preview_bounds = _calculate_spatial_bounds(preview_node, AABB()); } void SpatialEditorViewport::_remove_preview() { @@ -3149,6 +3249,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("View Environment")), VIEW_ENVIRONMENT); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("View Gizmos")), VIEW_GIZMOS); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_information", TTR("View Information")), VIEW_INFORMATION); + view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_fps", TTR("View FPS")), VIEW_FPS); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true); view_menu->get_popup()->add_separator(); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_half_resolution", TTR("Half Resolution")), VIEW_HALF_RESOLUTION); @@ -3191,6 +3292,14 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed info->add_child(info_label); info->hide(); + // FPS Counter. + fps = memnew(PanelContainer); + fps->set_self_modulate(Color(1, 1, 1, 0.4)); + surface->add_child(fps); + fps_label = memnew(Label); + fps->add_child(fps_label); + fps->hide(); + accept = NULL; freelook_active = false; @@ -3528,13 +3637,14 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) { move_plane_gizmo[i]->surface_set_material(0, (i + 6) == p_axis ? gizmo_hl : plane_gizmo_color[i]); rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_hl : gizmo_color[i]); scale_gizmo[i]->surface_set_material(0, (i + 9) == p_axis ? gizmo_hl : gizmo_color[i]); + scale_plane_gizmo[i]->surface_set_material(0, (i + 12) == p_axis ? gizmo_hl : plane_gizmo_color[i]); } } void SpatialEditor::update_transform_gizmo() { List<Node *> &selection = editor_selection->get_selected_node_list(); - Rect3 center; + AABB center; bool first = true; Basis gizmo_basis; @@ -3595,7 +3705,7 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) { void SpatialEditor::_generate_selection_box() { - Rect3 aabb(Vector3(), Vector3(1, 1, 1)); + AABB aabb(Vector3(), Vector3(1, 1, 1)); aabb.grow_by(aabb.get_longest_axis_size() / 20.0); Ref<SurfaceTool> st = memnew(SurfaceTool); @@ -4101,6 +4211,7 @@ void SpatialEditor::_init_indicators() { move_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); rotate_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); + scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); Ref<SpatialMaterial> mat = memnew(SpatialMaterial); mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); @@ -4296,6 +4407,49 @@ void SpatialEditor::_init_indicators() { surftool->set_material(mat); surftool->commit(scale_gizmo[i]); } + + // Plane Scale + { + Ref<SurfaceTool> surftool = memnew(SurfaceTool); + surftool->begin(Mesh::PRIMITIVE_TRIANGLES); + + Vector3 vec = ivec2 - ivec3; + Vector3 plane[4] = { + vec * GIZMO_PLANE_DST, + vec * GIZMO_PLANE_DST + ivec2 * GIZMO_PLANE_SIZE, + vec * (GIZMO_PLANE_DST + GIZMO_PLANE_SIZE), + vec * GIZMO_PLANE_DST - ivec3 * GIZMO_PLANE_SIZE + }; + + Basis ma(ivec, Math_PI / 2); + + Vector3 points[4] = { + ma.xform(plane[0]), + ma.xform(plane[1]), + ma.xform(plane[2]), + ma.xform(plane[3]), + }; + surftool->add_vertex(points[0]); + surftool->add_vertex(points[1]); + surftool->add_vertex(points[2]); + + surftool->add_vertex(points[0]); + surftool->add_vertex(points[2]); + surftool->add_vertex(points[3]); + + Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial); + plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + plane_mat->set_on_top_of_alpha(); + plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + Color col; + col[i] = 1.0; + col.a = gizmo_alph; + plane_mat->set_albedo(col); + plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides + surftool->set_material(plane_mat); + surftool->commit(scale_plane_gizmo[i]); + } } } @@ -4622,7 +4776,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { // Drag and drop support; preview_node = memnew(Spatial); - preview_bounds = Rect3(); + preview_bounds = AABB(); ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7); ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index c2b698068f..c986e45f43 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -88,6 +88,7 @@ class SpatialEditorViewport : public Control { VIEW_AUDIO_DOPPLER, VIEW_GIZMOS, VIEW_INFORMATION, + VIEW_FPS, VIEW_DISPLAY_NORMAL, VIEW_DISPLAY_WIREFRAME, VIEW_DISPLAY_OVERDRAW, @@ -108,7 +109,7 @@ private: Size2 prev_size; Spatial *preview_node; - Rect3 *preview_bounds; + AABB *preview_bounds; Vector<String> selected_files; AcceptDialog *accept; @@ -138,6 +139,9 @@ private: PanelContainer *info; Label *info_label; + PanelContainer *fps; + Label *fps_label; + struct _RayResult { Spatial *item; @@ -255,7 +259,7 @@ private: real_t zoom_indicator_delay; - RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3], scale_gizmo_instance[3]; + RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3], scale_gizmo_instance[3], scale_plane_gizmo_instance[3]; String last_message; String message; @@ -287,7 +291,7 @@ private: Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const; Vector3 _get_instance_position(const Point2 &p_pos) const; - static Rect3 _calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds); + static AABB _calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds); void _create_preview(const Vector<String> &files) const; void _remove_preview(); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); @@ -314,7 +318,7 @@ public: void assign_pending_data_pointers( Spatial *p_preview_node, - Rect3 *p_preview_bounds, + AABB *p_preview_bounds, AcceptDialog *p_accept); Viewport *get_viewport_node() { return viewport; } @@ -327,7 +331,7 @@ class SpatialEditorSelectedItem : public Object { GDCLASS(SpatialEditorSelectedItem, Object); public: - Rect3 aabb; + AABB aabb; Transform original; // original location when moving Transform original_local; Transform last_xform; // last transform @@ -418,7 +422,7 @@ private: bool grid_enable[3]; //should be always visible if true bool grid_enabled; - Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3]; + Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3], scale_plane_gizmo[3]; Ref<SpatialMaterial> gizmo_color[3]; Ref<SpatialMaterial> plane_gizmo_color[3]; Ref<SpatialMaterial> gizmo_hl; @@ -435,7 +439,7 @@ private: // Scene drag and drop support Spatial *preview_node; - Rect3 preview_bounds; + AABB preview_bounds; /* struct Selected { @@ -571,6 +575,7 @@ public: Ref<ArrayMesh> get_move_plane_gizmo(int idx) const { return move_plane_gizmo[idx]; } Ref<ArrayMesh> get_rotate_gizmo(int idx) const { return rotate_gizmo[idx]; } Ref<ArrayMesh> get_scale_gizmo(int idx) const { return scale_gizmo[idx]; } + Ref<ArrayMesh> get_scale_plane_gizmo(int idx) const { return scale_plane_gizmo[idx]; } void update_transform_gizmo(); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 0ee0eed3a2..ffddd8a3a9 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -363,7 +363,7 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era return PoolVector<Vector2>(); } - Rect2i r = node->get_item_rect(); + Rect2i r = node->_edit_get_rect(); r.position = r.position / node->get_cell_size(); r.size = r.size / node->get_cell_size(); |