diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-06-11 15:43:37 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-02-11 11:53:26 +0100 |
commit | 3f335ce3d446372eeb9ed87f7e117099c4d2dd6a (patch) | |
tree | 669db7ddb21f328215a9c26e9bdaf2565db8c853 /editor | |
parent | 9ffe57a10eecf79ab8df2f0497d0387383755df3 (diff) |
Texture refactor
-Texture renamed to Texture2D
-TextureLayered as base now inherits 2Darray, cubemap and cubemap array
-Removed all references to flags in textures (they will go in the shader)
-Texture3D gone for now (will come back later done properly)
-Create base rasterizer for RenderDevice, RasterizerRD
Diffstat (limited to 'editor')
106 files changed, 622 insertions, 583 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index af2760e82b..719e4af6b5 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -258,7 +258,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor); - Ref<Texture> close_icon = get_icon("Close", "EditorIcons"); + Ref<Texture2D> close_icon = get_icon("Close", "EditorIcons"); close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep); close_icon_rect.size = close_icon->get_size(); @@ -290,7 +290,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { if (node) { int ofs = 0; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); h = MAX(h, icon->get_height()); @@ -391,7 +391,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { //draw OTHER curves float scale = timeline->get_zoom_scale(); - Ref<Texture> point = get_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> point = get_icon("KeyValue", "EditorIcons"); for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) { _draw_track(E->key(), E->get()); diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index ef4e62231f..2be388fd57 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -63,9 +63,9 @@ class AnimationBezierTrackEdit : public Control { Vector<Rect2> view_rects; - Ref<Texture> bezier_icon; - Ref<Texture> bezier_handle_icon; - Ref<Texture> selected_icon; + Ref<Texture2D> bezier_icon; + Ref<Texture2D> bezier_handle_icon; + Ref<Texture2D> selected_icon; Rect2 close_icon_rect; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 2edfcced60..cc64db22cc 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1442,11 +1442,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() { int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture> interp_mode = get_icon("TrackContinuous", "EditorIcons"); - Ref<Texture> interp_type = get_icon("InterpRaw", "EditorIcons"); - Ref<Texture> loop_type = get_icon("InterpWrapClamp", "EditorIcons"); - Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons"); - Ref<Texture> down_icon = get_icon("select_arrow", "Tree"); + Ref<Texture2D> interp_mode = get_icon("TrackContinuous", "EditorIcons"); + Ref<Texture2D> interp_type = get_icon("InterpRaw", "EditorIcons"); + Ref<Texture2D> loop_type = get_icon("InterpWrapClamp", "EditorIcons"); + Ref<Texture2D> remove_icon = get_icon("Remove", "EditorIcons"); + Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree"); int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width(); total_w += (down_icon->get_width() + 4 * EDSCALE) * 4; @@ -1456,7 +1456,7 @@ int AnimationTimelineEdit::get_buttons_width() const { int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons"); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1504,7 +1504,7 @@ void AnimationTimelineEdit::_notification(int p_what) { if (l <= 0) l = 0.001; //avoid crashor - Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons"); hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height()); draw_texture(hsize_icon, hsize_rect.position); @@ -1934,7 +1934,7 @@ void AnimationTrackEdit::_notification(int p_what) { Ref<Font> font = get_font("font", "Label"); Color color = get_color("font_color", "Label"); - Ref<Texture> type_icons[6] = { + Ref<Texture2D> type_icons[6] = { get_icon("KeyValue", "EditorIcons"), get_icon("KeyXform", "EditorIcons"), get_icon("KeyCall", "EditorIcons"), @@ -1950,7 +1950,7 @@ void AnimationTrackEdit::_notification(int p_what) { { - Ref<Texture> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox"); + Ref<Texture2D> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox"); int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but.. @@ -1958,7 +1958,7 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(check, check_rect.position); ofs += check->get_width() + hsep; - Ref<Texture> type_icon = type_icons[animation->track_get_type(track)]; + Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)]; draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); ofs += type_icon->get_width() + hsep; @@ -1987,7 +1987,7 @@ void AnimationTrackEdit::_notification(int p_what) { } text_color.a *= 0.7; } else if (node) { - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2)); icon_cache = icon; @@ -2049,17 +2049,17 @@ void AnimationTrackEdit::_notification(int p_what) { { - Ref<Texture> wrap_icon[2] = { + Ref<Texture2D> wrap_icon[2] = { get_icon("InterpWrapClamp", "EditorIcons"), get_icon("InterpWrapLoop", "EditorIcons"), }; - Ref<Texture> interp_icon[3] = { + Ref<Texture2D> interp_icon[3] = { get_icon("InterpRaw", "EditorIcons"), get_icon("InterpLinear", "EditorIcons"), get_icon("InterpCubic", "EditorIcons") }; - Ref<Texture> cont_icon[4] = { + Ref<Texture2D> cont_icon[4] = { get_icon("TrackContinuous", "EditorIcons"), get_icon("TrackDiscrete", "EditorIcons"), get_icon("TrackTrigger", "EditorIcons"), @@ -2068,7 +2068,7 @@ void AnimationTrackEdit::_notification(int p_what) { int ofs = get_size().width - timeline->get_buttons_width(); - Ref<Texture> down_icon = get_icon("select_arrow", "Tree"); + Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree"); draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE)); @@ -2084,7 +2084,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode = Animation::UPDATE_CONTINUOUS; } - Ref<Texture> update_icon = cont_icon[update_mode]; + Ref<Texture2D> update_icon = cont_icon[update_mode]; update_mode_rect.position.x = ofs; update_mode_rect.position.y = int(get_size().height - update_icon->get_height()) / 2; @@ -2105,7 +2105,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect = Rect2(); } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture> bezier_icon = get_icon("EditBezier", "EditorIcons"); + Ref<Texture2D> bezier_icon = get_icon("EditBezier", "EditorIcons"); update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2; bezier_edit_rect.size = bezier_icon->get_size(); @@ -2126,7 +2126,7 @@ void AnimationTrackEdit::_notification(int p_what) { Animation::InterpolationType interp_mode = animation->track_get_interpolation_type(track); - Ref<Texture> icon = interp_icon[interp_mode]; + Ref<Texture2D> icon = interp_icon[interp_mode]; interp_mode_rect.position.x = ofs; interp_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2159,7 +2159,7 @@ void AnimationTrackEdit::_notification(int p_what) { bool loop_wrap = animation->track_get_interpolation_loop_wrap(track); - Ref<Texture> icon = wrap_icon[loop_wrap ? 1 : 0]; + Ref<Texture2D> icon = wrap_icon[loop_wrap ? 1 : 0]; loop_mode_rect.position.x = ofs; loop_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2190,7 +2190,7 @@ void AnimationTrackEdit::_notification(int p_what) { { //erase - Ref<Texture> icon = get_icon("Remove", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Remove", "EditorIcons"); remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2; remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2271,7 +2271,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool if (p_x < p_clip_left || p_x > p_clip_right) return; - Ref<Texture> icon_to_draw = p_selected ? selected_icon : type_icon; + Ref<Texture2D> icon_to_draw = p_selected ? selected_icon : type_icon; // Override type icon for invalid value keys, unless selected. if (!p_selected && animation->track_get_type(track) == Animation::TYPE_VALUE) { @@ -2335,12 +2335,12 @@ void AnimationTrackEdit::draw_bg(int p_clip_left, int p_clip_right) { void AnimationTrackEdit::draw_fg(int p_clip_left, int p_clip_right) { } -void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture> &p_texture, const Vector2 &p_pos) { +void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos) { draw_texture_region_clipped(p_texture, Rect2(p_pos, p_texture->get_size()), Rect2(Point2(), p_texture->get_size())); } -void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) { +void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) { int clip_left = timeline->get_name_limit(); int clip_right = get_size().width - timeline->get_buttons_width(); @@ -2391,7 +2391,7 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati track = p_track; update(); - Ref<Texture> type_icons[6] = { + Ref<Texture2D> type_icons[6] = { get_icon("KeyValue", "EditorIcons"), get_icon("KeyXform", "EditorIcons"), get_icon("KeyCall", "EditorIcons"), @@ -2413,7 +2413,7 @@ NodePath AnimationTrackEdit::get_path() const { Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture> texture = get_icon("Object", "EditorIcons"); + Ref<Texture2D> texture = get_icon("Object", "EditorIcons"); Ref<Font> font = get_font("font", "Label"); int separation = get_constant("vseparation", "ItemList"); @@ -3199,7 +3199,7 @@ void AnimationTrackEditGroup::_notification(int p_what) { } } -void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture> &p_type, const String &p_name, const NodePath &p_node) { +void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node) { icon = p_type; node_name = p_name; node = p_node; @@ -4214,7 +4214,7 @@ void AnimationTrackEditor::_update_tracks() { if (!group_sort.has(base_path)) { AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup); - Ref<Texture> icon = get_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Node", "EditorIcons"); String name = base_path; String tooltip; if (root && root->has_node(base_path)) { @@ -5273,7 +5273,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } String text; - Ref<Texture> icon = get_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Node", "EditorIcons"); if (node) { if (has_icon(node->get_class(), "EditorIcons")) { icon = get_icon(node->get_class(), "EditorIcons"); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 79abda2d49..c2660652d6 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -158,8 +158,8 @@ class AnimationTrackEdit : public Control { Rect2 remove_rect; Rect2 bezier_edit_rect; - Ref<Texture> type_icon; - Ref<Texture> selected_icon; + Ref<Texture2D> type_icon; + Ref<Texture2D> selected_icon; PopupMenu *menu; @@ -167,7 +167,7 @@ class AnimationTrackEdit : public Control { void _zoom_changed(); - Ref<Texture> icon_cache; + Ref<Texture2D> icon_cache; String path_cache; void _menu_selected(int p_index); @@ -208,8 +208,8 @@ public: virtual void draw_fg(int p_clip_left, int p_clip_right); //helper - void draw_texture_clipped(const Ref<Texture> &p_texture, const Vector2 &p_pos); - void draw_texture_region_clipped(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_region); + void draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos); + void draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region); void draw_rect_clipped(const Rect2 &p_rect, const Color &p_color, bool p_filled = true); int get_track() const; @@ -251,7 +251,7 @@ class AnimationBezierTrackEdit; class AnimationTrackEditGroup : public Control { GDCLASS(AnimationTrackEditGroup, Control); - Ref<Texture> icon; + Ref<Texture2D> icon; String node_name; NodePath node; Node *root; @@ -264,7 +264,7 @@ protected: void _notification(int p_what); public: - void set_type_and_name(const Ref<Texture> &p_type, const String &p_name, const NodePath &p_node); + void set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node); virtual Size2 get_minimum_size() const; void set_timeline(AnimationTimelineEdit *p_timeline); void set_root(Node *p_root); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index bb008e621e..bcdd09987f 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -42,12 +42,12 @@ /// BOOL /// int AnimationTrackEditBool::get_key_height() const { - Ref<Texture> checked = get_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_icon("checked", "CheckBox"); return checked->get_height(); } Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Texture> checked = get_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_icon("checked", "CheckBox"); return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height); } @@ -58,7 +58,7 @@ bool AnimationTrackEditBool::is_key_selectable_by_distance() const { void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { bool checked = get_animation()->track_get_key_value(get_track(), p_index); - Ref<Texture> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox"); + Ref<Texture2D> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox"); Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2); @@ -360,7 +360,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) { - Ref<Texture> texture = object->call("get_texture"); + Ref<Texture2D> texture = object->call("get_texture"); if (!texture.is_valid()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); } @@ -404,7 +404,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se animation = get_animation()->track_get_key_value(animation_track, animaiton_index); } - Ref<Texture> texture = sf->get_frame(animation, frame); + Ref<Texture2D> texture = sf->get_frame(animation, frame); if (!texture.is_valid()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); } @@ -434,7 +434,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in return; } - Ref<Texture> texture; + Ref<Texture2D> texture; Rect2 region; if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) { @@ -710,13 +710,13 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) { int AnimationTrackEditVolumeDB::get_key_height() const { - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); return volume_texture->get_height() * 1.2; } void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -728,7 +728,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; int db0 = y_from + (24 / 80.0) * tex_h; @@ -763,7 +763,7 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, to_x = p_clip_right; } - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; diff --git a/editor/animation_track_editor_plugins.h b/editor/animation_track_editor_plugins.h index 4a21ca4d27..378070a45d 100644 --- a/editor/animation_track_editor_plugins.h +++ b/editor/animation_track_editor_plugins.h @@ -35,8 +35,8 @@ class AnimationTrackEditBool : public AnimationTrackEdit { GDCLASS(AnimationTrackEditBool, AnimationTrackEdit); - Ref<Texture> icon_checked; - Ref<Texture> icon_unchecked; + Ref<Texture2D> icon_checked; + Ref<Texture2D> icon_unchecked; public: virtual int get_key_height() const; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index e05ace53da..f3da1b59b2 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -819,8 +819,8 @@ void CodeTextEditor::_complete_request() { text_editor->code_complete(entries, forced); } -Ref<Texture> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) { - Ref<Texture> tex; +Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) { + Ref<Texture2D> tex; switch (p_option.kind) { case ScriptCodeCompletionOption::KIND_CLASS: { if (has_icon(p_option.display, "EditorIcons")) { diff --git a/editor/code_editor.h b/editor/code_editor.h index fc06407166..6b733a2b3c 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -167,7 +167,7 @@ class CodeTextEditor : public VBoxContainer { void _update_font(); void _complete_request(); - Ref<Texture> _get_completion_icon(const ScriptCodeCompletionOption &p_option); + Ref<Texture2D> _get_completion_icon(const ScriptCodeCompletionOption &p_option); void _font_resize_timeout(); bool _add_font_size(int p_delta); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 1853133bc7..7e283bb27f 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -903,7 +903,7 @@ void ConnectionsDock::update_tree() { while (base) { List<MethodInfo> node_signals2; - Ref<Texture> icon; + Ref<Texture2D> icon; String name; if (!did_script) { diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 94ff1b5bb2..a807e50f65 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -77,7 +77,7 @@ class CreateDialog : public ConfirmationDialog { void _confirmed(); void _text_changed(const String &p_newtext); - Ref<Texture> _get_editor_icon(const String &p_type) const; + Ref<Texture2D> _get_editor_icon(const String &p_type) const; void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index df957611cf..46f6815f77 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -174,7 +174,7 @@ void DependencyEditor::_update_list() { TreeItem *root = tree->create_item(); - Ref<Texture> folder = get_icon("folder", "FileDialog"); + Ref<Texture2D> folder = get_icon("folder", "FileDialog"); bool broken = false; @@ -195,7 +195,7 @@ void DependencyEditor::_update_list() { } String name = path.get_file(); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); item->set_text(0, name); item->set_icon(0, icon); item->set_metadata(0, type); @@ -338,7 +338,7 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) { if (!found) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i)); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i)); owners->add_item(efsd->get_file_path(i), icon); } @@ -446,7 +446,7 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed } //List this file under this dependency - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(rd.file_type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(rd.file_type); TreeItem *file_item = owners->create_item(tree_items[rd.dependency]); file_item->set_text(0, rd.file); file_item->set_icon(0, icon); @@ -609,7 +609,7 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve if (report[i].get_slice_count("::") > 0) type = report[i].get_slice("::", 1); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); TreeItem *ti = files->create_item(root); ti->set_text(0, dep); @@ -720,7 +720,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa String type = efsd->get_file_type(i); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); ti->set_icon(0, icon); int ds = efsd->get_file_deps(i).size(); ti->set_text(1, itos(ds)); diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index adfffe27ba..0d9e53c71c 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -483,7 +483,7 @@ void DocData::generate(bool p_basic_types) { PropertyDoc pd; pd.name = E->get(); - pd.type = "Texture"; + pd.type = "Texture2D"; c.theme_properties.push_back(pd); } l.clear(); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 86611bd20a..783b996c4d 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -110,7 +110,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { ret = unzGoToNextFile(pkg); } - Map<String, Ref<Texture> > extension_guess; + Map<String, Ref<Texture2D> > extension_guess; { extension_guess["png"] = get_icon("ImageTexture", "EditorIcons"); extension_guess["jpg"] = get_icon("ImageTexture", "EditorIcons"); @@ -122,7 +122,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { extension_guess["vs"] = get_icon("VisualScript", "EditorIcons"); } - Ref<Texture> generic_extension = get_icon("Object", "EditorIcons"); + Ref<Texture2D> generic_extension = get_icon("Object", "EditorIcons"); unzClose(pkg); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 0a60aabd2d..594322f00d 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -144,8 +144,8 @@ void EditorAudioBus::_notification(int p_what) { if (activity_found != channel[i].prev_active) { if (activity_found) { - channel[i].vu_l->set_over_texture(Ref<Texture>()); - channel[i].vu_r->set_over_texture(Ref<Texture>()); + channel[i].vu_l->set_over_texture(Ref<Texture2D>()); + channel[i].vu_r->set_over_texture(Ref<Texture2D>()); } else { channel[i].vu_l->set_over_texture(disabled_vu); channel[i].vu_r->set_over_texture(disabled_vu); @@ -944,7 +944,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { if (!ClassDB::can_instance(E->get())) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(E->get()); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E->get()); String name = E->get().operator String().replace("AudioEffect", ""); effect_options->add_item(name); effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get()); diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index ef6f7e458f..72098c7232 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -54,7 +54,7 @@ class EditorAudioBus : public PanelContainer { GDCLASS(EditorAudioBus, PanelContainer); - Ref<Texture> disabled_vu; + Ref<Texture2D> disabled_vu; LineEdit *track_name; MenuButton *bus_options; VSlider *slider; diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 0b43fd5ac0..d7c610f109 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -479,7 +479,7 @@ EditorPlugin *EditorData::get_editor_plugin(int p_idx) { return editor_plugins[p_idx]; } -void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon) { +void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object."); CustomType ct; diff --git a/editor/editor_data.h b/editor/editor_data.h index 1b21ce4451..8a6f2f63f6 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -112,7 +112,7 @@ public: String name; Ref<Script> script; - Ref<Texture> icon; + Ref<Texture2D> icon; }; struct EditedScene { @@ -178,7 +178,7 @@ public: void save_editor_global_states(); void restore_editor_global_states(); - void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon); + void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon); Object *instance_custom_type(const String &p_type, const String &p_inherits); void remove_custom_type(const String &p_type); const Map<String, Vector<CustomType> > &get_custom_types() const { return custom_types; } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 3d8ea0b040..d661a3ec3c 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1477,7 +1477,7 @@ String EditorExportPlatformPC::get_os_name() const { return os_name; } -Ref<Texture> EditorExportPlatformPC::get_logo() const { +Ref<Texture2D> EditorExportPlatformPC::get_logo() const { return logo; } @@ -1629,7 +1629,7 @@ void EditorExportPlatformPC::set_os_name(const String &p_name) { os_name = p_name; } -void EditorExportPlatformPC::set_logo(const Ref<Texture> &p_logo) { +void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) { logo = p_logo; } diff --git a/editor/editor_export.h b/editor/editor_export.h index 577fd0cf7e..19651b2c62 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -236,7 +236,7 @@ public: virtual String get_os_name() const = 0; virtual String get_name() const = 0; - virtual Ref<Texture> get_logo() const = 0; + virtual Ref<Texture2D> get_logo() const = 0; Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = NULL); @@ -259,7 +259,7 @@ public: }; virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; } - virtual Ref<Texture> get_run_icon() const { return get_logo(); } + virtual Ref<Texture2D> get_run_icon() const { return get_logo(); } String test_etc2() const; //generic test for etc2 since most platforms use it virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0; @@ -420,7 +420,7 @@ public: virtual String get_name() const; virtual String get_os_name() const; - virtual Ref<Texture> get_logo() const; + virtual Ref<Texture2D> get_logo() const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const; @@ -431,7 +431,7 @@ public: void set_name(const String &p_name); void set_os_name(const String &p_name); - void set_logo(const Ref<Texture> &p_logo); + void set_logo(const Ref<Texture2D> &p_logo); void set_release_64(const String &p_file); void set_release_32(const String &p_file); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 625f46f9d3..c869768c6c 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -78,7 +78,7 @@ void EditorFileDialog::_notification(int p_what) { preview_wheel_index++; if (preview_wheel_index >= 8) preview_wheel_index = 0; - Ref<Texture> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons"); + Ref<Texture2D> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons"); preview->set_texture(frame); preview_wheel_timeout = 0.1; } @@ -263,7 +263,7 @@ void EditorFileDialog::_post_popup() { _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); if (is_visible_in_tree()) { - Ref<Texture> folder = get_icon("folder", "FileDialog"); + Ref<Texture2D> folder = get_icon("folder", "FileDialog"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); recent->clear(); @@ -295,7 +295,7 @@ void EditorFileDialog::_post_popup() { set_process_unhandled_input(true); } -void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { if (display_mode == DISPLAY_LIST || p_preview.is_null()) return; @@ -305,12 +305,12 @@ void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture String pname = d["path"]; if (pname == p_path) { item_list->set_item_icon(i, p_preview); - item_list->set_item_tag_icon(i, Ref<Texture>()); + item_list->set_item_tag_icon(i, Ref<Texture2D>()); } } } -void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { set_process(false); preview_waiting = false; @@ -326,7 +326,7 @@ void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture> } else { preview_vb->hide(); - preview->set_texture(Ref<Texture>()); + preview->set_texture(Ref<Texture2D>()); } } @@ -704,8 +704,8 @@ void EditorFileDialog::update_file_list() { int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; - Ref<Texture> folder_thumbnail; - Ref<Texture> file_thumbnail; + Ref<Texture2D> folder_thumbnail; + Ref<Texture2D> file_thumbnail; item_list->clear(); @@ -745,7 +745,7 @@ void EditorFileDialog::update_file_list() { dir_access->list_dir_begin(); - Ref<Texture> folder = get_icon("folder", "FileDialog"); + Ref<Texture2D> folder = get_icon("folder", "FileDialog"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); List<String> files; List<String> dirs; @@ -841,7 +841,7 @@ void EditorFileDialog::update_file_list() { if (get_icon_func) { - Ref<Texture> icon = get_icon_func(cdir.plus_file(files.front()->get())); + Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get())); if (display_mode == DISPLAY_THUMBNAILS) { item_list->set_item_icon(item_list->get_item_count() - 1, file_thumbnail); @@ -1215,7 +1215,7 @@ void EditorFileDialog::_update_favorites() { bool res = access == ACCESS_RESOURCES; String current = get_current_dir(); - Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons"); + Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); favorites->clear(); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 6af261e8dd..8b48604b31 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -68,7 +68,7 @@ public: MODE_SAVE_FILE }; - typedef Ref<Texture> (*GetIconFunc)(const String &); + typedef Ref<Texture2D> (*GetIconFunc)(const String &); typedef void (*RegisterFunc)(EditorFileDialog *); static GetIconFunc get_icon_func; @@ -188,10 +188,10 @@ private: virtual void _post_popup(); void _save_to_recent(); - //callback function is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load + //callback function is callback(String p_path,Ref<Texture2D> preview,Variant udata) preview null if could not load - void _thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); - void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); + void _thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); + void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); void _request_single_thumbnail(const String &p_path); void _unhandled_input(const Ref<InputEvent> &p_event); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 556dbcbfc4..22a16ac65a 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1374,7 +1374,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { end = bbcode.length(); String image = bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture> texture = ResourceLoader::load(base_path.plus_file(image), "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(base_path.plus_file(image), "Texture2D"); if (texture.is_valid()) p_rt->add_image(texture); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 80981e8fa1..d45b66afce 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -483,7 +483,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) { - Ref<Texture> icon = empty_icon; + Ref<Texture2D> icon = empty_icon; if (ui_service->has_icon(p_doc->name, "EditorIcons")) icon = ui_service->get_icon(p_doc->name, "EditorIcons"); else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) @@ -559,7 +559,7 @@ TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_pare TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_type, const String &p_metatype, const String &p_tooltip) { - Ref<Texture> icon; + Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { icon = ui_service->get_icon(p_icon, "EditorIcons"); diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index 5d089d1c24..feff96d2e5 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -116,7 +116,7 @@ class EditorHelpSearch::Runner : public Reference { String term; int search_flags; - Ref<Texture> empty_icon; + Ref<Texture2D> empty_icon; Color disabled_color; Map<String, DocData::ClassDoc>::Element *iterator_doc; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 7c1e58862e..6d2b891dc6 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -61,12 +61,12 @@ Size2 EditorProperty::get_minimum_size() const { } if (keying) { - Ref<Texture> key = get_icon("Key", "EditorIcons"); + Ref<Texture2D> key = get_icon("Key", "EditorIcons"); ms.width += key->get_width() + get_constant("hseparator", "Tree"); } if (checkable) { - Ref<Texture> check = get_icon("checked", "CheckBox"); + Ref<Texture2D> check = get_icon("checked", "CheckBox"); ms.width += check->get_width() + get_constant("hseparation", "CheckBox") + get_constant("hseparator", "Tree"); } @@ -139,7 +139,7 @@ void EditorProperty::_notification(int p_what) { } if (keying) { - Ref<Texture> key; + Ref<Texture2D> key; if (use_keying_next()) { key = get_icon("KeyNext", "EditorIcons"); @@ -215,7 +215,7 @@ void EditorProperty::_notification(int p_what) { int text_limit = text_size; if (checkable) { - Ref<Texture> checkbox; + Ref<Texture2D> checkbox; if (checked) checkbox = get_icon("GuiChecked", "EditorIcons"); else @@ -236,7 +236,7 @@ void EditorProperty::_notification(int p_what) { } if (can_revert) { - Ref<Texture> reload_icon = get_icon("ReloadSmall", "EditorIcons"); + Ref<Texture2D> reload_icon = get_icon("ReloadSmall", "EditorIcons"); text_limit -= reload_icon->get_width() + get_constant("hseparator", "Tree") * 2; revert_rect = Rect2(text_limit + get_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); @@ -256,7 +256,7 @@ void EditorProperty::_notification(int p_what) { draw_string(font, Point2(ofs, v_ofs + font->get_ascent()), label, color, text_limit); if (keying) { - Ref<Texture> key; + Ref<Texture2D> key; if (use_keying_next()) { key = get_icon("KeyNext", "EditorIcons"); @@ -1055,7 +1055,7 @@ void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { Ref<Font> font = get_font("font", "Tree"); - Ref<Texture> arrow; + Ref<Texture2D> arrow; if (foldable) { if (object->editor_is_section_unfolded(section)) { @@ -1096,7 +1096,7 @@ void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> arrow; + Ref<Texture2D> arrow; if (foldable) { if (object->editor_is_section_unfolded(section)) { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 792247138e..7ad55a13ad 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -198,7 +198,7 @@ class EditorInspectorCategory : public Control { GDCLASS(EditorInspectorCategory, Control); friend class EditorInspector; - Ref<Texture> icon; + Ref<Texture2D> icon; String label; Color bg_color; mutable String tooltip_text; diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 0495722a13..5b77db7707 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -76,7 +76,7 @@ void EditorLog::_notification(int p_what) { void EditorLog::_clear_request() { log->clear(); - tool_button->set_icon(Ref<Texture>()); + tool_button->set_icon(Ref<Texture2D>()); } void EditorLog::_copy_request() { @@ -102,14 +102,14 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) { } break; case MSG_TYPE_ERROR: { log->push_color(get_color("error_color", "Editor")); - Ref<Texture> icon = get_icon("Error", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Error", "EditorIcons"); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_WARNING: { log->push_color(get_color("warning_color", "Editor")); - Ref<Texture> icon = get_icon("Warning", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Warning", "EditorIcons"); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d6dcbf7e84..31d5f8c4fa 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -183,11 +183,11 @@ void EditorNode::_update_scene_tabs() { OS::get_singleton()->global_menu_clear("_dock"); scene_tabs->clear_tabs(); - Ref<Texture> script_icon = gui_base->get_icon("Script", "EditorIcons"); + Ref<Texture2D> script_icon = gui_base->get_icon("Script", "EditorIcons"); for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *type_node = editor_data.get_edited_scene_root(i); - Ref<Texture> icon; + Ref<Texture2D> icon; if (type_node) { icon = EditorNode::get_singleton()->get_object_icon(type_node, "Node"); } @@ -461,7 +461,7 @@ void EditorNode::_notification(int p_what) { ToolButton *tb = singleton->main_editor_buttons[i]; EditorPlugin *p_editor = singleton->editor_table[i]; - Ref<Texture> icon = p_editor->get_icon(); + Ref<Texture2D> icon = p_editor->get_icon(); if (icon.is_valid()) { tb->set_icon(icon); @@ -2942,7 +2942,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->set_toggle_mode(true); tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size())); tb->set_text(p_editor->get_name()); - Ref<Texture> icon = p_editor->get_icon(); + Ref<Texture2D> icon = p_editor->get_icon(); if (icon.is_valid()) { tb->set_icon(icon); @@ -3767,7 +3767,7 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons return NULL; } -Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { +Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { ERR_FAIL_COND_V(!p_object || !gui_base, NULL); Ref<Script> script = p_object->get_script(); @@ -3812,7 +3812,7 @@ Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p return NULL; } -Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const { +Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const { ERR_FAIL_COND_V_MSG(p_class.empty(), NULL, "Class name cannot be empty."); if (gui_base->has_icon(p_class, "EditorIcons")) { @@ -3907,7 +3907,7 @@ void EditorNode::progress_end_task_bg(const String &p_task) { singleton->progress_hb->end_task(p_task); } -Ref<Texture> EditorNode::_file_dialog_get_icon(const String &p_path) { +Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) { EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir()); if (efsd) { @@ -4732,7 +4732,7 @@ void EditorNode::_reposition_active_tab(int idx_to) { _update_scene_tabs(); } -void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { int p_tab = p_udata.operator signed int(); if (p_preview.is_valid()) { Rect2 rect = scene_tabs->get_tab_rect(p_tab); @@ -4972,7 +4972,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { TextureRect *drag_preview = memnew(TextureRect); Label *label = memnew(Label); - Ref<Texture> preview; + Ref<Texture2D> preview; { //todo make proper previews @@ -5582,7 +5582,6 @@ EditorNode::EditorNode() { Input::get_singleton()->set_use_accumulated_input(true); Resource::_get_local_scene_func = _resource_get_edited_scene; - VisualServer::get_singleton()->textures_keep_original(true); VisualServer::get_singleton()->set_debug_generate_wireframes(true); NavigationServer::get_singleton()->set_active(false); // no nav by default if editor @@ -5682,16 +5681,21 @@ EditorNode::EditorNode() { import_texture.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_texture); - Ref<ResourceImporterLayeredTexture> import_3d; - import_3d.instance(); - import_3d->set_3d(true); - ResourceFormatImporter::get_singleton()->add_importer(import_3d); + Ref<ResourceImporterLayeredTexture> import_cubemap; + import_cubemap.instance(); + import_cubemap->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP); + ResourceFormatImporter::get_singleton()->add_importer(import_cubemap); Ref<ResourceImporterLayeredTexture> import_array; import_array.instance(); - import_array->set_3d(false); + import_array->set_mode(ResourceImporterLayeredTexture::MODE_2D_ARRAY); ResourceFormatImporter::get_singleton()->add_importer(import_array); + Ref<ResourceImporterLayeredTexture> import_cubemap_array; + import_cubemap_array.instance(); + import_cubemap_array->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP_ARRAY); + ResourceFormatImporter::get_singleton()->add_importer(import_cubemap_array); + Ref<ResourceImporterImage> import_image; import_image.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_image); diff --git a/editor/editor_node.h b/editor/editor_node.h index a5c04d3531..bd2c3d73ae 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -522,13 +522,13 @@ private: Set<FileDialog *> file_dialogs; Set<EditorFileDialog *> editor_file_dialogs; - Map<String, Ref<Texture> > icon_type_cache; + Map<String, Ref<Texture2D> > icon_type_cache; void _build_icon_type_cache(); bool _initializing_addons; Map<String, EditorPlugin *> plugin_addons; - static Ref<Texture> _file_dialog_get_icon(const String &p_path); + static Ref<Texture2D> _file_dialog_get_icon(const String &p_path); static void _file_dialog_register(FileDialog *p_dialog); static void _file_dialog_unregister(FileDialog *p_dialog); static void _editor_file_dialog_register(EditorFileDialog *p_dialog); @@ -582,7 +582,7 @@ private: void _scene_tab_exit(); void _scene_tab_input(const Ref<InputEvent> &p_input); void _reposition_active_tab(int idx_to); - void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); + void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); void _scene_tab_script_edited(int p_tab); Dictionary _get_main_scene_state(); @@ -772,8 +772,8 @@ public: Ref<Theme> get_editor_theme() const { return theme; } Ref<Script> get_object_custom_type_base(const Object *p_object) const; StringName get_object_custom_type_name(const Object *p_object) const; - Ref<Texture> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const; - Ref<Texture> get_class_icon(const String &p_class, const String &p_fallback = "Object") const; + Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const; + Ref<Texture2D> get_class_icon(const String &p_class, const String &p_fallback = "Object") const; void show_accept(const String &p_text, const String &p_title); void show_warning(const String &p_text, const String &p_title = TTR("Warning!")); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index f0d69f98fb..6a1d052e02 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -54,7 +54,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { if (!obj) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); int index = get_popup()->get_item_count(); get_popup()->add_icon_item(icon, E->get().name.capitalize(), objects.size()); @@ -90,7 +90,7 @@ void EditorPath::update_path() { if (!obj) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); if (icon.is_valid()) set_icon(icon); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index b5f63dcd43..69a2344bc0 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -51,7 +51,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ meshes.push_back(p_meshes[i]); } - Vector<Ref<Texture> > textures = make_mesh_previews(meshes, NULL, p_preview_size); + Vector<Ref<Texture2D> > textures = make_mesh_previews(meshes, NULL, p_preview_size); Array ret; for (int i = 0; i < textures.size(); i++) { ret.push_back(textures[i]); @@ -60,7 +60,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ return ret; } -Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { +Vector<Ref<Texture2D> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { int size = p_preview_size; @@ -87,13 +87,13 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size()); - Vector<Ref<Texture> > textures; + Vector<Ref<Texture2D> > textures; for (int i = 0; i < p_meshes.size(); i++) { Ref<Mesh> mesh = p_meshes[i]; if (!mesh.is_valid()) { - textures.push_back(Ref<Texture>()); + textures.push_back(Ref<Texture2D>()); continue; } @@ -114,7 +114,7 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> AABB rot_aabb = xform.xform(aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) { - textures.push_back(Ref<Texture>()); + textures.push_back(Ref<Texture2D>()); continue; } xform.origin = -xform.basis.xform(ofs); //-ofs*m; @@ -131,7 +131,7 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> ep.step(TTR("Thumbnail..."), i); Main::iteration(); Main::iteration(); - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); ERR_CONTINUE(!img.is_valid() || img->empty()); Ref<ImageTexture> it(memnew(ImageTexture)); it->create_from_image(img); @@ -314,7 +314,7 @@ EditorInterface::EditorInterface() { } /////////////////////////////////////////// -void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) { +void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon); } @@ -605,13 +605,13 @@ String EditorPlugin::get_name() const { return String(); } -const Ref<Texture> EditorPlugin::get_icon() const { +const Ref<Texture2D> EditorPlugin::get_icon() const { if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) { return get_script_instance()->call("get_plugin_icon"); } - return Ref<Texture>(); + return Ref<Texture2D>(); } bool EditorPlugin::has_main_screen() const { diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 1a78b72ade..dee63e4322 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -98,7 +98,7 @@ public: Error save_scene(); void save_scene_as(const String &p_scene, bool p_with_preview = true); - Vector<Ref<Texture> > make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); + Vector<Ref<Texture2D> > make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); void set_main_screen_editor(const String &p_name); void set_distraction_free_mode(bool p_enter); @@ -123,7 +123,7 @@ protected: static void _bind_methods(); UndoRedo &get_undo_redo() { return *undo_redo; } - void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon); + void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon); void remove_custom_type(const String &p_type); public: @@ -187,7 +187,7 @@ public: virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay); virtual String get_name() const; - virtual const Ref<Texture> get_icon() const; + virtual const Ref<Texture2D> get_icon() const; virtual bool has_main_screen() const; virtual void make_visible(bool p_visible); virtual void selected_notify() {} //notify that it was raised by the user, not the editor diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index e5a9c4d699..3ac4fcc21b 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -353,10 +353,10 @@ void EditorProfiler::_update_plot() { if (graph_texture.is_null()) { graph_texture.instance(); } - graph_texture->create(img->get_width(), img->get_height(), img->get_format(), Texture::FLAG_VIDEO_SURFACE); + graph_texture->create_from_image(img); } - graph_texture->set_data(img); + graph_texture->update(img, true); graph->set_texture(graph_texture); graph->update(); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c134786b89..b018f34e8f 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -135,7 +135,7 @@ void EditorPropertyMultilineText::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - Ref<Texture> df = get_icon("DistractionFree", "EditorIcons"); + Ref<Texture2D> df = get_icon("DistractionFree", "EditorIcons"); open_big_text->set_icon(df); Ref<Font> font = get_font("font", "Label"); text->set_custom_minimum_size(Vector2(0, font->get_height() * 6)); @@ -865,7 +865,7 @@ void EditorPropertyObjectID::update_property() { } else { edit->set_text(TTR("[Empty]")); edit->set_disabled(true); - edit->set_icon(Ref<Texture>()); + edit->set_icon(Ref<Texture2D>()); } } @@ -1983,7 +1983,7 @@ void EditorPropertyNodePath::update_property() { assign->set_tooltip(p); if (p == NodePath()) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(TTR("Assign...")); assign->set_flat(false); return; @@ -2000,7 +2000,7 @@ void EditorPropertyNodePath::update_property() { } if (!base_node || !base_node->has_node(p)) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(p); return; } @@ -2009,7 +2009,7 @@ void EditorPropertyNodePath::update_property() { ERR_FAIL_COND(!target_node); if (String(target_node->get_name()).find("@") != -1) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(p); return; } @@ -2028,7 +2028,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam void EditorPropertyNodePath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture> t = get_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_icon("Clear", "EditorIcons"); clear->set_icon(t); } } @@ -2331,7 +2331,7 @@ void EditorPropertyResource::_menu_option(int p_which) { } } -void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj) { +void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj) { RES p = get_edited_object()->get(get_edited_property()); if (p.is_valid() && p->get_instance_id() == p_obj) { @@ -2412,7 +2412,7 @@ void EditorPropertyResource::_update_menu_items() { const String &t = F->get(); bool is_custom_resource = false; - Ref<Texture> icon; + Ref<Texture2D> icon; if (!custom_resources.empty()) { for (int j = 0; j < custom_resources.size(); j++) { if (custom_resources[j].name == t) { @@ -2493,7 +2493,7 @@ void EditorPropertyResource::_update_menu_items() { } for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); - Ref<Texture> icon; + Ref<Texture2D> icon; if (has_icon(what, "EditorIcons")) { icon = get_icon(what, "EditorIcons"); @@ -2659,9 +2659,9 @@ void EditorPropertyResource::update_property() { } } - preview->set_texture(Ref<Texture>()); + preview->set_texture(Ref<Texture2D>()); if (res == RES()) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(TTR("[empty]")); } else { @@ -2712,7 +2712,7 @@ void EditorPropertyResource::setup(const String &p_base_type) { void EditorPropertyResource::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture> t = get_icon("select_arrow", "Tree"); + Ref<Texture2D> t = get_icon("select_arrow", "Tree"); edit->set_icon(t); } diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 1853a6b6e1..7c343f1c67 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -574,7 +574,7 @@ class EditorPropertyResource : public EditorProperty { void _file_selected(const String &p_path); void _menu_option(int p_which); - void _resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj); + void _resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj); void _resource_selected(); void _viewport_selected(const NodePath &p_path); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 1f2a02c9a0..92bee53fdb 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -49,15 +49,15 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const { ERR_FAIL_V_MSG(false, "EditorResourcePreviewGenerator::handles needs to be overridden."); } -Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const { if (get_script_instance() && get_script_instance()->has_method("generate")) { return get_script_instance()->call("generate", p_from, p_size); } - ERR_FAIL_V_MSG(Ref<Texture>(), "EditorResourcePreviewGenerator::generate needs to be overridden."); + ERR_FAIL_V_MSG(Ref<Texture2D>(), "EditorResourcePreviewGenerator::generate needs to be overridden."); } -Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const { +Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const { if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) { return get_script_instance()->call("generate_from_path", p_path, p_size); @@ -90,8 +90,8 @@ bool EditorResourcePreviewGenerator::can_generate_small_preview() const { void EditorResourcePreviewGenerator::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::STRING, "type"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "generate_small_preview_automatically")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "can_generate_small_preview")); } @@ -107,7 +107,7 @@ void EditorResourcePreview::_thread_func(void *ud) { erp->_thread(); } -void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, const Ref<Texture> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { +void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { preview_mutex->lock(); @@ -160,7 +160,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< if (!preview_generators[i]->handles(type)) continue; - Ref<Texture> generated; + Ref<Texture2D> generated; if (p_item.resource.is_valid()) { generated = preview_generators[i]->generate(p_item.resource, Vector2(thumbnail_size, thumbnail_size)); } else { @@ -172,7 +172,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< small_thumbnail_size *= EDSCALE; if (preview_generators[i]->can_generate_small_preview()) { - Ref<Texture> generated_small; + Ref<Texture2D> generated_small; if (p_item.resource.is_valid()) { generated_small = preview_generators[i]->generate(p_item.resource, Vector2(small_thumbnail_size, small_thumbnail_size)); } else { @@ -322,14 +322,14 @@ void EditorResourcePreview::_thread() { } else { texture.instance(); - texture->create_from_image(img, Texture::FLAG_FILTER); + texture->create_from_image(img); if (has_small_texture) { if (small_img->load(cache_base + "_small.png") != OK) { cache_valid = false; } else { small_texture.instance(); - small_texture->create_from_image(small_img, Texture::FLAG_FILTER); + small_texture->create_from_image(small_img); } } } diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 8091fbafdc..94f4bcb466 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -45,8 +45,8 @@ protected: public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; - virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const; virtual bool generate_small_preview_automatically() const; virtual bool can_generate_small_preview() const; @@ -77,8 +77,8 @@ class EditorResourcePreview : public Node { volatile bool exited; struct Item { - Ref<Texture> preview; - Ref<Texture> small_preview; + Ref<Texture2D> preview; + Ref<Texture2D> small_preview; int order; uint32_t last_hash; uint64_t modified_time; @@ -88,7 +88,7 @@ class EditorResourcePreview : public Node { Map<String, Item> cache; - void _preview_ready(const String &p_str, const Ref<Texture> &p_texture, const Ref<Texture> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud); + void _preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud); void _generate_preview(Ref<ImageTexture> &r_texture, Ref<ImageTexture> &r_small_texture, const QueueItem &p_item, const String &cache_base); static void _thread_func(void *ud); @@ -102,7 +102,7 @@ protected: public: static EditorResourcePreview *get_singleton(); - //callback function is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load + //callback function is callback(String p_path,Ref<Texture2D> preview,Variant udata) preview null if could not load void queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata); void queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 4bbc111aea..db88b0cea4 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -53,7 +53,7 @@ void EditorRunNative::_notification(int p_what) { im->resize(16 * EDSCALE, 16 * EDSCALE); Ref<ImageTexture> small_icon; small_icon.instance(); - small_icon->create_from_image(im, 0); + small_icon->create_from_image(im); MenuButton *mb = memnew(MenuButton); mb->get_popup()->connect("id_pressed", this, "_run_native", varray(i)); mb->connect("pressed", this, "_run_native", varray(-1, i)); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 5db18d8853..bb8bcdfe6c 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -200,7 +200,7 @@ void EditorSpinSlider::_notification(int p_what) { int string_width = font->get_string_size(label).width; int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep; - Ref<Texture> updown = get_icon("updown", "SpinBox"); + Ref<Texture2D> updown = get_icon("updown", "SpinBox"); if (get_step() == 1) { number_width -= updown->get_width(); @@ -233,7 +233,7 @@ void EditorSpinSlider::_notification(int p_what) { draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width); if (get_step() == 1) { - Ref<Texture> updown2 = get_icon("updown", "SpinBox"); + Ref<Texture2D> updown2 = get_icon("updown", "SpinBox"); int updown_vofs = (get_size().height - updown2->get_height()) / 2; updown_offset = get_size().width - sb->get_margin(MARGIN_RIGHT) - updown2->get_width(); Color c(1, 1, 1); @@ -268,7 +268,7 @@ void EditorSpinSlider::_notification(int p_what) { } if (display_grabber) { - Ref<Texture> grabber_tex; + Ref<Texture2D> grabber_tex; if (mouse_over_grabber) { grabber_tex = get_icon("grabber_highlight", "HSlider"); } else { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 28bc20a957..78387fceb7 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -41,7 +41,7 @@ #include "modules/svg/image_loader_svg.h" #endif -static Ref<StyleBoxTexture> make_stylebox(Ref<Texture> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) { +static Ref<StyleBoxTexture> make_stylebox(Ref<Texture2D> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) { Ref<StyleBoxTexture> style(memnew(StyleBoxTexture)); style->set_texture(p_texture); style->set_margin_size(MARGIN_LEFT, p_left * EDSCALE); @@ -99,10 +99,7 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float const bool upsample = !Math::is_equal_approx(Math::round(p_scale), p_scale); ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, upsample, p_convert_color); - if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || p_force_filter) - icon->create_from_image(img); // in this case filter really helps - else - icon->create_from_image(img, 0); + icon->create_from_image(img); // in this case filter really helps return icon; } @@ -931,7 +928,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("panel", "EditorAbout", style_complex_window); // HScrollBar - Ref<Texture> empty_icon = memnew(ImageTexture); + Ref<Texture2D> empty_icon = memnew(ImageTexture); theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0)); theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0)); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 684942dbad..a3def15532 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -45,8 +45,8 @@ #include "scene/main/viewport.h" #include "scene/resources/packed_scene.h" -Ref<Texture> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) { - Ref<Texture> file_icon; +Ref<Texture2D> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) { + Ref<Texture2D> file_icon; if (!p_dir->get_file_import_is_valid(p_idx)) { file_icon = get_icon("ImportFail", "EditorIcons"); } else { @@ -198,11 +198,11 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo if (!fave.begins_with("res://")) continue; - Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons"); + Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); String text; - Ref<Texture> icon; + Ref<Texture2D> icon; Color color; if (fave == "res://") { text = "/"; @@ -496,7 +496,7 @@ void FileSystemDock::navigate_to_path(const String &p_path) { _navigate_to_path(p_path); } -void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { if ((file_list_vb->is_visible_in_tree() || path == p_path.get_base_dir()) && p_preview.is_valid()) { Array uarr = p_udata; int idx = uarr[0]; @@ -512,7 +512,7 @@ void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<T } } -void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { if (p_small_preview.is_valid()) { Array uarr = p_udata; if (tree_update_id == (int)uarr[0]) { @@ -613,9 +613,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String ei = "EditorIcons"; int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size"); thumbnail_size *= EDSCALE; - Ref<Texture> folder_thumbnail; - Ref<Texture> file_thumbnail; - Ref<Texture> file_thumbnail_broken; + Ref<Texture2D> folder_thumbnail; + Ref<Texture2D> file_thumbnail; + Ref<Texture2D> file_thumbnail_broken; bool use_thumbnails = (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS); @@ -645,7 +645,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2()); } - Ref<Texture> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog"); + Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); // Build the FileInfo list. @@ -656,7 +656,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { for (int i = 0; i < favorites.size(); i++) { String favorite = favorites[i]; String text; - Ref<Texture> icon; + Ref<Texture2D> icon; if (favorite == "res://") { text = "/"; icon = folder_icon; @@ -759,8 +759,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String fpath = finfo->path; String ftype = finfo->type; - Ref<Texture> type_icon; - Ref<Texture> big_icon; + Ref<Texture2D> type_icon; + Ref<Texture2D> big_icon; String tooltip = fpath; diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 49692c8349..d20d4add4e 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -176,7 +176,7 @@ private: ItemList *files; bool import_dock_needs_update; - Ref<Texture> _get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx); + Ref<Texture2D> _get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx); bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); Vector<String> _compute_uncollapsed_paths(); void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false); @@ -269,8 +269,8 @@ private: void _get_drag_target_folder(String &target, bool &target_favorites, const Point2 &p_point, Control *p_from) const; void _preview_invalidated(const String &p_path); - void _file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); - void _tree_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); + void _file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); + void _tree_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); void _update_display_mode(bool p_force = false); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index c76ff9d679..cd185ae12e 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -88,7 +88,7 @@ void GroupDialog::_load_nodes(Node *p_current) { node->set_metadata(0, path); node->set_tooltip(0, path); - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node"); node->set_icon(0, icon); if (!_can_edit(p_current, selected_group)) { diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index e2d8dc8962..bf293c3a5e 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -380,7 +380,7 @@ Error ColladaImport::_create_material(const String &p_target) { if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); @@ -405,7 +405,7 @@ Error ColladaImport::_create_material(const String &p_target) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); material->set_specular(1.0); @@ -432,7 +432,7 @@ Error ColladaImport::_create_material(const String &p_target) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); @@ -462,7 +462,7 @@ Error ColladaImport::_create_material(const String &p_target) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); material->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index d4664e1bb9..abdbdd29a9 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1277,7 +1277,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } else { uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows - Ref<Texture> texture = ResourceLoader::load(uri); + Ref<Texture2D> texture = ResourceLoader::load(uri); state.images.push_back(texture); continue; } @@ -1362,11 +1362,11 @@ Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) { return OK; } -Ref<Texture> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLTFTextureIndex p_texture) { - ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture>()); +Ref<Texture2D> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLTFTextureIndex p_texture) { + ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture2D>()); const GLTFImageIndex image = state.textures[p_texture].src_image; - ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture2D>()); return state.images[image]; } @@ -1423,7 +1423,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (mr.has("metallicRoughnessTexture")) { const Dictionary &bct = mr["metallicRoughnessTexture"]; if (bct.has("index")) { - const Ref<Texture> t = _get_texture(state, bct["index"]); + const Ref<Texture2D> t = _get_texture(state, bct["index"]); material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t); material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t); diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 78d7106b0d..a4a715d17c 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -310,7 +310,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Vector<int> root_nodes; Vector<GLTFTexture> textures; - Vector<Ref<Texture> > images; + Vector<Ref<Texture2D> > images; Vector<GLTFSkin> skins; Vector<GLTFCamera> cameras; @@ -335,7 +335,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { String _sanitize_bone_name(const String &name); String _gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name); - Ref<Texture> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture); + Ref<Texture2D> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture); Error _parse_json(const String &p_path, GLTFState &state); Error _parse_glb(const String &p_path, GLTFState &state); diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index 9b819bc341..01b938e690 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -40,24 +40,71 @@ String ResourceImporterLayeredTexture::get_importer_name() const { - return is_3d ? "texture_3d" : "texture_array"; + switch (mode) { + case MODE_CUBEMAP: { + return "cubemap_texture"; + } break; + case MODE_2D_ARRAY: { + return "2d_array_texture"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "cubemap_array_texture"; + } break; + } + + ERR_FAIL_V(""); } String ResourceImporterLayeredTexture::get_visible_name() const { - return is_3d ? "Texture3D" : "TextureArray"; + switch (mode) { + case MODE_CUBEMAP: { + return "Cubemap"; + } break; + case MODE_2D_ARRAY: { + return "Texture2DArray"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "CubemapArray"; + } break; + } + + ERR_FAIL_V(""); } void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_extensions) const { ImageLoader::get_recognized_extensions(p_extensions); } String ResourceImporterLayeredTexture::get_save_extension() const { - return is_3d ? "tex3d" : "texarr"; + switch (mode) { + case MODE_CUBEMAP: { + return "cube"; + } break; + case MODE_2D_ARRAY: { + return "tex2darr"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "cubearr"; + } break; + } + + ERR_FAIL_V(String()); } String ResourceImporterLayeredTexture::get_resource_type() const { - return is_3d ? "Texture3D" : "TextureArray"; + switch (mode) { + case MODE_CUBEMAP: { + return "Cubemap"; + } break; + case MODE_2D_ARRAY: { + return "Texture2DArray"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "CubemapArray"; + } break; + } + ERR_FAIL_V(String()); } bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { @@ -66,47 +113,48 @@ bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_optio } int ResourceImporterLayeredTexture::get_preset_count() const { - return 3; + return 0; } String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const { - static const char *preset_names[] = { - "3D", - "2D", - "ColorCorrect" - }; - - return preset_names[p_idx]; + return ""; } void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_COLOR_CORRECT ? 0 : 1)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/srgb", PROPERTY_HINT_ENUM, "Disable,Enable"), p_preset == PRESET_3D ? 1 : 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/horizontal", PROPERTY_HINT_RANGE, "1,256,1"), p_preset == PRESET_COLOR_CORRECT ? 16 : 8)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/vertical", PROPERTY_HINT_RANGE, "1,256,1"), p_preset == PRESET_COLOR_CORRECT ? 1 : 8)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), true)); + if (mode == MODE_2D_ARRAY) { + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/horizontal", PROPERTY_HINT_RANGE, "1,256,1"), 8)); + } + if (mode == MODE_2D_ARRAY || mode == MODE_CUBEMAP_ARRAY) { + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/vertical", PROPERTY_HINT_RANGE, "1,256,1"), 8)); + } } -void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags) { +void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps) { FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); f->store_8('G'); f->store_8('D'); - if (is_3d) { - f->store_8('3'); - } else { - f->store_8('A'); + switch (mode) { + case MODE_2D_ARRAY: f->store_8('A'); break; + case MODE_CUBEMAP: f->store_8('C'); break; + case MODE_CUBEMAP_ARRAY: f->store_8('X'); break; } + f->store_8('T'); //godot streamable texture f->store_32(p_images[0]->get_width()); f->store_32(p_images[0]->get_height()); f->store_32(p_images.size()); //depth - f->store_32(p_texture_flags); + uint32_t flags = 0; + if (p_mipmaps) { + flags |= TEXTURE_FLAGS_MIPMAPS; + } + f->store_32(flags); if (p_compress_mode != COMPRESS_VIDEO_RAM) { //vram needs to do a first compression to tell what the format is, for the rest its ok f->store_32(p_images[0]->get_format()); @@ -195,12 +243,18 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const int compress_mode = p_options["compress/mode"]; int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"]; - int repeat = p_options["flags/repeat"]; - bool filter = p_options["flags/filter"]; bool mipmaps = p_options["flags/mipmaps"]; - int srgb = p_options["flags/srgb"]; - int hslices = p_options["slices/horizontal"]; - int vslices = p_options["slices/vertical"]; + int channel_pack = p_options["compress/channel_pack"]; + int hslices = (p_options.has("slices/horizontal")) ? int(p_options["slices/horizontal"]) : 0; + int vslices = (p_options.has("slices/vertical")) ? int(p_options["slices/vertical"]) : 0; + + if (mode == MODE_CUBEMAP) { + hslices = 3; + vslices = 2; + } else if (mode == MODE_CUBEMAP_ARRAY) { + hslices = 3; + vslices *= 2; //put cubemaps vertically + } Ref<Image> image; image.instance(); @@ -208,17 +262,9 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const if (err != OK) return err; - int tex_flags = 0; - if (repeat > 0) - tex_flags |= Texture::FLAG_REPEAT; - if (repeat == 2) - tex_flags |= Texture::FLAG_MIRRORED_REPEAT; - if (filter) - tex_flags |= Texture::FLAG_FILTER; - if (mipmaps || compress_mode == COMPRESS_VIDEO_RAM) - tex_flags |= Texture::FLAG_MIPMAPS; - if (srgb == 1) - tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR; + if (compress_mode == COMPRESS_VIDEO_RAM) { + mipmaps = true; + } Vector<Ref<Image> > slices; @@ -228,7 +274,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const //optimize if (compress_mode == COMPRESS_VIDEO_RAM) { //if using video ram, optimize - if (srgb) { + if (channel_pack == 0) { //remove alpha if not needed, so compression is more efficient if (image->get_format() == Image::FORMAT_RGBA8 && !image->detect_alpha()) { image->convert(Image::FORMAT_RGB8); @@ -277,14 +323,14 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const if (encode_bptc) { - _save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps); r_platform_variants->push_back("bptc"); ok_on_pc = true; } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) { - _save_tex(slices, p_save_path + ".s3tc." + extension, compress_mode, Image::COMPRESS_S3TC, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".s3tc." + extension, compress_mode, Image::COMPRESS_S3TC, mipmaps); r_platform_variants->push_back("s3tc"); ok_on_pc = true; formats_imported.push_back("s3tc"); @@ -292,20 +338,20 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { - _save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, Image::COMPRESS_ETC2, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, Image::COMPRESS_ETC2, mipmaps); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) { - _save_tex(slices, p_save_path + ".etc." + extension, compress_mode, Image::COMPRESS_ETC, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".etc." + extension, compress_mode, Image::COMPRESS_ETC, mipmaps); r_platform_variants->push_back("etc"); formats_imported.push_back("etc"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { - _save_tex(slices, p_save_path + ".pvrtc." + extension, compress_mode, Image::COMPRESS_PVRTC4, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".pvrtc." + extension, compress_mode, Image::COMPRESS_PVRTC4, mipmaps); r_platform_variants->push_back("pvrtc"); formats_imported.push_back("pvrtc"); } @@ -315,7 +361,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const } } else { //import normally - _save_tex(slices, p_save_path + "." + extension, compress_mode, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags); + _save_tex(slices, p_save_path + "." + extension, compress_mode, Image::COMPRESS_S3TC /*this is ignored */, mipmaps); } if (r_metadata) { @@ -396,7 +442,7 @@ ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = NULL ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() { singleton = this; - is_3d = true; + mode = MODE_CUBEMAP; } ResourceImporterLayeredTexture::~ResourceImporterLayeredTexture() { diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index 6dc4b6ed3c..3dcf50e004 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -38,8 +38,19 @@ class StreamTexture; class ResourceImporterLayeredTexture : public ResourceImporter { GDCLASS(ResourceImporterLayeredTexture, ResourceImporter); +public: + enum Mode { + MODE_CUBEMAP, + MODE_2D_ARRAY, + MODE_CUBEMAP_ARRAY + }; + + enum TextureFlags { + TEXTURE_FLAGS_MIPMAPS = 1 + }; - bool is_3d; +private: + Mode mode; static const char *compression_formats[]; protected: @@ -57,12 +68,6 @@ public: virtual String get_save_extension() const; virtual String get_resource_type() const; - enum Preset { - PRESET_3D, - PRESET_2D, - PRESET_COLOR_CORRECT, - }; - enum CompressMode { COMPRESS_LOSSLESS, COMPRESS_VIDEO_RAM, @@ -75,7 +80,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags); + void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps); virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); @@ -84,7 +89,8 @@ public: virtual bool are_import_settings_valid(const String &p_path) const; virtual String get_import_settings_string() const; - void set_3d(bool p_3d) { is_3d = p_3d; } + void set_mode(Mode p_mode) { mode = p_mode; } + ResourceImporterLayeredTexture(); ~ResourceImporterLayeredTexture(); }; diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index bdd6a197f8..fedf1be94f 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -133,7 +133,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati path = base_path.plus_file(p); } - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); @@ -153,7 +153,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati path = base_path.plus_file(p); } - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); @@ -173,7 +173,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati path = base_path.plus_file(p); } - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture); @@ -187,7 +187,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati String p = l.replace("map_bump", "").replace("\\", "/").strip_edges(); String path = base_path.plus_file(p); - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 88547280ce..f1da5af31c 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -36,16 +36,18 @@ #include "editor/editor_node.h" #include "scene/resources/texture.h" -void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture> &p_tex) { +void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_channel) { singleton->mutex->lock(); StringName path = p_tex->get_path(); if (!singleton->make_flags.has(path)) { - singleton->make_flags[path] = 0; + singleton->make_flags[path] = MakeInfo(); } - singleton->make_flags[path] |= MAKE_SRGB_FLAG; + singleton->make_flags[path].flags |= MAKE_ROUGHNESS_FLAG; + singleton->make_flags[path].channel_for_roughness = p_channel; + singleton->make_flags[path].normal_path_for_roughness = p_normal_path; singleton->mutex->unlock(); } @@ -56,10 +58,10 @@ void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture> &p_t StringName path = p_tex->get_path(); if (!singleton->make_flags.has(path)) { - singleton->make_flags[path] = 0; + singleton->make_flags[path] = MakeInfo(); } - singleton->make_flags[path] |= MAKE_3D_FLAG; + singleton->make_flags[path].flags |= MAKE_3D_FLAG; singleton->mutex->unlock(); } @@ -70,10 +72,10 @@ void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture> StringName path = p_tex->get_path(); if (!singleton->make_flags.has(path)) { - singleton->make_flags[path] = 0; + singleton->make_flags[path] = MakeInfo(); } - singleton->make_flags[path] |= MAKE_NORMAL_FLAG; + singleton->make_flags[path].flags |= MAKE_NORMAL_FLAG; singleton->mutex->unlock(); } @@ -91,7 +93,7 @@ void ResourceImporterTexture::update_imports() { } Vector<String> to_reimport; - for (Map<StringName, int>::Element *E = make_flags.front(); E; E = E->next()) { + for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) { Ref<ConfigFile> cf; cf.instance(); @@ -101,22 +103,22 @@ void ResourceImporterTexture::update_imports() { ERR_CONTINUE(err != OK); bool changed = false; - if (E->get() & MAKE_SRGB_FLAG && int(cf->get_value("params", "flags/srgb")) == 2) { - cf->set_value("params", "flags/srgb", 1); + + if (E->get().flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) { + cf->set_value("params", "compress/normal_map", 1); changed = true; } - if (E->get() & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) { - cf->set_value("params", "compress/normal_map", 1); + if (E->get().flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) { + cf->set_value("params", "roughness/mode", E->get().channel_for_roughness + 2); + cf->set_value("params", "roughness/src_normal", E->get().normal_path_for_roughness); changed = true; } - if (E->get() & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d"))) { + if (E->get().flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d"))) { cf->set_value("params", "detect_3d", false); cf->set_value("params", "compress/mode", 2); - cf->set_value("params", "flags/repeat", true); - cf->set_value("params", "flags/filter", true); - cf->set_value("params", "flags/mipmaps", true); + cf->set_value("params", "format/mipmaps", true); changed = true; } @@ -142,7 +144,7 @@ String ResourceImporterTexture::get_importer_name() const { String ResourceImporterTexture::get_visible_name() const { - return "Texture"; + return "Texture2D"; } void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const { @@ -204,14 +206,12 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "Enabled,Force RGBE"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/bptc_ldr", PROPERTY_HINT_ENUM, "Enabled,RGBA Only"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/normal_map", PROPERTY_HINT_ENUM, "Detect,Enable,Disabled"), 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), p_preset == PRESET_3D ? 1 : 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), p_preset != PRESET_2D_PIXEL)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_3D)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/anisotropic"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/srgb", PROPERTY_HINT_ENUM, "Disable,Enable,Detect"), 2)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "format/mipmaps", PROPERTY_HINT_ENUM, "Detect,Disabled,Enabled"), p_preset == PRESET_DETECT ? 0 : (p_preset == PRESET_3D ? 2 : 1))); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "roughness/mode", PROPERTY_HINT_ENUM, "Detect,Disabled,Red,Green,Blue,Alpha,Gray"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "roughness/src_normal", PROPERTY_HINT_FILE, "*.png,*.jpg"), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/HDR_as_SRGB"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0)); @@ -219,7 +219,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "svg/scale", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 1.0)); } -void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_force_po2_for_compressed) { +void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed) { FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); f->store_8('G'); @@ -229,7 +229,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String bool resize_to_po2 = false; - if (p_compress_mode == COMPRESS_VIDEO_RAM && p_force_po2_for_compressed && (p_mipmaps || p_texture_flags & Texture::FLAG_REPEAT)) { + if (p_compress_mode == COMPRESS_VIDEO_RAM && p_force_po2_for_compressed && p_mipmaps) { resize_to_po2 = true; f->store_16(next_power_of_2(p_image->get_width())); f->store_16(p_image->get_width()); @@ -241,7 +241,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String f->store_16(p_image->get_height()); f->store_16(0); } - f->store_32(p_texture_flags); + f->store_32(0); //texture flags deprecated uint32_t format = 0; @@ -251,8 +251,8 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String format |= StreamTexture::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit if (p_detect_3d) format |= StreamTexture::FORMAT_BIT_DETECT_3D; - if (p_detect_srgb) - format |= StreamTexture::FORMAT_BIT_DETECT_SRGB; + if (p_detect_roughness) + format |= StreamTexture::FORMAT_BIT_DETECT_ROUGNESS; if (p_detect_normal) format |= StreamTexture::FORMAT_BIT_DETECT_NORMAL; @@ -335,7 +335,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String Image::CompressSource csource = Image::COMPRESS_SOURCE_GENERIC; if (p_force_normal) { csource = Image::COMPRESS_SOURCE_NORMAL; - } else if (p_texture_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + } else if (p_srgb_friendly) { csource = Image::COMPRESS_SOURCE_SRGB; } @@ -379,11 +379,8 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String int compress_mode = p_options["compress/mode"]; float lossy = p_options["compress/lossy_quality"]; - int repeat = p_options["flags/repeat"]; - bool filter = p_options["flags/filter"]; - bool mipmaps = p_options["flags/mipmaps"]; - bool anisotropic = p_options["flags/anisotropic"]; - int srgb = p_options["flags/srgb"]; + int pack_channels = p_options["compress/channel_pack"]; + bool mipmaps = p_options["format/mipmaps"]; bool fix_alpha_border = p_options["process/fix_alpha_border"]; bool premult_alpha = p_options["process/premult_alpha"]; bool invert_color = p_options["process/invert_color"]; @@ -394,6 +391,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String float scale = p_options["svg/scale"]; bool force_rgbe = p_options["compress/hdr_mode"]; int bptc_ldr = p_options["compress/bptc_ldr"]; + int roughness = p_options["roughness/mode"]; Ref<Image> image; image.instance(); @@ -403,20 +401,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String Array formats_imported; - int tex_flags = 0; - if (repeat > 0) - tex_flags |= Texture::FLAG_REPEAT; - if (repeat == 2) - tex_flags |= Texture::FLAG_MIRRORED_REPEAT; - if (filter) - tex_flags |= Texture::FLAG_FILTER; - if (mipmaps || compress_mode == COMPRESS_VIDEO_RAM) - tex_flags |= Texture::FLAG_MIPMAPS; - if (anisotropic) - tex_flags |= Texture::FLAG_ANISOTROPIC_FILTER; - if (srgb == 1) - tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR; - if (size_limit > 0 && (image->get_width() > size_limit || image->get_height() > size_limit)) { //limit size if (image->get_width() >= image->get_height()) { @@ -459,9 +443,10 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } bool detect_3d = p_options["detect_3d"]; - bool detect_srgb = srgb == 2; + bool detect_roughness = roughness == 0; bool detect_normal = normal == 0; bool force_normal = normal == 1; + bool srgb_friendly_pack = pack_channels == 0; if (compress_mode == COMPRESS_VIDEO_RAM) { //must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc). @@ -497,7 +482,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } if (can_bptc || can_s3tc) { - _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, can_bptc ? Image::COMPRESS_BPTC : Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, false); + _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, can_bptc ? Image::COMPRESS_BPTC : Image::COMPRESS_S3TC, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, false); r_platform_variants->push_back("s3tc"); formats_imported.push_back("s3tc"); ok_on_pc = true; @@ -505,20 +490,20 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { - _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true); + _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) { - _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true); + _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true); r_platform_variants->push_back("etc"); formats_imported.push_back("etc"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { - _save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true); + _save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true); r_platform_variants->push_back("pvrtc"); formats_imported.push_back("pvrtc"); } @@ -528,7 +513,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } } else { //import normally - _save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, false); + _save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, false); } if (r_metadata) { @@ -609,7 +594,7 @@ ResourceImporterTexture::ResourceImporterTexture() { singleton = this; StreamTexture::request_3d_callback = _texture_reimport_3d; - StreamTexture::request_srgb_callback = _texture_reimport_srgb; + StreamTexture::request_roughness_callback = _texture_reimport_roughness; StreamTexture::request_normal_callback = _texture_reimport_normal; mutex = Mutex::create(); } diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index fbfd47f4f0..acbfde8430 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -33,7 +33,7 @@ #include "core/image.h" #include "core/io/resource_importer.h" - +#include "servers/visual_server.h" class StreamTexture; class ResourceImporterTexture : public ResourceImporter { @@ -42,14 +42,25 @@ class ResourceImporterTexture : public ResourceImporter { protected: enum { MAKE_3D_FLAG = 1, - MAKE_SRGB_FLAG = 2, + MAKE_ROUGHNESS_FLAG = 2, MAKE_NORMAL_FLAG = 4 }; Mutex *mutex; - Map<StringName, int> make_flags; + struct MakeInfo { + + int flags; + String normal_path_for_roughness; + VS::TextureDetectRoughnessChannel channel_for_roughness; + MakeInfo() { + flags = 0; + channel_for_roughness = VS::TEXTURE_DETECT_ROUGNHESS_R; + } + }; + + Map<StringName, MakeInfo> make_flags; - static void _texture_reimport_srgb(const Ref<StreamTexture> &p_tex); + static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VisualServer::TextureDetectRoughnessChannel p_channel); static void _texture_reimport_3d(const Ref<StreamTexture> &p_tex); static void _texture_reimport_normal(const Ref<StreamTexture> &p_tex); @@ -84,7 +95,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_force_po2_for_compressed); + void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed); virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index 335e1114e6..00a25ec886 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -58,7 +58,7 @@ String ResourceImporterTextureAtlas::get_save_extension() const { String ResourceImporterTextureAtlas::get_resource_type() const { - return "Texture"; + return "Texture2D"; } bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { @@ -313,7 +313,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file new_atlas->save_png(p_group_file); //update cache if existing, else create - Ref<Texture> cache; + Ref<Texture2D> cache; if (ResourceCache::has(p_group_file)) { Resource *resptr = ResourceCache::get(p_group_file); cache.reference_ptr(resptr); @@ -331,7 +331,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file PackData &pack_data = pack_data_files.write[idx]; - Ref<Texture> texture; + Ref<Texture2D> texture; if (!pack_data.is_mesh) { Vector2 offset = charts[pack_data.chart_pieces[0]].vertices[0] + charts[pack_data.chart_pieces[0]].final_offset; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index ecd1e341d1..c681cdd033 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -215,7 +215,7 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); - Ref<Texture> base_icon = get_icon("Object", "EditorIcons"); + Ref<Texture2D> base_icon = get_icon("Object", "EditorIcons"); Set<ObjectID> already; for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) { @@ -230,7 +230,7 @@ void InspectorDock::_prepare_history() { already.insert(id); - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj, ""); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj, ""); if (icon.is_null()) { icon = base_icon; } diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index eef4db456c..b143f86ada 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -45,7 +45,7 @@ void PaneDrag::_notification(int p_what) { case NOTIFICATION_DRAW: { - Ref<Texture> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons"); + Ref<Texture2D> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) icon->draw(get_canvas_item(), Point2(0, 0)); @@ -62,7 +62,7 @@ void PaneDrag::_notification(int p_what) { } Size2 PaneDrag::get_minimum_size() const { - Ref<Texture> icon = get_icon("PaneDrag", "EditorIcons"); + Ref<Texture2D> icon = get_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) return icon->get_size(); return Size2(); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index c8a36a3a99..f38b95c615 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -573,7 +573,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); // All polygon points are sharp, so use the sharp handle icon - const Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); const Vertex active_point = get_active_point(); const int n_polygons = _get_polygon_count(); @@ -661,7 +661,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl if (edge_point.valid()) { - Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index d743d1ac2f..9261613ddd 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -202,8 +202,8 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { linecolor_soft.a *= 0.5; Ref<Font> font = get_font("font", "Label"); - Ref<Texture> icon = get_icon("KeyValue", "EditorIcons"); - Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons"); + Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons"); Size2 s = blend_space_draw->get_size(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index dc7754ba9a..358b763d0c 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -410,8 +410,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; Ref<Font> font = get_font("font", "Label"); - Ref<Texture> icon = get_icon("KeyValue", "EditorIcons"); - Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons"); + Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons"); Size2 s = blend_space_draw->get_size(); diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index 55c2f365ce..ab9db279d5 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -105,7 +105,7 @@ class AnimationPlayerEditor : public VBoxContainer { LineEdit *name; Label *name_title; UndoRedo *undo_redo; - Ref<Texture> autoplay_icon; + Ref<Texture2D> autoplay_icon; bool last_active; float timeline_position; diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 2a582a1249..63c837a216 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -514,7 +514,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co accent.a *= 0.6; } - Ref<Texture> icons[6] = { + Ref<Texture2D> icons[6] = { get_icon("TransitionImmediateBig", "EditorIcons"), get_icon("TransitionSyncBig", "EditorIcons"), get_icon("TransitionEndBig", "EditorIcons"), @@ -533,7 +533,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co } state_machine_draw->draw_line(p_from, p_to, linecolor, 2, true); - Ref<Texture> icon = icons[p_mode + (p_auto_advance ? 3 : 0)]; + Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)]; Transform2D xf; xf.elements[0] = (p_to - p_from).normalized(); @@ -578,9 +578,9 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { Ref<Font> font = get_font("title_font", "GraphNode"); Color font_color = get_color("title_color", "GraphNode"); - Ref<Texture> play = get_icon("Play", "EditorIcons"); - Ref<Texture> auto_play = get_icon("AutoPlay", "EditorIcons"); - Ref<Texture> edit = get_icon("Edit", "EditorIcons"); + Ref<Texture2D> play = get_icon("Play", "EditorIcons"); + Ref<Texture2D> auto_play = get_icon("AutoPlay", "EditorIcons"); + Ref<Texture2D> edit = get_icon("Edit", "EditorIcons"); Color accent = get_color("accent_color", "Editor"); Color linecolor = get_color("font_color", "Label"); linecolor.a *= 0.3; @@ -686,7 +686,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { _connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()), true, false, false, false); } - Ref<Texture> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons"); + Ref<Texture2D> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons"); float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8); //draw transition lines @@ -796,7 +796,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { nr.play.position = offset + Vector2(0, (h - play->get_height()) / 2).floor(); nr.play.size = play->get_size(); - Ref<Texture> play_tex = onstart ? auto_play : play; + Ref<Texture2D> play_tex = onstart ? auto_play : play; if (over_node == name && over_node_what == 0) { state_machine_draw->draw_texture(play_tex, nr.play.position, accent); @@ -918,14 +918,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { transition_mode->add_icon_item(get_icon("TransitionSync", "EditorIcons"), TTR("Sync")); transition_mode->add_icon_item(get_icon("TransitionEnd", "EditorIcons"), TTR("At End")); - //force filter on those, so they deform better - get_icon("TransitionImmediateBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionEndBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionSyncBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionImmediateAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionEndAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionSyncAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - tool_erase->set_icon(get_icon("Remove", "EditorIcons")); tool_autoplay->set_icon(get_icon("AutoPlay", "EditorIcons")); tool_end->set_icon(get_icon("AutoEnd", "EditorIcons")); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index d88a716122..a479703527 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -50,7 +50,7 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co price->set_text(p_cost); } -void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture> &p_image) { +void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) { ERR_FAIL_COND(p_type != EditorAssetLibrary::IMAGE_QUEUE_ICON); ERR_FAIL_COND(p_index != 0); @@ -145,7 +145,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { ////////////////////////////////////////////////////////////////////////////// -void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture> &p_image) { +void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) { switch (p_type) { @@ -393,7 +393,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int set_process(false); } -void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash) { +void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash) { title->set_text(p_title); icon->set_texture(p_preview); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 8852125b8b..e13d8a6149 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -68,7 +68,7 @@ class EditorAssetLibraryItem : public PanelContainer { void _category_clicked(); void _author_clicked(); - void set_image(int p_type, int p_index, const Ref<Texture> &p_image); + void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image); protected: void _notification(int p_what); @@ -95,19 +95,19 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog { bool is_video; String video_link; Button *button; - Ref<Texture> image; + Ref<Texture2D> image; }; Vector<Preview> preview_images; TextureRect *preview; - void set_image(int p_type, int p_index, const Ref<Texture> &p_image); + void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image); int asset_id; String download_url; String title; String sha256; - Ref<Texture> icon; + Ref<Texture2D> icon; void _link_click(const String &p_url); void _preview_click(int p_id); @@ -121,7 +121,7 @@ public: void add_preview(int p_id, bool p_video, const String &p_url); String get_title() { return title; } - Ref<Texture> get_preview_icon() { return icon; } + Ref<Texture2D> get_preview_icon() { return icon; } String get_download_url() { return download_url; } int get_asset_id() { return asset_id; } String get_sha256() { return sha256; } @@ -165,7 +165,7 @@ protected: public: void set_external_install(bool p_enable) { external_install = p_enable; } int get_asset_id() { return asset_id; } - void configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash); + void configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash); EditorAssetLibraryItemDownload(); }; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ab816dc7f3..11c188dca4 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2244,7 +2244,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { for (int i = 0; i < selection_results.size(); i++) { CanvasItem *item = selection_results[i].item; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(item, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(item, "Node"); String node_path = "/" + root_name + "/" + root_path.rel_path_to(item->get_path()); int locked = 0; @@ -2966,7 +2966,7 @@ void CanvasItemEditor::_draw_ruler_tool() { } else { if (grid_snap_active) { - Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons"); viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); } } @@ -3179,9 +3179,9 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { } void CanvasItemEditor::_draw_selection() { - Ref<Texture> pivot_icon = get_icon("EditorPivot", "EditorIcons"); - Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons"); - Ref<Texture> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons"); + Ref<Texture2D> pivot_icon = get_icon("EditorPivot", "EditorIcons"); + Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons"); RID ci = viewport->get_canvas_item(); @@ -3540,7 +3540,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position - Ref<Texture> position_icon = get_icon("EditorPositionUnselected", "EditorIcons"); + Ref<Texture2D> position_icon = get_icon("EditorPositionUnselected", "EditorIcons"); Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); @@ -3554,7 +3554,7 @@ void CanvasItemEditor::_draw_hover() { for (int i = 0; i < hovering_results.size(); i++) { - Ref<Texture> node_icon = hovering_results[i].icon; + Ref<Texture2D> node_icon = hovering_results[i].icon; String node_name = hovering_results[i].name; Ref<Font> font = get_font("font", "Label"); @@ -3608,13 +3608,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p if (canvas_item) { float offset = 0; - Ref<Texture> lock = get_icon("LockViewport", "EditorIcons"); + Ref<Texture2D> lock = get_icon("LockViewport", "EditorIcons"); if (p_node->has_meta("_edit_lock_") && show_edit_locks) { lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); offset += lock->get_size().x; } - Ref<Texture> group = get_icon("GroupViewport", "EditorIcons"); + Ref<Texture2D> group = get_icon("GroupViewport", "EditorIcons"); if (canvas_item->has_meta("_edit_group_") && show_edit_locks) { group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); //offset += group->get_size().x; @@ -5887,7 +5887,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons String path = files[i]; RES res = ResourceLoader::load(path); ERR_FAIL_COND(res.is_null()); - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); if (texture != NULL || scene != NULL) { if (texture != NULL) { @@ -5944,7 +5944,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) { child->set_name(path.get_file().get_basename()); - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(ResourceCache::get(path))); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(ResourceCache::get(path))); Size2 texture_size = texture->get_size(); if (parent) { @@ -6081,7 +6081,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { } } } else { - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); if (texture != NULL && texture.is_valid()) { Node *child; if (default_type == "Light2D") @@ -6136,7 +6136,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian continue; } memdelete(instanced_scene); - } else if (type == "Texture" || + } else if (type == "Texture2D" || type == "ImageTexture" || type == "ViewportTexture" || type == "CurveTexture" || @@ -6144,7 +6144,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian type == "StreamTexture" || type == "AtlasTexture" || type == "LargeTexture") { - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); if (!texture.is_valid()) { continue; } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index eb6e621c93..3c4cacf5c8 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -306,7 +306,7 @@ private: struct _HoverResult { Point2 position; - Ref<Texture> icon; + Ref<Texture2D> icon; String name; }; Vector<_HoverResult> hovering_results; @@ -406,8 +406,8 @@ private: Point2 box_selecting_to; Ref<StyleBoxTexture> select_sb; - Ref<Texture> select_handle; - Ref<Texture> anchor_handle; + Ref<Texture2D> select_handle; + Ref<Texture2D> anchor_handle; Ref<ShortCut> drag_pivot_shortcut; Ref<ShortCut> set_pivot_shortcut; diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 8620437ac6..f2b4fdfdf1 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -384,7 +384,7 @@ void Polygon3DEditor::_polygon_draw() { imgeom->clear(); imgeom->set_material_override(line_material); - imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture>()); + imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture2D>()); Rect2 rect; @@ -561,7 +561,7 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) { handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - Ref<Texture> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle); diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 179ebca562..01b4a61a85 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -435,7 +435,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Ref<Texture> h = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> h = get_icon("EditorHandle", "EditorIcons"); Vector2 size = h->get_size() * 0.5; handles.clear(); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index a4fc9b37ad..6438b3e6a8 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -787,10 +787,10 @@ bool CurvePreviewGenerator::handles(const String &p_type) const { return p_type == "Curve"; } -Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const { +Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const { Ref<Curve> curve_ref = p_from; - ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture>(), "It's not a reference to a valid Resource object."); + ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture2D>(), "It's not a reference to a valid Resource object."); Curve &curve = **curve_ref; // FIXME: Should be ported to use p_size as done in b2633a97 @@ -848,6 +848,6 @@ Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img_ref, 0); + ptex->create_from_image(img_ref); return ptex; } diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h index 06e2692373..c00aa3eca5 100644 --- a/editor/plugins/curve_editor_plugin.h +++ b/editor/plugins/curve_editor_plugin.h @@ -141,7 +141,7 @@ class CurvePreviewGenerator : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const Ref<Resource> &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const; }; #endif // CURVE_EDITOR_PLUGIN_H diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 9b0d5d3daf..2037c17b89 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -76,34 +76,34 @@ void post_process_preview(Ref<Image> p_image) { bool EditorTexturePreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } bool EditorTexturePreviewPlugin::generate_small_preview_automatically() const { return true; } -Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Image> img; Ref<AtlasTexture> atex = p_from; Ref<LargeTexture> ltex = p_from; if (atex.is_valid()) { - Ref<Texture> tex = atex->get_atlas(); + Ref<Texture2D> tex = atex->get_atlas(); if (!tex.is_valid()) { - return Ref<Texture>(); + return Ref<Texture2D>(); } Ref<Image> atlas = tex->get_data(); if (!atlas.is_valid()) { - return Ref<Texture>(); + return Ref<Texture2D>(); } img = atlas->get_rect(atex->get_region()); } else if (ltex.is_valid()) { img = ltex->to_image(); } else { - Ref<Texture> tex = p_from; + Ref<Texture2D> tex = p_from; if (tex.is_valid()) { img = tex->get_data(); if (img.is_valid()) { @@ -113,13 +113,13 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 } if (img.is_null() || img->empty()) - return Ref<Texture>(); + return Ref<Texture2D>(); img->clear_mipmaps(); if (img->is_compressed()) { if (img->decompress() != OK) - return Ref<Texture>(); + return Ref<Texture2D>(); } else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) { img->convert(Image::FORMAT_RGBA8); } @@ -137,7 +137,7 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -151,7 +151,7 @@ bool EditorImagePreviewPlugin::handles(const String &p_type) const { return p_type == "Image"; } -Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Image> img = p_from; @@ -182,7 +182,7 @@ Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 & Ref<ImageTexture> ptex; ptex.instance(); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -199,12 +199,12 @@ bool EditorBitmapPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "BitMap"); } -Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<BitMap> bm = p_from; if (bm->get_size() == Size2()) { - return Ref<Texture>(); + return Ref<Texture2D>(); } PoolVector<uint8_t> data; @@ -231,7 +231,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 if (img->is_compressed()) { if (img->decompress() != OK) - return Ref<Texture>(); + return Ref<Texture2D>(); } else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) { img->convert(Image::FORMAT_RGBA8); } @@ -249,7 +249,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -266,12 +266,13 @@ bool EditorPackedScenePreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "PackedScene"); } -Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { + +Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { return generate_from_path(p_from->get_path(), p_size); } -Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { +Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); @@ -282,7 +283,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_ String path = cache_base + ".png"; if (!FileAccess::exists(path)) - return Ref<Texture>(); + return Ref<Texture2D>(); Ref<Image> img; img.instance(); @@ -292,11 +293,11 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_ Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); post_process_preview(img); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } else { - return Ref<Texture>(); + return Ref<Texture2D>(); } } @@ -324,10 +325,10 @@ bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const { return true; } -Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Material> material = p_from; - ERR_FAIL_COND_V(material.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(material.is_null(), Ref<Texture2D>()); if (material->get_shader_mode() == Shader::MODE_SPATIAL) { @@ -342,7 +343,7 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>()); @@ -352,11 +353,11 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size img->resize(thumbnail_size, thumbnail_size, Image::INTERPOLATE_CUBIC); post_process_preview(img); Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } - return Ref<Texture>(); + return Ref<Texture2D>(); } EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { @@ -490,15 +491,15 @@ bool EditorScriptPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "Script"); } -Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Script> scr = p_from; if (scr.is_null()) - return Ref<Texture>(); + return Ref<Texture2D>(); String code = scr->get_source_code().strip_edges(); if (code == "") - return Ref<Texture>(); + return Ref<Texture2D>(); List<String> kwors; scr->get_language()->get_reserved_words(&kwors); @@ -599,7 +600,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -612,10 +613,10 @@ bool EditorAudioStreamPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "AudioStream"); } -Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<AudioStream> stream = p_from; - ERR_FAIL_COND_V(stream.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(stream.is_null(), Ref<Texture2D>()); PoolVector<uint8_t> img; @@ -627,7 +628,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S uint8_t *imgw = imgdata.ptr(); Ref<AudioStreamPlayback> playback = stream->instance_playback(); - ERR_FAIL_COND_V(playback.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(playback.is_null(), Ref<Texture2D>()); float len_s = stream->get_length(); if (len_s == 0) { @@ -687,7 +688,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S Ref<Image> image; image.instance(); image->create(w, h, false, Image::FORMAT_RGB8, img); - ptex->create_from_image(image, 0); + ptex->create_from_image(image); return ptex; } @@ -710,10 +711,10 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh } -Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Mesh> mesh = p_from; - ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>()); VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); @@ -726,7 +727,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p 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>(); + return Ref<Texture2D>(); m = 1.0 / m; m *= 0.5; xform.basis.scale(Vector3(m, m, m)); @@ -743,7 +744,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); VS::get_singleton()->instance_set_base(mesh_instance, RID()); @@ -762,7 +763,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p post_process_preview(img); Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -831,7 +832,7 @@ bool EditorFontPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont"); } -Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { +Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { RES res = ResourceLoader::load(p_path); Ref<DynamicFont> sampled_font; @@ -868,7 +869,7 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c VS::get_singleton()->canvas_item_clear(canvas_item); - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); img->convert(Image::FORMAT_RGBA8); @@ -885,16 +886,16 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c post_process_preview(img); Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } -Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { String path = p_from->get_path(); if (!FileAccess::exists(path)) { - return Ref<Texture>(); + return Ref<Texture2D>(); } return generate_from_path(path, p_size); } diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index e6e4aff8de..840fa2410a 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -41,7 +41,7 @@ class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorTexturePreviewPlugin(); }; @@ -52,7 +52,7 @@ class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorImagePreviewPlugin(); }; @@ -63,7 +63,7 @@ class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorBitmapPreviewPlugin(); }; @@ -72,8 +72,8 @@ class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; - virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const; EditorPackedScenePreviewPlugin(); }; @@ -102,7 +102,7 @@ protected: public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorMaterialPreviewPlugin(); ~EditorMaterialPreviewPlugin(); @@ -111,7 +111,7 @@ public: class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorScriptPreviewPlugin(); }; @@ -119,7 +119,7 @@ public: class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorAudioStreamPreviewPlugin(); }; @@ -146,7 +146,7 @@ protected: public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorMeshPreviewPlugin(); ~EditorMeshPreviewPlugin(); @@ -169,8 +169,8 @@ protected: public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; - virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const; EditorFontPreviewPlugin(); ~EditorFontPreviewPlugin(); diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 9f836ed0d3..b7dfe97081 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -105,7 +105,7 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const { String base = itos(i) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, base + "text")); - p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture")); + p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D")); int flags = get_flags(); diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h index 8a73367bf7..8dcf938139 100644 --- a/editor/plugins/item_list_editor_plugin.h +++ b/editor/plugins/item_list_editor_plugin.h @@ -66,8 +66,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) {} virtual String get_item_text(int p_idx) const { return ""; }; - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) {} - virtual Ref<Texture> get_item_icon(int p_idx) const { return Ref<Texture>(); }; + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) {} + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return Ref<Texture2D>(); }; virtual void set_item_checkable(int p_idx, bool p_check) {} virtual void set_item_radio_checkable(int p_idx, bool p_check) {} @@ -109,8 +109,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) { ob->set_item_text(p_idx, p_text); } virtual String get_item_text(int p_idx) const { return ob->get_item_text(p_idx); } - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { ob->set_item_icon(p_idx, p_tex); } - virtual Ref<Texture> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); } + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { ob->set_item_icon(p_idx, p_tex); } + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); } virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); } virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); } @@ -139,8 +139,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); } virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); } - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); } - virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); } + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx, p_check); } virtual void set_item_radio_checkable(int p_idx, bool p_check) { pp->set_item_as_radio_checkable(p_idx, p_check); } @@ -182,8 +182,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); } virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); } - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); } - virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); } + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); } virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 750f814319..7895c31778 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -59,7 +59,7 @@ void MaterialEditor::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -268,7 +268,7 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re // Texture parameter has to be treated specially since SpatialMaterial saved it // as RID but ShaderMaterial needs Texture itself - Ref<Texture> texture = mat->get_texture_by_name(E->get().name); + Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name); if (texture.is_valid()) { smat->set_shader_param(E->get().name, texture); } else { diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 42859e9190..b77cb6453f 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -182,7 +182,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, } } - Vector<Ref<Texture> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size")); + Vector<Ref<Texture2D> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size")); int j = 0; for (int i = 0; i < ids.size(); i++) { diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index b036368bc8..3a48673d8e 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -292,7 +292,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() { Ref<ImageTexture> imgt; imgt.instance(); - imgt->create_from_image(img, 0); + imgt->create_from_image(img); pm->set_emission_point_texture(imgt); pm->set_emission_point_count(vpc); @@ -314,7 +314,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() { img->create(w, h, false, Image::FORMAT_RGBA8, colordata); imgt.instance(); - imgt->create_from_image(img, 0); + imgt->create_from_image(img); pm->set_emission_color_texture(imgt); } @@ -337,7 +337,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() { img->create(w, h, false, Image::FORMAT_RGF, normdata); imgt.instance(); - imgt->create_from_image(img, 0); + imgt->create_from_image(img); pm->set_emission_normal_texture(imgt); } else { diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index f869dabf9a..cb29e11b9d 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -410,7 +410,6 @@ void ParticlesEditor::_generate_emission_points() { Ref<ImageTexture> tex; tex.instance(); - tex->create_from_image(image, Texture::FLAG_FILTER); Ref<ParticlesMaterial> material = node->get_process_material(); ERR_FAIL_COND(material.is_null()); @@ -440,7 +439,6 @@ void ParticlesEditor::_generate_emission_points() { Ref<ImageTexture> tex2; tex2.instance(); - tex2->create_from_image(image2, Texture::FLAG_FILTER); material->set_emission_normal_texture(tex2); } else { diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 3737dbdd57..9c5b7ecd01 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -373,12 +373,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - const Ref<Texture> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons"); - const Ref<Texture> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons"); + const Ref<Texture2D> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons"); // Both handle icons must be of the same size const Size2 handle_size = path_sharp_handle->get_size(); - const Ref<Texture> curve_handle = get_icon("EditorCurveHandle", "EditorIcons"); + const Ref<Texture2D> curve_handle = get_icon("EditorCurveHandle", "EditorIcons"); const Size2 curve_handle_size = curve_handle->get_size(); Ref<Curve2D> curve = node->get_curve(); @@ -420,7 +420,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (on_edge) { - Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 35c0142d4b..4cd30a5242 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -980,7 +980,7 @@ void Polygon2DEditor::_uv_draw() { if (!uv_edit->is_visible() || !_get_node()) return; - Ref<Texture> base_tex = node->get_texture(); + Ref<Texture2D> base_tex = node->get_texture(); if (base_tex.is_null()) return; @@ -1050,7 +1050,7 @@ void Polygon2DEditor::_uv_draw() { } // All UV points are sharp, so use the sharp handle icon - Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); + Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); Color poly_line_color = Color(0.9, 0.5, 0.5); if (polygons.size() || polygon_create.size()) { diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 3489537fa4..1349de5d8e 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -205,7 +205,7 @@ void EditorPropertyRootMotion::update_property() { assign->set_tooltip(p); if (p == NodePath()) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(TTR("Assign...")); assign->set_flat(false); return; @@ -222,7 +222,7 @@ void EditorPropertyRootMotion::update_property() { } if (!base_node || !base_node->has_node(p)) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(p); return; } @@ -242,7 +242,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) { void EditorPropertyRootMotion::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture> t = get_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_icon("Clear", "EditorIcons"); clear->set_icon(t); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 1da47196f8..078c1e9238 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1647,7 +1647,7 @@ struct _ScriptEditorItemData { String name; String sort_key; - Ref<Texture> icon; + Ref<Texture2D> icon; int index; String tooltip; bool used; @@ -1832,7 +1832,7 @@ void ScriptEditor::_update_script_names() { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - Ref<Texture> icon = se->get_icon(); + Ref<Texture2D> icon = se->get_icon(); String path = se->get_edited_resource()->get_path(); bool built_in = !path.is_resource_file(); String name; @@ -1893,7 +1893,7 @@ void ScriptEditor::_update_script_names() { if (eh) { String name = eh->get_class(); - Ref<Texture> icon = get_icon("Help", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Help", "EditorIcons"); String tooltip = vformat(TTR("%s Class Reference"), name); _ScriptEditorItemData sd; @@ -2416,7 +2416,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { HBoxContainer *drag_preview = memnew(HBoxContainer); String preview_name = ""; - Ref<Texture> preview_icon; + Ref<Texture2D> preview_icon; ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node); if (se) { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index a41480c80d..3fb67c7ecc 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -92,7 +92,7 @@ public: virtual void set_edited_resource(const RES &p_res) = 0; virtual void reload_text() = 0; virtual String get_name() = 0; - virtual Ref<Texture> get_icon() = 0; + virtual Ref<Texture2D> get_icon() = 0; virtual bool is_unsaved() = 0; virtual Variant get_edit_state() = 0; virtual void set_edit_state(const Variant &p_state) = 0; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 1432c3fc63..3a49538542 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -548,13 +548,13 @@ String ScriptTextEditor::get_name() { return name; } -Ref<Texture> ScriptTextEditor::get_icon() { +Ref<Texture2D> ScriptTextEditor::get_icon() { if (get_parent_control() && get_parent_control()->has_icon(script->get_class(), "EditorIcons")) { return get_parent_control()->get_icon(script->get_class(), "EditorIcons"); } - return Ref<Texture>(); + return Ref<Texture2D>(); } void ScriptTextEditor::_validate_script() { diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 9018e9d3c2..39c9d519eb 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -199,7 +199,7 @@ public: virtual Vector<String> get_functions(); virtual void reload_text(); virtual String get_name(); - virtual Ref<Texture> get_icon(); + virtual Ref<Texture2D> get_icon(); virtual bool is_unsaved(); virtual Variant get_edit_state(); virtual void set_edit_state(const Variant &p_state); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 8f7ff04b2c..5ff344166a 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -864,7 +864,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { Spatial *spat = selection_results[i].item; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node"); String node_path = "/" + root_name + "/" + root_path.rel_path_to(spat->get_path()); @@ -2371,7 +2371,7 @@ void SpatialEditorViewport::_notification(int p_what) { } } -static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture> icon) { +static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> icon) { // Adjust bar size from control height Vector2 surface_size = surface.get_size(); @@ -3841,12 +3841,12 @@ void SpatialEditorViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW && mouseover) { - Ref<Texture> h_grabber = get_icon("grabber", "HSplitContainer"); - Ref<Texture> v_grabber = get_icon("grabber", "VSplitContainer"); + Ref<Texture2D> h_grabber = get_icon("grabber", "HSplitContainer"); + Ref<Texture2D> v_grabber = get_icon("grabber", "VSplitContainer"); - Ref<Texture> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons"); - Ref<Texture> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons"); - Ref<Texture> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons"); + Ref<Texture2D> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons"); + Ref<Texture2D> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons"); + Ref<Texture2D> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons"); Vector2 size = get_size(); @@ -6181,7 +6181,7 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color materials[p_name] = mats; } -void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top, const Color &p_albedo) { +void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); @@ -6227,7 +6227,7 @@ void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); - Ref<Texture> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle_t->get_width()); handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle_t); handle_material->set_albedo(Color(1, 1, 1)); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 269e1715ef..f82d796cda 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -785,7 +785,7 @@ protected: public: void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); - void create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); + void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); void create_handle_material(const String &p_name, bool p_billboard = false); void add_material(const String &p_name, Ref<SpatialMaterial> p_material); diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp index 6757b180a3..9fd9fefee6 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_editor_plugin.cpp @@ -167,7 +167,7 @@ void SpriteEditor::_menu_option(int p_option) { void SpriteEditor::_update_mesh_data() { - Ref<Texture> texture = node->get_texture(); + Ref<Texture2D> texture = node->get_texture(); if (texture.is_null()) { err_dialog->set_text(TTR("Sprite is empty!")); err_dialog->popup_centered_minsize(); @@ -476,7 +476,7 @@ void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) void SpriteEditor::_debug_uv_draw() { - Ref<Texture> tex = node->get_texture(); + Ref<Texture2D> tex = node->get_texture(); ERR_FAIL_COND(!tex.is_valid()); Point2 draw_pos_offset = Point2(1.0, 1.0); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 4101980e29..2d756af213 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -44,7 +44,7 @@ void SpriteFramesEditor::_open_sprite_sheet() { file_split_sheet->clear_filters(); List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions); + ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); for (int i = 0; i < extensions.size(); i++) { file_split_sheet->add_filter("*." + extensions[i]); } @@ -249,11 +249,11 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, in ERR_FAIL_COND(!frames->has_animation(edited_anim)); - List<Ref<Texture> > resources; + List<Ref<Texture2D> > resources; for (int i = 0; i < p_path.size(); i++) { - Ref<Texture> resource; + Ref<Texture2D> resource; resource = ResourceLoader::load(p_path[i]); if (resource.is_null()) { @@ -278,7 +278,7 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, in int count = 0; - for (List<Ref<Texture> >::Element *E = resources.front(); E; E = E->next()) { + for (List<Ref<Texture2D> >::Element *E = resources.front(); E; E = E->next()) { undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos); @@ -297,7 +297,7 @@ void SpriteFramesEditor::_load_pressed() { file->clear_filters(); List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions); + ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); for (int i = 0; i < extensions.size(); i++) file->add_filter("*." + extensions[i]); @@ -310,7 +310,7 @@ void SpriteFramesEditor::_paste_pressed() { ERR_FAIL_COND(!frames->has_animation(edited_anim)); - Ref<Texture> r = EditorSettings::get_singleton()->get_resource_clipboard(); + Ref<Texture2D> r = EditorSettings::get_singleton()->get_resource_clipboard(); if (!r.is_valid()) { dialog->set_text(TTR("Resource clipboard is empty or not a texture!")); dialog->set_title(TTR("Error!")); @@ -333,7 +333,7 @@ void SpriteFramesEditor::_copy_pressed() { if (tree->get_current() < 0) return; - Ref<Texture> r = frames->get_frame(edited_anim, tree->get_current()); + Ref<Texture2D> r = frames->get_frame(edited_anim, tree->get_current()); if (!r.is_valid()) { return; } @@ -356,7 +356,7 @@ void SpriteFramesEditor::_empty_pressed() { from = frames->get_frame_count(edited_anim); } - Ref<Texture> r; + Ref<Texture2D> r; undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from); @@ -381,7 +381,7 @@ void SpriteFramesEditor::_empty2_pressed() { from = frames->get_frame_count(edited_anim); } - Ref<Texture> r; + Ref<Texture2D> r; undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from + 1); @@ -603,7 +603,7 @@ void SpriteFramesEditor::_animation_remove_confirmed() { undo_redo->add_undo_method(frames, "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim)); int fc = frames->get_frame_count(edited_anim); for (int i = 0; i < fc; i++) { - Ref<Texture> frame = frames->get_frame(edited_anim, i); + Ref<Texture2D> frame = frames->get_frame(edited_anim, i); undo_redo->add_undo_method(frames, "add_frame", edited_anim, frame); } undo_redo->add_do_method(this, "_update_library"); @@ -688,7 +688,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { for (int i = 0; i < frames->get_frame_count(edited_anim); i++) { String name; - Ref<Texture> icon; + Ref<Texture2D> icon; if (frames->get_frame(edited_anim, i).is_null()) { @@ -775,7 +775,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) { @@ -794,7 +794,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & String file = files[i]; String ftype = EditorFileSystem::get_singleton()->get_file_type(file); - if (!ClassDB::is_parent_class(ftype, "Texture")) { + if (!ClassDB::is_parent_class(ftype, "Texture2D")) { return false; } } @@ -819,7 +819,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) { bool reorder = false; diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 57447abf47..804a900582 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -163,7 +163,7 @@ String TextEditor::get_name() { return name; } -Ref<Texture> TextEditor::get_icon() { +Ref<Texture2D> TextEditor::get_icon() { return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), ""); } diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index fe157a29e6..81896d92be 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -120,7 +120,7 @@ public: virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter); virtual String get_name(); - virtual Ref<Texture> get_icon(); + virtual Ref<Texture2D> get_icon(); virtual RES get_edited_resource() const; virtual void set_edited_resource(const RES &p_res); void set_edited_file(const Ref<TextFile> &p_file); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 9489836984..675ba55b34 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -46,7 +46,7 @@ void TextureEditor::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -110,7 +110,7 @@ void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) { update(); } -void TextureEditor::edit(Ref<Texture> p_texture) { +void TextureEditor::edit(Ref<Texture2D> p_texture) { if (!texture.is_null()) texture->remove_change_receptor(this); @@ -148,11 +148,11 @@ bool EditorInspectorPluginTexture::can_handle(Object *p_object) { void EditorInspectorPluginTexture::parse_begin(Object *p_object) { - Texture *texture = Object::cast_to<Texture>(p_object); + Texture2D *texture = Object::cast_to<Texture2D>(p_object); if (!texture) { return; } - Ref<Texture> m(texture); + Ref<Texture2D> m(texture); TextureEditor *editor = memnew(TextureEditor); editor->edit(m); diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index f587579902..29ad0183dc 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -39,7 +39,7 @@ class TextureEditor : public Control { GDCLASS(TextureEditor, Control); - Ref<Texture> texture; + Ref<Texture2D> texture; protected: void _notification(int p_what); @@ -48,7 +48,7 @@ protected: static void _bind_methods(); public: - void edit(Ref<Texture> p_texture); + void edit(Ref<Texture2D> p_texture); TextureEditor(); ~TextureEditor(); }; @@ -66,7 +66,7 @@ class TextureEditorPlugin : public EditorPlugin { GDCLASS(TextureEditorPlugin, EditorPlugin); public: - virtual String get_name() const { return "Texture"; } + virtual String get_name() const { return "Texture2D"; } TextureEditorPlugin(EditorNode *p_node); }; diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 94aef60f1f..2350c20cb7 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -49,7 +49,7 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) { } void TextureRegionEditor::_region_draw() { - Ref<Texture> base_tex = NULL; + Ref<Texture2D> base_tex = NULL; if (node_sprite) base_tex = node_sprite->get_texture(); else if (node_sprite_3d) @@ -134,7 +134,7 @@ void TextureRegionEditor::_region_draw() { } } - Ref<Texture> select_handle = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> select_handle = get_icon("EditorHandle", "EditorIcons"); Rect2 scroll_rect(Point2(), base_tex->get_size()); @@ -672,7 +672,7 @@ void TextureRegionEditor::_update_autoslice() { autoslice_is_dirty = false; autoslice_cache.clear(); - Ref<Texture> texture = NULL; + Ref<Texture2D> texture = NULL; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) @@ -863,7 +863,7 @@ void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_pro } void TextureRegionEditor::_edit_region() { - Ref<Texture> texture = NULL; + Ref<Texture2D> texture = NULL; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 22105f7ed4..48d80a0017 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -122,7 +122,7 @@ struct _TECategory { Set<RefItem<StyleBox> > stylebox_items; Set<RefItem<Font> > font_items; - Set<RefItem<Texture> > icon_items; + Set<RefItem<Texture2D> > icon_items; Set<Item<Color> > color_items; Set<Item<int> > constant_items; @@ -167,7 +167,7 @@ void ThemeEditor::_save_template_cbk(String fname) { List<StringName> icon_list; Theme::get_default()->get_icon_list(E->key(), &icon_list); for (List<StringName>::Element *F = icon_list.front(); F; F = F->next()) { - _TECategory::RefItem<Texture> it; + _TECategory::RefItem<Texture2D> it; it.name = F->get(); it.item = Theme::get_default()->get_icon(F->get(), E->key()); tc.icon_items.insert(it); @@ -291,7 +291,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (tc.icon_items.size()) file->store_line("\n; Icon Items:\n"); - for (Set<_TECategory::RefItem<Texture> >::Element *F = tc.icon_items.front(); F; F = F->next()) { + for (Set<_TECategory::RefItem<Texture2D> >::Element *F = tc.icon_items.front(); F; F = F->next()) { file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -324,7 +324,7 @@ void ThemeEditor::_dialog_cbk() { switch (type_select->get_selected()) { - case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture>()); break; + case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture2D>()); break; case 1: theme->set_stylebox(name_edit->get_text(), type_edit->get_text(), Ref<StyleBox>()); break; case 2: theme->set_font(name_edit->get_text(), type_edit->get_text(), Ref<Font>()); break; case 3: theme->set_color(name_edit->get_text(), type_edit->get_text(), Color()); break; @@ -341,7 +341,7 @@ void ThemeEditor::_dialog_cbk() { names.clear(); Theme::get_default()->get_icon_list(fromtype, &names); for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - theme->set_icon(E->get(), fromtype, Ref<Texture>()); + theme->set_icon(E->get(), fromtype, Ref<Texture2D>()); } } { @@ -454,7 +454,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_icon_list(type, &icons); for (List<StringName>::Element *E = icons.front(); E; E = E->next()) { - theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture>()); + theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture2D>()); } List<StringName> shaders; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 0c3e29028c..425a759dac 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -468,7 +468,7 @@ void TileMapEditor::_update_palette() { palette->add_item(String()); } - Ref<Texture> tex = tileset->tile_get_texture(entries[i].id); + Ref<Texture2D> tex = tileset->tile_get_texture(entries[i].id); if (tex.is_valid()) { Rect2 region = tileset->tile_get_region(entries[i].id); @@ -528,7 +528,7 @@ void TileMapEditor::_update_palette() { }; entries2.sort_custom<SwapComparator>(); - Ref<Texture> tex = tileset->tile_get_texture(sel_tile); + Ref<Texture2D> tex = tileset->tile_get_texture(sel_tile); for (int i = 0; i < entries2.size(); i++) { @@ -761,7 +761,7 @@ void TileMapEditor::_erase_selection() { void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) { - Ref<Texture> t = node->get_tileset()->tile_get_texture(p_cell); + Ref<Texture2D> t = node->get_tileset()->tile_get_texture(p_cell); if (t.is_null()) return; diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index b24d5add9f..9907871e98 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -62,8 +62,8 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { } Sprite *mi = Object::cast_to<Sprite>(child); - Ref<Texture> texture = mi->get_texture(); - Ref<Texture> normal_map = mi->get_normal_map(); + Ref<Texture2D> texture = mi->get_texture(); + Ref<Texture2D> normal_map = mi->get_normal_map(); Ref<ShaderMaterial> material = mi->get_material(); if (texture.is_null()) @@ -195,7 +195,7 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) { @@ -237,7 +237,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) add_texture(texture); @@ -639,7 +639,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { texture_dialog->clear_filters(); List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions); + ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); for (List<String>::Element *E = extensions.front(); E; E = E->next()) { texture_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper()); @@ -753,7 +753,7 @@ void TileSetEditor::_on_texture_list_selected(int p_index) { void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) { int invalid_count = 0; for (int i = 0; i < p_paths.size(); i++) { - Ref<Texture> t = Ref<Texture>(ResourceLoader::load(p_paths[i])); + Ref<Texture2D> t = Ref<Texture2D>(ResourceLoader::load(p_paths[i])); ERR_CONTINUE_MSG(!t.is_valid(), "'" + p_paths[i] + "' is not a valid texture."); @@ -1183,7 +1183,7 @@ void TileSetEditor::_on_workspace_overlay_draw() { if (t_id < 0) return; - Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> handle = get_icon("EditorHandle", "EditorIcons"); if (draw_handles) { for (int i = 0; i < current_shape.size(); i++) { workspace_overlay->draw_texture(handle, current_shape[i] * workspace->get_scale().x - handle->get_size() * 0.5); @@ -3098,13 +3098,13 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) { return p; } -void TileSetEditor::add_texture(Ref<Texture> p_texture) { +void TileSetEditor::add_texture(Ref<Texture2D> p_texture) { texture_list->add_item(p_texture->get_path().get_file()); texture_map.insert(p_texture->get_rid(), p_texture); texture_list->set_item_metadata(texture_list->get_item_count() - 1, p_texture->get_rid()); } -void TileSetEditor::remove_texture(Ref<Texture> p_texture) { +void TileSetEditor::remove_texture(Ref<Texture2D> p_texture) { texture_list->remove_item(texture_list->find_metadata(p_texture->get_rid())); texture_map.erase(p_texture->get_rid()); @@ -3117,7 +3117,7 @@ void TileSetEditor::remove_texture(Ref<Texture> p_texture) { } void TileSetEditor::update_texture_list() { - Ref<Texture> selected_texture = get_current_texture(); + Ref<Texture2D> selected_texture = get_current_texture(); helper->set_tileset(tileset); @@ -3326,9 +3326,9 @@ void TileSetEditor::set_current_tile(int p_id) { } } -Ref<Texture> TileSetEditor::get_current_texture() { +Ref<Texture2D> TileSetEditor::get_current_texture() { if (texture_list->get_selected_items().size() == 0) - return Ref<Texture>(); + return Ref<Texture2D>(); else return texture_map[texture_list->get_item_metadata(texture_list->get_selected_items()[0])]; } @@ -3487,7 +3487,7 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const int id = tileset_editor->get_current_tile(); p_list->push_back(PropertyInfo(Variant::NIL, "Selected Tile", PROPERTY_HINT_NONE, "tile_", PROPERTY_USAGE_GROUP)); p_list->push_back(PropertyInfo(Variant::STRING, "tile_name")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture")); + p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_tex_offset")); p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial")); p_list->push_back(PropertyInfo(Variant::COLOR, "tile_modulate")); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index 0e0bd6448c..26340824a0 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -114,7 +114,7 @@ class TileSetEditor : public HSplitContainer { int option; ToolButton *tileset_toolbar_buttons[TOOL_TILESET_MAX]; MenuButton *tileset_toolbar_tools; - Map<RID, Ref<Texture> > texture_map; + Map<RID, Ref<Texture2D> > texture_map; bool creating_shape; int dragging_point; @@ -165,10 +165,10 @@ class TileSetEditor : public HSplitContainer { void update_texture_list(); void update_texture_list_icon(); - void add_texture(Ref<Texture> p_texture); - void remove_texture(Ref<Texture> p_texture); + void add_texture(Ref<Texture2D> p_texture); + void remove_texture(Ref<Texture2D> p_texture); - Ref<Texture> get_current_texture(); + Ref<Texture2D> get_current_texture(); static void _import_node(Node *p_node, Ref<TileSet> p_library); static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index fb095692bc..ae6087263e 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2693,8 +2693,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, -1)); texture_node_option_idx = add_options.size(); - add_options.push_back(AddOption("Texture", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1)); - + add_options.push_back(AddOption("Texture2D", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1)); add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, -1)); add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, -1)); add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, -1, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL)); @@ -2894,7 +2893,7 @@ public: void setup(const Ref<VisualShaderNodeInput> &p_input) { input = p_input; - Ref<Texture> type_icon[5] = { + Ref<Texture2D> type_icon[5] = { EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"), EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"), EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"), diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 9cc2a79399..14b24892b2 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -107,9 +107,9 @@ private: void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS, InputType input_type = PROJECT_PATH) { msg->set_text(p_msg); - Ref<Texture> current_path_icon = status_rect->get_texture(); - Ref<Texture> current_install_icon = install_status_rect->get_texture(); - Ref<Texture> new_icon; + Ref<Texture2D> current_path_icon = status_rect->get_texture(); + Ref<Texture2D> current_install_icon = install_status_rect->get_texture(); + Ref<Texture2D> new_icon; switch (p_type) { @@ -1141,8 +1141,8 @@ void ProjectList::_notification(int p_what) { void ProjectList::load_project_icon(int p_index) { Item &item = _projects.write[p_index]; - Ref<Texture> default_icon = get_icon("DefaultProjectIcon", "EditorIcons"); - Ref<Texture> icon; + Ref<Texture2D> default_icon = get_icon("DefaultProjectIcon", "EditorIcons"); + Ref<Texture2D> icon; if (item.icon != "") { Ref<Image> img; img.instance(); @@ -1304,7 +1304,7 @@ void ProjectList::create_project_item_control(int p_index) { Item &item = _projects.write[p_index]; ERR_FAIL_COND(item.control != NULL); // Already created - Ref<Texture> favorite_icon = get_icon("Favorites", "EditorIcons"); + Ref<Texture2D> favorite_icon = get_icon("Favorites", "EditorIcons"); Color font_color = get_color("font_color", "Tree"); ProjectListItemControl *hb = memnew(ProjectListItemControl); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 2dcbc4c14c..63f0b02a40 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -935,7 +935,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: const String &t = j->get(); bool is_custom_resource = false; - Ref<Texture> icon; + Ref<Texture2D> icon; if (!custom_resources.empty()) { for (int k = 0; k < custom_resources.size(); k++) { if (custom_resources[k].name == t) { @@ -1023,7 +1023,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); - Ref<Texture> icon; + Ref<Texture2D> icon; if (has_icon(what, "EditorIcons")) { icon = get_icon(what, "EditorIcons"); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 426ec51e4c..fdb1ce3e62 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -120,7 +120,7 @@ void PropertySelector::_update_search() { bool found = false; - Ref<Texture> type_icons[Variant::VARIANT_MAX] = { + Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -159,7 +159,7 @@ void PropertySelector::_update_search() { category->set_text(0, E->get().name); category->set_selectable(0, false); - Ref<Texture> icon; + Ref<Texture2D> icon; if (E->get().name == "Script Variables") { icon = get_icon("Script", "EditorIcons"); } else { @@ -234,7 +234,7 @@ void PropertySelector::_update_search() { category->set_text(0, E->get().name.replace_first("*", "")); category->set_selectable(0, false); - Ref<Texture> icon; + Ref<Texture2D> icon; script_methods = false; String rep = E->get().name.replace("*", ""); if (E->get().name == "*Script Methods") { diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index 43963d3aae..f9efe6a50d 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -98,7 +98,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { // Save source PNG. Ref<ImageTexture> t = memnew(ImageTexture); - t->create_from_image(Ref<Image>(p_image), 0); + t->create_from_image(Ref<Image>(p_image)); ResourceSaver::save(src_img, t); Error err = OS::get_singleton()->execute(ttpath, args, true); @@ -109,7 +109,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { ERR_FAIL_MSG("Could not execute PVRTC tool: " + ttpath); } - t = ResourceLoader::load(dst_img, "Texture"); + t = ResourceLoader::load(dst_img, "Texture2D"); if (t.is_null()) { // Clean up generated files. DirAccess::remove_file_or_error(src_img); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 4cd70b0f8e..ea92e6407c 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -122,7 +122,7 @@ float EditorQuickOpen::_path_cmp(String search, String path) const { return path.to_lower().similarity(search.to_lower()); } -void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list) { +void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D> > > &list) { if (!add_directories) { for (int i = 0; i < efsd->get_subdir_count(); i++) { @@ -140,7 +140,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str if (path != "res://") { path = path.substr(6, path.length()); if (search_text.is_subsequence_ofi(path)) { - Pair<String, Ref<Texture> > pair; + Pair<String, Ref<Texture2D> > pair; pair.first = path; pair.second = get_icon("folder", "FileDialog"); @@ -169,7 +169,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str file = file.substr(6, file.length()); if (ClassDB::is_parent_class(efsd->get_file_type(i), base_type) && (search_text.is_subsequence_ofi(file))) { - Pair<String, Ref<Texture> > pair; + Pair<String, Ref<Texture2D> > pair; pair.first = file; pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); list.push_back(pair); @@ -184,10 +184,10 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str } } -Vector<Pair<String, Ref<Texture> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture> > > &list) { +Vector<Pair<String, Ref<Texture2D> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D> > > &list) { String search_text = search_box->get_text(); - Vector<Pair<String, Ref<Texture> > > sorted_list; + Vector<Pair<String, Ref<Texture2D> > > sorted_list; if (search_text == String() || list.size() == 0) return list; @@ -223,7 +223,7 @@ void EditorQuickOpen::_update_search() { search_options->clear(); TreeItem *root = search_options->create_item(); EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); - Vector<Pair<String, Ref<Texture> > > list; + Vector<Pair<String, Ref<Texture2D> > > list; _parse_fs(efsd, list); list = _sort_fs(list); diff --git a/editor/quick_open.h b/editor/quick_open.h index a4eb44c805..4814e5f310 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -49,8 +49,8 @@ class EditorQuickOpen : public ConfirmationDialog { void _update_search(); void _sbox_input(const Ref<InputEvent> &p_ie); - void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list); - Vector<Pair<String, Ref<Texture> > > _sort_fs(Vector<Pair<String, Ref<Texture> > > &list); + void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D> > > &list); + Vector<Pair<String, Ref<Texture2D> > > _sort_fs(Vector<Pair<String, Ref<Texture2D> > > &list); float _path_cmp(String search, String path) const; void _confirmed(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 7410a998ad..34d6d0580e 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2371,7 +2371,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { if (!obj) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); if (menu->get_item_count() == 0) { menu->add_submenu_item(TTR("Sub-Resources"), "Sub-Resources"); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index c49ea72e99..c168418972 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -205,7 +205,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_collapsed(true); } - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(p_node, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_node, "Node"); item->set_icon(0, icon); item->set_metadata(0, p_node->get_path()); @@ -929,7 +929,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from return Variant(); //not editable tree Vector<Node *> selected; - Vector<Ref<Texture> > icons; + Vector<Ref<Texture2D> > icons; TreeItem *next = tree->get_next_selected(NULL); while (next) { diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index c4627e6627..a3764b4085 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -47,13 +47,13 @@ void ScriptCreateDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { for (int i = 0; i < ScriptServer::get_language_count(); i++) { String lang = ScriptServer::get_language(i)->get_type(); - Ref<Texture> lang_icon = get_icon(lang, "EditorIcons"); + Ref<Texture2D> lang_icon = get_icon(lang, "EditorIcons"); if (lang_icon.is_valid()) { language_menu->set_item_icon(i, lang_icon); } } String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); - Ref<Texture> last_lang_icon; + Ref<Texture2D> last_lang_icon; if (!last_lang.empty()) { for (int i = 0; i < language_menu->get_item_count(); i++) { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 34547717fd..f1946953db 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -434,7 +434,7 @@ int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &node item->set_text(0, item_text); item->set_tooltip(0, TTR("Type:") + " " + item_type); ObjectID id = ObjectID(nodes[current_index + 3]); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], ""); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], ""); if (icon.is_valid()) { item->set_icon(0, icon); } @@ -1281,8 +1281,8 @@ void ScriptEditorDebugger::_notification(int p_what) { if (error_count == 0 && warning_count == 0) { errors_tab->set_name(TTR("Errors")); debugger_button->set_text(TTR("Debugger")); - debugger_button->set_icon(Ref<Texture>()); - tabs->set_tab_icon(errors_tab->get_index(), Ref<Texture>()); + debugger_button->set_icon(Ref<Texture2D>()); + tabs->set_tab_icon(errors_tab->get_index(), Ref<Texture2D>()); } else { errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); |