diff options
-rw-r--r-- | editor/editor_node.cpp | 64 | ||||
-rw-r--r-- | scene/2d/canvas_item.h | 4 | ||||
-rw-r--r-- | scene/2d/navigation2d.cpp | 26 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 30 | ||||
-rw-r--r-- | scene/2d/tile_map.h | 7 |
5 files changed, 85 insertions, 46 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index cee65387f5..4e8ac7fb38 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4773,6 +4773,38 @@ EditorNode::EditorNode() { prev_scene->set_position(Point2(3, 24)); prev_scene->hide(); + accept = memnew(AcceptDialog); + gui_base->add_child(accept); + accept->connect("confirmed", this, "_menu_confirm_current"); + + project_export = memnew(ProjectExportDialog); + gui_base->add_child(project_export); + + dependency_error = memnew(DependencyErrorDialog); + gui_base->add_child(dependency_error); + + dependency_fixer = memnew(DependencyEditor); + gui_base->add_child(dependency_fixer); + + settings_config_dialog = memnew(EditorSettingsDialog); + gui_base->add_child(settings_config_dialog); + + project_settings = memnew(ProjectSettingsEditor(&editor_data)); + gui_base->add_child(project_settings); + + run_settings_dialog = memnew(RunSettingsDialog); + gui_base->add_child(run_settings_dialog); + + export_template_manager = memnew(ExportTemplateManager); + gui_base->add_child(export_template_manager); + + about = memnew(EditorAbout); + about->get_logo()->set_texture(gui_base->get_icon("Logo", "EditorIcons")); + gui_base->add_child(about); + + warning = memnew(AcceptDialog); + gui_base->add_child(warning); + ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB); ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB); ED_SHORTCUT("editor/filter_files", TTR("Filter Files.."), KEY_MASK_ALT + KEY_MASK_CMD + KEY_P); @@ -5197,38 +5229,6 @@ EditorNode::EditorNode() { save_confirmation->connect("confirmed", this, "_menu_confirm_current"); save_confirmation->connect("custom_action", this, "_discard_changes"); - accept = memnew(AcceptDialog); - gui_base->add_child(accept); - accept->connect("confirmed", this, "_menu_confirm_current"); - - project_export = memnew(ProjectExportDialog); - gui_base->add_child(project_export); - - dependency_error = memnew(DependencyErrorDialog); - gui_base->add_child(dependency_error); - - dependency_fixer = memnew(DependencyEditor); - gui_base->add_child(dependency_fixer); - - settings_config_dialog = memnew(EditorSettingsDialog); - gui_base->add_child(settings_config_dialog); - - project_settings = memnew(ProjectSettingsEditor(&editor_data)); - gui_base->add_child(project_settings); - - run_settings_dialog = memnew(RunSettingsDialog); - gui_base->add_child(run_settings_dialog); - - export_template_manager = memnew(ExportTemplateManager); - gui_base->add_child(export_template_manager); - - about = memnew(EditorAbout); - about->get_logo()->set_texture(gui_base->get_icon("Logo", "EditorIcons")); - gui_base->add_child(about); - - warning = memnew(AcceptDialog); - gui_base->add_child(warning); - file_templates = memnew(FileDialog); file_templates->set_title(TTR("Import Templates From ZIP File")); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 3a99e917eb..5a0a9c6e6a 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -291,10 +291,10 @@ public: RID get_canvas() const; Ref<World2D> get_world_2d() const; - void set_material(const Ref<Material> &p_material); + virtual void set_material(const Ref<Material> &p_material); Ref<Material> get_material() const; - void set_use_parent_material(bool p_use_parent_material); + virtual void set_use_parent_material(bool p_use_parent_material); bool get_use_parent_material() const; Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const; diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index fa488b6b23..74d835dfb2 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -476,7 +476,6 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect Polygon *left_poly = end_poly; Polygon *right_poly = end_poly; Polygon *p = end_poly; - path.push_back(end_point); while (p) { @@ -534,7 +533,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect left_poly = p; portal_left = apex_point; portal_right = apex_point; - if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) + if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) path.push_back(apex_point); skip = true; //print_line("addpoint left"); @@ -555,7 +554,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect right_poly = p; portal_right = apex_point; portal_left = apex_point; - if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) + if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) path.push_back(apex_point); //print_line("addpoint right"); //print_line("***CLIP RIGHT"); @@ -568,16 +567,10 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect p = NULL; } - if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON) - path.push_back(begin_point); - - path.invert(); - } else { //midpoints Polygon *p = end_poly; - path.push_back(end_point); while (true) { int prev = p->prev_edge; int prev_n = (p->prev_edge + 1) % p->edges.size(); @@ -587,11 +580,20 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect if (p == begin_poly) break; } + } - if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON) - path.push_back(begin_point); + if (!path.size() || path[path.size() - 1].distance_squared_to(begin_point) > CMP_EPSILON) { + path.push_back(begin_point); // Add the begin point + } else { + path[path.size() - 1] = begin_point; // Replace first midpoint by the exact begin point + } + + path.invert(); - path.invert(); + if (path.size() <= 1 || path[path.size() - 1].distance_squared_to(end_point) > CMP_EPSILON) { + path.push_back(end_point); // Add the end point + } else { + path[path.size() - 1] = end_point; // Replace last midpoint by the exact end point } return path; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index d41db1dce5..b1cc8c226a 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -336,6 +336,7 @@ void TileMap::_update_dirty_quadrants() { if (mat.is_valid()) vs->canvas_item_set_material(canvas_item, mat->get_rid()); vs->canvas_item_set_parent(canvas_item, get_canvas_item()); + _update_item_material_state(canvas_item); Transform2D xform; xform.set_origin(q.pos); vs->canvas_item_set_transform(canvas_item, xform); @@ -780,6 +781,35 @@ void TileMap::_clear_quadrants() { } } +void TileMap::set_material(const Ref<Material> &p_material) { + + CanvasItem::set_material(p_material); + _update_all_items_material_state(); +} + +void TileMap::set_use_parent_material(bool p_use_parent_material) { + + CanvasItem::set_use_parent_material(p_use_parent_material); + _update_all_items_material_state(); +} + +void TileMap::_update_all_items_material_state() { + + for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { + + Quadrant &q = E->get(); + for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { + + _update_item_material_state(E->get()); + } + } +} + +void TileMap::_update_item_material_state(const RID &p_canvas_item) { + + VS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid()); +} + void TileMap::clear() { _clear_quadrants(); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index f401d51eeb..c9d14e09d1 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -183,6 +183,9 @@ private: void _update_quadrant_transform(); void _recompute_rect_cache(); + void _update_all_items_material_state(); + _FORCE_INLINE_ void _update_item_material_state(const RID &p_canvas_item); + _FORCE_INLINE_ int _get_quadrant_size() const; void _set_tile_data(const PoolVector<int> &p_data); @@ -278,6 +281,10 @@ public: virtual void set_light_mask(int p_light_mask); + virtual void set_material(const Ref<Material> &p_material); + + virtual void set_use_parent_material(bool p_use_parent_material); + void clear(); TileMap(); |