diff options
48 files changed, 385 insertions, 445 deletions
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 05f9da03e1..7e20077fd6 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -122,20 +122,24 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); //dfd->set_force_autohinter(true); //just looks better..i think? - MAKE_DEFAULT_FONT(df, int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE); + int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE; + MAKE_DEFAULT_FONT(df, default_font_size); p_theme->set_default_theme_font(df); + MAKE_DEFAULT_FONT(df_title, default_font_size + 2 * EDSCALE); + p_theme->set_font("title", "EditorFonts", df_title); + //Ref<BitmapFont> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons")); //Ref<BitmapFont> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons")); //Ref<BitmapFont> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons")); - MAKE_DEFAULT_FONT(df_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 16)) * EDSCALE); + MAKE_DEFAULT_FONT(df_doc_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 16)) * EDSCALE); MAKE_DEFAULT_FONT(df_doc, int(EDITOR_DEF("text_editor/help/help_font_size", 14)) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); - p_theme->set_font("doc_title", "EditorFonts", df_title); + p_theme->set_font("doc_title", "EditorFonts", df_doc_title); MAKE_DEFAULT_FONT(df_rulers, int(EDITOR_DEF("canvas_item_editor/rulers", 8)) * EDSCALE); p_theme->set_font("rulers", "EditorFonts", df_rulers); @@ -176,9 +180,4 @@ void editor_register_fonts(Ref<Theme> p_theme) { df_output_code->set_font_data(dfmono); MAKE_FALLBACKS(df_output_code); p_theme->set_font("status_source", "EditorFonts", df_output_code); - - //replace default theme - Ref<Texture> di; - Ref<StyleBox> ds; - fill_default_theme(p_theme, df, df_doc, di, ds, EDSCALE); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 57bc2d62f5..740dd360ae 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4226,61 +4226,53 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { return drag_data; } -Variant EditorNode::drag_files(const Vector<String> &p_files, Control *p_from) { - - VBoxContainer *files = memnew(VBoxContainer); - - int max_files = 6; - - for (int i = 0; i < MIN(max_files, p_files.size()); i++) { - +Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from) { + bool has_folder = false; + bool has_file = false; + for (int i = 0; i < p_paths.size(); i++) { + bool is_folder = p_paths[i].ends_with("/"); + has_folder |= is_folder; + has_file |= !is_folder; + } + + int max_rows = 6; + int num_rows = p_paths.size() > max_rows ? max_rows - 1 : p_paths.size(); //Don't waste a row to say "1 more file" - list it instead. + VBoxContainer *vbox = memnew(VBoxContainer); + for (int i = 0; i < num_rows; i++) { + HBoxContainer *hbox = memnew(HBoxContainer); + TextureRect *icon = memnew(TextureRect); Label *label = memnew(Label); - label->set_text(p_files[i].get_file()); - files->add_child(label); - } - - if (p_files.size() > max_files) { - Label *label = memnew(Label); - label->set_text(vformat(TTR("%d more file(s)"), p_files.size() - max_files)); - files->add_child(label); + if (p_paths[i].ends_with("/")) { + label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file()); + icon->set_texture(gui_base->get_icon("Folder", "EditorIcons")); + } else { + label->set_text(p_paths[i].get_file()); + icon->set_texture(gui_base->get_icon("File", "EditorIcons")); + } + icon->set_size(Size2(16, 16)); + hbox->add_child(icon); + hbox->add_child(label); + vbox->add_child(hbox); } - Dictionary drag_data; - drag_data["type"] = "files"; - drag_data["files"] = p_files; - drag_data["from"] = p_from; - - p_from->set_drag_preview(files); //wait until it enters scene - - return drag_data; -} - -Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_files, Control *p_from) { - - VBoxContainer *files = memnew(VBoxContainer); - - int max_files = 6; - - for (int i = 0; i < MIN(max_files, p_files.size()); i++) { + if (p_paths.size() > num_rows) { Label *label = memnew(Label); - label->set_text(p_files[i].get_file()); - files->add_child(label); + if (has_file && has_folder) { + label->set_text(vformat(TTR("%d more files or folders"), p_paths.size() - num_rows)); + } else if (has_folder) { + label->set_text(vformat(TTR("%d more folders"), p_paths.size() - num_rows)); + } else { + label->set_text(vformat(TTR("%d more files"), p_paths.size() - num_rows)); + } + vbox->add_child(label); } + p_from->set_drag_preview(vbox); //wait until it enters scene - if (p_files.size() > max_files) { - - Label *label = memnew(Label); - label->set_text(vformat(TTR("%d more file(s) or folder(s)"), p_files.size() - max_files)); - files->add_child(label); - } Dictionary drag_data; - drag_data["type"] = "files_and_dirs"; - drag_data["files"] = p_files; + drag_data["type"] = has_folder ? "files_and_dirs" : "files"; + drag_data["files"] = p_paths; drag_data["from"] = p_from; - - p_from->set_drag_preview(files); //wait until it enters scene - return drag_data; } diff --git a/editor/editor_node.h b/editor/editor_node.h index 32d46e686b..6e0117a4ac 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -765,8 +765,7 @@ public: void remove_bottom_panel_item(Control *p_item); Variant drag_resource(const Ref<Resource> &p_res, Control *p_from); - Variant drag_files(const Vector<String> &p_files, Control *p_from); - Variant drag_files_and_dirs(const Vector<String> &p_files, Control *p_from); + Variant drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from); void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant()); void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index c8abc1f9db..0bd677ca1b 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -76,11 +76,11 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - RID light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + RID light = VS::get_singleton()->directional_light_create(); RID light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - RID light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + RID light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index bc91fcdf04..bf4ef3ae39 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -135,6 +135,7 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { void EditorSettings::_initial_set(const StringName &p_name, const Variant &p_value) { set(p_name, p_value); props[p_name].initial = p_value; + props[p_name].initial_set = true; } struct _EVCSort { @@ -214,6 +215,14 @@ void EditorSettings::_add_property_info_bind(const Dictionary &p_info) { } // Default configs +bool EditorSettings::has_default_value(const String &p_setting) const { + + _THREAD_SAFE_METHOD_ + + if (!props.has(p_setting)) + return false; + return props[p_setting].initial_set; +} void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { @@ -834,10 +843,10 @@ void EditorSettings::setup_network() { hint += ip; } - set("network/debug/remote_host", lip); + _initial_set("network/debug/remote_host", lip); add_property_hint(PropertyInfo(Variant::STRING, "network/debug/remote_host", PROPERTY_HINT_ENUM, hint)); - set("network/debug/remote_port", port); + _initial_set("network/debug/remote_port", port); add_property_hint(PropertyInfo(Variant::INT, "network/debug/remote_port", PROPERTY_HINT_RANGE, "1,65535,1")); } @@ -915,16 +924,20 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian ERR_FAIL_COND(!props.has(p_setting)); props[p_setting].initial = p_value; + props[p_setting].initial_set = true; } Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) { + Variant ret = p_default; if (EditorSettings::get_singleton()->has_setting(p_setting)) - return EditorSettings::get_singleton()->get(p_setting); - EditorSettings::get_singleton()->set(p_setting, p_default); - EditorSettings::get_singleton()->set_initial_value(p_setting, p_default); + ret = EditorSettings::get_singleton()->get(p_setting); + if (!EditorSettings::get_singleton()->has_default_value(p_setting)) { + EditorSettings::get_singleton()->set_initial_value(p_setting, p_default); + EditorSettings::get_singleton()->set(p_setting, p_default); + } - return p_default; + return ret; } Variant _EDITOR_GET(const String &p_setting) { diff --git a/editor/editor_settings.h b/editor/editor_settings.h index a74be6494a..29665369c4 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -66,11 +66,13 @@ private: int order; Variant variant; Variant initial; + bool initial_set; bool hide_from_editor; bool save; VariantContainer() { order = 0; hide_from_editor = false; + initial_set = false; save = false; } VariantContainer(const Variant &p_variant, int p_order) { @@ -128,6 +130,7 @@ public: static void destroy(); void set_optimize_save(bool p_optimize); + bool has_default_value(const String &p_setting) const; void set_setting(const String &p_setting, const Variant &p_value); Variant get_setting(const String &p_setting) const; bool has_setting(const String &p_setting) const; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 29859a1a56..de0c3f55cc 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -801,6 +801,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE); theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE); theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE); + theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts")); // complex window, for now only Editor settings and Project settings Ref<StyleBoxFlat> style_complex_window = style_window->duplicate(); @@ -1044,7 +1045,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { } Ref<Theme> create_custom_theme() { - Ref<Theme> theme; + Ref<Theme> theme = create_editor_theme(); String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme"); if (custom_theme != "") { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 00cbd9bb72..9314839768 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1186,78 +1186,36 @@ void FileSystemDock::set_display_mode(int p_mode) { } Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) { + bool is_favorite = false; + Vector<String> paths; if (p_from == tree) { - TreeItem *selected = tree->get_selected(); if (!selected) return Variant(); - String fpath = selected->get_metadata(0); - if (fpath == String()) + String folder = selected->get_metadata(0); + if (folder == String()) return Variant(); - if (!fpath.ends_with("/")) - fpath = fpath + "/"; - Vector<String> paths; - paths.push_back(fpath); - Dictionary d = EditorNode::get_singleton()->drag_files(paths, p_from); - - if (selected->get_parent() && tree->get_root()->get_children() == selected->get_parent()) { - //a favorite.. treat as such - d["type"] = "favorite"; - } - - return d; - } - - if (p_from == files) { - - List<int> seldirs; - List<int> selfiles; + paths.push_back(folder.ends_with("/") ? folder : (folder + "/")); + is_favorite = selected->get_parent() != NULL && tree->get_root()->get_children() == selected->get_parent(); + } else if (p_from == files) { for (int i = 0; i < files->get_item_count(); i++) { if (files->is_selected(i)) { - String fpath = files->get_item_metadata(i); - if (fpath.ends_with("/")) - seldirs.push_back(i); - else - selfiles.push_back(i); + paths.push_back(files->get_item_metadata(i)); } } + } - if (seldirs.empty() && selfiles.empty()) - return Variant(); - /* - if (seldirs.size() && selfiles.size()) - return Variant(); //can't really mix files and dirs (i think?) - yes you can, commenting - */ - - /*if (selfiles.size()==1) { - Ref<Resource> resource = ResourceLoader::load(files->get_item_metadata(selfiles.front()->get())); - if (resource.is_valid()) { - return EditorNode::get_singleton()->drag_resource(resource,p_from); - } - }*/ - - Vector<String> fnames; - if (selfiles.size() > 0 || seldirs.size() > 0) { - if (selfiles.size() > 0) { - for (List<int>::Element *E = selfiles.front(); E; E = E->next()) { - fnames.push_back(files->get_item_metadata(E->get())); - } - if (seldirs.size() == 0) - return EditorNode::get_singleton()->drag_files(fnames, p_from); - } - - for (List<int>::Element *E = seldirs.front(); E; E = E->next()) { - fnames.push_back(files->get_item_metadata(E->get())); - } + if (paths.empty()) + return Variant(); - return EditorNode::get_singleton()->drag_files_and_dirs(fnames, p_from); - } + Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from); + if (is_favorite) { + drag_data["type"] = "favorite"; } - - return Variant(); + return drag_data; } bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { @@ -1288,36 +1246,25 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da } if (drag_data.has("type") && String(drag_data["type"]) == "resource") { - return true; + String to_dir = _get_drag_target_folder(p_point, p_from); + return !to_dir.empty(); } if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) { + String to_dir = _get_drag_target_folder(p_point, p_from); + if (to_dir.empty()) + return false; + //Attempting to move a folder into itself will fail later + //Rather than bring up a message don't try to do it in the first place + to_dir = to_dir.ends_with("/") ? to_dir : (to_dir + "/"); Vector<String> fnames = drag_data["files"]; - - if (p_from == files) { - - int at_pos = files->get_item_at_position(p_point); - if (at_pos != -1) { - - String dir = files->get_item_metadata(at_pos); - if (dir.ends_with("/")) - return true; - } - } - - if (p_from == tree) { - - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return false; - - String fpath = ti->get_metadata(0); - if (fpath == String()) + for (int i = 0; i < fnames.size(); ++i) { + if (fnames[i].ends_with("/") && to_dir.begins_with(fnames[i])) return false; - - return true; } + + return true; } return false; @@ -1393,66 +1340,16 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, if (drag_data.has("type") && String(drag_data["type"]) == "resource") { Ref<Resource> res = drag_data["resource"]; - - if (!res.is_valid()) { - return; - } - - if (p_from == tree) { - - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return; - - String fpath = ti->get_metadata(0); - if (fpath == String()) - return; - - EditorNode::get_singleton()->save_resource_as(res, fpath); - return; - } - - if (p_from == files) { - String save_path = path; - - int at_pos = files->get_item_at_position(p_point); - if (at_pos != -1) { - String to_dir = files->get_item_metadata(at_pos); - if (to_dir.ends_with("/")) { - save_path = to_dir; - if (save_path != "res://") - save_path = save_path.substr(0, save_path.length() - 1); - } - } - - EditorNode::get_singleton()->save_resource_as(res, save_path); - return; + String to_dir = _get_drag_target_folder(p_point, p_from); + if (res.is_valid() && !to_dir.empty()) { + EditorNode::get_singleton()->push_item(res.ptr()); + EditorNode::get_singleton()->save_resource_as(res, to_dir); } } if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) { - - if (p_from == files || p_from == tree) { - - String to_dir; - - if (p_from == files) { - - int at_pos = files->get_item_at_position(p_point); - ERR_FAIL_COND(at_pos == -1); - to_dir = files->get_item_metadata(at_pos); - } else { - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return; - to_dir = ti->get_metadata(0); - ERR_FAIL_COND(to_dir == String()); - } - - if (to_dir != "res://" && to_dir.ends_with("/")) { - to_dir = to_dir.substr(0, to_dir.length() - 1); - } - + String to_dir = _get_drag_target_folder(p_point, p_from); + if (!to_dir.empty()) { Vector<String> fnames = drag_data["files"]; to_move.clear(); for (int i = 0; i < fnames.size(); i++) { @@ -1463,6 +1360,25 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, } } +String FileSystemDock::_get_drag_target_folder(const Point2 &p_point, Control *p_from) const { + if (p_from == files) { + int pos = files->get_item_at_position(p_point, true); + if (pos == -1) + return path; + + String target = files->get_item_metadata(pos); + return target.ends_with("/") ? target : path; + } + + if (p_from == tree) { + TreeItem *ti = tree->get_item_at_position(p_point); + if (ti && ti != tree->get_root()->get_children()) + return ti->get_metadata(0); + } + + return String(); +} + void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) { //Right clicking ".." should clear current selection diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 2cb0573a3d..249621564d 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -209,6 +209,7 @@ private: Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + String _get_drag_target_folder(const Point2 &p_point, Control *p_from) const; void _preview_invalidated(const String &p_path); void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index c48a241e4d..5f73d0b465 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -278,11 +278,11 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); VS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); - light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light = VS::get_singleton()->directional_light_create(); light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); @@ -850,11 +850,11 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light = VS::get_singleton()->directional_light_create(); light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 25ca2d731e..e8714cece6 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1285,12 +1285,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; Vector3 motion = intersection - click; - print_line(String(intersection) + " --- " + String(click)); if (motion_mask != Vector3()) { - motion = motion_mask.dot(motion) * motion_mask; - } else { + } else { float center_click_dist = click.distance_to(_edit.center); float center_inters_dist = intersection.distance_to(_edit.center); if (center_click_dist == 0) @@ -1308,6 +1306,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (_edit.snap || spatial_editor->is_snap_enabled()) { snap = spatial_editor->get_scale_snap() / 100; + + Vector3 motion_snapped = motion; + motion_snapped.snap(Vector3(snap, snap, snap)); + set_message(TTR("Scaling XYZ: ") + motion_snapped); + + } else { + set_message(TTR("Scaling XYZ: ") + motion); } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1339,6 +1344,15 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { local_scale = original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); + // Prevent scaling to 0 it would break the gizmo + Basis check = original_local.basis; + check.scale(local_scale); + if (check.determinant() != 0) { + + // Apply scale + sp->set_scale(local_scale); + } + } else { if (_edit.snap || spatial_editor->is_snap_enabled()) { @@ -1348,12 +1362,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform r; r.basis.scale(motion + Vector3(1, 1, 1)); t = base * (r * (base.inverse() * original)); - } - // Apply scale - if (local_coords) { - sp->set_scale(local_scale); - } else { + // Apply scale sp->set_global_transform(t); } } @@ -1386,17 +1396,14 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { 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; @@ -1410,55 +1417,27 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) break; - //_validate_selection(); Vector3 motion = intersection - click; if (motion_mask != Vector3()) { - if (plane_mv) - motion *= motion_mask; - else + if (!plane_mv) { motion = motion_mask.dot(motion) * motion_mask; + } } - //set_message("Translating: "+motion); - List<Node *> &selection = editor_selection->get_selected_node_list(); - float snap = 0; + bool local_coords = (spatial_editor->are_local_coords_enabled() && motion_mask != Vector3()); // Disable local transformation for TRANSFORM_VIEW + float snap = 0; if (_edit.snap || spatial_editor->is_snap_enabled()) { snap = spatial_editor->get_translate_snap(); - bool local_coords = spatial_editor->are_local_coords_enabled(); - - if (local_coords) { - bool multiple = false; - Spatial *node = NULL; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - - Spatial *sp = Object::cast_to<Spatial>(E->get()); - if (!sp) { - continue; - } - if (node) { - multiple = true; - break; - } else { - node = sp; - } - } - - if (multiple) { - motion.snap(Vector3(snap, snap, snap)); - } else { - Basis b = node->get_global_transform().basis.orthonormalized(); - Vector3 local_motion = b.inverse().xform(motion); - local_motion.snap(Vector3(snap, snap, snap)); - motion = b.xform(local_motion); - } - } else { - motion.snap(Vector3(snap, snap, snap)); - } + Vector3 motion_snapped = motion; + motion_snapped.snap(Vector3(snap, snap, snap)); + set_message(TTR("Translating: ") + motion_snapped); + } else { + set_message(TTR("Translating: ") + motion); } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1473,10 +1452,34 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform t = se->original; + Transform original = se->original; + Transform t; + + if (local_coords) { + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + Basis g = original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(motion); + local_motion.snap(Vector3(snap, snap, snap)); + + motion = g.xform(local_motion); + } + + } else { + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + motion.snap(Vector3(snap, snap, snap)); + } + } + + // Apply translation + t = original; t.origin += motion; sp->set_global_transform(t); } + + surface->update(); + } break; case TRANSFORM_ROTATE: { @@ -1552,10 +1555,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform original_local = se->original_local; Basis rot = Basis(axis, angle); - t.basis = original_local.get_basis() * rot; + t.basis = original_local.get_basis().orthonormalized() * rot; t.origin = original_local.origin; + // Apply rotation sp->set_transform(t); + sp->set_scale(original_local.basis.get_scale()); // re-apply original scale } else { @@ -1566,6 +1571,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { r.basis.rotate(plane.normal, angle); t = base * r * base.inverse() * original; + // Apply rotation sp->set_global_transform(t); } } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 18416868ec..5bfdd73aad 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1053,7 +1053,7 @@ void ProjectManager::_load_recent_projects() { ec->set_custom_minimum_size(Size2(0, 1)); vb->add_child(ec); Label *title = memnew(Label(project_name)); - title->add_font_override("font", gui_base->get_font("large", "Fonts")); + title->add_font_override("font", gui_base->get_font("title", "EditorFonts")); title->add_color_override("font_color", font_color); title->set_clip_text(true); vb->add_child(title); @@ -1492,7 +1492,6 @@ ProjectManager::ProjectManager() { CenterContainer *ccl = memnew(CenterContainer); Label *l = memnew(Label); l->set_text(_MKSTR(VERSION_NAME) + String(" - ") + TTR("Project Manager")); - l->add_font_override("font", gui_base->get_font("doc", "EditorFonts")); ccl->add_child(l); top_hb->add_child(ccl); top_hb->add_spacer(); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f4d5530faa..002ae568ff 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4258,7 +4258,7 @@ PropertyEditor::PropertyEditor() { use_filter = false; subsection_selectable = false; property_selectable = false; - show_type_icons = EDITOR_DEF("interface/editor/show_type_icons", false); + show_type_icons = false; // maybe one day will return. } PropertyEditor::~PropertyEditor() { diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp index f149821928..1c50470544 100644 --- a/main/tests/test_physics.cpp +++ b/main/tests/test_physics.cpp @@ -299,7 +299,7 @@ public: VisualServer *vs = VisualServer::get_singleton(); /* LIGHT */ - RID lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL); + RID lightaux = vs->directional_light_create(); scenario = vs->scenario_create(); vs->light_set_shadow(lightaux, true); light = vs->instance_create2(lightaux, scenario); diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index a746973799..7d596fbda3 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -86,7 +86,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_create_from_image(image); - RID segment_shape = ps->shape_create(Physics2DServer::SHAPE_SEGMENT); + RID segment_shape = ps->segment_shape_create(); Rect2 sg(Point2(-16, 0), Point2(16, 0)); ps->shape_set_data(segment_shape, sg); @@ -113,7 +113,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_create_from_image(image); - RID circle_shape = ps->shape_create(Physics2DServer::SHAPE_CIRCLE); + RID circle_shape = ps->circle_shape_create(); ps->shape_set_data(circle_shape, 16); body_shape_data[Physics2DServer::SHAPE_CIRCLE].shape = circle_shape; @@ -140,7 +140,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_create_from_image(image); - RID rectangle_shape = ps->shape_create(Physics2DServer::SHAPE_RECTANGLE); + RID rectangle_shape = ps->rectangle_shape_create(); ps->shape_set_data(rectangle_shape, Vector2(16, 16)); body_shape_data[Physics2DServer::SHAPE_RECTANGLE].shape = rectangle_shape; @@ -168,7 +168,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_create_from_image(image); - RID capsule_shape = ps->shape_create(Physics2DServer::SHAPE_CAPSULE); + RID capsule_shape = ps->capsule_shape_create(); ps->shape_set_data(capsule_shape, Vector2(16, 32)); body_shape_data[Physics2DServer::SHAPE_CAPSULE].shape = capsule_shape; @@ -182,7 +182,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_create_from_image(image); - RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON); + RID convex_polygon_shape = ps->convex_polygon_shape_create(); PoolVector<Vector2> arr; Point2 sb(32, 32); @@ -277,10 +277,11 @@ protected: arr.push_back(p_normal); arr.push_back(p_d); - RID plane = ps->shape_create(Physics2DServer::SHAPE_LINE); + RID plane = ps->line_shape_create(); ps->shape_set_data(plane, arr); - RID plane_body = ps->body_create(Physics2DServer::BODY_MODE_STATIC); + RID plane_body = ps->body_create(); + ps->body_set_mode(plane_body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(plane_body, space); ps->body_add_shape(plane_body, plane); } @@ -290,9 +291,10 @@ protected: Physics2DServer *ps = Physics2DServer::get_singleton(); VisualServer *vs = VisualServer::get_singleton(); - RID concave = ps->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON); + RID concave = ps->concave_polygon_shape_create(); ps->shape_set_data(concave, p_points); - RID body = ps->body_create(Physics2DServer::BODY_MODE_STATIC); + RID body = ps->body_create(); + ps->body_set_mode(body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(body, space); ps->body_add_shape(body, concave); ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform); diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index 1f6217928d..cbf1a57855 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -180,7 +180,7 @@ public: */ RID lightaux; - lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL); + lightaux = vs->directional_light_create(); //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 1.0)); //vs->light_set_shadow( lightaux, true ); @@ -191,7 +191,7 @@ public: vs->instance_set_transform(light, lla); - lightaux = vs->light_create(VisualServer::LIGHT_OMNI); + lightaux = vs->omni_light_create(); //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 0.0)); vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_RANGE, 4); diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp index a26f36d64f..24247ed3b4 100644 --- a/modules/mono/editor/godotsharp_builds.cpp +++ b/modules/mono/editor/godotsharp_builds.cpp @@ -365,16 +365,14 @@ GodotSharpBuilds::GodotSharpBuilds() { // Build tool settings EditorSettings *ed_settings = EditorSettings::get_singleton(); - if (!ed_settings->has_setting("mono/builds/build_tool")) { - ed_settings->set_setting("mono/builds/build_tool", + EDITOR_DEF("mono/builds/build_tool", #ifdef WINDOWS_ENABLED - // TODO: Default to MSBUILD_MONO if its csc.exe issue is fixed in the installed mono version - MSBUILD + // TODO: Default to MSBUILD_MONO if its csc.exe issue is fixed in the installed mono version + MSBUILD #else - MSBUILD_MONO + MSBUILD_MONO #endif - ); - } + ); ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/builds/build_tool", PROPERTY_HINT_ENUM, #ifdef WINDOWS_ENABLED "MSBuild (Mono),MSBuild (System)" diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index 837dbfde66..1bc1e8a515 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -221,9 +221,7 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) { // External editor settings EditorSettings *ed_settings = EditorSettings::get_singleton(); - if (!ed_settings->has_setting("mono/editor/external_editor")) { - ed_settings->set_setting("mono/editor/external_editor", EDITOR_NONE); - } + EDITOR_DEF("mono/editor/external_editor", EDITOR_NONE); ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/editor/external_editor", PROPERTY_HINT_ENUM, "None,MonoDevelop,Visual Studio Code")); } diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index e62b59dd4d..b6111e9765 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -155,14 +155,6 @@ void Node2D::set_rotation_in_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -// Kept for compatibility after rename to set_rotd. -// Could be removed after a couple releases. -void Node2D::_set_rotd(float p_degrees) { - - WARN_PRINT("Deprecated method Node2D._set_rotd(): This method was renamed to set_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_in_degrees(p_degrees); -} - void Node2D::set_scale(const Size2 &p_scale) { if (_xform_dirty) @@ -182,23 +174,19 @@ Point2 Node2D::get_position() const { ((Node2D *)this)->_update_xform_values(); return pos; } + float Node2D::get_rotation() const { if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); return angle; } + float Node2D::get_rotation_in_degrees() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to get_rotd. -// Could be removed after a couple releases. -float Node2D::_get_rotd() const { - WARN_PRINT("Deprecated method Node2D._get_rotd(): This method was renamed to get_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_in_degrees(); -} Size2 Node2D::get_scale() const { if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); @@ -410,10 +398,6 @@ Point2 Node2D::to_global(Point2 p_local) const { void Node2D::_bind_methods() { - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_get_rotd"), &Node2D::_get_rotd); - ClassDB::bind_method(D_METHOD("_set_rotd", "degrees"), &Node2D::_set_rotd); - ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation); ClassDB::bind_method(D_METHOD("set_rotation_in_degrees", "degrees"), &Node2D::set_rotation_in_degrees); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 19aafc81ff..8890c829f8 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -48,10 +48,6 @@ class Node2D : public CanvasItem { void _update_transform(); - // Deprecated, should be removed in a future version. - void _set_rotd(float p_degrees); - float _get_rotd() const; - void _update_xform_values(); protected: diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index f0ee64a53f..1287a800e3 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -133,8 +133,9 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const { } PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) - : CollisionObject2D(Physics2DServer::get_singleton()->body_create(p_mode), false) { + : CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) { + Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode); collision_layer = 1; collision_mask = 1; set_pickable(false); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 4286d88ab1..41097ce8d7 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -587,7 +587,9 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons xform.set_origin(q.pos); //q.canvas_item = VisualServer::get_singleton()->canvas_item_create(); - q.body = Physics2DServer::get_singleton()->body_create(use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC); + q.body = Physics2DServer::get_singleton()->body_create(); + Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC); + Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id()); Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer); Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask); diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 02d10523e7..389d87cd90 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -255,7 +255,13 @@ void Light::_bind_methods() { Light::Light(VisualServer::LightType p_type) { type = p_type; - light = VisualServer::get_singleton()->light_create(p_type); + switch (p_type) { + case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break; + case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break; + case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break; + default: {}; + } + VS::get_singleton()->instance_set_base(get_instance(), light); reverse_cull = false; diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index bc089e5b41..4e06b272e2 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -995,7 +995,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve Transform gt = get_global_transform(); gt.origin -= collision.travel; set_global_transform(gt); - return floor_velocity; + return floor_velocity - p_floor_direction * p_floor_direction.dot(floor_velocity); } } else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle)) { //ceiling on_ceiling = true; diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 0dfd80ca90..bc306481ce 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -332,12 +332,6 @@ void Spatial::set_rotation_in_degrees(const Vector3 &p_euler_deg) { set_rotation(p_euler_deg * Math_PI / 180.0); } -void Spatial::_set_rotation_deg(const Vector3 &p_euler_deg) { - - WARN_PRINT("Deprecated method Spatial._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_in_degrees(p_euler_deg); -} - void Spatial::set_scale(const Vector3 &p_scale) { if (data.dirty & DIRTY_VECTORS) { @@ -375,14 +369,6 @@ Vector3 Spatial::get_rotation_in_degrees() const { return get_rotation() * 180.0 / Math_PI; } -// Kept for compatibility after rename to set_rotd. -// Could be removed after a couple releases. -Vector3 Spatial::_get_rotation_deg() const { - - WARN_PRINT("Deprecated method Spatial._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_in_degrees(); -} - Vector3 Spatial::get_scale() const { if (data.dirty & DIRTY_VECTORS) { @@ -705,10 +691,6 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel); ClassDB::bind_method(D_METHOD("get_world"), &Spatial::get_world); - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotation_deg", "rotation_deg"), &Spatial::_set_rotation_deg); - ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Spatial::_get_rotation_deg); - #ifdef TOOLS_ENABLED ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo); #endif diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index b912d1f906..afac855de0 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -106,10 +106,6 @@ class Spatial : public Node { void _notify_dirty(); void _propagate_transform_changed(Spatial *p_origin); - // Deprecated, should be removed in a future version. - void _set_rotation_deg(const Vector3 &p_euler_deg); - Vector3 _get_rotation_deg() const; - void _propagate_visibility_changed(); protected: diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 54a58159ac..1f230e95c7 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2424,16 +2424,6 @@ float Control::get_rotation_deg() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to {s,g}et_rotation_deg. -// Could be removed after a couple releases. -void Control::_set_rotation_deg(float p_degrees) { - WARN_PRINT("Deprecated method Control._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_deg(p_degrees); -} -float Control::_get_rotation_deg() const { - WARN_PRINT("Deprecated method Control._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_deg(); -} //needed to update the control if the font changes.. void Control::_ref_font(Ref<Font> p_sc) { @@ -2607,8 +2597,6 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Control::set_global_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation); ClassDB::bind_method(D_METHOD("set_rotation_deg", "degrees"), &Control::set_rotation_deg); - // TODO: Obsolete this method (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotation_deg", "degrees"), &Control::_set_rotation_deg); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale); ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset); ClassDB::bind_method(D_METHOD("get_margin", "margin"), &Control::get_margin); @@ -2618,8 +2606,6 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_size"), &Control::get_size); ClassDB::bind_method(D_METHOD("get_rotation"), &Control::get_rotation); ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Control::get_rotation_deg); - // TODO: Obsolete this method (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Control::_get_rotation_deg); ClassDB::bind_method(D_METHOD("get_scale"), &Control::get_scale); ClassDB::bind_method(D_METHOD("get_pivot_offset"), &Control::get_pivot_offset); ClassDB::bind_method(D_METHOD("get_custom_minimum_size"), &Control::get_custom_minimum_size); diff --git a/scene/gui/control.h b/scene/gui/control.h index 5b146b4454..8c1df6784a 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -226,10 +226,6 @@ private: void _size_changed(); String _get_tooltip() const; - // Deprecated, should be removed in a future version. - void _set_rotation_deg(float p_degrees); - float _get_rotation_deg() const; - void _ref_font(Ref<Font> p_sc); void _unref_font(Ref<Font> p_sc); void _font_changed(); diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index ce8714e574..f626c567a9 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -115,20 +115,6 @@ real_t CanvasLayer::get_rotationd() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to {s,g}et_rotationd. -// Could be removed after a couple releases. -void CanvasLayer::_set_rotationd(real_t p_degrees) { - - WARN_PRINT("Deprecated method CanvasLayer._set_rotationd(): This method was renamed to set_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotationd(p_degrees); -} - -real_t CanvasLayer::_get_rotationd() const { - - WARN_PRINT("Deprecated method CanvasLayer._get_rotationd(): This method was renamed to get_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotationd(); -} - void CanvasLayer::set_scale(const Vector2 &p_scale) { if (locrotscale_dirty) @@ -255,10 +241,6 @@ void CanvasLayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotationd", "degrees"), &CanvasLayer::set_rotationd); ClassDB::bind_method(D_METHOD("get_rotationd"), &CanvasLayer::get_rotationd); - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotationd", "degrees"), &CanvasLayer::_set_rotationd); - ClassDB::bind_method(D_METHOD("_get_rotationd"), &CanvasLayer::_get_rotationd); - ClassDB::bind_method(D_METHOD("set_scale", "scale"), &CanvasLayer::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &CanvasLayer::get_scale); diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index fbee87f487..bb7692de0f 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -54,10 +54,6 @@ class CanvasLayer : public Node { int sort_index; - // Deprecated, should be removed in a future version. - void _set_rotationd(real_t p_degrees); - real_t _get_rotationd() const; - void _update_xform(); void _update_locrotscale(); diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 56a09bc3bf..912150b939 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -98,7 +98,7 @@ void CapsuleShape2D::_bind_methods() { } CapsuleShape2D::CapsuleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CAPSULE)) { + : Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) { radius = 10; height = 20; diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp index ecfc98ea60..287bde4bfb 100644 --- a/scene/resources/circle_shape_2d.cpp +++ b/scene/resources/circle_shape_2d.cpp @@ -77,7 +77,7 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) { } CircleShape2D::CircleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CIRCLE)) { + : Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) { radius = 10; _update_shape(); diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp index 7f4abf7ae0..bb91e33ec2 100644 --- a/scene/resources/concave_polygon_shape_2d.cpp +++ b/scene/resources/concave_polygon_shape_2d.cpp @@ -85,5 +85,5 @@ void ConcavePolygonShape2D::_bind_methods() { } ConcavePolygonShape2D::ConcavePolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON)) { + : Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) { } diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index 7588909d90..a76b6a7cf4 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -87,7 +87,7 @@ Rect2 ConvexPolygonShape2D::get_rect() const { } ConvexPolygonShape2D::ConvexPolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON)) { + : Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) { int pcount = 3; for (int i = 0; i < pcount; i++) diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp index 507dbce861..69dbb76744 100644 --- a/scene/resources/rectangle_shape_2d.cpp +++ b/scene/resources/rectangle_shape_2d.cpp @@ -67,7 +67,7 @@ void RectangleShape2D::_bind_methods() { } RectangleShape2D::RectangleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RECTANGLE)) { + : Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) { extents = Vector2(10, 10); _update_shape(); diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp index 1171db5c02..7c7ec0d112 100644 --- a/scene/resources/segment_shape_2d.cpp +++ b/scene/resources/segment_shape_2d.cpp @@ -87,7 +87,7 @@ void SegmentShape2D::_bind_methods() { } SegmentShape2D::SegmentShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) { + : Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) { a = Vector2(); b = Vector2(0, 10); @@ -146,7 +146,7 @@ real_t RayShape2D::get_length() const { } RayShape2D::RayShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) { + : Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) { length = 20; _update_shape(); diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp index 4dcc5ac981..d046ce876c 100644 --- a/scene/resources/shape_line_2d.cpp +++ b/scene/resources/shape_line_2d.cpp @@ -96,7 +96,7 @@ void LineShape2D::_bind_methods() { } LineShape2D::LineShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_LINE)) { + : Shape2D(Physics2DServer::get_singleton()->line_shape_create()) { normal = Vector2(0, -1); d = 0; diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 5d3305c82d..475a3fe3b3 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -35,7 +35,7 @@ #include "project_settings.h" #include "script_language.h" -RID Physics2DServerSW::shape_create(ShapeType p_shape) { +RID Physics2DServerSW::_shape_create(ShapeType p_shape) { Shape2DSW *shape = NULL; switch (p_shape) { @@ -83,7 +83,42 @@ RID Physics2DServerSW::shape_create(ShapeType p_shape) { shape->set_self(id); return id; -}; +} + +RID Physics2DServerSW::line_shape_create() { + + return _shape_create(SHAPE_LINE); +} + +RID Physics2DServerSW::ray_shape_create() { + + return _shape_create(SHAPE_RAY); +} +RID Physics2DServerSW::segment_shape_create() { + + return _shape_create(SHAPE_SEGMENT); +} +RID Physics2DServerSW::circle_shape_create() { + + return _shape_create(SHAPE_CIRCLE); +} +RID Physics2DServerSW::rectangle_shape_create() { + + return _shape_create(SHAPE_RECTANGLE); +} +RID Physics2DServerSW::capsule_shape_create() { + + return _shape_create(SHAPE_CAPSULE); +} + +RID Physics2DServerSW::convex_polygon_shape_create() { + + return _shape_create(SHAPE_CONVEX_POLYGON); +} +RID Physics2DServerSW::concave_polygon_shape_create() { + + return _shape_create(SHAPE_CONCAVE_POLYGON); +} void Physics2DServerSW::shape_set_data(RID p_shape, const Variant &p_data) { @@ -519,17 +554,13 @@ void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_rec /* BODY API */ -RID Physics2DServerSW::body_create(BodyMode p_mode, bool p_init_sleeping) { +RID Physics2DServerSW::body_create() { Body2DSW *body = memnew(Body2DSW); - if (p_mode != BODY_MODE_RIGID) - body->set_mode(p_mode); - if (p_init_sleeping) - body->set_state(BODY_STATE_SLEEPING, p_init_sleeping); RID rid = body_owner.make_rid(body); body->set_self(rid); return rid; -}; +} void Physics2DServerSW::body_set_space(RID p_body, RID p_space) { diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index c40cf0e3e0..171a0b7a81 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -67,6 +67,9 @@ class Physics2DServerSW : public Physics2DServer { static Physics2DServerSW *singletonsw; //void _clear_query(Query2DSW *p_query); + + RID _shape_create(ShapeType p_shape); + public: struct CollCbkData { @@ -78,9 +81,17 @@ public: Vector2 *ptr; }; + virtual RID line_shape_create(); + virtual RID ray_shape_create(); + virtual RID segment_shape_create(); + virtual RID circle_shape_create(); + virtual RID rectangle_shape_create(); + virtual RID capsule_shape_create(); + virtual RID convex_polygon_shape_create(); + virtual RID concave_polygon_shape_create(); + static void _shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata); - virtual RID shape_create(ShapeType p_shape); virtual void shape_set_data(RID p_shape, const Variant &p_data); virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias); @@ -149,7 +160,7 @@ public: /* BODY API */ // create a body of a given type - virtual RID body_create(BodyMode p_mode = BODY_MODE_RIGID, bool p_init_sleeping = false); + virtual RID body_create(); virtual void body_set_space(RID p_body, RID p_space); virtual RID body_get_space(RID p_body) const; diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index f8f3b620d4..f92ed18de2 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -130,19 +130,23 @@ void Physics2DServerWrapMT::finish() { Thread::wait_to_finish(thread); memdelete(thread); - /* - shape_free_cached_ids(); - area_free_cached_ids(); - body_free_cached_ids(); - pin_joint_free_cached_ids(); - groove_joint_free_cached_ids(); - damped_string_free_cached_ids(); -*/ thread = NULL; } else { physics_2d_server->finish(); } + line_shape_free_cached_ids(); + ray_shape_free_cached_ids(); + segment_shape_free_cached_ids(); + circle_shape_free_cached_ids(); + rectangle_shape_free_cached_ids(); + convex_polygon_shape_free_cached_ids(); + concave_polygon_shape_free_cached_ids(); + + space_free_cached_ids(); + area_free_cached_ids(); + body_free_cached_ids(); + if (step_sem) memdelete(step_sem); } @@ -158,12 +162,7 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool step_thread_up = false; alloc_mutex = Mutex::create(); - shape_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - area_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - body_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - pin_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - groove_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - damped_spring_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); + pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); if (!p_create_thread) { server_thread = Thread::get_caller_id(); diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 50e9ab1005..cbc316cb7a 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -64,21 +64,10 @@ class Physics2DServerWrapMT : public Physics2DServer { void thread_exit(); - Mutex *alloc_mutex; bool first_frame; - int shape_pool_max_size; - List<RID> shape_id_pool; - int area_pool_max_size; - List<RID> area_id_pool; - int body_pool_max_size; - List<RID> body_id_pool; - int pin_joint_pool_max_size; - List<RID> pin_joint_id_pool; - int groove_joint_pool_max_size; - List<RID> groove_joint_id_pool; - int damped_spring_joint_pool_max_size; - List<RID> damped_spring_joint_id_pool; + Mutex *alloc_mutex; + int pool_max_size; public: #define ServerName Physics2DServer @@ -87,7 +76,15 @@ public: #include "servers/server_wrap_mt_common.h" //FUNC1RID(shape,ShapeType); todo fix - FUNC1R(RID, shape_create, ShapeType); + FUNCRID(line_shape) + FUNCRID(ray_shape) + FUNCRID(segment_shape) + FUNCRID(circle_shape) + FUNCRID(rectangle_shape) + FUNCRID(capsule_shape) + FUNCRID(convex_polygon_shape) + FUNCRID(concave_polygon_shape) + FUNC2(shape_set_data, RID, const Variant &); FUNC2(shape_set_custom_solver_bias, RID, real_t); @@ -104,7 +101,7 @@ public: /* SPACE API */ - FUNC0R(RID, space_create); + FUNCRID(space); FUNC2(space_set_active, RID, bool); FUNC1RC(bool, space_is_active, RID); @@ -134,7 +131,7 @@ public: /* AREA API */ //FUNC0RID(area); - FUNC0R(RID, area_create); + FUNCRID(area); FUNC2(area_set_space, RID, RID); FUNC1RC(RID, area_get_space, RID); @@ -174,7 +171,7 @@ public: /* BODY API */ //FUNC2RID(body,BodyMode,bool); - FUNC2R(RID, body_create, BodyMode, bool) + FUNCRID(body) FUNC2(body_set_space, RID, RID); FUNC1RC(RID, body_get_space, RID); @@ -269,6 +266,8 @@ public: ///FUNC5RID(groove_joint,const Vector2&,const Vector2&,const Vector2&,RID,RID); ///FUNC4RID(damped_spring_joint,const Vector2&,const Vector2&,RID,RID); + //TODO need to convert this to FUNCRID, but it's a hassle.. + FUNC3R(RID, pin_joint_create, const Vector2 &, RID, RID); FUNC5R(RID, groove_joint_create, const Vector2 &, const Vector2 &, const Vector2 &, RID, RID); FUNC4R(RID, damped_spring_joint_create, const Vector2 &, const Vector2 &, RID, RID); diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 130c0583dc..a5128c9435 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -475,7 +475,15 @@ bool Physics2DServer::_body_test_motion(RID p_body, const Transform2D &p_from, c void Physics2DServer::_bind_methods() { - ClassDB::bind_method(D_METHOD("shape_create", "type"), &Physics2DServer::shape_create); + ClassDB::bind_method(D_METHOD("line_shape_create"), &Physics2DServer::line_shape_create); + ClassDB::bind_method(D_METHOD("ray_shape_create"), &Physics2DServer::ray_shape_create); + ClassDB::bind_method(D_METHOD("segment_shape_create"), &Physics2DServer::segment_shape_create); + ClassDB::bind_method(D_METHOD("circle_shape_create"), &Physics2DServer::circle_shape_create); + ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &Physics2DServer::rectangle_shape_create); + ClassDB::bind_method(D_METHOD("capsule_shape_create"), &Physics2DServer::capsule_shape_create); + ClassDB::bind_method(D_METHOD("convex_polygon_shape_create"), &Physics2DServer::convex_polygon_shape_create); + ClassDB::bind_method(D_METHOD("concave_polygon_shape_create"), &Physics2DServer::concave_polygon_shape_create); + ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &Physics2DServer::shape_set_data); ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &Physics2DServer::shape_get_type); diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index ddd1555768..241255bdb5 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -252,7 +252,15 @@ public: SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error }; - virtual RID shape_create(ShapeType p_shape) = 0; + virtual RID line_shape_create() = 0; + virtual RID ray_shape_create() = 0; + virtual RID segment_shape_create() = 0; + virtual RID circle_shape_create() = 0; + virtual RID rectangle_shape_create() = 0; + virtual RID capsule_shape_create() = 0; + virtual RID convex_polygon_shape_create() = 0; + virtual RID concave_polygon_shape_create() = 0; + virtual void shape_set_data(RID p_shape, const Variant &p_data) = 0; virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) = 0; @@ -366,7 +374,7 @@ public: //BODY_MODE_SOFT ?? }; - virtual RID body_create(BodyMode p_mode = BODY_MODE_RIGID, bool p_init_sleeping = false) = 0; + virtual RID body_create() = 0; virtual void body_set_space(RID p_body, RID p_space) = 0; virtual RID body_get_space(RID p_body) const = 0; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index cd4b465d79..164baa8c9b 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -320,6 +320,10 @@ public: virtual RID light_create(VS::LightType p_type) = 0; + RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); } + RID omni_light_create() { return light_create(VS::LIGHT_OMNI); } + RID spot_light_create() { return light_create(VS::LIGHT_SPOT); } + virtual void light_set_color(RID p_light, const Color &p_color) = 0; virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value) = 0; virtual void light_set_shadow(RID p_light, bool p_enabled) = 0; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 425381550e..b579f4032f 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -799,7 +799,9 @@ public: /* Light API */ - BIND1R(RID, light_create, LightType) + BIND0R(RID, directional_light_create) + BIND0R(RID, omni_light_create) + BIND0R(RID, spot_light_create) BIND2(light_set_color, RID, const Color &) BIND3(light_set_param, RID, LightParam, float) diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index d9a0077e60..1a03c72529 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -154,14 +154,34 @@ void VisualServerWrapMT::finish() { Thread::wait_to_finish(thread); memdelete(thread); - texture_free_cached_ids(); - //mesh_free_cached_ids(); - thread = NULL; } else { visual_server->finish(); } + texture_free_cached_ids(); + shader_free_cached_ids(); + material_free_cached_ids(); + mesh_free_cached_ids(); + multimesh_free_cached_ids(); + immediate_free_cached_ids(); + skeleton_free_cached_ids(); + directional_light_free_cached_ids(); + omni_light_free_cached_ids(); + spot_light_free_cached_ids(); + reflection_probe_free_cached_ids(); + gi_probe_free_cached_ids(); + particles_free_cached_ids(); + camera_free_cached_ids(); + viewport_free_cached_ids(); + environment_free_cached_ids(); + scenario_free_cached_ids(); + instance_free_cached_ids(); + canvas_free_cached_ids(); + canvas_item_free_cached_ids(); + canvas_light_occluder_free_cached_ids(); + canvas_occluder_polygon_free_cached_ids(); + if (draw_mutex) memdelete(draw_mutex); } diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 67d503dfca..80a1ef3879 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -103,12 +103,12 @@ public: /* SKY API */ - FUNC0R(RID, sky_create) + FUNCRID(sky) FUNC3(sky_set_texture, RID, RID, int) /* SHADER API */ - FUNC0R(RID, shader_create) + FUNCRID(shader) FUNC2(shader_set_code, RID, const String &) FUNC1RC(String, shader_get_code, RID) @@ -120,7 +120,7 @@ public: /* COMMON MATERIAL API */ - FUNC0R(RID, material_create) + FUNCRID(material) FUNC2(material_set_shader, RID, RID) FUNC1RC(RID, material_get_shader, RID) @@ -134,7 +134,7 @@ public: /* MESH API */ - FUNC0R(RID, mesh_create) + FUNCRID(mesh) FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &) @@ -170,7 +170,7 @@ public: /* MULTIMESH API */ - FUNC0R(RID, multimesh_create) + FUNCRID(multimesh) FUNC4(multimesh_allocate, RID, int, MultimeshTransformFormat, MultimeshColorFormat) FUNC1RC(int, multimesh_get_instance_count, RID) @@ -192,7 +192,7 @@ public: /* IMMEDIATE API */ - FUNC0R(RID, immediate_create) + FUNCRID(immediate) FUNC3(immediate_begin, RID, PrimitiveType, RID) FUNC2(immediate_vertex, RID, const Vector3 &) FUNC2(immediate_normal, RID, const Vector3 &) @@ -207,7 +207,7 @@ public: /* SKELETON API */ - FUNC0R(RID, skeleton_create) + FUNCRID(skeleton) FUNC3(skeleton_allocate, RID, int, bool) FUNC1RC(int, skeleton_get_bone_count, RID) FUNC3(skeleton_bone_set_transform, RID, int, const Transform &) @@ -217,7 +217,9 @@ public: /* Light API */ - FUNC1R(RID, light_create, LightType) + FUNCRID(directional_light) + FUNCRID(omni_light) + FUNCRID(spot_light) FUNC2(light_set_color, RID, const Color &) FUNC3(light_set_param, RID, LightParam, float) @@ -237,7 +239,7 @@ public: /* PROBE API */ - FUNC0R(RID, reflection_probe_create) + FUNCRID(reflection_probe) FUNC2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode) FUNC2(reflection_probe_set_intensity, RID, float) @@ -254,7 +256,7 @@ public: /* BAKED LIGHT API */ - FUNC0R(RID, gi_probe_create) + FUNCRID(gi_probe) FUNC2(gi_probe_set_bounds, RID, const Rect3 &) FUNC1RC(Rect3, gi_probe_get_bounds, RID) @@ -291,7 +293,7 @@ public: /* PARTICLES */ - FUNC0R(RID, particles_create) + FUNCRID(particles) FUNC2(particles_set_emitting, RID, bool) FUNC2(particles_set_amount, RID, int) @@ -318,7 +320,7 @@ public: /* CAMERA API */ - FUNC0R(RID, camera_create) + FUNCRID(camera) FUNC4(camera_set_perspective, RID, float, float, float) FUNC4(camera_set_orthogonal, RID, float, float, float) FUNC2(camera_set_transform, RID, const Transform &) @@ -328,7 +330,7 @@ public: /* VIEWPORT TARGET API */ - FUNC0R(RID, viewport_create) + FUNCRID(viewport) FUNC2(viewport_set_use_arvr, RID, bool) @@ -377,7 +379,7 @@ public: /* ENVIRONMENT API */ - FUNC0R(RID, environment_create) + FUNCRID(environment) FUNC2(environment_set_background, RID, EnvironmentBG) FUNC2(environment_set_sky, RID, RID) @@ -401,7 +403,7 @@ public: FUNC6(environment_set_fog_depth, RID, bool, float, float, bool, float) FUNC5(environment_set_fog_height, RID, bool, float, float, float) - FUNC0R(RID, scenario_create) + FUNCRID(scenario) FUNC2(scenario_set_debug, RID, ScenarioDebugMode) FUNC2(scenario_set_environment, RID, RID) @@ -410,7 +412,7 @@ public: /* INSTANCING API */ // from can be mesh, light, area and portal so far. - FUNC0R(RID, instance_create) + FUNCRID(instance) FUNC2(instance_set_base, RID, RID) // from can be mesh, light, poly, area and portal so far. FUNC2(instance_set_scenario, RID, RID) // from can be mesh, light, poly, area and portal so far. @@ -440,11 +442,11 @@ public: /* CANVAS (2D) */ - FUNC0R(RID, canvas_create) + FUNCRID(canvas) FUNC3(canvas_set_item_mirroring, RID, RID, const Point2 &) FUNC2(canvas_set_modulate, RID, const Color &) - FUNC0R(RID, canvas_item_create) + FUNCRID(canvas_item) FUNC2(canvas_item_set_parent, RID, RID) FUNC2(canvas_item_set_visible, RID, bool) @@ -510,14 +512,14 @@ public: FUNC2(canvas_light_set_shadow_color, RID, const Color &) FUNC2(canvas_light_set_shadow_smooth, RID, float) - FUNC0R(RID, canvas_light_occluder_create) + FUNCRID(canvas_light_occluder) FUNC2(canvas_light_occluder_attach_to_canvas, RID, RID) FUNC2(canvas_light_occluder_set_enabled, RID, bool) FUNC2(canvas_light_occluder_set_polygon, RID, RID) FUNC2(canvas_light_occluder_set_transform, RID, const Transform2D &) FUNC2(canvas_light_occluder_set_light_mask, RID, int) - FUNC0R(RID, canvas_occluder_polygon_create) + FUNCRID(canvas_occluder_polygon) FUNC3(canvas_occluder_polygon_set_shape, RID, const PoolVector<Vector2> &, bool) FUNC2(canvas_occluder_polygon_set_shape_as_lines, RID, const PoolVector<Vector2> &) diff --git a/servers/visual_server.h b/servers/visual_server.h index 64ed540501..86c32a45a0 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -373,7 +373,9 @@ public: LIGHT_PARAM_MAX }; - virtual RID light_create(LightType p_type) = 0; + virtual RID directional_light_create() = 0; + virtual RID omni_light_create() = 0; + virtual RID spot_light_create() = 0; virtual void light_set_color(RID p_light, const Color &p_color) = 0; virtual void light_set_param(RID p_light, LightParam p_param, float p_value) = 0; |