summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_bezier_editor.cpp6
-rw-r--r--editor/animation_bezier_editor.h6
-rw-r--r--editor/animation_track_editor.cpp56
-rw-r--r--editor/animation_track_editor.h14
-rw-r--r--editor/animation_track_editor_plugins.cpp20
-rw-r--r--editor/animation_track_editor_plugins.h4
-rw-r--r--editor/code_editor.cpp4
-rw-r--r--editor/code_editor.h2
-rw-r--r--editor/connections_dialog.cpp2
-rw-r--r--editor/create_dialog.h2
-rw-r--r--editor/dependency_editor.cpp12
-rw-r--r--editor/doc/doc_data.cpp4
-rw-r--r--editor/editor_asset_installer.cpp4
-rw-r--r--editor/editor_audio_buses.cpp6
-rw-r--r--editor/editor_audio_buses.h2
-rw-r--r--editor/editor_data.cpp2
-rw-r--r--editor/editor_data.h4
-rw-r--r--editor/editor_export.cpp4
-rw-r--r--editor/editor_export.h8
-rw-r--r--editor/editor_file_dialog.cpp22
-rw-r--r--editor/editor_file_dialog.h8
-rw-r--r--editor/editor_help.cpp2
-rw-r--r--editor/editor_help_search.cpp4
-rw-r--r--editor/editor_help_search.h2
-rw-r--r--editor/editor_inspector.cpp16
-rw-r--r--editor/editor_inspector.h2
-rw-r--r--editor/editor_log.cpp6
-rw-r--r--editor/editor_node.cpp66
-rw-r--r--editor/editor_node.h10
-rw-r--r--editor/editor_path.cpp4
-rw-r--r--editor/editor_plugin.cpp19
-rw-r--r--editor/editor_plugin.h6
-rw-r--r--editor/editor_profiler.cpp4
-rw-r--r--editor/editor_properties.cpp26
-rw-r--r--editor/editor_properties.h2
-rw-r--r--editor/editor_resource_preview.cpp22
-rw-r--r--editor/editor_resource_preview.h14
-rw-r--r--editor/editor_run_native.cpp2
-rw-r--r--editor/editor_spin_slider.cpp6
-rw-r--r--editor/editor_themes.cpp9
-rw-r--r--editor/editor_visual_profiler.cpp863
-rw-r--r--editor/editor_visual_profiler.h154
-rw-r--r--editor/filesystem_dock.cpp26
-rw-r--r--editor/filesystem_dock.h6
-rw-r--r--editor/groups_editor.cpp2
-rw-r--r--editor/icons/icon_o_r_m_material_3d.svg66
-rw-r--r--editor/icons/icon_standard_material_3d.svg11
-rw-r--r--editor/icons/icon_track_color.svg61
-rw-r--r--editor/import/editor_import_collada.cpp44
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp57
-rw-r--r--editor/import/editor_scene_importer_gltf.h4
-rw-r--r--editor/import/resource_importer_layered_texture.cpp150
-rw-r--r--editor/import/resource_importer_layered_texture.h58
-rw-r--r--editor/import/resource_importer_obj.cpp30
-rw-r--r--editor/import/resource_importer_scene.cpp8
-rw-r--r--editor/import/resource_importer_texture.cpp383
-rw-r--r--editor/import/resource_importer_texture.h42
-rw-r--r--editor/import/resource_importer_texture_atlas.cpp6
-rw-r--r--editor/inspector_dock.cpp4
-rw-r--r--editor/pane_drag.cpp4
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp8
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp4
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp10
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp3
-rw-r--r--editor/plugins/animation_player_editor_plugin.h2
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp26
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp6
-rw-r--r--editor/plugins/asset_library_editor_plugin.h12
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.cpp2
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.h2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp45
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h6
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp33
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.h4
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/curve_editor_plugin.cpp12
-rw-r--r--editor/plugins/curve_editor_plugin.h2
-rw-r--r--editor/plugins/editor_preview_plugins.cpp90
-rw-r--r--editor/plugins/editor_preview_plugins.h22
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp73
-rw-r--r--editor/plugins/gi_probe_editor_plugin.h6
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp2
-rw-r--r--editor/plugins/item_list_editor_plugin.h16
-rw-r--r--editor/plugins/material_editor_plugin.cpp20
-rw-r--r--editor/plugins/material_editor_plugin.h4
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp2
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp2
-rw-r--r--editor/plugins/particles_2d_editor_plugin.cpp6
-rw-r--r--editor/plugins/particles_editor_plugin.cpp2
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp16
-rw-r--r--editor/plugins/path_editor_plugin.cpp6
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp12
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp6
-rw-r--r--editor/plugins/script_editor_plugin.cpp8
-rw-r--r--editor/plugins/script_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp4
-rw-r--r--editor/plugins/script_text_editor.h2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp271
-rw-r--r--editor/plugins/spatial_editor_plugin.h34
-rw-r--r--editor/plugins/sprite_editor_plugin.cpp6
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp28
-rw-r--r--editor/plugins/text_editor.cpp2
-rw-r--r--editor/plugins/text_editor.h2
-rw-r--r--editor/plugins/texture_editor_plugin.cpp9
-rw-r--r--editor/plugins/texture_editor_plugin.h6
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp8
-rw-r--r--editor/plugins/theme_editor_plugin.cpp12
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp6
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp50
-rw-r--r--editor/plugins/tile_set_editor_plugin.h8
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp5
-rw-r--r--editor/project_manager.cpp12
-rw-r--r--editor/property_editor.cpp4
-rw-r--r--editor/property_selector.cpp6
-rw-r--r--editor/pvrtc_compress.cpp4
-rw-r--r--editor/quick_open.cpp12
-rw-r--r--editor/quick_open.h4
-rw-r--r--editor/scene_tree_dock.cpp2
-rw-r--r--editor/scene_tree_editor.cpp4
-rw-r--r--editor/script_create_dialog.cpp4
-rw-r--r--editor/script_editor_debugger.cpp70
-rw-r--r--editor/script_editor_debugger.h3
-rw-r--r--editor/spatial_editor_gizmos.cpp33
-rw-r--r--editor/spatial_editor_gizmos.h3
124 files changed, 2497 insertions, 984 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..c128ca4321 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc/doc_data.cpp
@@ -304,6 +304,8 @@ void DocData::generate(bool p_basic_types) {
}
}
+ //used to track uninitialized values using valgrind
+ //print_line("getting default value for " + String(name) + "." + String(E->get().name));
if (default_value_valid && default_value.get_type() != Variant::OBJECT) {
prop.default_value = default_value.get_construct_string().replace("\n", "");
}
@@ -483,7 +485,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..4552ce1348 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");
}
@@ -343,6 +343,27 @@ void EditorNode::_notification(int p_what) {
scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")));
+ { //TODO should only happen on settings changed
+ int current_filter = GLOBAL_GET("rendering/canvas_textures/default_texture_filter");
+ if (current_filter != scene_root->get_default_canvas_item_texture_filter()) {
+ Viewport::DefaultCanvasItemTextureFilter tf = (Viewport::DefaultCanvasItemTextureFilter)current_filter;
+ scene_root->set_default_canvas_item_texture_filter(tf);
+ }
+ int current_repeat = GLOBAL_GET("rendering/canvas_textures/default_texture_repeat");
+ if (current_repeat != scene_root->get_default_canvas_item_texture_repeat()) {
+ Viewport::DefaultCanvasItemTextureRepeat tr = (Viewport::DefaultCanvasItemTextureRepeat)current_repeat;
+ scene_root->set_default_canvas_item_texture_repeat(tr);
+ }
+
+ VS::DOFBokehShape dof_shape = VS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape")));
+ VS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape);
+ VS::DOFBlurQuality dof_quality = VS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality")));
+ bool dof_jitter = GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter");
+ VS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter);
+ VS::get_singleton()->environment_set_ssao_quality(VS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
+ VS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve"));
+ }
+
ResourceImporterTexture::get_singleton()->update_imports();
} break;
@@ -350,8 +371,6 @@ void EditorNode::_notification(int p_what) {
Engine::get_singleton()->set_editor_hint(true);
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
- get_tree()->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING); //reduce memory usage
- get_tree()->get_root()->set_disable_3d(true);
get_tree()->get_root()->set_as_audio_listener(false);
get_tree()->get_root()->set_as_audio_listener_2d(false);
get_tree()->set_auto_accept_quit(false);
@@ -461,7 +480,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 +2961,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 +3786,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 +3831,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 +3926,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 +4751,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 +4991,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
@@ -5337,6 +5356,8 @@ void EditorNode::_update_video_driver_color() {
video_driver->add_color_override("font_color", Color::hex(0x5586a4ff));
} else if (video_driver->get_text() == "GLES3") {
video_driver->add_color_override("font_color", Color::hex(0xa5557dff));
+ } else if (video_driver->get_text() == "Vulkan") {
+ video_driver->add_color_override("font_color", Color::hex(0xad1128ff));
}
}
@@ -5582,7 +5603,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 +5702,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);
@@ -5807,7 +5832,7 @@ EditorNode::EditorNode() {
EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false);
EDITOR_DEF("interface/inspector/horizontal_vector_types_editing", true);
EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true);
- EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "SpatialMaterial,Script,MeshLibrary,TileSet");
+ EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "StandardMaterial3D,ORMMaterial3D,Script,MeshLibrary,TileSet");
EDITOR_DEF("interface/inspector/default_color_picker_mode", 0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT));
EDITOR_DEF("run/auto_save/save_before_running", true);
@@ -6040,7 +6065,6 @@ EditorNode::EditorNode() {
scene_root = memnew(Viewport);
//scene_root->set_usage(Viewport::USAGE_2D); canvas BG mode prevents usage of this as 2D
- scene_root->set_disable_3d(true);
VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
scene_root->set_disable_input(true);
@@ -6666,7 +6690,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TextureRegionEditorPlugin(this)));
add_editor_plugin(memnew(Particles2DEditorPlugin(this)));
add_editor_plugin(memnew(GIProbeEditorPlugin(this)));
- add_editor_plugin(memnew(BakedLightmapEditorPlugin(this)));
+ // add_editor_plugin(memnew(BakedLightmapEditorPlugin(this)));
add_editor_plugin(memnew(Path2DEditorPlugin(this)));
add_editor_plugin(memnew(PathEditorPlugin(this)));
add_editor_plugin(memnew(Line2DEditorPlugin(this)));
@@ -6702,7 +6726,7 @@ EditorNode::EditorNode() {
resource_preview->add_preview_generator(Ref<EditorFontPreviewPlugin>(memnew(EditorFontPreviewPlugin)));
{
- Ref<SpatialMaterialConversionPlugin> spatial_mat_convert;
+ Ref<StandardMaterial3DConversionPlugin> spatial_mat_convert;
spatial_mat_convert.instance();
resource_conversion_plugins.push_back(spatial_mat_convert);
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..ce847d02eb 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;
@@ -68,7 +68,6 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>
RID viewport = VS::get_singleton()->viewport_create();
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ALWAYS);
- VS::get_singleton()->viewport_set_vflip(viewport, true);
VS::get_singleton()->viewport_set_scenario(viewport, scenario);
VS::get_singleton()->viewport_set_size(viewport, size, size);
VS::get_singleton()->viewport_set_transparent_background(viewport, true);
@@ -87,13 +86,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 +113,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 +130,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 +313,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 +604,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..0794940cb1 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>());
}
}
@@ -1019,7 +1019,7 @@ void EditorPropertyEasing::_draw_easing() {
prev = h;
}
- easing_draw->draw_multiline(lines, line_color, 1.0, true);
+ easing_draw->draw_multiline(lines, line_color, 1.0);
f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), font_color);
}
@@ -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..c0f58c9aae 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);
}
}
}
@@ -476,7 +476,7 @@ EditorResourcePreview::EditorResourcePreview() {
thread = NULL;
singleton = this;
preview_mutex = Mutex::create();
- preview_sem = Semaphore::create();
+ preview_sem = SemaphoreOld::create();
order = 0;
exit = false;
exited = false;
diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h
index 8091fbafdc..0a89154243 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;
@@ -71,14 +71,14 @@ class EditorResourcePreview : public Node {
List<QueueItem> queue;
Mutex *preview_mutex;
- Semaphore *preview_sem;
+ SemaphoreOld *preview_sem;
Thread *thread;
volatile bool exit;
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/editor_visual_profiler.cpp b/editor/editor_visual_profiler.cpp
new file mode 100644
index 0000000000..3f3da7c4a5
--- /dev/null
+++ b/editor/editor_visual_profiler.cpp
@@ -0,0 +1,863 @@
+/*************************************************************************/
+/* editor_visual_profiler.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_visual_profiler.h"
+
+#include "core/os/os.h"
+#include "editor_scale.h"
+#include "editor_settings.h"
+
+void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
+
+ ++last_metric;
+ if (last_metric >= frame_metrics.size())
+ last_metric = 0;
+
+ frame_metrics.write[last_metric] = p_metric;
+ // _make_metric_ptrs(frame_metrics.write[last_metric]);
+
+ List<String> stack;
+ for (int i = 0; i < frame_metrics[last_metric].areas.size(); i++) {
+ String name = frame_metrics[last_metric].areas[i].name;
+ frame_metrics.write[last_metric].areas.write[i].color_cache = _get_color_from_signature(name);
+ String full_name;
+
+ if (name[0] == '<') {
+ stack.pop_back();
+ }
+
+ if (stack.size()) {
+ full_name = stack.back()->get() + name;
+ } else {
+ full_name = name;
+ }
+
+ if (name[0] == '>') {
+
+ stack.push_back(full_name + "/");
+ }
+
+ frame_metrics.write[last_metric].areas.write[i].fullpath_cache = full_name;
+ }
+
+ updating_frame = true;
+ cursor_metric_edit->set_max(frame_metrics[last_metric].frame_number);
+ cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0));
+
+ if (!seeking) {
+ cursor_metric_edit->set_value(frame_metrics[last_metric].frame_number);
+ if (hover_metric != -1) {
+ hover_metric++;
+ if (hover_metric >= frame_metrics.size()) {
+ hover_metric = 0;
+ }
+ }
+ }
+ updating_frame = false;
+
+ if (frame_delay->is_stopped()) {
+
+ frame_delay->set_wait_time(0.1);
+ frame_delay->start();
+ }
+
+ if (plot_delay->is_stopped()) {
+ plot_delay->set_wait_time(0.1);
+ plot_delay->start();
+ }
+}
+
+void EditorVisualProfiler::clear() {
+
+ int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size");
+ metric_size = CLAMP(metric_size, 60, 1024);
+ frame_metrics.clear();
+ frame_metrics.resize(metric_size);
+ last_metric = -1;
+ variables->clear();
+ //activate->set_pressed(false);
+
+ updating_frame = true;
+ cursor_metric_edit->set_min(0);
+ cursor_metric_edit->set_max(0);
+ cursor_metric_edit->set_value(0);
+ updating_frame = false;
+ hover_metric = -1;
+ seeking = false;
+}
+
+static String _get_percent_txt(float p_value, float p_total) {
+ if (p_total == 0)
+ p_total = 0.00001;
+ return String::num((p_value / p_total) * 100, 1) + "%";
+}
+
+String EditorVisualProfiler::_get_time_as_text(float p_time) {
+
+ int dmode = display_mode->get_selected();
+
+ if (dmode == DISPLAY_FRAME_TIME) {
+ return rtos(p_time) + "ms";
+ } else if (dmode == DISPLAY_FRAME_PERCENT) {
+ return String::num(p_time * 100 / graph_limit, 2) + "%"; //_get_percent_txt(p_time, m.frame_time);
+ }
+
+ return "err";
+}
+
+Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const {
+
+ Color bc = get_color("error_color", "Editor");
+ double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
+ Color c;
+ c.set_hsv(rot, bc.get_s(), bc.get_v());
+ return c.linear_interpolate(get_color("base_color", "Editor"), 0.07);
+}
+
+void EditorVisualProfiler::_item_selected() {
+
+ if (updating_frame)
+ return;
+
+ TreeItem *item = variables->get_selected();
+ if (!item)
+ return;
+ selected_area = item->get_metadata(0);
+ _update_plot();
+}
+
+void EditorVisualProfiler::_update_plot() {
+
+ int w = graph->get_size().width;
+ int h = graph->get_size().height;
+
+ bool reset_texture = false;
+
+ int desired_len = w * h * 4;
+
+ if (graph_image.size() != desired_len) {
+ reset_texture = true;
+ graph_image.resize(desired_len);
+ }
+
+ PoolVector<uint8_t>::Write wr = graph_image.write();
+
+ //clear
+ for (int i = 0; i < desired_len; i += 4) {
+ wr[i + 0] = 0;
+ wr[i + 1] = 0;
+ wr[i + 2] = 0;
+ wr[i + 3] = 255;
+ }
+
+ //find highest value
+
+ float highest_cpu = 0;
+ float highest_gpu = 0;
+
+ for (int i = 0; i < frame_metrics.size(); i++) {
+ const Metric &m = frame_metrics[i];
+ if (!m.valid)
+ continue;
+
+ if (m.areas.size()) {
+ highest_cpu = MAX(highest_cpu, m.areas[m.areas.size() - 1].cpu_time);
+ highest_gpu = MAX(highest_gpu, m.areas[m.areas.size() - 1].gpu_time);
+ }
+ }
+
+ if (highest_cpu > 0 || highest_gpu > 0) {
+
+ if (frame_relative->is_pressed()) {
+ highest_cpu = MAX(graph_limit, highest_cpu);
+ highest_gpu = MAX(graph_limit, highest_gpu);
+ }
+
+ if (linked->is_pressed()) {
+ float highest = MAX(highest_cpu, highest_gpu);
+ highest_cpu = highest_gpu = highest;
+ }
+
+ //means some data exists..
+ highest_cpu *= 1.2; //leave some upper room
+ highest_gpu *= 1.2; //leave some upper room
+ graph_height_cpu = highest_cpu;
+ graph_height_gpu = highest_gpu;
+
+ Vector<Color> columnv_cpu;
+ columnv_cpu.resize(h);
+ Color *column_cpu = columnv_cpu.ptrw();
+
+ Vector<Color> columnv_gpu;
+ columnv_gpu.resize(h);
+ Color *column_gpu = columnv_gpu.ptrw();
+
+ int half_w = w / 2;
+ for (int i = 0; i < half_w; i++) {
+ for (int j = 0; j < h; j++) {
+ column_cpu[j] = Color(0, 0, 0, 0);
+ column_gpu[j] = Color(0, 0, 0, 0);
+ }
+
+ int current = i * frame_metrics.size() / half_w;
+ int next = (i + 1) * frame_metrics.size() / half_w;
+ if (next > frame_metrics.size()) {
+ next = frame_metrics.size();
+ }
+ if (next == current)
+ next = current + 1; //just because for loop must work
+
+ for (int j = current; j < next; j++) {
+
+ //wrap
+ int idx = last_metric + 1 + j;
+ while (idx >= frame_metrics.size()) {
+ idx -= frame_metrics.size();
+ }
+
+ int area_count = frame_metrics[idx].areas.size();
+ const Metric::Area *areas = frame_metrics[idx].areas.ptr();
+ int prev_cpu = 0;
+ int prev_gpu = 0;
+ for (int k = 1; k < area_count; k++) {
+ int ofs_cpu = int(areas[k].cpu_time * h / highest_cpu);
+ ofs_cpu = CLAMP(ofs_cpu, 0, h - 1);
+ Color color = selected_area == areas[k - 1].fullpath_cache ? Color(1, 1, 1, 1) : areas[k - 1].color_cache;
+
+ for (int l = prev_cpu; l < ofs_cpu; l++) {
+ column_cpu[h - l - 1] += color;
+ }
+ prev_cpu = ofs_cpu;
+
+ int ofs_gpu = int(areas[k].gpu_time * h / highest_gpu);
+ ofs_gpu = CLAMP(ofs_gpu, 0, h - 1);
+ for (int l = prev_gpu; l < ofs_gpu; l++) {
+ column_gpu[h - l - 1] += color;
+ }
+
+ prev_gpu = ofs_gpu;
+ }
+ }
+
+ //plot CPU
+ for (int j = 0; j < h; j++) {
+
+ uint8_t r, g, b;
+
+ if (column_cpu[j].a == 0) {
+ r = 0;
+ g = 0;
+ b = 0;
+ } else {
+ r = CLAMP((column_cpu[j].r / column_cpu[j].a) * 255.0, 0, 255);
+ g = CLAMP((column_cpu[j].g / column_cpu[j].a) * 255.0, 0, 255);
+ b = CLAMP((column_cpu[j].b / column_cpu[j].a) * 255.0, 0, 255);
+ }
+
+ int widx = (j * w + i) * 4;
+ wr[widx + 0] = r;
+ wr[widx + 1] = g;
+ wr[widx + 2] = b;
+ wr[widx + 3] = 255;
+ }
+ //plot GPU
+ for (int j = 0; j < h; j++) {
+
+ uint8_t r, g, b;
+
+ if (column_gpu[j].a == 0) {
+ r = 0;
+ g = 0;
+ b = 0;
+ } else {
+ r = CLAMP((column_gpu[j].r / column_gpu[j].a) * 255.0, 0, 255);
+ g = CLAMP((column_gpu[j].g / column_gpu[j].a) * 255.0, 0, 255);
+ b = CLAMP((column_gpu[j].b / column_gpu[j].a) * 255.0, 0, 255);
+ }
+
+ int widx = (j * w + w / 2 + i) * 4;
+ wr[widx + 0] = r;
+ wr[widx + 1] = g;
+ wr[widx + 2] = b;
+ wr[widx + 3] = 255;
+ }
+ }
+ }
+
+ wr.release();
+
+ Ref<Image> img;
+ img.instance();
+ img->create(w, h, 0, Image::FORMAT_RGBA8, graph_image);
+
+ if (reset_texture) {
+
+ if (graph_texture.is_null()) {
+ graph_texture.instance();
+ }
+ graph_texture->create_from_image(img);
+ }
+
+ graph_texture->update(img, true);
+
+ graph->set_texture(graph_texture);
+ graph->update();
+}
+
+void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
+
+ int cursor_metric = _get_cursor_index();
+
+ Ref<Texture> track_icon = get_icon("TrackColor", "EditorIcons");
+
+ ERR_FAIL_INDEX(cursor_metric, frame_metrics.size());
+
+ updating_frame = true;
+ variables->clear();
+
+ TreeItem *root = variables->create_item();
+ const Metric &m = frame_metrics[cursor_metric];
+
+ List<TreeItem *> stack;
+ List<TreeItem *> categories;
+
+ TreeItem *ensure_selected = nullptr;
+
+ for (int i = 1; i < m.areas.size() - 1; i++) {
+
+ TreeItem *parent = stack.size() ? stack.back()->get() : root;
+
+ String name = m.areas[i].name;
+
+ float cpu_time = m.areas[i].cpu_time;
+ float gpu_time = m.areas[i].gpu_time;
+ if (i < m.areas.size() - 1) {
+ cpu_time = m.areas[i + 1].cpu_time - cpu_time;
+ gpu_time = m.areas[i + 1].gpu_time - gpu_time;
+ }
+
+ if (name.begins_with(">")) {
+ TreeItem *category = variables->create_item(parent);
+
+ stack.push_back(category);
+ categories.push_back(category);
+
+ name = name.substr(1, name.length());
+
+ category->set_text(0, name);
+ category->set_metadata(1, cpu_time);
+ category->set_metadata(2, gpu_time);
+ continue;
+ }
+
+ if (name.begins_with("<")) {
+ stack.pop_back();
+ continue;
+ }
+ TreeItem *category = variables->create_item(parent);
+
+ for (List<TreeItem *>::Element *E = stack.front(); E; E = E->next()) {
+ float total_cpu = E->get()->get_metadata(1);
+ float total_gpu = E->get()->get_metadata(2);
+ total_cpu += cpu_time;
+ total_gpu += gpu_time;
+ E->get()->set_metadata(1, cpu_time);
+ E->get()->set_metadata(2, gpu_time);
+ }
+
+ category->set_icon(0, track_icon);
+ category->set_icon_modulate(0, m.areas[i].color_cache);
+ category->set_selectable(0, true);
+ category->set_metadata(0, m.areas[i].fullpath_cache);
+ category->set_text(0, m.areas[i].name);
+ category->set_text(1, _get_time_as_text(cpu_time));
+ category->set_metadata(1, m.areas[i].cpu_time);
+ category->set_text(2, _get_time_as_text(gpu_time));
+ category->set_metadata(2, m.areas[i].gpu_time);
+
+ if (selected_area == m.areas[i].fullpath_cache) {
+ category->select(0);
+ if (p_focus_selected) {
+ ensure_selected = category;
+ }
+ }
+ }
+
+ for (List<TreeItem *>::Element *E = categories.front(); E; E = E->next()) {
+ float total_cpu = E->get()->get_metadata(1);
+ float total_gpu = E->get()->get_metadata(2);
+ E->get()->set_text(1, _get_time_as_text(total_cpu));
+ E->get()->set_text(2, _get_time_as_text(total_gpu));
+ }
+
+ if (ensure_selected) {
+ variables->ensure_cursor_is_visible();
+ }
+ updating_frame = false;
+}
+
+void EditorVisualProfiler::_activate_pressed() {
+
+ if (activate->is_pressed()) {
+ activate->set_icon(get_icon("Stop", "EditorIcons"));
+ activate->set_text(TTR("Stop"));
+ _clear_pressed(); //always clear on start
+ } else {
+ activate->set_icon(get_icon("Play", "EditorIcons"));
+ activate->set_text(TTR("Start"));
+ }
+ emit_signal("enable_profiling", activate->is_pressed());
+}
+
+void EditorVisualProfiler::_clear_pressed() {
+
+ clear();
+ _update_plot();
+}
+
+void EditorVisualProfiler::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ activate->set_icon(get_icon("Play", "EditorIcons"));
+ clear_button->set_icon(get_icon("Clear", "EditorIcons"));
+ }
+}
+
+void EditorVisualProfiler::_graph_tex_draw() {
+
+ if (last_metric < 0)
+ return;
+ Ref<Font> font = get_font("font", "Label");
+ if (seeking) {
+
+ int max_frames = frame_metrics.size();
+ int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1);
+ if (frame < 0)
+ frame = 0;
+
+ int half_width = graph->get_size().x / 2;
+ int cur_x = frame * half_width / max_frames;
+ //cur_x /= 2.0;
+
+ graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.8));
+ graph->draw_line(Vector2(cur_x + half_width, 0), Vector2(cur_x + half_width, graph->get_size().y), Color(1, 1, 1, 0.8));
+ }
+
+ if (graph_height_cpu > 0) {
+ int frame_y = graph->get_size().y - graph_limit * graph->get_size().y / graph_height_cpu - 1;
+
+ int half_width = graph->get_size().x / 2;
+
+ graph->draw_line(Vector2(0, frame_y), Vector2(half_width, frame_y), Color(1, 1, 1, 0.3));
+
+ String limit_str = String::num(graph_limit, 2);
+ graph->draw_string(font, Vector2(half_width - font->get_string_size(limit_str).x - 2, frame_y - 2), limit_str, Color(1, 1, 1, 0.6));
+ }
+
+ if (graph_height_gpu > 0) {
+ int frame_y = graph->get_size().y - graph_limit * graph->get_size().y / graph_height_gpu - 1;
+
+ int half_width = graph->get_size().x / 2;
+
+ graph->draw_line(Vector2(half_width, frame_y), Vector2(graph->get_size().x, frame_y), Color(1, 1, 1, 0.3));
+
+ String limit_str = String::num(graph_limit, 2);
+ graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str).x - 2, frame_y - 2), limit_str, Color(1, 1, 1, 0.6));
+ }
+
+ graph->draw_string(font, Vector2(font->get_string_size("X").x, font->get_ascent() + 2), "CPU:", Color(1, 1, 1, 0.8));
+ graph->draw_string(font, Vector2(font->get_string_size("X").x + graph->get_size().width / 2, font->get_ascent() + 2), "GPU:", Color(1, 1, 1, 0.8));
+
+ /*
+ if (hover_metric != -1 && frame_metrics[hover_metric].valid) {
+
+ int max_frames = frame_metrics.size();
+ int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1);
+ if (frame < 0)
+ frame = 0;
+
+ int cur_x = frame * graph->get_size().x / max_frames;
+
+ graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.4));
+ }
+*/
+}
+
+void EditorVisualProfiler::_graph_tex_mouse_exit() {
+
+ hover_metric = -1;
+ graph->update();
+}
+
+void EditorVisualProfiler::_cursor_metric_changed(double) {
+ if (updating_frame)
+ return;
+
+ graph->update();
+ _update_frame();
+}
+
+void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
+
+ if (last_metric < 0)
+ return;
+
+ Ref<InputEventMouse> me = p_ev;
+ Ref<InputEventMouseButton> mb = p_ev;
+ Ref<InputEventMouseMotion> mm = p_ev;
+
+ if (
+ (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) ||
+ (mm.is_valid())) {
+
+ int half_w = graph->get_size().width / 2;
+ int x = me->get_position().x;
+ if (x > half_w) {
+ x -= half_w;
+ }
+ x = x * frame_metrics.size() / half_w;
+
+ bool show_hover = x >= 0 && x < frame_metrics.size();
+
+ if (x < 0) {
+ x = 0;
+ }
+
+ if (x >= frame_metrics.size()) {
+ x = frame_metrics.size() - 1;
+ }
+
+ int metric = frame_metrics.size() - x - 1;
+ metric = last_metric - metric;
+ while (metric < 0) {
+ metric += frame_metrics.size();
+ }
+
+ if (show_hover) {
+
+ hover_metric = metric;
+
+ } else {
+ hover_metric = -1;
+ }
+
+ if (mb.is_valid() || mm->get_button_mask() & BUTTON_MASK_LEFT) {
+ //cursor_metric=x;
+ updating_frame = true;
+
+ //metric may be invalid, so look for closest metric that is valid, this makes snap feel better
+ bool valid = false;
+ for (int i = 0; i < frame_metrics.size(); i++) {
+
+ if (frame_metrics[metric].valid) {
+ valid = true;
+ break;
+ }
+
+ metric++;
+ if (metric >= frame_metrics.size())
+ metric = 0;
+ }
+
+ if (!valid) {
+ return;
+ }
+
+ cursor_metric_edit->set_value(frame_metrics[metric].frame_number);
+
+ updating_frame = false;
+
+ if (activate->is_pressed()) {
+ if (!seeking) {
+ //probably not need to break request, can just stop profiling
+ //emit_signal("break_request");
+ }
+ }
+
+ seeking = true;
+
+ if (!frame_delay->is_processing()) {
+ frame_delay->set_wait_time(0.1);
+ frame_delay->start();
+ }
+
+ bool touched_cpu = me->get_position().x < graph->get_size().width * 0.5;
+
+ const Metric::Area *areas = frame_metrics[metric].areas.ptr();
+ int area_count = frame_metrics[metric].areas.size();
+ float posy = (1.0 - (me->get_position().y / graph->get_size().height)) * (touched_cpu ? graph_height_cpu : graph_height_gpu);
+ int last_valid = -1;
+ bool found = false;
+ for (int i = 0; i < area_count - 1; i++) {
+
+ if (areas[i].name[0] != '<' && areas[i].name[0] != '>') {
+ last_valid = i;
+ }
+ float h = touched_cpu ? areas[i + 1].cpu_time : areas[i + 1].gpu_time;
+
+ if (h > posy) {
+ found = true;
+ break;
+ }
+ }
+
+ StringName area_found;
+ if (found && last_valid != -1) {
+ area_found = areas[last_valid].fullpath_cache;
+ }
+
+ if (area_found != selected_area) {
+ selected_area = area_found;
+ _update_frame(true);
+ _update_plot();
+ }
+ }
+
+ graph->update();
+ }
+}
+
+int EditorVisualProfiler::_get_cursor_index() const {
+
+ if (last_metric < 0)
+ return 0;
+ if (!frame_metrics[last_metric].valid)
+ return 0;
+
+ int diff = (frame_metrics[last_metric].frame_number - cursor_metric_edit->get_value());
+
+ int idx = last_metric - diff;
+ while (idx < 0) {
+ idx += frame_metrics.size();
+ }
+
+ return idx;
+}
+
+void EditorVisualProfiler::disable_seeking() {
+
+ seeking = false;
+ graph->update();
+}
+
+void EditorVisualProfiler::_combo_changed(int) {
+
+ _update_frame();
+ _update_plot();
+}
+
+void EditorVisualProfiler::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("_update_frame"), &EditorVisualProfiler::_update_frame, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("_update_plot"), &EditorVisualProfiler::_update_plot);
+ ClassDB::bind_method(D_METHOD("_activate_pressed"), &EditorVisualProfiler::_activate_pressed);
+ ClassDB::bind_method(D_METHOD("_clear_pressed"), &EditorVisualProfiler::_clear_pressed);
+ ClassDB::bind_method(D_METHOD("_graph_tex_draw"), &EditorVisualProfiler::_graph_tex_draw);
+ ClassDB::bind_method(D_METHOD("_graph_tex_input"), &EditorVisualProfiler::_graph_tex_input);
+ ClassDB::bind_method(D_METHOD("_graph_tex_mouse_exit"), &EditorVisualProfiler::_graph_tex_mouse_exit);
+ ClassDB::bind_method(D_METHOD("_cursor_metric_changed"), &EditorVisualProfiler::_cursor_metric_changed);
+ ClassDB::bind_method(D_METHOD("_combo_changed"), &EditorVisualProfiler::_combo_changed);
+
+ ClassDB::bind_method(D_METHOD("_item_selected"), &EditorVisualProfiler::_item_selected);
+ ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable")));
+ ADD_SIGNAL(MethodInfo("break_request"));
+}
+
+void EditorVisualProfiler::set_enabled(bool p_enable) {
+
+ activate->set_disabled(!p_enable);
+}
+
+bool EditorVisualProfiler::is_profiling() {
+ return activate->is_pressed();
+}
+
+Vector<Vector<String> > EditorVisualProfiler::get_data_as_csv() const {
+ Vector<Vector<String> > res;
+#if 0
+ if (frame_metrics.empty()) {
+ return res;
+ }
+
+ // signatures
+ Vector<String> signatures;
+ const Vector<EditorFrameProfiler::Metric::Category> &categories = frame_metrics[0].categories;
+
+ for (int j = 0; j < categories.size(); j++) {
+
+ const EditorFrameProfiler::Metric::Category &c = categories[j];
+ signatures.push_back(c.signature);
+
+ for (int k = 0; k < c.items.size(); k++) {
+ signatures.push_back(c.items[k].signature);
+ }
+ }
+ res.push_back(signatures);
+
+ // values
+ Vector<String> values;
+ values.resize(signatures.size());
+
+ int index = last_metric;
+
+ for (int i = 0; i < frame_metrics.size(); i++) {
+
+ ++index;
+
+ if (index >= frame_metrics.size()) {
+ index = 0;
+ }
+
+ if (!frame_metrics[index].valid) {
+ continue;
+ }
+ int it = 0;
+ const Vector<EditorFrameProfiler::Metric::Category> &frame_cat = frame_metrics[index].categories;
+
+ for (int j = 0; j < frame_cat.size(); j++) {
+
+ const EditorFrameProfiler::Metric::Category &c = frame_cat[j];
+ values.write[it++] = String::num_real(c.total_time);
+
+ for (int k = 0; k < c.items.size(); k++) {
+ values.write[it++] = String::num_real(c.items[k].total);
+ }
+ }
+ res.push_back(values);
+ }
+#endif
+ return res;
+}
+
+EditorVisualProfiler::EditorVisualProfiler() {
+
+ HBoxContainer *hb = memnew(HBoxContainer);
+ add_child(hb);
+ activate = memnew(Button);
+ activate->set_toggle_mode(true);
+ activate->set_text(TTR("Start"));
+ activate->connect("pressed", this, "_activate_pressed");
+ hb->add_child(activate);
+
+ clear_button = memnew(Button);
+ clear_button->set_text(TTR("Clear"));
+ clear_button->connect("pressed", this, "_clear_pressed");
+ hb->add_child(clear_button);
+
+ hb->add_child(memnew(Label(TTR("Measure:"))));
+
+ display_mode = memnew(OptionButton);
+ display_mode->add_item(TTR("Frame Time (msec)"));
+ display_mode->add_item(TTR("Frame %"));
+ display_mode->connect("item_selected", this, "_combo_changed");
+
+ hb->add_child(display_mode);
+
+ frame_relative = memnew(CheckBox(TTR("Fit to Frame")));
+ frame_relative->set_pressed(true);
+ hb->add_child(frame_relative);
+ frame_relative->connect("pressed", this, "_update_plot");
+ linked = memnew(CheckBox(TTR("Linked")));
+ linked->set_pressed(true);
+ hb->add_child(linked);
+ linked->connect("pressed", this, "_update_plot");
+
+ hb->add_spacer();
+
+ hb->add_child(memnew(Label(TTR("Frame #:"))));
+
+ cursor_metric_edit = memnew(SpinBox);
+ cursor_metric_edit->set_h_size_flags(SIZE_FILL);
+ hb->add_child(cursor_metric_edit);
+ cursor_metric_edit->connect("value_changed", this, "_cursor_metric_changed");
+
+ hb->add_constant_override("separation", 8 * EDSCALE);
+
+ h_split = memnew(HSplitContainer);
+ add_child(h_split);
+ h_split->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ variables = memnew(Tree);
+ variables->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
+ variables->set_hide_folding(true);
+ h_split->add_child(variables);
+ variables->set_hide_root(true);
+ variables->set_columns(3);
+ variables->set_column_titles_visible(true);
+ variables->set_column_title(0, TTR("Name"));
+ variables->set_column_expand(0, true);
+ variables->set_column_min_width(0, 60);
+ variables->set_column_title(1, TTR("CPU"));
+ variables->set_column_expand(1, false);
+ variables->set_column_min_width(1, 60 * EDSCALE);
+ variables->set_column_title(2, TTR("GPU"));
+ variables->set_column_expand(2, false);
+ variables->set_column_min_width(2, 60 * EDSCALE);
+ variables->connect("cell_selected", this, "_item_selected");
+
+ graph = memnew(TextureRect);
+ graph->set_expand(true);
+ graph->set_mouse_filter(MOUSE_FILTER_STOP);
+ //graph->set_ignore_mouse(false);
+ graph->connect("draw", this, "_graph_tex_draw");
+ graph->connect("gui_input", this, "_graph_tex_input");
+ graph->connect("mouse_exited", this, "_graph_tex_mouse_exit");
+
+ h_split->add_child(graph);
+ graph->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024);
+ frame_metrics.resize(metric_size);
+ last_metric = -1;
+ //cursor_metric=-1;
+ hover_metric = -1;
+
+ //display_mode=DISPLAY_FRAME_TIME;
+
+ frame_delay = memnew(Timer);
+ frame_delay->set_wait_time(0.1);
+ frame_delay->set_one_shot(true);
+ add_child(frame_delay);
+ frame_delay->connect("timeout", this, "_update_frame");
+
+ plot_delay = memnew(Timer);
+ plot_delay->set_wait_time(0.1);
+ plot_delay->set_one_shot(true);
+ add_child(plot_delay);
+ plot_delay->connect("timeout", this, "_update_plot");
+
+ seeking = false;
+ graph_height_cpu = 1;
+ graph_height_gpu = 1;
+
+ graph_limit = 1000 / 60.0;
+
+ //activate->set_disabled(true);
+}
diff --git a/editor/editor_visual_profiler.h b/editor/editor_visual_profiler.h
new file mode 100644
index 0000000000..b4c03b227e
--- /dev/null
+++ b/editor/editor_visual_profiler.h
@@ -0,0 +1,154 @@
+/*************************************************************************/
+/* editor_visual_profiler.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_FRAME_PROFILER_H
+#define EDITOR_FRAME_PROFILER_H
+
+#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
+#include "scene/gui/check_box.h"
+#include "scene/gui/label.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/spin_box.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/gui/tree.h"
+
+class EditorVisualProfiler : public VBoxContainer {
+
+ GDCLASS(EditorVisualProfiler, VBoxContainer);
+
+public:
+ struct Metric {
+
+ bool valid;
+
+ uint64_t frame_number;
+
+ struct Area {
+ String name;
+ Color color_cache;
+ StringName fullpath_cache;
+ float cpu_time = 0;
+ float gpu_time = 0;
+ };
+
+ Vector<Area> areas;
+
+ Metric() {
+ valid = false;
+ }
+ };
+
+ enum DisplayTimeMode {
+ DISPLAY_FRAME_TIME,
+ DISPLAY_FRAME_PERCENT,
+ };
+
+private:
+ Button *activate;
+ Button *clear_button;
+
+ TextureRect *graph;
+ Ref<ImageTexture> graph_texture;
+ PoolVector<uint8_t> graph_image;
+ Tree *variables;
+ HSplitContainer *h_split;
+ CheckBox *frame_relative;
+ CheckBox *linked;
+
+ OptionButton *display_mode;
+
+ SpinBox *cursor_metric_edit;
+
+ Vector<Metric> frame_metrics;
+ int last_metric;
+
+ StringName selected_area;
+
+ bool updating_frame;
+
+ //int cursor_metric;
+ int hover_metric;
+
+ float graph_height_cpu;
+ float graph_height_gpu;
+
+ float graph_limit;
+
+ bool seeking;
+
+ Timer *frame_delay;
+ Timer *plot_delay;
+
+ void _update_frame(bool p_focus_selected = false);
+
+ void _activate_pressed();
+ void _clear_pressed();
+
+ String _get_time_as_text(float p_time);
+
+ //void _make_metric_ptrs(Metric &m);
+ void _item_selected();
+
+ void _update_plot();
+
+ void _graph_tex_mouse_exit();
+
+ void _graph_tex_draw();
+ void _graph_tex_input(const Ref<InputEvent> &p_ev);
+
+ int _get_cursor_index() const;
+
+ Color _get_color_from_signature(const StringName &p_signature) const;
+
+ void _cursor_metric_changed(double);
+
+ void _combo_changed(int);
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ void add_frame_metric(const Metric &p_metric);
+ void set_enabled(bool p_enable);
+ bool is_profiling();
+ bool is_seeking() { return seeking; }
+ void disable_seeking();
+
+ void clear();
+
+ Vector<Vector<String> > get_data_as_csv() const;
+
+ EditorVisualProfiler();
+};
+
+#endif // EDITOR_FRAME_PROFILER_H
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/icons/icon_o_r_m_material_3d.svg b/editor/icons/icon_o_r_m_material_3d.svg
new file mode 100644
index 0000000000..3dd6013436
--- /dev/null
+++ b/editor/icons/icon_o_r_m_material_3d.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ version="1.1"
+ viewBox="0 0 16 16"
+ id="svg18"
+ sodipodi:docname="icon_o_r_m_material_3d.svg"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
+ <metadata
+ id="metadata24">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs22" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1010"
+ inkscape:window-height="553"
+ id="namedview20"
+ showgrid="false"
+ inkscape:zoom="7.375"
+ inkscape:cx="16.698858"
+ inkscape:cy="18.275823"
+ inkscape:window-x="345"
+ inkscape:window-y="144"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg18" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4541"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:Uroob;-inkscape-font-specification:Uroob;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.33291078"
+ d="m 5.0534707,10.652714 q 0,0.729229 -0.4538398,1.253141 -0.4538403,0.516832 -1.0868283,0.516832 H 2.3184864 q -0.6389592,0 -1.1047425,-0.509753 -0.47175502,-0.509751 -0.47175502,-1.26022 V 5.1304021 q 0,-0.7575473 0.47175502,-1.2672998 0.4717549,-0.5097517 1.1047425,-0.5097517 h 1.1943162 q 0.6270165,0 1.0868283,0.516832 0.4538398,0.5168313 0.4538398,1.2602195 z M 3.9726148,10.419078 V 5.3640385 q 0,-0.5734707 -0.3344086,-0.8141867 Q 3.5307175,4.4648927 3.381428,4.471973 H 2.3901454 q -0.2567779,0 -0.4120391,0.2690357 -0.1552611,0.2690357 -0.1552611,0.6230298 v 5.0550395 q 0,0.559311 0.3164938,0.807108 0.1074885,0.08496 0.2508064,0.08496 H 3.381428 q 0.2746925,0 0.4359254,-0.276116 0.1552614,-0.276115 0.1552614,-0.61595 z" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4543"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:Uroob;-inkscape-font-specification:Uroob;letter-spacing:0px;word-spacing:0px;fill:#008000;fill-opacity:1;stroke:none;stroke-width:0.32084218"
+ d="M 9.9872948,12.451006 H 8.9445586 L 7.4747449,8.5287488 H 6.6815992 V 12.451006 H 5.6721419 V 3.37459 h 2.739956 q 0.5435541,0 0.9318066,0.4601926 0.3882524,0.4601933 0.3882524,1.1540217 V 7.112771 q 0,1.0053443 -0.6766682,1.3168588 -0.2107668,0.099119 -0.4659043,0.099119 z M 8.7282467,6.808336 V 5.2224407 q 0,-0.4743524 -0.2884169,-0.6867495 -0.088743,-0.070798 -0.2052192,-0.063719 H 6.6815992 v 2.9452329 h 1.7194053 q 0.2828702,-0.00708 0.3161488,-0.389394 0.011093,-0.1132781 0.011093,-0.2194752 z" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4545"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:Uroob;-inkscape-font-specification:Uroob;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.31984535"
+ d="m 10.201004,3.7285848 q 0,-0.4106342 0.529158,-0.3681546 0.126777,0.014161 0.209458,0.014161 v 0.00708 h 0.115753 l 1.692202,4.9205216 1.697714,-4.9205216 h 0.06063 v -0.00708 h 0.463013 q 0.198434,0 0.297651,0.212397 0.03307,0.063719 0.03307,0.1415978 v 8.694102 h -1.01422 V 6.8224966 L 13.227119,10.050925 H 12.273535 L 11.21522,7.1198527 v 5.3028353 h -1.014218 z" />
+</svg>
diff --git a/editor/icons/icon_standard_material_3d.svg b/editor/icons/icon_standard_material_3d.svg
new file mode 100644
index 0000000000..aa8bfc9a5b
--- /dev/null
+++ b/editor/icons/icon_standard_material_3d.svg
@@ -0,0 +1,11 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m7.9629 1.002a1.0001 1.0001 0 0 0 -0.41016 0.10352l-3.7891 1.8945h8.4727l-3.7891-1.8945a1.0001 1.0001 0 0 0 -0.48438 -0.10352z" fill="#ff7070"/>
+<path transform="translate(0 1036.4)" d="m3.7637 3l-2.2109 1.1055a1.0001 1.0001 0 0 0 -0.55273 0.89453h3.2363l3.7637-1.8809 3.7637 1.8809h3.2363a1.0001 1.0001 0 0 0 -0.55273 -0.89453l-2.2109-1.1055h-8.4727z" fill="#ffeb70"/>
+<path transform="translate(0 1036.4)" d="m1 5v2h2v-0.38086l0.76172 0.38086h8.4766l0.76172-0.38086v0.38086h2v-2h-3.2363l-3.7637 1.8828-3.7637-1.8828h-3.2363z" fill="#9dff70"/>
+<path transform="translate(0 1036.4)" d="m1 7v2h2v-2h-2zm2.7617 0l3.2383 1.6191v0.38086h2v-0.38086l3.2383-1.6191h-8.4766zm9.2383 0v2h2v-2h-2z" fill="#70ffb9"/>
+<path transform="translate(0 1036.4)" d="m1 9v2h3.2344l-1.2344-0.61719v-1.3828h-2zm6 0v2h2v-2h-2zm6 0v1.3828l-1.2344 0.61719h3.2344v-2h-2z" fill="#70deff"/>
+<path transform="translate(0 1036.4)" d="m3.7637 13l3.7891 1.8945a1.0001 1.0001 0 0 0 0.48438 0.10547 1.0001 1.0001 0 0 0 0.41016 -0.10547l3.7891-1.8945h-8.4727z" fill="#ff70ac"/>
+<path transform="translate(0 1036.4)" d="m1 11a1.0001 1.0001 0 0 0 0.55273 0.89453l2.2109 1.1055h8.4727l2.2109-1.1055a1.0001 1.0001 0 0 0 0.55273 -0.89453h-3.2344l-2.7656 1.3828v-1.3828h-2v1.3828l-2.7656-1.3828h-3.2344z" fill="#9f70ff"/>
+</g>
+</svg>
diff --git a/editor/icons/icon_track_color.svg b/editor/icons/icon_track_color.svg
new file mode 100644
index 0000000000..6a736c7a84
--- /dev/null
+++ b/editor/icons/icon_track_color.svg
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="10"
+ viewBox="0 0 10 10"
+ width="10"
+ version="1.1"
+ id="svg4"
+ sodipodi:docname="icon_track_color.svg"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
+ <metadata
+ id="metadata10">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="838"
+ inkscape:window-height="480"
+ id="namedview6"
+ showgrid="false"
+ inkscape:zoom="23.6"
+ inkscape:cx="5"
+ inkscape:cy="5"
+ inkscape:window-x="593"
+ inkscape:window-y="314"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg4" />
+ <rect
+ fill="#5792f6"
+ height="6.1027"
+ ry=".76286"
+ transform="matrix(.70710678 -.70710678 .70710678 .70710678 0 -1042.4)"
+ width="6.1027"
+ x="-740.13947"
+ y="741.10779"
+ id="rect2"
+ style="fill:#ffffff;fill-opacity:1" />
+</svg>
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index e2d8dc8962..2f97f4aa31 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -363,7 +363,7 @@ Error ColladaImport::_create_material(const String &p_target) {
ERR_FAIL_COND_V(!collada.state.effect_map.has(src_mat.instance_effect), ERR_INVALID_PARAMETER);
Collada::Effect &effect = collada.state.effect_map[src_mat.instance_effect];
- Ref<SpatialMaterial> material = memnew(SpatialMaterial);
+ Ref<StandardMaterial3D> material = memnew(StandardMaterial3D);
if (src_mat.name != "")
material->set_name(src_mat.name);
@@ -380,12 +380,12 @@ 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);
+ material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture);
material->set_albedo(Color(1, 1, 1, 1));
- //material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,1));
+ //material->set_parameter(StandardMaterial3D::PARAM_DIFFUSE,Color(1,1,1,1));
} else {
missing_textures.push_back(texfile.get_file());
}
@@ -405,13 +405,13 @@ 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_texture(StandardMaterial3D::TEXTURE_METALLIC, texture);
material->set_specular(1.0);
- //material->set_texture(SpatialMaterial::PARAM_SPECULAR,texture);
- //material->set_parameter(SpatialMaterial::PARAM_SPECULAR,Color(1,1,1,1));
+ //material->set_texture(StandardMaterial3D::PARAM_SPECULAR,texture);
+ //material->set_parameter(StandardMaterial3D::PARAM_SPECULAR,Color(1,1,1,1));
} else {
missing_textures.push_back(texfile.get_file());
}
@@ -432,21 +432,21 @@ 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);
- material->set_texture(SpatialMaterial::TEXTURE_EMISSION, texture);
+ material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true);
+ material->set_texture(StandardMaterial3D::TEXTURE_EMISSION, texture);
material->set_emission(Color(1, 1, 1, 1));
- //material->set_parameter(SpatialMaterial::PARAM_EMISSION,Color(1,1,1,1));
+ //material->set_parameter(StandardMaterial3D::PARAM_EMISSION,Color(1,1,1,1));
} else {
missing_textures.push_back(texfile.get_file());
}
}
} else {
if (effect.emission.color != Color()) {
- material->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
+ material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true);
material->set_emission(effect.emission.color);
}
}
@@ -462,13 +462,13 @@ 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);
+ material->set_feature(StandardMaterial3D::FEATURE_NORMAL_MAPPING, true);
+ material->set_texture(StandardMaterial3D::TEXTURE_NORMAL, texture);
//material->set_emission(Color(1,1,1,1));
- //material->set_texture(SpatialMaterial::PARAM_NORMAL,texture);
+ //material->set_texture(StandardMaterial3D::PARAM_NORMAL,texture);
} else {
//missing_textures.push_back(texfile.get_file());
}
@@ -479,9 +479,11 @@ Error ColladaImport::_create_material(const String &p_target) {
material->set_roughness(roughness);
if (effect.double_sided) {
- material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
+ }
+ if (effect.unshaded) {
+ material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
}
- material->set_flag(SpatialMaterial::FLAG_UNSHADED, effect.unshaded);
material_cache[p_target] = material;
return OK;
@@ -877,7 +879,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
{
- Ref<SpatialMaterial> material;
+ Ref<StandardMaterial3D> material;
{
@@ -984,7 +986,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
mr.push_back(a);
}
- p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, p_use_compression ? Mesh::ARRAY_COMPRESS_DEFAULT : 0);
+ p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, Dictionary(), p_use_compression ? Mesh::ARRAY_COMPRESS_DEFAULT : 0);
if (material.is_valid()) {
if (p_use_mesh_material) {
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index d4664e1bb9..c0d84b61b4 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -984,11 +984,15 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
static const Mesh::PrimitiveType primitives2[7] = {
Mesh::PRIMITIVE_POINTS,
Mesh::PRIMITIVE_LINES,
- Mesh::PRIMITIVE_LINE_LOOP,
- Mesh::PRIMITIVE_LINE_STRIP,
+ Mesh::PRIMITIVE_LINES, //loop not supported, should ce converted
+ Mesh::PRIMITIVE_LINES,
Mesh::PRIMITIVE_TRIANGLES,
Mesh::PRIMITIVE_TRIANGLE_STRIP,
- Mesh::PRIMITIVE_TRIANGLE_FAN,
+ Mesh::PRIMITIVE_TRIANGLES, //fan not supported, should be converted
+#ifndef _MSC_VER
+#warning line loop and triangle fan are not supported and need to be converted to lines and triangles
+#endif
+
};
primitive = primitives2[mode];
@@ -1277,7 +1281,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 +1366,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];
}
@@ -1381,7 +1385,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
const Dictionary &d = materials[i];
- Ref<SpatialMaterial> material;
+ Ref<StandardMaterial3D> material;
material.instance();
if (d.has("name")) {
material->set_name(d["name"]);
@@ -1401,7 +1405,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
if (mr.has("baseColorTexture")) {
const Dictionary &bct = mr["baseColorTexture"];
if (bct.has("index")) {
- material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, _get_texture(state, bct["index"]));
+ material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, _get_texture(state, bct["index"]));
}
if (!mr.has("baseColorFactor")) {
material->set_albedo(Color(1, 1, 1));
@@ -1423,11 +1427,11 @@ 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"]);
- material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t);
- material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE);
- material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t);
- material->set_roughness_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_GREEN);
+ const Ref<Texture2D> t = _get_texture(state, bct["index"]);
+ material->set_texture(StandardMaterial3D::TEXTURE_METALLIC, t);
+ material->set_metallic_texture_channel(StandardMaterial3D::TEXTURE_CHANNEL_BLUE);
+ material->set_texture(StandardMaterial3D::TEXTURE_ROUGHNESS, t);
+ material->set_roughness_texture_channel(StandardMaterial3D::TEXTURE_CHANNEL_GREEN);
if (!mr.has("metallicFactor")) {
material->set_metallic(1);
}
@@ -1441,8 +1445,8 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
if (d.has("normalTexture")) {
const Dictionary &bct = d["normalTexture"];
if (bct.has("index")) {
- material->set_texture(SpatialMaterial::TEXTURE_NORMAL, _get_texture(state, bct["index"]));
- material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true);
+ material->set_texture(StandardMaterial3D::TEXTURE_NORMAL, _get_texture(state, bct["index"]));
+ material->set_feature(StandardMaterial3D::FEATURE_NORMAL_MAPPING, true);
}
if (bct.has("scale")) {
material->set_normal_scale(bct["scale"]);
@@ -1451,9 +1455,9 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
if (d.has("occlusionTexture")) {
const Dictionary &bct = d["occlusionTexture"];
if (bct.has("index")) {
- material->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"]));
- material->set_ao_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED);
- material->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true);
+ material->set_texture(StandardMaterial3D::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"]));
+ material->set_ao_texture_channel(StandardMaterial3D::TEXTURE_CHANNEL_RED);
+ material->set_feature(StandardMaterial3D::FEATURE_AMBIENT_OCCLUSION, true);
}
}
@@ -1461,7 +1465,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
const Array &arr = d["emissiveFactor"];
ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR);
const Color c = Color(arr[0], arr[1], arr[2]).to_srgb();
- material->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
+ material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true);
material->set_emission(c);
}
@@ -1469,8 +1473,8 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
if (d.has("emissiveTexture")) {
const Dictionary &bct = d["emissiveTexture"];
if (bct.has("index")) {
- material->set_texture(SpatialMaterial::TEXTURE_EMISSION, _get_texture(state, bct["index"]));
- material->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
+ material->set_texture(StandardMaterial3D::TEXTURE_EMISSION, _get_texture(state, bct["index"]));
+ material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true);
material->set_emission(Color(0, 0, 0));
}
}
@@ -1478,17 +1482,16 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
if (d.has("doubleSided")) {
const bool ds = d["doubleSided"];
if (ds) {
- material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
}
}
if (d.has("alphaMode")) {
const String &am = d["alphaMode"];
if (am == "BLEND") {
- material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- material->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS);
+ material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS);
} else if (am == "MASK") {
- material->set_flag(SpatialMaterial::FLAG_USE_ALPHA_SCISSOR, true);
+ material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_SCISSOR);
if (d.has("alphaCutoff")) {
material->set_alpha_scissor_threshold(d["alphaCutoff"]);
} else {
@@ -2615,7 +2618,7 @@ struct EditorSceneImporterGLTFInterpolate {
const float t2 = t * t;
const float t3 = t2 * t;
- return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
+ return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
}
T bezier(T start, T control_1, T control_2, T end, float 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..9ea2911c63 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -38,26 +38,74 @@
#include "editor/editor_node.h"
#include "scene/resources/texture.h"
+#if 0
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 +114,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 +244,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 +263,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 +275,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);
@@ -266,8 +313,8 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
encode_bptc = true;
if (no_bptc_if_rgb) {
- Image::DetectChannels channels = image->get_detected_channels();
- if (channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) {
+ Image::UsedChannels channels = image->detect_used_channels();
+ if (channels != Image::USED_CHANNELS_LA && channels != Image::USED_CHANNELS_RGBA) {
encode_bptc = false;
}
}
@@ -277,14 +324,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 +339,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 +362,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,8 +443,9 @@ ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = NULL
ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() {
singleton = this;
- is_3d = true;
+ mode = MODE_CUBEMAP;
}
ResourceImporterLayeredTexture::~ResourceImporterLayeredTexture() {
}
+#endif
diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h
index 6dc4b6ed3c..6a6bc89a81 100644
--- a/editor/import/resource_importer_layered_texture.h
+++ b/editor/import/resource_importer_layered_texture.h
@@ -28,18 +28,61 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#if 0
+/*************************************************************************/
+/* resource_importer_layered_texture.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
#ifndef RESOURCE_IMPORTER_LAYERED_TEXTURE_H
#define RESOURCE_IMPORTER_LAYERED_TEXTURE_H
#include "core/image.h"
#include "core/io/resource_importer.h"
+
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 +100,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 +112,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,8 +121,11 @@ 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();
};
#endif // RESOURCE_IMPORTER_LAYERED_TEXTURE_H
+
+#endif
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index bdd6a197f8..7fd3bcc478 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -42,12 +42,12 @@ uint32_t EditorOBJImporter::get_import_flags() const {
return IMPORT_SCENE;
}
-static Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) {
+static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D> > &material_map, List<String> *r_missing_deps) {
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path));
- Ref<SpatialMaterial> current;
+ Ref<StandardMaterial3D> current;
String current_name;
String base_path = p_path.get_base_dir();
while (true) {
@@ -102,7 +102,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
c.a = d;
current->set_albedo(c);
if (c.a < 0.99) {
- current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ current->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
}
} else if (l.begins_with("Tr ")) {
//normal
@@ -114,7 +114,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
c.a = 1.0 - d;
current->set_albedo(c);
if (c.a < 0.99) {
- current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ current->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
}
} else if (l.begins_with("map_Ka ")) {
@@ -133,10 +133,10 @@ 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);
+ current->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture);
} else if (r_missing_deps) {
r_missing_deps->push_back(path);
}
@@ -153,10 +153,10 @@ 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);
+ current->set_texture(StandardMaterial3D::TEXTURE_METALLIC, texture);
} else if (r_missing_deps) {
r_missing_deps->push_back(path);
}
@@ -173,10 +173,10 @@ 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);
+ current->set_texture(StandardMaterial3D::TEXTURE_ROUGHNESS, texture);
} else if (r_missing_deps) {
r_missing_deps->push_back(path);
}
@@ -187,11 +187,11 @@ 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);
- current->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture);
+ current->set_feature(StandardMaterial3D::FEATURE_NORMAL_MAPPING, true);
+ current->set_texture(StandardMaterial3D::TEXTURE_NORMAL, texture);
} else if (r_missing_deps) {
r_missing_deps->push_back(path);
}
@@ -221,7 +221,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
Vector<Vector2> uvs;
String name;
- Map<String, Map<String, Ref<SpatialMaterial> > > material_map;
+ Map<String, Map<String, Ref<StandardMaterial3D> > > material_map;
Ref<SurfaceTool> surf_tool = memnew(SurfaceTool);
surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
@@ -397,7 +397,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
current_material_library = l.replace("mtllib", "").strip_edges();
if (!material_map.has(current_material_library)) {
- Map<String, Ref<SpatialMaterial> > lib;
+ Map<String, Ref<StandardMaterial3D> > lib;
Error err = _parse_material_library(current_material_library, lib, r_missing_deps);
if (err == ERR_CANT_OPEN) {
String dir = p_path.get_base_dir();
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 0774d0b5dc..2c2b05d6fc 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -324,19 +324,19 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
for (int i = 0; i < m->get_surface_count(); i++) {
- Ref<SpatialMaterial> mat = m->surface_get_material(i);
+ Ref<StandardMaterial3D> mat = m->surface_get_material(i);
if (!mat.is_valid())
continue;
if (_teststr(mat->get_name(), "alpha")) {
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
mat->set_name(_fixstr(mat->get_name(), "alpha"));
}
if (_teststr(mat->get_name(), "vcol")) {
- mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
mat->set_name(_fixstr(mat->get_name(), "vcol"));
}
}
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 88547280ce..aa7346efe8 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -32,20 +32,22 @@
#include "core/io/config_file.h"
#include "core/io/image_loader.h"
+#include "core/version.h"
#include "editor/editor_file_system.h"
#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,27 @@ 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"))) {
- 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);
+ if (E->get().flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d/compress_to"))) {
+ int compress_to = cf->get_value("params", "detect_3d/compress_to");
+ cf->set_value("params", "detect_3d/compress_to", 0);
+ if (compress_to == 1) {
+ cf->set_value("params", "compress/mode", COMPRESS_VRAM_COMPRESSED);
+ } else if (compress_to == 2) {
+ cf->set_value("params", "compress/mode", COMPRESS_BASIS_UNIVERSAL);
+ }
+ cf->set_value("params", "mipmaps/generate", true);
changed = true;
}
@@ -142,7 +149,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 {
@@ -161,17 +168,20 @@ bool ResourceImporterTexture::get_option_visibility(const String &p_option, cons
if (p_option == "compress/lossy_quality") {
int compress_mode = int(p_options["compress/mode"]);
- if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VIDEO_RAM) {
+ if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VRAM_COMPRESSED) {
return false;
}
} else if (p_option == "compress/hdr_mode") {
int compress_mode = int(p_options["compress/mode"]);
- if (compress_mode != COMPRESS_VIDEO_RAM) {
+ if (compress_mode < COMPRESS_VRAM_COMPRESSED) {
return false;
}
+ } else if (p_option == "mipmaps/limit") {
+ return p_options["mipmaps/generate"];
+
} else if (p_option == "compress/bptc_ldr") {
int compress_mode = int(p_options["compress/mode"]);
- if (compress_mode != COMPRESS_VIDEO_RAM) {
+ if (compress_mode < COMPRESS_VRAM_COMPRESSED) {
return false;
}
if (!ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc")) {
@@ -199,90 +209,40 @@ String ResourceImporterTexture::get_preset_name(int p_idx) const {
void ResourceImporterTexture::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,Lossy,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,VRAM Compressed,VRAM Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
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, "compress/streamed"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "mipmaps/generate"), (p_preset == PRESET_3D ? true : false)));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "mipmaps/limit", PROPERTY_HINT_RANGE, "-1,256"), -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));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/HDR_as_SRGB"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "process/size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "detect_3d/compress_to", PROPERTY_HINT_ENUM, "Disabled,VRAM Compressed,Basis Universal"), (p_preset == PRESET_DETECT) ? 1 : 0));
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) {
-
- FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
- f->store_8('G');
- f->store_8('D');
- f->store_8('S');
- f->store_8('T'); //godot streamable texture
-
- 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)) {
- resize_to_po2 = true;
- f->store_16(next_power_of_2(p_image->get_width()));
- f->store_16(p_image->get_width());
- f->store_16(next_power_of_2(p_image->get_height()));
- f->store_16(p_image->get_height());
- } else {
- f->store_16(p_image->get_width());
- f->store_16(0);
- f->store_16(p_image->get_height());
- f->store_16(0);
- }
- f->store_32(p_texture_flags);
-
- uint32_t format = 0;
-
- if (p_streamable)
- format |= StreamTexture::FORMAT_BIT_STREAM;
- if (p_mipmaps)
- 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_normal)
- format |= StreamTexture::FORMAT_BIT_DETECT_NORMAL;
-
- if ((p_compress_mode == COMPRESS_LOSSLESS || p_compress_mode == COMPRESS_LOSSY) && p_image->get_format() > Image::FORMAT_RGBA8) {
- p_compress_mode = COMPRESS_UNCOMPRESSED; //these can't go as lossy
- }
+void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality, bool p_force_rgbe) {
switch (p_compress_mode) {
case COMPRESS_LOSSLESS: {
- Ref<Image> image = p_image->duplicate();
- if (p_mipmaps) {
- image->generate_mipmaps();
- } else {
- image->clear_mipmaps();
- }
-
- int mmc = image->get_mipmap_count() + 1;
-
- format |= StreamTexture::FORMAT_BIT_LOSSLESS;
- f->store_32(format);
- f->store_32(mmc);
-
- for (int i = 0; i < mmc; i++) {
+ f->store_32(StreamTexture::DATA_FORMAT_LOSSLESS);
+ f->store_16(p_image->get_width());
+ f->store_16(p_image->get_height());
+ f->store_32(p_image->get_mipmap_count());
+ f->store_32(p_image->get_format());
- if (i > 0) {
- image->shrink_x2();
- }
+ for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) {
- PoolVector<uint8_t> data = Image::lossless_packer(image);
+ PoolVector<uint8_t> data = Image::lossless_packer(p_image->get_image_from_mipmap(i));
int data_len = data.size();
f->store_32(data_len);
@@ -292,26 +252,16 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
} break;
case COMPRESS_LOSSY: {
- Ref<Image> image = p_image->duplicate();
- if (p_mipmaps) {
- image->generate_mipmaps();
- } else {
- image->clear_mipmaps();
- }
-
- int mmc = image->get_mipmap_count() + 1;
- format |= StreamTexture::FORMAT_BIT_LOSSY;
- f->store_32(format);
- f->store_32(mmc);
+ f->store_32(StreamTexture::DATA_FORMAT_LOSSY);
+ f->store_16(p_image->get_width());
+ f->store_16(p_image->get_height());
+ f->store_32(p_image->get_mipmap_count());
+ f->store_32(p_image->get_format());
- for (int i = 0; i < mmc; i++) {
+ for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) {
- if (i > 0) {
- image->shrink_x2();
- }
-
- PoolVector<uint8_t> data = Image::lossy_packer(image, p_lossy_quality);
+ PoolVector<uint8_t> data = Image::lossy_packer(p_image->get_image_from_mipmap(i), p_lossy_quality);
int data_len = data.size();
f->store_32(data_len);
@@ -319,82 +269,173 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
f->store_buffer(r.ptr(), data_len);
}
} break;
- case COMPRESS_VIDEO_RAM: {
+ case COMPRESS_VRAM_COMPRESSED: {
Ref<Image> image = p_image->duplicate();
- if (resize_to_po2) {
- image->resize_to_po2();
- }
- if (p_mipmaps) {
- image->generate_mipmaps(p_force_normal);
- }
- if (p_force_rgbe && image->get_format() >= Image::FORMAT_R8 && image->get_format() <= Image::FORMAT_RGBE9995) {
+ if (p_force_rgbe && image->get_format() >= Image::FORMAT_RF && image->get_format() < Image::FORMAT_RGBE9995) {
image->convert(Image::FORMAT_RGBE9995);
} else {
- 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) {
- csource = Image::COMPRESS_SOURCE_SRGB;
- }
-
- image->compress(p_vram_compression, csource, p_lossy_quality);
+ image->compress_from_channels(p_compress_format, p_channels, p_lossy_quality);
}
- format |= image->get_format();
-
- f->store_32(format);
+ f->store_32(StreamTexture::DATA_FORMAT_IMAGE);
+ f->store_16(image->get_width());
+ f->store_16(image->get_height());
+ f->store_32(image->get_mipmap_count());
+ f->store_32(image->get_format());
PoolVector<uint8_t> data = image->get_data();
int dl = data.size();
PoolVector<uint8_t>::Read r = data.read();
f->store_buffer(r.ptr(), dl);
} break;
- case COMPRESS_UNCOMPRESSED: {
+ case COMPRESS_VRAM_UNCOMPRESSED: {
- Ref<Image> image = p_image->duplicate();
- if (p_mipmaps) {
- image->generate_mipmaps();
- } else {
- image->clear_mipmaps();
- }
+ f->store_32(StreamTexture::DATA_FORMAT_IMAGE);
+ f->store_16(p_image->get_width());
+ f->store_16(p_image->get_height());
+ f->store_32(p_image->get_mipmap_count());
+ f->store_32(p_image->get_format());
- format |= image->get_format();
- f->store_32(format);
-
- PoolVector<uint8_t> data = image->get_data();
+ PoolVector<uint8_t> data = p_image->get_data();
int dl = data.size();
PoolVector<uint8_t>::Read r = data.read();
f->store_buffer(r.ptr(), dl);
} break;
+ case COMPRESS_BASIS_UNIVERSAL: {
+
+ f->store_32(StreamTexture::DATA_FORMAT_BASIS_UNIVERSAL);
+ f->store_16(p_image->get_width());
+ f->store_16(p_image->get_height());
+ f->store_32(p_image->get_mipmap_count());
+ f->store_32(p_image->get_format());
+
+ for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) {
+
+ PoolVector<uint8_t> data = Image::basis_universal_packer(p_image->get_image_from_mipmap(i), p_channels);
+ int data_len = data.size();
+ f->store_32(data_len);
+
+ PoolVector<uint8_t>::Read r = data.read();
+ f->store_buffer(r.ptr(), data_len);
+ }
+ } break;
+ }
+}
+
+void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode 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, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) {
+
+ FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
+ f->store_8('G');
+ f->store_8('S');
+ f->store_8('T');
+ f->store_8('2'); //godot streamable texture 2D
+
+ //format version
+ f->store_32(StreamTexture::FORMAT_VERSION);
+ //texture may be resized later, so original size must be saved first
+ f->store_32(p_image->get_width());
+ f->store_32(p_image->get_height());
+
+ uint32_t flags = 0;
+ if (p_streamable)
+ flags |= StreamTexture::FORMAT_BIT_STREAM;
+ if (p_mipmaps)
+ flags |= StreamTexture::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
+ if (p_detect_3d)
+ flags |= StreamTexture::FORMAT_BIT_DETECT_3D;
+ if (p_detect_roughness)
+ flags |= StreamTexture::FORMAT_BIT_DETECT_ROUGNESS;
+ if (p_detect_normal)
+ flags |= StreamTexture::FORMAT_BIT_DETECT_NORMAL;
+
+ f->store_32(flags);
+ f->store_32(p_limit_mipmap);
+ //reserverd for future use
+ f->store_32(0);
+ f->store_32(0);
+ f->store_32(0);
+
+ /*
+ print_line("streamable " + itos(p_streamable));
+ print_line("mipmaps " + itos(p_mipmaps));
+ print_line("detect_3d " + itos(p_detect_3d));
+ print_line("roughness " + itos(p_detect_roughness));
+ print_line("normal " + itos(p_detect_normal));
+*/
+
+ if ((p_compress_mode == COMPRESS_LOSSLESS || p_compress_mode == COMPRESS_LOSSY) && p_image->get_format() > Image::FORMAT_RGBA8) {
+ p_compress_mode = COMPRESS_VRAM_UNCOMPRESSED; //these can't go as lossy
+ }
+
+ Ref<Image> image = p_image->duplicate();
+
+ if (((p_compress_mode == COMPRESS_BASIS_UNIVERSAL) || (p_compress_mode == COMPRESS_VRAM_COMPRESSED && p_force_po2_for_compressed)) && p_mipmaps) {
+ image->resize_to_po2();
+ }
+
+ if (p_mipmaps && (!image->has_mipmaps() || p_force_normal)) {
+ image->generate_mipmaps(p_force_normal);
+ }
+
+ if (!p_mipmaps) {
+ image->clear_mipmaps();
}
+ if (image->has_mipmaps() && p_normal.is_valid()) {
+ image->generate_mipmap_roughness(p_roughness_channel, p_normal);
+ }
+
+ if (p_force_rgbe && image->get_format() >= Image::FORMAT_RF && image->get_format() < Image::FORMAT_RGBE9995) {
+ image->convert(Image::FORMAT_RGBE9995);
+ }
+
+ Image::CompressSource csource = Image::COMPRESS_SOURCE_GENERIC;
+ if (p_force_normal) {
+ csource = Image::COMPRESS_SOURCE_NORMAL;
+ } else if (p_srgb_friendly) {
+ csource = Image::COMPRESS_SOURCE_SRGB;
+ }
+
+ Image::UsedChannels used_channels = image->detect_used_channels(csource);
+
+ save_to_stex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality, p_force_rgbe);
+
memdelete(f);
}
Error ResourceImporterTexture::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, Variant *r_metadata) {
- int compress_mode = p_options["compress/mode"];
+ CompressMode compress_mode = CompressMode(int(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["mipmaps/generate"];
+ uint32_t mipmap_limit = int(mipmaps ? int(p_options["mipmaps/limit"]) : int(-1));
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"];
- bool stream = p_options["stream"];
- int size_limit = p_options["size_limit"];
+ bool stream = p_options["compress/streamed"];
+ int size_limit = p_options["process/size_limit"];
bool hdr_as_srgb = p_options["process/HDR_as_SRGB"];
int normal = p_options["compress/normal_map"];
float scale = p_options["svg/scale"];
- bool force_rgbe = p_options["compress/hdr_mode"];
+ bool force_rgbe = int(p_options["compress/hdr_mode"]) == 1;
int bptc_ldr = p_options["compress/bptc_ldr"];
+ int roughness = p_options["roughness/mode"];
+ String normal_map = p_options["roughness/src_normal"];
+
+ Ref<Image> normal_image;
+ Image::RoughnessChannel roughness_channel;
+ if (mipmaps && roughness > 1 && FileAccess::exists(normal_map)) {
+ normal_image.instance();
+ if (ImageLoader::load_image(normal_map, normal_image) == OK) {
+ roughness_channel = Image::RoughnessChannel(roughness - 2);
+ }
+ }
Ref<Image> image;
image.instance();
Error err = ImageLoader::load_image(p_source_file, image, NULL, hdr_as_srgb, scale);
@@ -403,20 +444,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()) {
@@ -458,32 +485,38 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
image->unlock();
}
- bool detect_3d = p_options["detect_3d"];
- bool detect_srgb = srgb == 2;
+ if (compress_mode == COMPRESS_BASIS_UNIVERSAL && image->get_format() >= Image::FORMAT_RF) {
+ //basis universal does not support float formats, fall back
+ compress_mode = COMPRESS_VRAM_COMPRESSED;
+ }
+
+ bool detect_3d = int(p_options["detect_3d/compress_to"]) > 0;
+ 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) {
+ if (compress_mode == COMPRESS_VRAM_COMPRESSED) {
//must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc).
//Android, GLES 2.x
bool ok_on_pc = false;
bool is_hdr = (image->get_format() >= Image::FORMAT_RF && image->get_format() <= Image::FORMAT_RGBE9995);
- bool is_ldr = (image->get_format() >= Image::FORMAT_L8 && image->get_format() <= Image::FORMAT_RGBA5551);
+ bool is_ldr = (image->get_format() >= Image::FORMAT_L8 && image->get_format() <= Image::FORMAT_RGB565);
bool can_bptc = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc");
bool can_s3tc = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc");
if (can_bptc) {
- Image::DetectChannels channels = image->get_detected_channels();
+ Image::UsedChannels channels = image->detect_used_channels();
if (is_hdr) {
- if (channels == Image::DETECTED_LA || channels == Image::DETECTED_RGBA) {
+ if (channels == Image::USED_CHANNELS_LA || channels == Image::USED_CHANNELS_RGBA) {
can_bptc = false;
}
} else if (is_ldr) {
//handle "RGBA Only" setting
- if (bptc_ldr == 1 && channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) {
+ if (bptc_ldr == 1 && channels != Image::USED_CHANNELS_LA && channels != Image::USED_CHANNELS_RGBA) {
can_bptc = false;
}
}
@@ -497,7 +530,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, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("s3tc");
formats_imported.push_back("s3tc");
ok_on_pc = true;
@@ -505,20 +538,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, mipmap_limit, normal_image, roughness_channel);
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, mipmap_limit, normal_image, roughness_channel);
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, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("pvrtc");
formats_imported.push_back("pvrtc");
}
@@ -528,12 +561,12 @@ 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, mipmap_limit, normal_image, roughness_channel);
}
if (r_metadata) {
Dictionary metadata;
- metadata["vram_texture"] = compress_mode == COMPRESS_VIDEO_RAM;
+ metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
if (formats_imported.size()) {
metadata["imported_formats"] = formats_imported;
}
@@ -609,7 +642,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..19d5498b4a 100644
--- a/editor/import/resource_importer_texture.h
+++ b/editor/import/resource_importer_texture.h
@@ -33,30 +33,57 @@
#include "core/image.h"
#include "core/io/resource_importer.h"
+#include "core/os/file_access.h"
+#include "scene/resources/texture.h"
+#include "servers/visual_server.h"
class StreamTexture;
class ResourceImporterTexture : public ResourceImporter {
GDCLASS(ResourceImporterTexture, ResourceImporter);
+public:
+ enum CompressMode {
+ COMPRESS_LOSSLESS,
+ COMPRESS_LOSSY,
+ COMPRESS_VRAM_COMPRESSED,
+ COMPRESS_VRAM_UNCOMPRESSED,
+ COMPRESS_BASIS_UNIVERSAL
+ };
+
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);
static ResourceImporterTexture *singleton;
static const char *compression_formats[];
+ void _save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode 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, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel);
+
public:
+ void save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality, bool p_force_rgbe);
+
static ResourceImporterTexture *get_singleton() { return singleton; }
virtual String get_importer_name() const;
virtual String get_visible_name() const;
@@ -71,21 +98,12 @@ public:
PRESET_3D,
};
- enum CompressMode {
- COMPRESS_LOSSLESS,
- COMPRESS_LOSSY,
- COMPRESS_VIDEO_RAM,
- COMPRESS_UNCOMPRESSED
- };
-
virtual int get_preset_count() const;
virtual String get_preset_name(int p_idx) const;
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);
-
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);
void update_imports();
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..b2d132b3da 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();
@@ -612,7 +612,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
Vector2 point = xform.xform(p);
Vector2 next_point = xform.xform(p2);
- p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE), true);
+ p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE));
}
}
@@ -636,7 +636,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
p2 = points[(i + 1) % n_points] + offset;
const Vector2 next_point = xform.xform(p2);
- p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE), true);
+ p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE));
}
}
@@ -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..fdd8ffd58f 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();
@@ -497,7 +497,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
for (int j = 0; j < 3; j++) {
- blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, 1, true);
+ blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, 1);
}
Color color;
@@ -553,9 +553,9 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
for (int i = 0; i < points.size() - 1; i++) {
- blend_space_draw->draw_line(points[i], points[i + 1], linecolor, 2, true);
+ blend_space_draw->draw_line(points[i], points[i + 1], linecolor, 2);
}
- blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, 2, true);
+ blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, 2);
}
///draw cursor position
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 5e69ce4e69..d8bbac9c49 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -1322,11 +1322,10 @@ void AnimationPlayerEditor::_allocate_onion_layers() {
// Each capture is a viewport with a canvas item attached that renders a full-size rect with the contents of the main viewport.
onion.captures.write[i] = VS::get_singleton()->viewport_create();
- VS::get_singleton()->viewport_set_usage(onion.captures[i], VS::VIEWPORT_USAGE_2D);
+
VS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height);
VS::get_singleton()->viewport_set_update_mode(onion.captures[i], VS::VIEWPORT_UPDATE_ALWAYS);
VS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present);
- VS::get_singleton()->viewport_set_vflip(onion.captures[i], true);
VS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas);
}
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..035a67b821 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"),
@@ -524,16 +524,16 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
};
if (p_selected) {
- state_machine_draw->draw_line(p_from, p_to, accent, 6, true);
+ state_machine_draw->draw_line(p_from, p_to, accent, 6);
}
if (p_travel) {
linecolor = accent;
linecolor.set_hsv(1.0, linecolor.get_s(), linecolor.get_v());
}
- state_machine_draw->draw_line(p_from, p_to, linecolor, 2, true);
+ state_machine_draw->draw_line(p_from, p_to, linecolor, 2);
- 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/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp
index 7db936ccb8..6bc9562c5a 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.cpp
+++ b/editor/plugins/baked_lightmap_editor_plugin.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#if 0
#include "baked_lightmap_editor_plugin.h"
void BakedLightmapEditorPlugin::_bake() {
@@ -124,3 +125,4 @@ BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) {
BakedLightmapEditorPlugin::~BakedLightmapEditorPlugin() {
}
+#endif
diff --git a/editor/plugins/baked_lightmap_editor_plugin.h b/editor/plugins/baked_lightmap_editor_plugin.h
index 8b94257a62..818cdfe8fa 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.h
+++ b/editor/plugins/baked_lightmap_editor_plugin.h
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#if 0
#ifndef BAKED_LIGHTMAP_EDITOR_PLUGIN_H
#define BAKED_LIGHTMAP_EDITOR_PLUGIN_H
@@ -67,3 +68,4 @@ public:
};
#endif // BAKED_LIGHTMAP_EDITOR_PLUGIN_H
+#endif
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index ab816dc7f3..27ba518f01 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;
@@ -2859,7 +2859,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
bool draw_secondary_lines = !(Math::is_equal_approx(begin.y, corner.y) || Math::is_equal_approx(end.x, corner.x));
- viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3), true);
+ viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3));
if (draw_secondary_lines) {
viewport->draw_line(begin, corner, ruler_secondary_color, Math::round(EDSCALE));
viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE));
@@ -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();
@@ -3210,7 +3210,7 @@ void CanvasItemEditor::_draw_selection() {
};
for (int i = 0; i < 4; i++) {
- viewport->draw_line(pre_drag_endpoints[i], pre_drag_endpoints[(i + 1) % 4], pre_drag_color, Math::round(2 * EDSCALE), true);
+ viewport->draw_line(pre_drag_endpoints[i], pre_drag_endpoints[(i + 1) % 4], pre_drag_color, Math::round(2 * EDSCALE));
}
} else {
viewport->draw_texture(previous_position_icon, (pre_drag_xform.xform(Point2()) - (previous_position_icon->get_size() / 2)).floor());
@@ -3232,7 +3232,7 @@ void CanvasItemEditor::_draw_selection() {
Color c = Color(1, 0.6, 0.4, 0.7);
for (int i = 0; i < 4; i++) {
- viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE), true);
+ viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE));
}
} else {
@@ -3305,7 +3305,7 @@ void CanvasItemEditor::_draw_selection() {
points.push_back(Vector2((move_factor.x + 10) * EDSCALE, 0));
viewport->draw_colored_polygon(points, get_color("axis_x_color", "Editor"));
- viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE), true);
+ viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE));
points.clear();
points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE));
@@ -3313,7 +3313,7 @@ void CanvasItemEditor::_draw_selection() {
points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE));
viewport->draw_colored_polygon(points, get_color("axis_y_color", "Editor"));
- viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE), true);
+ viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE));
viewport->draw_set_transform_matrix(viewport->get_transform());
}
@@ -3344,11 +3344,11 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_set_transform_matrix(simple_xform);
Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
viewport->draw_rect(x_handle_rect, get_color("axis_x_color", "Editor"));
- viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE), true);
+ viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE));
Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
viewport->draw_rect(y_handle_rect, get_color("axis_y_color", "Editor"));
- viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE), true);
+ viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE));
viewport->draw_set_transform_matrix(viewport->get_transform());
}
@@ -3378,8 +3378,7 @@ void CanvasItemEditor::_draw_selection() {
transform.xform(drag_rotation_center),
transform.xform(drag_to),
get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
- Math::round(2 * EDSCALE),
- true);
+ Math::round(2 * EDSCALE));
}
}
@@ -3540,7 +3539,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 +3553,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 +3607,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 +5886,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 +5943,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 +6080,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 +6135,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 +6143,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..3de67589ee 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;
@@ -463,9 +463,7 @@ void Polygon3DEditor::_polygon_draw() {
imgeom->end();
- while (m->get_surface_count()) {
- m->surface_remove(0);
- }
+ m->clear_surfaces();
if (poly.size() == 0)
return;
@@ -547,23 +545,22 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
imgeom = memnew(ImmediateGeometry);
imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));
- line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
line_material->set_albedo(Color(1, 1, 1));
- handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
- 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");
+ handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
+ handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ 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);
+ handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle);
pointsm = memnew(MeshInstance);
imgeom->add_child(pointsm);
diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h
index 1871c6ee7e..3b6c25ac17 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_editor_plugin.h
@@ -57,8 +57,8 @@ class Polygon3DEditor : public HBoxContainer {
ToolButton *button_create;
ToolButton *button_edit;
- Ref<SpatialMaterial> line_material;
- Ref<SpatialMaterial> handle_material;
+ Ref<StandardMaterial3D> line_material;
+ Ref<StandardMaterial3D> handle_material;
EditorNode *editor;
Panel *panel;
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..0af983f780 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -612,7 +612,7 @@ struct CanvasItemPlotCurve {
void operator()(Vector2 pos0, Vector2 pos1, bool in_definition) {
// FIXME: Using a line width greater than 1 breaks curve rendering
- ci.draw_line(pos0, pos1, in_definition ? color1 : color2, 1, true);
+ ci.draw_line(pos0, pos1, in_definition ? color1 : color2, 1);
}
};
@@ -693,13 +693,13 @@ void CurveEditor::_draw() {
if (i != 0) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_LEFT);
- draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE), true);
+ draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE));
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color);
}
if (i != curve.get_point_count() - 1) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_RIGHT);
- draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE), true);
+ draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE));
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color);
}
}
@@ -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..6e8aef0aea 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() {
@@ -369,7 +370,6 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
VS::get_singleton()->viewport_set_size(viewport, 128, 128);
VS::get_singleton()->viewport_set_transparent_background(viewport, true);
VS::get_singleton()->viewport_set_active(viewport, true);
- VS::get_singleton()->viewport_set_vflip(viewport, true);
viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
camera = VS::get_singleton()->camera_create();
@@ -490,15 +490,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 +599,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 +612,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 +627,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 +687,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 +710,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 +726,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 +743,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 +762,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;
}
@@ -772,7 +772,6 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
viewport = VS::get_singleton()->viewport_create();
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED);
- VS::get_singleton()->viewport_set_vflip(viewport, true);
VS::get_singleton()->viewport_set_scenario(viewport, scenario);
VS::get_singleton()->viewport_set_size(viewport, 128, 128);
VS::get_singleton()->viewport_set_transparent_background(viewport, true);
@@ -831,7 +830,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 +867,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 +884,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);
}
@@ -903,7 +902,6 @@ EditorFontPreviewPlugin::EditorFontPreviewPlugin() {
viewport = VS::get_singleton()->viewport_create();
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED);
- VS::get_singleton()->viewport_set_vflip(viewport, true);
VS::get_singleton()->viewport_set_size(viewport, 128, 128);
VS::get_singleton()->viewport_set_active(viewport, true);
viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
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/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index 8914e0ed01..fe2c0d33b7 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -33,6 +33,18 @@
void GIProbeEditorPlugin::_bake() {
if (gi_probe) {
+ if (gi_probe->get_probe_data().is_null()) {
+ String path = get_tree()->get_edited_scene_root()->get_filename();
+ if (path == String()) {
+ path = "res://" + gi_probe->get_name() + "_data.res";
+ } else {
+ String ext = path.get_extension();
+ path = path.get_basename() + "." + gi_probe->get_name() + "_data.res";
+ }
+ probe_file->set_current_path(path);
+ probe_file->popup_centered_ratio();
+ return;
+ }
gi_probe->bake();
}
}
@@ -51,13 +63,42 @@ bool GIProbeEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("GIProbe");
}
+void GIProbeEditorPlugin::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_PROCESS) {
+ if (!gi_probe) {
+ return;
+ }
+
+ String text;
+
+ Vector3i size = gi_probe->get_estimated_cell_size();
+ text = itos(size.x) + ", " + itos(size.y) + ", " + itos(size.z);
+ int data_size = 4;
+ if (GLOBAL_GET("rendering/quality/gi_probes/anisotropic")) {
+ data_size += 4;
+ }
+ text += " - VRAM Size: " + String::num(size.x * size.y * size.z * data_size / (1024.0 * 1024.0), 2) + " Mb.";
+
+ if (bake_info->get_text() == text) {
+ return;
+ }
+
+ bake_info->add_color_override("font_color", bake_info->get_color("success_color", "Editor"));
+
+ bake_info->set_text(text);
+ }
+}
+
void GIProbeEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- bake->show();
+ bake_hb->show();
+ set_process(true);
} else {
- bake->hide();
+ bake_hb->hide();
+ set_process(false);
}
}
@@ -82,21 +123,45 @@ void GIProbeEditorPlugin::bake_func_end() {
tmp_progress = NULL;
}
+void GIProbeEditorPlugin::_giprobe_save_path_and_bake(const String &p_path) {
+ probe_file->hide();
+ if (gi_probe) {
+ gi_probe->bake();
+ ERR_FAIL_COND(gi_probe->get_probe_data().is_null());
+ ResourceSaver::save(p_path, gi_probe->get_probe_data(), ResourceSaver::FLAG_CHANGE_PATH);
+ }
+}
+
void GIProbeEditorPlugin::_bind_methods() {
ClassDB::bind_method("_bake", &GIProbeEditorPlugin::_bake);
+ ClassDB::bind_method("_giprobe_save_path_and_bake", &GIProbeEditorPlugin::_giprobe_save_path_and_bake);
}
GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
editor = p_node;
+ bake_hb = memnew(HBoxContainer);
+ bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ bake_hb->hide();
bake = memnew(ToolButton);
bake->set_icon(editor->get_gui_base()->get_icon("Bake", "EditorIcons"));
bake->set_text(TTR("Bake GI Probe"));
- bake->hide();
bake->connect("pressed", this, "_bake");
- add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake);
+ bake_hb->add_child(bake);
+ bake_info = memnew(Label);
+ bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ bake_info->set_clip_text(true);
+ bake_hb->add_child(bake_info);
+
+ add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb);
gi_probe = NULL;
+ probe_file = memnew(EditorFileDialog);
+ probe_file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ probe_file->add_filter("*.res");
+ probe_file->connect("file_selected", this, "_giprobe_save_path_and_bake");
+ get_editor_interface()->get_base_control()->add_child(probe_file);
+ probe_file->set_title(TTR("Select path for GIProbe Data File"));
GIProbe::bake_begin_function = bake_func_begin;
GIProbe::bake_step_function = bake_func_step;
diff --git a/editor/plugins/gi_probe_editor_plugin.h b/editor/plugins/gi_probe_editor_plugin.h
index 5db682835d..2068ebaaa8 100644
--- a/editor/plugins/gi_probe_editor_plugin.h
+++ b/editor/plugins/gi_probe_editor_plugin.h
@@ -42,18 +42,24 @@ class GIProbeEditorPlugin : public EditorPlugin {
GIProbe *gi_probe;
+ HBoxContainer *bake_hb;
+ Label *bake_info;
ToolButton *bake;
EditorNode *editor;
+ EditorFileDialog *probe_file;
+
static EditorProgress *tmp_progress;
static void bake_func_begin(int p_steps);
static void bake_func_step(int p_step, const String &p_description);
static void bake_func_end();
void _bake();
+ void _giprobe_save_path_and_bake(const String &p_path);
protected:
static void _bind_methods();
+ void _notification(int p_what);
public:
virtual String get_name() const { return "GIProbe"; }
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..4e44082853 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);
@@ -225,7 +225,9 @@ EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() {
env.instance();
Ref<ProceduralSky> proc_sky = memnew(ProceduralSky(true));
env->set_sky(proc_sky);
- env->set_background(Environment::BG_COLOR_SKY);
+ env->set_background(Environment::BG_COLOR);
+ env->set_ambient_source(Environment::AMBIENT_SOURCE_SKY);
+ env->set_reflection_source(Environment::REFLECTION_SOURCE_SKY);
}
MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
@@ -235,18 +237,18 @@ MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
add_inspector_plugin(plugin);
}
-String SpatialMaterialConversionPlugin::converts_to() const {
+String StandardMaterial3DConversionPlugin::converts_to() const {
return "ShaderMaterial";
}
-bool SpatialMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool StandardMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource) const {
- Ref<SpatialMaterial> mat = p_resource;
+ Ref<StandardMaterial3D> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const {
- Ref<SpatialMaterial> mat = p_resource;
+ Ref<StandardMaterial3D> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
@@ -266,9 +268,9 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
- // Texture parameter has to be treated specially since SpatialMaterial saved it
+ // Texture parameter has to be treated specially since StandardMaterial3D 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/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 7f0a373dc7..95a6c4bf8f 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -100,8 +100,8 @@ public:
MaterialEditorPlugin(EditorNode *p_node);
};
-class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin {
- GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin);
+class StandardMaterial3DConversionPlugin : public EditorResourceConversionPlugin {
+ GDCLASS(StandardMaterial3DConversionPlugin, EditorResourceConversionPlugin);
public:
virtual String converts_to() const;
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/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index 5dc222f84c..ddd27b5e97 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -172,7 +172,7 @@ void MultiMeshEditor::_populate() {
int instance_count = populate_amount->get_value();
multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
- multimesh->set_color_format(MultiMesh::COLOR_NONE);
+ multimesh->set_use_colors(false);
multimesh->set_instance_count(instance_count);
float _tilt_random = populate_tilt_random->get_value();
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..383dada590 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();
@@ -396,8 +396,8 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
if (point != pointout) {
smooth = true;
// Draw the line with a dark and light color to be visible on all backgrounds
- vpc->draw_line(point, pointout, Color(0, 0, 0, 0.5), Math::round(EDSCALE), true);
- vpc->draw_line(point, pointout, Color(1, 1, 1, 0.5), Math::round(EDSCALE), true);
+ vpc->draw_line(point, pointout, Color(0, 0, 0, 0.5), Math::round(EDSCALE));
+ vpc->draw_line(point, pointout, Color(1, 1, 1, 0.5), Math::round(EDSCALE));
vpc->draw_texture_rect(curve_handle, Rect2(pointout - curve_handle_size * 0.5, curve_handle_size), false, Color(1, 1, 1, 0.75));
}
}
@@ -407,8 +407,8 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
if (point != pointin) {
smooth = true;
// Draw the line with a dark and light color to be visible on all backgrounds
- vpc->draw_line(point, pointin, Color(0, 0, 0, 0.5), Math::round(EDSCALE), true);
- vpc->draw_line(point, pointin, Color(1, 1, 1, 0.5), Math::round(EDSCALE), true);
+ vpc->draw_line(point, pointin, Color(0, 0, 0, 0.5), Math::round(EDSCALE));
+ vpc->draw_line(point, pointin, Color(1, 1, 1, 0.5), Math::round(EDSCALE));
vpc->draw_texture_rect(curve_handle, Rect2(pointin - curve_handle_size * 0.5, curve_handle_size), false, Color(1, 1, 1, 0.75));
}
}
@@ -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/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index 67889bc074..92f21d8428 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -221,9 +221,9 @@ void PathSpatialGizmo::redraw() {
clear();
- Ref<SpatialMaterial> path_material = gizmo_plugin->get_material("path_material", this);
- Ref<SpatialMaterial> path_thin_material = gizmo_plugin->get_material("path_thin_material", this);
- Ref<SpatialMaterial> handles_material = gizmo_plugin->get_material("handles");
+ Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this);
+ Ref<StandardMaterial3D> path_thin_material = gizmo_plugin->get_material("path_thin_material", this);
+ Ref<StandardMaterial3D> handles_material = gizmo_plugin->get_material("handles");
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 35c0142d4b..14e22625d9 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()) {
@@ -1078,7 +1078,7 @@ void Polygon2DEditor::_uv_draw() {
int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0;
if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) {
- uv_edit_draw->draw_line(mtx.xform(points_prev[i]), mtx.xform(points_prev[next]), prev_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(points_prev[i]), mtx.xform(points_prev[next]), prev_color, Math::round(EDSCALE));
}
Vector2 next_point = uvs[next];
@@ -1086,7 +1086,7 @@ void Polygon2DEditor::_uv_draw() {
next_point = uv_create_to;
}
if (i < uv_draw_max /*&& polygons.size() == 0 && polygon_create.size() == 0*/) { //if using or creating polygons, do not show outline (will show polygons instead)
- uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE));
}
rect.expand_to(mtx.basis_xform(uvs[i]));
@@ -1107,7 +1107,7 @@ void Polygon2DEditor::_uv_draw() {
if (idx_next < 0 || idx_next >= uvs.size())
continue;
- uv_edit_draw->draw_line(mtx.xform(uvs[idx]), mtx.xform(uvs[idx_next]), polygon_line_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(uvs[idx]), mtx.xform(uvs[idx_next]), polygon_line_color, Math::round(EDSCALE));
}
if (points.size() >= 3) {
uv_edit_draw->draw_polygon(polypoints, polygon_fill_color);
@@ -1134,7 +1134,7 @@ void Polygon2DEditor::_uv_draw() {
for (int i = 0; i < polygon_create.size(); i++) {
Vector2 from = uvs[polygon_create[i]];
Vector2 to = (i + 1) < polygon_create.size() ? uvs[polygon_create[i + 1]] : uv_create_to;
- uv_edit_draw->draw_line(mtx.xform(from), mtx.xform(to), polygon_line_color, Math::round(EDSCALE), true);
+ uv_edit_draw->draw_line(mtx.xform(from), mtx.xform(to), polygon_line_color, Math::round(EDSCALE));
}
}
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..88376f6ce6 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());
@@ -2272,9 +2272,6 @@ void SpatialEditorViewport::_notification(int p_what) {
int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/filters/msaa");
viewport->set_msaa(Viewport::MSAA(msaa_mode));
- bool hdr = ProjectSettings::get_singleton()->get("rendering/quality/depth/hdr");
- viewport->set_hdr(hdr);
-
bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
info_label->set_visible(show_info);
@@ -2371,7 +2368,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();
@@ -2442,8 +2439,7 @@ void SpatialEditorViewport::_draw() {
_edit.mouse_pos,
center,
get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
- Math::round(2 * EDSCALE),
- true);
+ Math::round(2 * EDSCALE));
}
if (previewing) {
@@ -2763,43 +2759,76 @@ void SpatialEditorViewport::_menu_option(int p_option) {
view_menu->get_popup()->set_item_checked(idx, !current);
} break;
- case VIEW_DISPLAY_NORMAL: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_DISABLED);
-
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), true);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), false);
- } break;
- case VIEW_DISPLAY_WIREFRAME: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_WIREFRAME);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), true);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), false);
-
- } break;
- case VIEW_DISPLAY_OVERDRAW: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_OVERDRAW);
- VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_OVERDRAW);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), true);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), false);
-
- } break;
- case VIEW_DISPLAY_SHADELESS: {
-
- viewport->set_debug_draw(Viewport::DEBUG_DRAW_UNSHADED);
- VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_SHADELESS);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW), false);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS), true);
+ case VIEW_DISPLAY_NORMAL:
+ case VIEW_DISPLAY_WIREFRAME:
+ case VIEW_DISPLAY_OVERDRAW:
+ case VIEW_DISPLAY_SHADELESS:
+ case VIEW_DISPLAY_LIGHTING:
+ case VIEW_DISPLAY_NORMAL_BUFFER:
+ case VIEW_DISPLAY_DEBUG_SHADOW_ATLAS:
+ case VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS:
+ case VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO:
+ case VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING:
+ case VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION:
+ case VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE:
+ case VIEW_DISPLAY_DEBUG_SSAO:
+ case VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER: {
+
+ static const int display_options[] = {
+ VIEW_DISPLAY_NORMAL,
+ VIEW_DISPLAY_WIREFRAME,
+ VIEW_DISPLAY_OVERDRAW,
+ VIEW_DISPLAY_SHADELESS,
+ VIEW_DISPLAY_LIGHTING,
+ VIEW_DISPLAY_NORMAL_BUFFER,
+ VIEW_DISPLAY_WIREFRAME,
+ VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO,
+ VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING,
+ VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION,
+ VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE,
+ VIEW_DISPLAY_DEBUG_SSAO,
+ VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER,
+ VIEW_MAX
+ };
+ static const Viewport::DebugDraw debug_draw_modes[] = {
+ Viewport::DEBUG_DRAW_DISABLED,
+ Viewport::DEBUG_DRAW_WIREFRAME,
+ Viewport::DEBUG_DRAW_OVERDRAW,
+ Viewport::DEBUG_DRAW_UNSHADED,
+ Viewport::DEBUG_DRAW_LIGHTING,
+ Viewport::DEBUG_DRAW_NORMAL_BUFFER,
+ Viewport::DEBUG_DRAW_WIREFRAME,
+ Viewport::DEBUG_DRAW_SHADOW_ATLAS,
+ Viewport::DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
+ Viewport::DEBUG_DRAW_GI_PROBE_ALBEDO,
+ Viewport::DEBUG_DRAW_GI_PROBE_LIGHTING,
+ Viewport::DEBUG_DRAW_GI_PROBE_EMISSION,
+ Viewport::DEBUG_DRAW_SCENE_LUMINANCE,
+ Viewport::DEBUG_DRAW_SSAO,
+ Viewport::DEBUG_DRAW_ROUGHNESS_LIMITER,
+ };
+
+ int idx = 0;
+
+ while (display_options[idx] != VIEW_MAX) {
+
+ int id = display_options[idx];
+ int item_idx = view_menu->get_popup()->get_item_index(id);
+ if (item_idx != -1) {
+ view_menu->get_popup()->set_item_checked(item_idx, id == p_option);
+ }
+ item_idx = display_submenu->get_item_index(id);
+ if (item_idx != -1) {
+ display_submenu->set_item_checked(item_idx, id == p_option);
+ }
+ if (id == p_option) {
+ viewport->set_debug_draw(debug_draw_modes[idx]);
+ }
+ idx++;
+ }
} break;
}
}
@@ -3594,6 +3623,9 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
vbox->add_child(view_menu);
view_menu->set_h_size_flags(0);
+ display_submenu = memnew(PopupMenu);
+ view_menu->get_popup()->add_child(display_submenu);
+
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
@@ -3610,8 +3642,25 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_normal", TTR("Display Normal")), VIEW_DISPLAY_NORMAL);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_wireframe", TTR("Display Wireframe")), VIEW_DISPLAY_WIREFRAME);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_overdraw", TTR("Display Overdraw")), VIEW_DISPLAY_OVERDRAW);
+ view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_lighting", TTR("Display Lighting")), VIEW_DISPLAY_LIGHTING);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_unshaded", TTR("Display Unshaded")), VIEW_DISPLAY_SHADELESS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), true);
+ display_submenu->add_radio_check_item(TTR("Normal Buffer"), VIEW_DISPLAY_NORMAL_BUFFER);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Shadow Atlas"), VIEW_DISPLAY_DEBUG_SHADOW_ATLAS);
+ display_submenu->add_radio_check_item(TTR("Directional Shadow"), VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("GIProbe Lighting"), VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING);
+ display_submenu->add_radio_check_item(TTR("GIProbe Albedo"), VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO);
+ display_submenu->add_radio_check_item(TTR("GIProbe Emission"), VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Scene Luminance"), VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("SSAO"), VIEW_DISPLAY_DEBUG_SSAO);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Roughness Limiter"), VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER);
+ display_submenu->set_name("display_advanced");
+ view_menu->get_popup()->add_submenu_item(TTR("Display Advanced..."), "display_advanced");
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("View Environment")), VIEW_ENVIRONMENT);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("View Gizmos")), VIEW_GIZMOS);
@@ -3634,7 +3683,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_transform_with_view"), VIEW_ALIGN_TRANSFORM_WITH_VIEW);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_rotation_with_view"), VIEW_ALIGN_ROTATION_WITH_VIEW);
view_menu->get_popup()->connect("id_pressed", this, "_menu_option");
-
+ display_submenu->connect("id_pressed", this, "_menu_option");
view_menu->set_disable_shortcuts(true);
if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
@@ -3841,12 +3890,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();
@@ -4198,12 +4247,12 @@ void SpatialEditor::_generate_selection_box() {
st->add_vertex(b);
}
- Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
- mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
+ mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
mat->set_albedo(Color(1, 1, 1));
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
st->set_material(mat);
selection_box = st->commit();
}
@@ -4757,9 +4806,9 @@ void SpatialEditor::_init_indicators() {
grid_enabled = true;
indicator_mat.instance();
- indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
Vector<Color> origin_colors;
Vector<Vector3> origin_points;
@@ -4842,14 +4891,14 @@ void SpatialEditor::_init_indicators() {
scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
- Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
- mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
+ mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
mat->set_on_top_of_alpha();
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
mat->set_albedo(col);
gizmo_color[i] = mat;
- Ref<SpatialMaterial> mat_hl = mat->duplicate();
+ Ref<StandardMaterial3D> mat_hl = mat->duplicate();
mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
gizmo_color_hl[i] = mat_hl;
@@ -4937,17 +4986,17 @@ void SpatialEditor::_init_indicators() {
surftool->add_vertex(points[2]);
surftool->add_vertex(points[3]);
- Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial);
- plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> plane_mat = memnew(StandardMaterial3D);
+ plane_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
plane_mat->set_on_top_of_alpha();
- plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ plane_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ plane_mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
plane_mat->set_albedo(col);
plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides
surftool->set_material(plane_mat);
surftool->commit(move_plane_gizmo[i]);
- Ref<SpatialMaterial> plane_mat_hl = plane_mat->duplicate();
+ Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate();
plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides
}
@@ -5067,17 +5116,17 @@ void SpatialEditor::_init_indicators() {
surftool->add_vertex(points[2]);
surftool->add_vertex(points[3]);
- Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial);
- plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ Ref<StandardMaterial3D> plane_mat = memnew(StandardMaterial3D);
+ plane_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
plane_mat->set_on_top_of_alpha();
- plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ plane_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ plane_mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
plane_mat->set_albedo(col);
plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides
surftool->set_material(plane_mat);
surftool->commit(scale_plane_gizmo[i]);
- Ref<SpatialMaterial> plane_mat_hl = plane_mat->duplicate();
+ Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate();
plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides
}
@@ -5591,7 +5640,7 @@ void SpatialEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<CPUParticlesGizmoPlugin>(memnew(CPUParticlesGizmoPlugin)));
add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin)));
add_gizmo_plugin(Ref<GIProbeGizmoPlugin>(memnew(GIProbeGizmoPlugin)));
- add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin)));
+ // add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin)));
add_gizmo_plugin(Ref<CollisionShapeSpatialGizmoPlugin>(memnew(CollisionShapeSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<CollisionPolygonSpatialGizmoPlugin>(memnew(CollisionPolygonSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<NavigationMeshSpatialGizmoPlugin>(memnew(NavigationMeshSpatialGizmoPlugin)));
@@ -6143,13 +6192,13 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
- Vector<Ref<SpatialMaterial> > mats;
+ Vector<Ref<StandardMaterial3D> > mats;
for (int i = 0; i < 4; i++) {
bool selected = i % 2 == 1;
bool instanced = i < 2;
- Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
Color color = instanced ? instanced_color : p_color;
@@ -6158,17 +6207,17 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color
}
material->set_albedo(color);
- material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 1);
+ material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 1);
if (p_use_vertex_color) {
- material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
}
if (p_billboard) {
- material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED);
}
if (p_on_top && selected) {
@@ -6181,17 +6230,17 @@ 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));
- Vector<Ref<SpatialMaterial> > icons;
+ Vector<Ref<StandardMaterial3D> > icons;
for (int i = 0; i < 4; i++) {
bool selected = i % 2 == 1;
bool instanced = i < 2;
- Ref<SpatialMaterial> icon = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
Color color = instanced ? instanced_color : p_albedo;
@@ -6201,16 +6250,16 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const
icon->set_albedo(color);
- icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- icon->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- icon->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- icon->set_cull_mode(SpatialMaterial::CULL_DISABLED);
- icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED);
- icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, p_texture);
- icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true);
- icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
- icon->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN);
+ icon->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ icon->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ icon->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ icon->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
+ icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED);
+ icon->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ icon->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, p_texture);
+ icon->set_flag(StandardMaterial3D::FLAG_FIXED_SIZE, true);
+ icon->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED);
+ icon->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN);
if (p_on_top && selected) {
icon->set_on_top_of_alpha();
@@ -6223,46 +6272,46 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const
}
void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) {
- Ref<SpatialMaterial> handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
- 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");
+ handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
+ 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_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t);
handle_material->set_albedo(Color(1, 1, 1));
- 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);
+ handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
handle_material->set_on_top_of_alpha();
if (p_billboard) {
- handle_material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ handle_material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED);
handle_material->set_on_top_of_alpha();
}
- materials[p_name] = Vector<Ref<SpatialMaterial> >();
+ materials[p_name] = Vector<Ref<StandardMaterial3D> >();
materials[p_name].push_back(handle_material);
}
-void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<SpatialMaterial> p_material) {
- materials[p_name] = Vector<Ref<SpatialMaterial> >();
+void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) {
+ materials[p_name] = Vector<Ref<StandardMaterial3D> >();
materials[p_name].push_back(p_material);
}
-Ref<SpatialMaterial> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) {
- ERR_FAIL_COND_V(!materials.has(p_name), Ref<SpatialMaterial>());
- ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<SpatialMaterial>());
+Ref<StandardMaterial3D> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) {
+ ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>());
+ ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>());
if (p_gizmo.is_null() || materials[p_name].size() == 1) return materials[p_name][0];
int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0);
- Ref<SpatialMaterial> mat = materials[p_name][index];
+ Ref<StandardMaterial3D> mat = materials[p_name][index];
if (current_state == ON_TOP && p_gizmo->is_selected()) {
- mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
+ mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
} else {
- mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, false);
+ mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false);
}
return mat;
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 269e1715ef..a4d6b13389 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -167,8 +167,19 @@ class SpatialEditorViewport : public Control {
VIEW_DISPLAY_WIREFRAME,
VIEW_DISPLAY_OVERDRAW,
VIEW_DISPLAY_SHADELESS,
+ VIEW_DISPLAY_LIGHTING,
+ VIEW_DISPLAY_NORMAL_BUFFER,
+ VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
+ VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO,
+ VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING,
+ VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION,
+ VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE,
+ VIEW_DISPLAY_DEBUG_SSAO,
+ VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER,
VIEW_LOCK_ROTATION,
- VIEW_CINEMATIC_PREVIEW
+ VIEW_CINEMATIC_PREVIEW,
+ VIEW_MAX
};
public:
@@ -205,6 +216,7 @@ private:
ViewportContainer *viewport_container;
MenuButton *view_menu;
+ PopupMenu *display_submenu;
Control *surface;
Viewport *viewport;
@@ -527,10 +539,10 @@ private:
bool grid_enabled;
Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3], scale_plane_gizmo[3];
- Ref<SpatialMaterial> gizmo_color[3];
- Ref<SpatialMaterial> plane_gizmo_color[3];
- Ref<SpatialMaterial> gizmo_color_hl[3];
- Ref<SpatialMaterial> plane_gizmo_color_hl[3];
+ Ref<StandardMaterial3D> gizmo_color[3];
+ Ref<StandardMaterial3D> plane_gizmo_color[3];
+ Ref<StandardMaterial3D> gizmo_color_hl[3];
+ Ref<StandardMaterial3D> plane_gizmo_color_hl[3];
int over_gizmo_handle;
@@ -539,8 +551,8 @@ private:
RID indicators_instance;
RID cursor_mesh;
RID cursor_instance;
- Ref<SpatialMaterial> indicator_mat;
- Ref<SpatialMaterial> cursor_material;
+ Ref<StandardMaterial3D> indicator_mat;
+ Ref<StandardMaterial3D> cursor_material;
// Scene drag and drop support
Spatial *preview_node;
@@ -776,7 +788,7 @@ public:
private:
int current_state;
List<EditorSpatialGizmo *> current_gizmos;
- HashMap<String, Vector<Ref<SpatialMaterial> > > materials;
+ HashMap<String, Vector<Ref<StandardMaterial3D> > > materials;
protected:
static void _bind_methods();
@@ -785,11 +797,11 @@ 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);
+ void add_material(const String &p_name, Ref<StandardMaterial3D> p_material);
- Ref<SpatialMaterial> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>());
+ Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>());
virtual String get_name() const;
virtual int get_priority() const;
diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp
index 6757b180a3..2736bbfd3a 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();
@@ -330,7 +330,7 @@ void SpriteEditor::_convert_to_mesh_2d_node() {
a[Mesh::ARRAY_TEX_UV] = computed_uv;
a[Mesh::ARRAY_INDEX] = computed_indices;
- mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a, Array(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a, Array(), Dictionary(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
MeshInstance2D *mesh_instance = memnew(MeshInstance2D);
mesh_instance->set_mesh(mesh);
@@ -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..60f9bb5dc1 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);
@@ -132,6 +132,7 @@ void TextureEditor::_bind_methods() {
TextureEditor::TextureEditor() {
+ set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
set_custom_minimum_size(Size2(1, 150));
}
@@ -148,11 +149,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..5700623f98 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);
@@ -2662,9 +2662,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (coord == edited_shape_coord || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_collision_shape) {
draw_handles = true;
@@ -2700,9 +2700,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (!creating_shape) {
if (polygon.size() > 1) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
}
if (shape == edited_occlusion_shape) {
@@ -2749,9 +2749,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (coord == edited_shape_coord) {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_occlusion_shape) {
draw_handles = true;
@@ -2789,9 +2789,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_navigation_shape) {
draw_handles = true;
@@ -2838,9 +2838,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (coord == edited_shape_coord) {
if (!creating_shape) {
for (int j = 0; j < polygon.size() - 1; j++) {
- workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1, true);
+ workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1);
}
- workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1, true);
+ workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1);
}
if (shape == edited_navigation_shape) {
draw_handles = true;
@@ -2856,9 +2856,9 @@ void TileSetEditor::draw_polygon_shapes() {
if (creating_shape) {
for (int j = 0; j < current_shape.size() - 1; j++) {
- workspace->draw_line(current_shape[j], current_shape[j + 1], Color(0, 1, 1), 1, true);
+ workspace->draw_line(current_shape[j], current_shape[j + 1], Color(0, 1, 1), 1);
}
- workspace->draw_line(current_shape[current_shape.size() - 1], snap_point(workspace->get_local_mouse_position()), Color(0, 1, 1), 1, true);
+ workspace->draw_line(current_shape[current_shape.size() - 1], snap_point(workspace->get_local_mouse_position()), Color(0, 1, 1), 1);
draw_handles = true;
}
}
@@ -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..3aec50528f 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -33,10 +33,11 @@
#include "core/io/marshalls.h"
#include "core/project_settings.h"
#include "core/ustring.h"
+#include "editor/editor_log.h"
+#include "editor/editor_network_profiler.h"
+#include "editor/editor_visual_profiler.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/spatial_editor_plugin.h"
-#include "editor_log.h"
-#include "editor_network_profiler.h"
#include "editor_node.h"
#include "editor_profiler.h"
#include "editor_scale.h"
@@ -434,7 +435,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);
}
@@ -833,6 +834,32 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
}
perf_history.push_front(p);
perf_draw->update();
+ } else if (p_msg == "visual_profile") {
+ uint64_t frame = p_data[0];
+ PoolVector<String> names = p_data[1];
+ PoolVector<real_t> values = p_data[2];
+
+ EditorVisualProfiler::Metric metric;
+ metric.areas.resize(names.size());
+ metric.frame_number = frame;
+ metric.valid = true;
+
+ {
+ EditorVisualProfiler::Metric::Area *areas_ptr = metric.areas.ptrw();
+ int metric_count = names.size();
+
+ PoolVector<String>::Read rs = names.read();
+ PoolVector<real_t>::Read rr = values.read();
+
+ for (int i = 0; i < metric_count; i++) {
+
+ areas_ptr[i].name = rs[i];
+ areas_ptr[i].cpu_time = rr[i * 2 + 0];
+ areas_ptr[i].gpu_time = rr[i * 2 + 1];
+ }
+ }
+
+ visual_profiler->add_frame_metric(metric);
} else if (p_msg == "error") {
@@ -1178,7 +1205,7 @@ void ScriptEditorDebugger::_performance_draw() {
h2 = (1.0 - h2) * r.size.y;
if (E != perf_history.front())
- perf_draw->draw_line(r.position + Point2(from, h2), r.position + Point2(from + spacing, prev), c, Math::round(EDSCALE), true);
+ perf_draw->draw_line(r.position + Point2(from, h2), r.position + Point2(from + spacing, prev), c, Math::round(EDSCALE));
prev = h2;
E = E->next();
from -= spacing;
@@ -1281,8 +1308,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) + ")");
@@ -1565,12 +1592,33 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
}
}
+void ScriptEditorDebugger::_visual_profiler_activate(bool p_enable) {
+
+ if (!connection.is_valid())
+ return;
+
+ if (p_enable) {
+ profiler_signature.clear();
+ Array msg;
+ msg.push_back("start_visual_profiling");
+ ppeer->put_var(msg);
+ print_verbose("Starting visual profiling.");
+
+ } else {
+ Array msg;
+ msg.push_back("stop_visual_profiling");
+ ppeer->put_var(msg);
+ print_verbose("Ending visual profiling.");
+ }
+}
+
void ScriptEditorDebugger::_network_profiler_activate(bool p_enable) {
if (!connection.is_valid())
return;
if (p_enable) {
+ profiler_signature.clear();
Array msg;
msg.push_back("start_network_profiling");
ppeer->put_var(msg);
@@ -2224,6 +2272,7 @@ void ScriptEditorDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("_expand_errors_list"), &ScriptEditorDebugger::_expand_errors_list);
ClassDB::bind_method(D_METHOD("_collapse_errors_list"), &ScriptEditorDebugger::_collapse_errors_list);
ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate);
+ ClassDB::bind_method(D_METHOD("_visual_profiler_activate"), &ScriptEditorDebugger::_visual_profiler_activate);
ClassDB::bind_method(D_METHOD("_network_profiler_activate"), &ScriptEditorDebugger::_network_profiler_activate);
ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked);
ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list);
@@ -2455,11 +2504,20 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
profiler->connect("break_request", this, "_profiler_seeked");
}
+ { //frame profiler
+ visual_profiler = memnew(EditorVisualProfiler);
+ visual_profiler->set_name(TTR("Visual Profiler"));
+ tabs->add_child(visual_profiler);
+ visual_profiler->connect("enable_profiling", this, "_visual_profiler_activate");
+ visual_profiler->connect("break_request", this, "_profiler_seeked");
+ }
+
{ //network profiler
network_profiler = memnew(EditorNetworkProfiler);
network_profiler->set_name(TTR("Network Profiler"));
tabs->add_child(network_profiler);
network_profiler->connect("enable_profiling", this, "_network_profiler_activate");
+ network_profiler->connect("break_request", this, "_profiler_seeked");
}
{ //monitors
diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h
index 589a011bff..5a821a4a88 100644
--- a/editor/script_editor_debugger.h
+++ b/editor/script_editor_debugger.h
@@ -51,6 +51,7 @@ class TreeItem;
class HSplitContainer;
class ItemList;
class EditorProfiler;
+class EditorVisualProfiler;
class EditorNetworkProfiler;
class ScriptEditorDebuggerInspectedObject;
@@ -169,6 +170,7 @@ private:
Map<String, int> res_path_cache;
EditorProfiler *profiler;
+ EditorVisualProfiler *visual_profiler;
EditorNetworkProfiler *network_profiler;
EditorNode *editor;
@@ -213,6 +215,7 @@ private:
void _expand_errors_list();
void _collapse_errors_list();
+ void _visual_profiler_activate(bool p_enable);
void _profiler_activate(bool p_enable);
void _profiler_seeked();
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index d012b2f821..1163621815 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -170,8 +170,9 @@ void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base, bool p_hidde
instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario());
VS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id());
- if (skin_reference.is_valid())
+ if (skin_reference.is_valid()) {
VS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton());
+ }
if (extra_margin)
VS::get_singleton()->instance_set_extra_visibility_margin(instance, 1);
VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, VS::SHADOW_CASTING_SETTING_OFF);
@@ -280,8 +281,16 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
a.resize(Mesh::ARRAY_MAX);
a[Mesh::ARRAY_VERTEX] = vs;
a[Mesh::ARRAY_TEX_UV] = uv;
+ Vector<int> indices;
+ indices.push_back(0);
+ indices.push_back(1);
+ indices.push_back(2);
+ indices.push_back(0);
+ indices.push_back(2);
+ indices.push_back(3);
+ a[Mesh::ARRAY_INDEX] = indices;
a[Mesh::ARRAY_COLOR] = colors;
- mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLE_FAN, a);
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a);
mesh->surface_set_material(0, p_material);
float md = 0;
@@ -1572,12 +1581,12 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() {
cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor"));
cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor"));
- Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
- mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- mat->set_line_width(3);
+ Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
+ mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+
Array d;
d.resize(VS::ARRAY_MAX);
d[Mesh::ARRAY_VERTEX] = cursor_points;
@@ -1983,7 +1992,7 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
lines.push_back(Vector3());
lines.push_back(raycast->get_cast_to());
- const Ref<SpatialMaterial> material =
+ const Ref<StandardMaterial3D> material =
get_material(raycast->is_enabled() ? "shape_material" : "shape_material_disabled", p_gizmo);
p_gizmo->add_lines(lines, material);
@@ -2003,7 +2012,7 @@ void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
lines.push_back(Vector3());
lines.push_back(Vector3(0, 0, 1.0) * spring_arm->get_length());
- Ref<SpatialMaterial> material = get_material("shape_material", p_gizmo);
+ Ref<StandardMaterial3D> material = get_material("shape_material", p_gizmo);
p_gizmo->add_lines(lines, material);
p_gizmo->add_collision_segments(lines);
@@ -2895,7 +2904,7 @@ void GIProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
}
////
-
+#if 0
BakedIndirectLightGizmoPlugin::BakedIndirectLightGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/baked_indirect_light", Color(0.5, 0.6, 1));
@@ -3024,7 +3033,7 @@ void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_unscaled_billboard(icon, 0.05);
p_gizmo->add_handles(handles, get_material("handles"));
}
-
+#endif
////
CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() {
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index 81b62981ac..b786aa2b50 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -303,6 +303,7 @@ public:
GIProbeGizmoPlugin();
};
+#if 0
class BakedIndirectLightGizmoPlugin : public EditorSpatialGizmoPlugin {
GDCLASS(BakedIndirectLightGizmoPlugin, EditorSpatialGizmoPlugin);
@@ -320,7 +321,7 @@ public:
BakedIndirectLightGizmoPlugin();
};
-
+#endif
class CollisionShapeSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
GDCLASS(CollisionShapeSpatialGizmoPlugin, EditorSpatialGizmoPlugin);