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.cpp60
-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.cpp9
-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/dictionary_property_edit.cpp1
-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.cpp16
-rw-r--r--editor/editor_data.h4
-rw-r--r--editor/editor_export.cpp19
-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_file_system.cpp30
-rw-r--r--editor/editor_file_system.h1
-rw-r--r--editor/editor_help.cpp4
-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.cpp85
-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.cpp36
-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_sectioned_inspector.cpp3
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/editor_spin_slider.cpp6
-rw-r--r--editor/editor_themes.cpp17
-rw-r--r--editor/editor_visual_profiler.cpp857
-rw-r--r--editor/editor_visual_profiler.h154
-rw-r--r--editor/filesystem_dock.cpp34
-rw-r--r--editor/filesystem_dock.h6
-rw-r--r--editor/find_in_files.cpp4
-rw-r--r--editor/groups_editor.cpp2
-rw-r--r--editor/icons/icon_animation_tree_player.svg1
-rw-r--r--editor/icons/icon_godot_docs.svg1
-rw-r--r--editor/icons/icon_o_r_m_material_3d.svg66
-rw-r--r--editor/icons/icon_particle_attractor_2d.svg1
-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/import_dock.cpp64
-rw-r--r--editor/import_dock.h1
-rw-r--r--editor/inspector_dock.cpp18
-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/animation_tree_editor_plugin.cpp7
-rw-r--r--editor/plugins/animation_tree_player_editor_plugin.cpp1451
-rw-r--r--editor/plugins/animation_tree_player_editor_plugin.h184
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp25
-rw-r--r--editor/plugins/asset_library_editor_plugin.h13
-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.cpp95
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h8
-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.cpp10
-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_instance_editor_plugin.cpp72
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.h4
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp4
-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.cpp350
-rw-r--r--editor/plugins/spatial_editor_plugin.h36
-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.cpp10
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp73
-rw-r--r--editor/plugins/tile_set_editor_plugin.h8
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp46
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h3
-rw-r--r--editor/project_manager.cpp94
-rw-r--r--editor/project_manager.h2
-rw-r--r--editor/project_settings_editor.cpp38
-rw-r--r--editor/property_editor.cpp12
-rw-r--r--editor/property_selector.cpp18
-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.cpp29
-rw-r--r--editor/script_create_dialog.cpp4
-rw-r--r--editor/script_editor_debugger.cpp83
-rw-r--r--editor/script_editor_debugger.h3
-rw-r--r--editor/spatial_editor_gizmos.cpp35
-rw-r--r--editor/spatial_editor_gizmos.h3
143 files changed, 2938 insertions, 2879 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 e9719f8618..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);
@@ -1727,7 +1727,7 @@ void AnimationTimelineEdit::update_values() {
time_icon->set_tooltip(TTR("Animation length (frames)"));
} else {
length->set_value(animation->get_length());
- length->set_step(0.01);
+ length->set_step(0.001);
length->set_tooltip(TTR("Animation length (seconds)"));
time_icon->set_tooltip(TTR("Animation length (seconds)"));
}
@@ -1890,7 +1890,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
length = memnew(EditorSpinSlider);
length->set_min(0.001);
length->set_max(36000);
- length->set_step(0.01);
+ length->set_step(0.001);
length->set_allow_greater(true);
length->set_custom_minimum_size(Vector2(70 * EDSCALE, 0));
length->set_hide_slider(true);
@@ -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..e898bc54dd 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -517,6 +517,11 @@ void FindReplaceBar::_replace_text_entered(const String &p_text) {
if (selection_only->is_pressed() && text_edit->is_selection_active()) {
_replace_all();
_hide_bar();
+ } else if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ _replace();
+ search_prev();
+ } else {
+ _replace();
}
}
@@ -819,8 +824,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/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp
index bb01fadb72..82db639379 100644
--- a/editor/dictionary_property_edit.cpp
+++ b/editor/dictionary_property_edit.cpp
@@ -190,5 +190,4 @@ bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) cons
}
DictionaryPropertyEdit::DictionaryPropertyEdit() {
- obj = 0;
}
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..5cb7720170 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -156,8 +156,8 @@ bool EditorHistory::is_history_obj_inspector_only(int p_obj) const {
}
ObjectID EditorHistory::get_history_obj(int p_obj) const {
- ERR_FAIL_INDEX_V(p_obj, history.size(), 0);
- ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), 0);
+ ERR_FAIL_INDEX_V(p_obj, history.size(), ObjectID());
+ ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), ObjectID());
return history[p_obj].path[history[p_obj].level].object;
}
@@ -204,12 +204,12 @@ bool EditorHistory::is_current_inspector_only() const {
ObjectID EditorHistory::get_current() {
if (current < 0 || current >= history.size())
- return 0;
+ return ObjectID();
History &h = history.write[current];
Object *obj = ObjectDB::get_instance(h.path[h.level].object);
if (!obj)
- return 0;
+ return ObjectID();
return obj->get_instance_id();
}
@@ -226,15 +226,15 @@ int EditorHistory::get_path_size() const {
ObjectID EditorHistory::get_path_object(int p_index) const {
if (current < 0 || current >= history.size())
- return 0;
+ return ObjectID();
const History &h = history[current];
- ERR_FAIL_INDEX_V(p_index, h.path.size(), 0);
+ ERR_FAIL_INDEX_V(p_index, h.path.size(), ObjectID());
Object *obj = ObjectDB::get_instance(h.path[p_index].object);
if (!obj)
- return 0;
+ return ObjectID();
return obj->get_instance_id();
}
@@ -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..f638df28a8 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -1245,23 +1245,14 @@ void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, in
String EditorExportPlatform::test_etc2() const {
String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
- bool driver_fallback = ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
bool etc_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc");
bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2");
if (driver == "GLES2" && !etc_supported) {
return TTR("Target platform requires 'ETC' texture compression for GLES2. Enable 'Import Etc' in Project Settings.");
- } else if (driver == "GLES3") {
- String err;
- if (!etc2_supported) {
- err += TTR("Target platform requires 'ETC2' texture compression for GLES3. Enable 'Import Etc 2' in Project Settings.");
- }
- if (driver_fallback && !etc_supported) {
- if (err != String())
- err += "\n";
- err += TTR("Target platform requires 'ETC' texture compression for the driver fallback to GLES2.\nEnable 'Import Etc' in Project Settings, or disable 'Driver Fallback Enabled'.");
- }
- return err;
+ } else if (driver == "Vulkan" && !etc2_supported) {
+ // FIXME: Review if this is true for Vulkan.
+ return TTR("Target platform requires 'ETC2' texture compression for Vulkan. Enable 'Import Etc 2' in Project Settings.");
}
return String();
}
@@ -1477,7 +1468,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 +1620,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_file_system.cpp b/editor/editor_file_system.cpp
index 04fe6e5ce6..107ecac3b0 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -675,9 +675,12 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
if (f == "")
break;
+ if (da->current_is_hidden())
+ continue;
+
if (da->current_is_dir()) {
- if (f.begins_with(".")) //ignore hidden and . / ..
+ if (f.begins_with(".")) // Ignore special and . / ..
continue;
if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this
@@ -871,9 +874,12 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
if (f == "")
break;
+ if (da->current_is_hidden())
+ continue;
+
if (da->current_is_dir()) {
- if (f.begins_with(".")) //ignore hidden and . / ..
+ if (f.begins_with(".")) // Ignore special and . / ..
continue;
int idx = p_dir->find_dir_index(f);
@@ -1059,8 +1065,12 @@ void EditorFileSystem::get_changed_sources(List<String> *r_changed) {
void EditorFileSystem::scan_changes() {
- if (scanning || scanning_changes || thread)
+ if (first_scan || // Prevent a premature changes scan from inhibiting the first full scan
+ scanning || scanning_changes || thread) {
+ scan_changes_pending = true;
+ set_process(true);
return;
+ }
_update_extensions();
sources_changed.clear();
@@ -1105,15 +1115,17 @@ void EditorFileSystem::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
- if (use_threads && thread) {
+ Thread *active_thread = thread ? thread : thread_sources;
+ if (use_threads && active_thread) {
//abort thread if in progress
abort_scan = true;
while (scanning) {
OS::get_singleton()->delay_usec(1000);
}
- Thread::wait_to_finish(thread);
- memdelete(thread);
+ Thread::wait_to_finish(active_thread);
+ memdelete(active_thread);
thread = NULL;
+ thread_sources = NULL;
WARN_PRINT("Scan thread aborted...");
set_process(false);
}
@@ -1164,6 +1176,11 @@ void EditorFileSystem::_notification(int p_what) {
_queue_update_script_classes();
first_scan = false;
}
+
+ if (!is_processing() && scan_changes_pending) {
+ scan_changes_pending = false;
+ scan_changes();
+ }
}
} break;
}
@@ -2138,6 +2155,7 @@ EditorFileSystem::EditorFileSystem() {
scan_total = 0;
update_script_classes_queued = false;
first_scan = true;
+ scan_changes_pending = false;
revalidate_import_files = false;
}
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index ce9936f983..381acc0fe2 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -145,6 +145,7 @@ class EditorFileSystem : public Node {
bool scanning;
bool importing;
bool first_scan;
+ bool scan_changes_pending;
float scan_total;
String filesystem_settings_version_for_import;
bool revalidate_import_files;
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 556dbcbfc4..0ade4c5c80 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -50,7 +50,7 @@ void EditorHelp::_init_colors() {
text_color = get_color("default_color", "RichTextLabel");
headline_color = get_color("headline_color", "EditorHelp");
base_type_color = title_color.linear_interpolate(text_color, 0.5);
- comment_color = text_color * Color(1, 1, 1, 0.4);
+ comment_color = text_color * Color(1, 1, 1, 0.6);
symbol_color = comment_color;
value_color = text_color * Color(1, 1, 1, 0.6);
qualifier_color = text_color * Color(1, 1, 1, 0.8);
@@ -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 bc5058eb53..56581d671a 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -62,6 +62,8 @@
#include "scene/gui/texture_progress.h"
#include "scene/gui/tool_button.h"
#include "scene/resources/packed_scene.h"
+#include "servers/navigation_2d_server.h"
+#include "servers/navigation_server.h"
#include "servers/physics_2d_server.h"
#include "editor/audio_stream_preview.h"
@@ -110,7 +112,6 @@
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/animation_state_machine_editor.h"
#include "editor/plugins/animation_tree_editor_plugin.h"
-#include "editor/plugins/animation_tree_player_editor_plugin.h"
#include "editor/plugins/asset_library_editor_plugin.h"
#include "editor/plugins/audio_stream_editor_plugin.h"
#include "editor/plugins/baked_lightmap_editor_plugin.h"
@@ -182,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");
}
@@ -342,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;
@@ -349,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);
@@ -460,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);
@@ -1538,7 +1558,7 @@ void EditorNode::_dialog_action(String p_file) {
save_resource_in_path(saving_resource, p_file);
saving_resource = Ref<Resource>();
ObjectID current = editor_history.get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj);
current_obj->_change_notify();
} break;
@@ -1691,7 +1711,7 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in
return;
}
- uint32_t id = p_object->get_instance_id();
+ ObjectID id = p_object->get_instance_id();
if (id != editor_history.get_current()) {
if (p_inspector_only) {
@@ -1747,8 +1767,8 @@ static bool overrides_external_editor(Object *p_object) {
void EditorNode::_edit_current() {
- uint32_t current = editor_history.get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = editor_history.get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
bool inspector_only = editor_history.is_current_inspector_only();
this->current = current_obj;
@@ -2709,7 +2729,6 @@ void EditorNode::_save_screenshot(NodePath p_path) {
Viewport *viewport = EditorInterface::get_singleton()->get_editor_viewport()->get_viewport();
viewport->set_clear_mode(Viewport::CLEAR_MODE_ONLY_NEXT_FRAME);
Ref<Image> img = viewport->get_texture()->get_data();
- img->flip_y();
viewport->set_clear_mode(Viewport::CLEAR_MODE_ALWAYS);
Error error = img->save_png(p_path);
ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'.");
@@ -2941,7 +2960,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);
@@ -3766,7 +3785,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();
@@ -3811,7 +3830,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")) {
@@ -3906,7 +3925,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) {
@@ -4731,7 +4750,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);
@@ -4971,7 +4990,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
@@ -5334,8 +5353,8 @@ void EditorNode::_update_video_driver_color() {
// TODO: Probably should de-hardcode this and add to editor settings.
if (video_driver->get_text() == "GLES2") {
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", theme_base->get_color("vulkan_color", "Editor"));
}
}
@@ -5581,9 +5600,10 @@ 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
+
PhysicsServer::get_singleton()->set_active(false); // no physics by default if editor
Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor
ScriptServer::set_scripting_enabled(false); // no scripting by default if editor
@@ -5679,16 +5699,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);
@@ -5804,7 +5829,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);
@@ -6037,7 +6062,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);
@@ -6382,6 +6406,8 @@ EditorNode::EditorNode() {
video_driver->set_focus_mode(Control::FOCUS_NONE);
video_driver->connect("item_selected", this, "_video_driver_selected");
video_driver->add_font_override("font", gui_base->get_font("bold", "EditorFonts"));
+ // TODO re-enable when GLES2 is ported
+ video_driver->set_disabled(true);
right_menu_hb->add_child(video_driver);
String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/quality/driver/driver_name"].hint_string;
@@ -6646,7 +6672,6 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
add_editor_plugin(memnew(MeshInstanceEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
- add_editor_plugin(memnew(AnimationTreePlayerEditorPlugin(this)));
add_editor_plugin(memnew(MeshLibraryEditorPlugin(this)));
add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
add_editor_plugin(memnew(SpriteEditorPlugin(this)));
@@ -6664,7 +6689,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)));
@@ -6700,7 +6725,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..905e928c5a 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));
@@ -388,13 +388,13 @@ void EditorPropertyMember::_property_select() {
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
selector->select_method_from_instance(instance, current);
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
}
@@ -420,13 +420,13 @@ void EditorPropertyMember::_property_select() {
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
selector->select_property_from_instance(instance, current);
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
}
@@ -858,14 +858,14 @@ void EditorPropertyObjectID::update_property() {
type = "Object";
ObjectID id = get_edited_object()->get(get_edited_property());
- if (id != 0) {
+ if (id.is_valid()) {
edit->set_text(type + " ID: " + itos(id));
edit->set_disabled(false);
edit->set_icon(EditorNode::get_singleton()->get_class_icon(type));
} 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_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index 2090c12c91..c4a84bfcdc 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -177,7 +177,7 @@ String SectionedInspector::get_full_item_path(const String &p_item) {
void SectionedInspector::edit(Object *p_object) {
if (!p_object) {
- obj = 0;
+ obj = ObjectID();
sections->clear();
filter->set_edited(NULL);
@@ -308,7 +308,6 @@ EditorInspector *SectionedInspector::get_inspector() {
}
SectionedInspector::SectionedInspector() :
- obj(0),
sections(memnew(Tree)),
filter(memnew(SectionedInspectorFilter)),
inspector(memnew(EditorInspector)),
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 715ce6bea7..d81b9bbb82 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -628,7 +628,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
/* Extra config */
_initial_set("project_manager/sorting_order", 0);
- hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Path,Last Modified");
+ hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Path,Last Edited");
if (p_extra_config.is_valid()) {
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..50e3408037 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);
@@ -90,19 +90,13 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float
Ref<ImageTexture> icon = memnew(ImageTexture);
Ref<Image> img = memnew(Image);
- // dumb gizmo check
- bool is_gizmo = String(editor_icons_names[p_index]).begins_with("Gizmo");
-
// Upsample icon generation only if the editor scale isn't an integer multiplier.
// Generating upsampled icons is slower, and the benefit is hardly visible
// with integer editor scales.
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;
}
@@ -412,6 +406,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("error_color", "Editor", error_color);
theme->set_color("property_color", "Editor", property_color);
+ if (!dark_theme) {
+ theme->set_color("vulkan_color", "Editor", Color::hex(0xad1128ff));
+ } else {
+ theme->set_color("vulkan_color", "Editor", Color(1.0, 0.0, 0.0));
+ }
const int thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
theme->set_constant("scale", "Editor", EDSCALE);
theme->set_constant("thumb_size", "Editor", thumb_size);
@@ -931,7 +930,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..1b68a89181
--- /dev/null
+++ b/editor/editor_visual_profiler.cpp
@@ -0,0 +1,857 @@
+/*************************************************************************/
+/* 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;
+}
+
+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) + "%";
+ }
+
+ 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 5041441ac3..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;
@@ -1782,6 +1782,14 @@ void FileSystemDock::_resource_created() const {
Resource *r = Object::cast_to<Resource>(c);
ERR_FAIL_COND(!r);
+ PackedScene *scene = Object::cast_to<PackedScene>(r);
+ if (scene) {
+ Node *node = memnew(Node);
+ node->set_name("Node");
+ scene->pack(node);
+ memdelete(node);
+ }
+
REF res(r);
editor->push_item(c);
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/find_in_files.cpp b/editor/find_in_files.cpp
index 4ab90ad3e4..b24a5c38f2 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -235,9 +235,11 @@ void FindInFiles::_scan_dir(String path, PoolStringArray &out_folders) {
if (file == "")
break;
- // Ignore special dirs and hidden dirs (such as .git and .import)
+ // Ignore special dirs (such as .git and .import)
if (file == "." || file == ".." || file.begins_with("."))
continue;
+ if (dir->current_is_hidden())
+ continue;
if (dir->current_is_dir())
out_folders.append(file);
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_animation_tree_player.svg b/editor/icons/icon_animation_tree_player.svg
deleted file mode 100644
index 718eaac2d2..0000000000
--- a/editor/icons/icon_animation_tree_player.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v14h1.166v-2h1.834v2h8v-2h2v2h1v-14h-1v2h-2v-2h-8v2h-1.834v-2zm4 3h2v1 1h1 3v2h-2v1 1h1 1v2h-1-2a1.0001 1.0001 0 0 1 -1-1v-1-2h-1a1.0001 1.0001 0 0 1 -1-1v-1-1zm-2.834 1h1.834v2h-1.834zm9.834 0h2v2h-2zm-9.834 4h1.834v2h-1.834zm9.834 0h2v2h-2z" fill="#cea4f1"/></svg> \ No newline at end of file
diff --git a/editor/icons/icon_godot_docs.svg b/editor/icons/icon_godot_docs.svg
deleted file mode 100644
index e38885aed9..0000000000
--- a/editor/icons/icon_godot_docs.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g stroke-width=".32031" transform="matrix(.017241 0 0 .017241 -.82759 -2.7)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 919.24 771.67)"/><path d="m0 0v-59.041c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325h.134c4.795 6.12 9.232 12.569 13.487 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.253-6.88 8.693-13.329 13.487-19.449z" fill="#478cbf" transform="matrix(4.1626 0 0 -4.1626 104.7 525.91)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.133c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(4.1626 0 0 -4.1626 784.07 817.24)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 389.21 625.67)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(4.1626 0 0 -4.1626 367.37 631.06)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 511.99 724.74)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(4.1626 0 0 -4.1626 634.79 625.67)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(4.1626 0 0 -4.1626 656.64 631.06)"/></g><path d="m4 5a3 3 0 0 0 -3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3h2a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0 -3-3 3 3 0 0 0 -2.8262 2h-2.3496a3 3 0 0 0 -2.8242-2zm0 1a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2-2 2 2 0 0 1 2-2zm8 0a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2-2 2 2 0 0 1 2-2z"/></svg> \ No newline at end of file
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_particle_attractor_2d.svg b/editor/icons/icon_particle_attractor_2d.svg
deleted file mode 100644
index 85f289dc4b..0000000000
--- a/editor/icons/icon_particle_attractor_2d.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1a3 7 0 0 0 -2.0801 1.9668 7 3 45 0 0 -2.8691.083984 7 3 45 0 0 -.080078 2.8633 7 3 0 0 0 -1.9707 2.0859 7 3 0 0 0 1.9668 2.0801 3 7 45 0 0 .083984 2.8691 3 7 45 0 0 2.8633.080078 3 7 0 0 0 2.0859 1.9707 3 7 0 0 0 2.0801-1.9668 7 3 45 0 0 2.8691-.083984 7 3 45 0 0 .080078-2.8633 7 3 0 0 0 1.9707-2.0859 7 3 0 0 0 -1.9668-2.0801 3 7 45 0 0 -.083984-2.8691 3 7 45 0 0 -2.8633-.080078 3 7 0 0 0 -2.0859-1.9707zm0 1a2 6 0 0 1 1.2598 1.3438 3 7 45 0 0 -1.2578.75977 7 3 45 0 0 -1.2637-.75781 2 6 0 0 1 1.2617-1.3457zm-3.6348 1.5293a6 2 45 0 1 1.2344.28906 3 7 0 0 0 -.35352 1.4238 7 3 0 0 0 -1.4297.35742 6 2 45 0 1 -.058594-1.8418 6 2 45 0 1 .60742-.22852zm7.0762.0039062a2 6 45 0 1 .80078.22461 2 6 45 0 1 -.060547 1.8418 7 3 0 0 0 -1.4238-.35352 3 7 0 0 0 -.35742-1.4297 2 6 45 0 1 1.041-.2832zm-4.998.70703a6 2 45 0 1 .74023.4707 3 7 45 0 0 -.41211.33984 7 3 0 0 0 -.52344.048828 2 6 0 0 1 .19531-.85938zm3.1152.0019531a2 6 0 0 1 .18945.85547 7 3 0 0 0 -.5293-.050781 7 3 45 0 0 -.4043-.33594 2 6 45 0 1 .74414-.46875zm-1.5586 1.7578a6 2 0 0 1 .82031.021484 6 2 45 0 1 .59375.56445 6 2 45 0 1 .56445.59375 2 6 0 0 1 .021484.82031 2 6 0 0 1 -.021484.82031 2 6 45 0 1 -.56445.59375 2 6 45 0 1 -.59375.56445 6 2 0 0 1 -.82031.021484 6 2 0 0 1 -.82031-.021484 6 2 45 0 1 -.59375-.56445 6 2 45 0 1 -.56445-.59375 2 6 0 0 1 -.021484-.82031 2 6 0 0 1 .021484-.82031 2 6 45 0 1 .56445-.59375 2 6 45 0 1 .59375-.56445 6 2 0 0 1 .82031-.021484zm2.9004.24805a6 2 0 0 1 .85938.19531 2 6 45 0 1 -.4707.74023 7 3 45 0 0 -.33984-.41211 3 7 0 0 0 -.048828-.52344zm-5.8027.0039062a3 7 0 0 0 -.050781.5293 3 7 45 0 0 -.33594.4043 6 2 45 0 1 -.46875-.74414 6 2 0 0 1 .85547-.18945zm7.5566.48633a6 2 0 0 1 1.3457 1.2617 6 2 0 0 1 -1.3438 1.2598 7 3 45 0 0 -.75977-1.2578 3 7 45 0 0 .75781-1.2637zm-9.3105.0019532a7 3 45 0 0 .75977 1.2578 3 7 45 0 0 -.75781 1.2637 6 2 0 0 1 -1.3457-1.2617 6 2 0 0 1 1.3438-1.2598zm4.6562.25977a1 1 0 0 0 -1 1 1 1 0 0 0 1 1 1 1 0 0 0 1-1 1 1 0 0 0 -1-1zm3.2891 1.8145a6 2 45 0 1 .46875.74414 6 2 0 0 1 -.85547.18945 3 7 0 0 0 .050781-.5293 3 7 45 0 0 .33594-.4043zm-6.5781.0019531a7 3 45 0 0 .33984.41211 3 7 0 0 0 .048828.52344 6 2 0 0 1 -.85938-.19531 2 6 45 0 1 .4707-.74023zm-.89258 1.584a7 3 0 0 0 1.4238.35352 3 7 0 0 0 .35742 1.4297 2 6 45 0 1 -1.8418.058594 2 6 45 0 1 .060547-1.8418zm8.3652 0a6 2 45 0 1 .058594 1.8418 6 2 45 0 1 -1.8418-.060547 3 7 0 0 0 .35352-1.4238 7 3 0 0 0 1.4297-.35742zm-2.4316.5a2 6 0 0 1 -.19531.85938 6 2 45 0 1 -.74023-.4707 3 7 45 0 0 .41211-.33984 7 3 0 0 0 .52344-.048828zm-3.5.001953a7 3 0 0 0 .5293.050781 7 3 45 0 0 .4043.33594 2 6 45 0 1 -.74414.46875 2 6 0 0 1 -.18945-.85547zm1.7461.99414a7 3 45 0 0 1.2637.75781 2 6 0 0 1 -1.2617 1.3457 2 6 0 0 1 -1.2598-1.3438 3 7 45 0 0 1.2578-.75977z" fill="#a5b7f3" fill-opacity=".98824"/></svg> \ No newline at end of file
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/import_dock.cpp b/editor/import_dock.cpp
index 20d47e8250..1eb453f4d0 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -49,7 +49,7 @@ public:
values[p_name] = p_value;
if (checking) {
checked.insert(p_name);
- _change_notify(String(p_name).utf8().get_data());
+ _change_notify();
}
return true;
}
@@ -159,24 +159,7 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) {
}
params->update();
-
- preset->get_popup()->clear();
-
- if (params->importer->get_preset_count() == 0) {
- preset->get_popup()->add_item(TTR("Default"));
- } else {
- for (int i = 0; i < params->importer->get_preset_count(); i++) {
- preset->get_popup()->add_item(params->importer->get_preset_name(i));
- }
- }
-
- preset->get_popup()->add_separator();
- preset->get_popup()->add_item(vformat(TTR("Set as Default for '%s'"), params->importer->get_visible_name()), ITEM_SET_AS_DEFAULT);
- if (ProjectSettings::get_singleton()->has_setting("importer_defaults/" + params->importer->get_importer_name())) {
- preset->get_popup()->add_item(TTR("Load Default"), ITEM_LOAD_DEFAULT);
- preset->get_popup()->add_separator();
- preset->get_popup()->add_item(vformat(TTR("Clear Default for '%s'"), params->importer->get_visible_name()), ITEM_CLEAR_DEFAULT);
- }
+ _update_preset_menu();
}
void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
@@ -276,6 +259,17 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
}
}
+ _update_preset_menu();
+
+ params->paths = p_paths;
+ import->set_disabled(false);
+ import_as->set_disabled(false);
+ preset->set_disabled(false);
+
+ imported->set_text(itos(p_paths.size()) + TTR(" Files"));
+}
+
+void ImportDock::_update_preset_menu() {
preset->get_popup()->clear();
if (params->importer->get_preset_count() == 0) {
@@ -286,12 +280,13 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
}
}
- params->paths = p_paths;
- import->set_disabled(false);
- import_as->set_disabled(false);
- preset->set_disabled(false);
-
- imported->set_text(itos(p_paths.size()) + TTR(" Files"));
+ preset->get_popup()->add_separator();
+ preset->get_popup()->add_item(vformat(TTR("Set as Default for '%s'"), params->importer->get_visible_name()), ITEM_SET_AS_DEFAULT);
+ if (ProjectSettings::get_singleton()->has_setting("importer_defaults/" + params->importer->get_importer_name())) {
+ preset->get_popup()->add_item(TTR("Load Default"), ITEM_LOAD_DEFAULT);
+ preset->get_popup()->add_separator();
+ preset->get_popup()->add_item(vformat(TTR("Clear Default for '%s'"), params->importer->get_visible_name()), ITEM_CLEAR_DEFAULT);
+ }
}
void ImportDock::_importer_selected(int i_idx) {
@@ -326,7 +321,7 @@ void ImportDock::_preset_selected(int p_idx) {
ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), d);
ProjectSettings::get_singleton()->save();
-
+ _update_preset_menu();
} break;
case ITEM_LOAD_DEFAULT: {
@@ -336,17 +331,22 @@ void ImportDock::_preset_selected(int p_idx) {
List<Variant> v;
d.get_key_list(&v);
+ if (params->checking) {
+ params->checked.clear();
+ }
for (List<Variant>::Element *E = v.front(); E; E = E->next()) {
params->values[E->get()] = d[E->get()];
+ if (params->checking) {
+ params->checked.insert(E->get());
+ }
}
params->update();
-
} break;
case ITEM_CLEAR_DEFAULT: {
ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), Variant());
ProjectSettings::get_singleton()->save();
-
+ _update_preset_menu();
} break;
default: {
@@ -354,11 +354,15 @@ void ImportDock::_preset_selected(int p_idx) {
params->importer->get_import_options(&options, p_idx);
+ if (params->checking) {
+ params->checked.clear();
+ }
for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
-
params->values[E->get().option.name] = E->get().default_value;
+ if (params->checking) {
+ params->checked.insert(E->get().option.name);
+ }
}
-
params->update();
} break;
}
diff --git a/editor/import_dock.h b/editor/import_dock.h
index a4378fb60d..7a2e669620 100644
--- a/editor/import_dock.h
+++ b/editor/import_dock.h
@@ -62,6 +62,7 @@ class ImportDock : public VBoxContainer {
void _preset_selected(int p_idx);
void _importer_selected(int i_idx);
void _update_options(const Ref<ConfigFile> &p_config = Ref<ConfigFile>());
+ void _update_preset_menu();
void _property_toggled(const StringName &p_prop, bool p_checked);
void _reimport_attempt();
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index b65482cc6b..954a941a96 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -166,8 +166,8 @@ void InspectorDock::_resource_file_selected(String p_file) {
}
void InspectorDock::_save_resource(bool save_as) const {
- uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -180,8 +180,8 @@ void InspectorDock::_save_resource(bool save_as) const {
}
void InspectorDock::_unref_resource() const {
- uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -191,8 +191,8 @@ void InspectorDock::_unref_resource() const {
}
void InspectorDock::_copy_resource() const {
- uint32_t current = EditorNode::get_singleton()->get_editor_history()->get_current();
- Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
+ ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current();
+ Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
@@ -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;
}
@@ -337,6 +337,7 @@ void InspectorDock::_notification(int p_what) {
history_menu->set_icon(get_icon("History", "EditorIcons"));
object_menu->set_icon(get_icon("Tools", "EditorIcons"));
warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
+ warning->add_color_override("font_color", get_color("warning_color", "Editor"));
} break;
}
}
@@ -584,6 +585,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
add_child(warning);
warning->set_text(TTR("Changes may be lost!"));
warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
+ warning->add_color_override("font_color", get_color("warning_color", "Editor"));
warning->set_clip_text(true);
warning->hide();
warning->connect("pressed", this, "_warning_pressed");
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/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 8dc7e4638d..a729c90160 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -59,7 +59,7 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) {
path = tree->get_meta("_tree_edit_path");
edit_path(path);
} else {
- current_root = 0;
+ current_root = ObjectID();
}
}
@@ -128,7 +128,7 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
}
}
} else {
- current_root = 0;
+ current_root = ObjectID();
edited_path = button_path;
}
@@ -151,7 +151,7 @@ void AnimationTreeEditor::_about_to_show_root() {
void AnimationTreeEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) {
- ObjectID root = 0;
+ ObjectID root;
if (tree && tree->get_tree_root().is_valid()) {
root = tree->get_tree_root()->get_instance_id();
}
@@ -242,7 +242,6 @@ AnimationTreeEditor::AnimationTreeEditor() {
add_child(memnew(HSeparator));
- current_root = 0;
singleton = this;
editor_base = memnew(PanelContainer);
editor_base->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/animation_tree_player_editor_plugin.cpp b/editor/plugins/animation_tree_player_editor_plugin.cpp
deleted file mode 100644
index 2b365feec5..0000000000
--- a/editor/plugins/animation_tree_player_editor_plugin.cpp
+++ /dev/null
@@ -1,1451 +0,0 @@
-/*************************************************************************/
-/* animation_tree_player_editor_plugin.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 "animation_tree_player_editor_plugin.h"
-
-#include "core/io/resource_loader.h"
-#include "core/os/input.h"
-#include "core/os/keyboard.h"
-#include "core/project_settings.h"
-#include "editor/editor_scale.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/panel.h"
-#include "scene/main/viewport.h"
-
-void AnimationTreePlayerEditor::edit(AnimationTreePlayer *p_anim_tree) {
-
- anim_tree = p_anim_tree;
-
- if (!anim_tree) {
- hide();
- } else {
- order.clear();
- p_anim_tree->get_node_list(&order);
- /*
- for(List<StringName>::Element* E=order.front();E;E=E->next()) {
-
- if (E->get() >= (int)last_id)
- last_id=E->get()+1;
- }*/
- play_button->set_pressed(p_anim_tree->is_active());
- //read the orders
- }
-}
-
-Size2 AnimationTreePlayerEditor::_get_maximum_size() {
-
- Size2 max;
-
- for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
-
- Point2 pos = anim_tree->node_get_position(E->get());
-
- if (click_type == CLICK_NODE && click_node == E->get()) {
-
- pos += click_motion - click_pos;
- }
- pos += get_node_size(E->get());
- if (pos.x > max.x)
- max.x = pos.x;
- if (pos.y > max.y)
- max.y = pos.y;
- }
-
- return max;
-}
-
-const char *AnimationTreePlayerEditor::_node_type_names[] = { "Output", "Animation", "OneShot", "Mix", "Blend2", "Blend3", "Blend4", "TimeScale", "TimeSeek", "Transition" };
-
-Size2 AnimationTreePlayerEditor::get_node_size(const StringName &p_node) const {
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
-
- Size2 size = style->get_minimum_size();
-
- int count = 2; // title and name
- int inputs = anim_tree->node_get_input_count(p_node);
- count += inputs ? inputs : 1;
- String name = p_node;
-
- float name_w = font->get_string_size(name).width;
- float type_w = font->get_string_size(String(_node_type_names[type])).width;
- float max_w = MAX(name_w, type_w);
-
- switch (type) {
- case AnimationTreePlayer::NODE_TIMESEEK:
- case AnimationTreePlayer::NODE_OUTPUT: {
- } break;
- case AnimationTreePlayer::NODE_ANIMATION:
- case AnimationTreePlayer::NODE_ONESHOT:
- case AnimationTreePlayer::NODE_MIX:
- case AnimationTreePlayer::NODE_BLEND2:
- case AnimationTreePlayer::NODE_BLEND3:
- case AnimationTreePlayer::NODE_BLEND4:
- case AnimationTreePlayer::NODE_TIMESCALE:
- case AnimationTreePlayer::NODE_TRANSITION: {
-
- size.height += font->get_height();
- } break;
- case AnimationTreePlayer::NODE_MAX: {
- }
- }
-
- size.x += max_w + 20;
- size.y += count * (font->get_height() + get_constant("vseparation", "PopupMenu"));
-
- return size;
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changede(String) {
-
- edit_dialog->hide();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changeds(String s) {
-
- _edit_dialog_changed();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changedf(float) {
-
- _edit_dialog_changed();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_changed() {
-
- if (updating_edit)
- return;
-
- if (renaming_edit) {
-
- if (anim_tree->node_rename(edited_node, edit_line[0]->get_text()) == OK) {
- for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
-
- if (E->get() == edited_node)
- E->get() = edit_line[0]->get_text();
- }
- edited_node = edit_line[0]->get_text();
- }
- update();
- return;
- }
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
-
- switch (type) {
-
- case AnimationTreePlayer::NODE_TIMESCALE:
- anim_tree->timescale_node_set_scale(edited_node, edit_line[0]->get_text().to_double());
- break;
- case AnimationTreePlayer::NODE_ONESHOT:
- anim_tree->oneshot_node_set_fadein_time(edited_node, edit_line[0]->get_text().to_double());
- anim_tree->oneshot_node_set_fadeout_time(edited_node, edit_line[1]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart_delay(edited_node, edit_line[2]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart_random_delay(edited_node, edit_line[3]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart(edited_node, edit_check->is_pressed());
- anim_tree->oneshot_node_set_mix_mode(edited_node, edit_option->get_selected());
-
- break;
-
- case AnimationTreePlayer::NODE_MIX:
-
- anim_tree->mix_node_set_amount(edited_node, edit_scroll[0]->get_value());
- break;
- case AnimationTreePlayer::NODE_BLEND2:
- anim_tree->blend2_node_set_amount(edited_node, edit_scroll[0]->get_value());
-
- break;
-
- case AnimationTreePlayer::NODE_BLEND3:
- anim_tree->blend3_node_set_amount(edited_node, edit_scroll[0]->get_value());
-
- break;
- case AnimationTreePlayer::NODE_BLEND4:
-
- anim_tree->blend4_node_set_amount(edited_node, Point2(edit_scroll[0]->get_value(), edit_scroll[1]->get_value()));
-
- break;
-
- case AnimationTreePlayer::NODE_TRANSITION: {
- anim_tree->transition_node_set_xfade_time(edited_node, edit_line[0]->get_text().to_double());
- if (anim_tree->transition_node_get_current(edited_node) != edit_option->get_selected())
- anim_tree->transition_node_set_current(edited_node, edit_option->get_selected());
- } break;
- default: {
- }
- }
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_animation_changed() {
-
- Ref<Animation> anim = property_editor->get_variant().operator RefPtr();
- anim_tree->animation_node_set_animation(edited_node, anim);
- update();
-}
-
-void AnimationTreePlayerEditor::_edit_dialog_edit_animation() {
-
- if (Engine::get_singleton()->is_editor_hint()) {
- get_tree()->get_root()->get_child(0)->call("_resource_selected", property_editor->get_variant().operator RefPtr());
- };
-};
-
-void AnimationTreePlayerEditor::_edit_oneshot_start() {
-
- anim_tree->oneshot_node_start(edited_node);
-}
-
-void AnimationTreePlayerEditor::_play_toggled() {
-
- anim_tree->set_active(play_button->is_pressed());
-}
-
-void AnimationTreePlayerEditor::_master_anim_menu_item(int p_item) {
-
- if (p_item == 0)
- _edit_filters();
- else {
-
- String str = master_anim_popup->get_item_text(p_item);
- anim_tree->animation_node_set_master_animation(edited_node, str);
- }
- update();
-}
-
-void AnimationTreePlayerEditor::_popup_edit_dialog() {
-
- updating_edit = true;
-
- for (int i = 0; i < 2; i++)
- edit_scroll[i]->hide();
-
- for (int i = 0; i < 4; i++) {
-
- edit_line[i]->hide();
- edit_label[i]->hide();
- }
-
- edit_option->hide();
- edit_button->hide();
- filter_button->hide();
- edit_check->hide();
-
- Point2 pos = anim_tree->node_get_position(edited_node) - Point2(h_scroll->get_value(), v_scroll->get_value());
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Size2 size = get_node_size(edited_node);
- Point2 popup_pos(pos.x + style->get_margin(MARGIN_LEFT), pos.y + size.y - style->get_margin(MARGIN_BOTTOM));
- popup_pos += get_global_position();
-
- if (renaming_edit) {
-
- edit_label[0]->set_text(TTR("New name:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(edited_node);
- edit_line[0]->show();
- edit_dialog->set_size(Size2(150, 50));
-
- } else {
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
-
- switch (type) {
-
- case AnimationTreePlayer::NODE_ANIMATION:
-
- if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()))) {
-
- AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()));
- master_anim_popup->clear();
- master_anim_popup->add_item(TTR("Edit Filters"));
- master_anim_popup->add_separator();
- List<StringName> sn;
- ap->get_animation_list(&sn);
- sn.sort_custom<StringName::AlphCompare>();
- for (List<StringName>::Element *E = sn.front(); E; E = E->next()) {
- master_anim_popup->add_item(E->get());
- }
-
- master_anim_popup->set_position(popup_pos);
- master_anim_popup->popup();
- } else {
- property_editor->edit(this, "", Variant::OBJECT, anim_tree->animation_node_get_animation(edited_node), PROPERTY_HINT_RESOURCE_TYPE, "Animation");
- property_editor->set_position(popup_pos);
- property_editor->popup();
- updating_edit = false;
- }
- return;
- case AnimationTreePlayer::NODE_TIMESCALE:
- edit_label[0]->set_text(TTR("Scale:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(rtos(anim_tree->timescale_node_get_scale(edited_node)));
- edit_line[0]->show();
- edit_dialog->set_size(Size2(150, 50));
- break;
- case AnimationTreePlayer::NODE_ONESHOT:
- edit_label[0]->set_text(TTR("Fade In (s):"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(rtos(anim_tree->oneshot_node_get_fadein_time(edited_node)));
- edit_line[0]->show();
- edit_label[1]->set_text(TTR("Fade Out (s):"));
- edit_label[1]->set_position(Point2(5, 55));
- edit_label[1]->show();
- edit_line[1]->set_begin(Point2(15, 75));
- edit_line[1]->set_text(rtos(anim_tree->oneshot_node_get_fadeout_time(edited_node)));
- edit_line[1]->show();
-
- edit_option->clear();
- edit_option->add_item(TTR("Blend"), 0);
- edit_option->add_item(TTR("Mix"), 1);
- edit_option->set_begin(Point2(15, 105));
-
- edit_option->select(anim_tree->oneshot_node_get_mix_mode(edited_node));
- edit_option->show();
-
- edit_check->set_text(TTR("Auto Restart:"));
- edit_check->set_begin(Point2(15, 125));
- edit_check->set_pressed(anim_tree->oneshot_node_has_autorestart(edited_node));
- edit_check->show();
-
- edit_label[2]->set_text(TTR("Restart (s):"));
- edit_label[2]->set_position(Point2(5, 145));
- edit_label[2]->show();
- edit_line[2]->set_begin(Point2(15, 165));
- edit_line[2]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_delay(edited_node)));
- edit_line[2]->show();
- edit_label[3]->set_text(TTR("Random Restart (s):"));
- edit_label[3]->set_position(Point2(5, 195));
- edit_label[3]->show();
- edit_line[3]->set_begin(Point2(15, 215));
- edit_line[3]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_random_delay(edited_node)));
- edit_line[3]->show();
-
- filter_button->set_begin(Point2(10, 245));
- filter_button->show();
-
- edit_button->set_begin(Point2(10, 268));
- edit_button->set_text(TTR("Start!"));
-
- edit_button->show();
-
- edit_dialog->set_size(Size2(180, 293));
-
- break;
-
- case AnimationTreePlayer::NODE_MIX:
-
- edit_label[0]->set_text(TTR("Amount:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->mix_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- edit_dialog->set_size(Size2(150, 50));
-
- break;
- case AnimationTreePlayer::NODE_BLEND2:
- edit_label[0]->set_text(TTR("Blend:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->blend2_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- filter_button->set_begin(Point2(10, 47));
- filter_button->show();
- edit_dialog->set_size(Size2(150, 74));
-
- break;
-
- case AnimationTreePlayer::NODE_BLEND3:
- edit_label[0]->set_text(TTR("Blend:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(-1);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->blend3_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- edit_dialog->set_size(Size2(150, 50));
-
- break;
- case AnimationTreePlayer::NODE_BLEND4:
-
- edit_label[0]->set_text(TTR("Blend 0:"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_step(0.01);
- edit_scroll[0]->set_value(anim_tree->blend4_node_get_amount(edited_node).x);
- edit_scroll[0]->set_begin(Point2(15, 25));
- edit_scroll[0]->show();
- edit_label[1]->set_text(TTR("Blend 1:"));
- edit_label[1]->set_position(Point2(5, 55));
- edit_label[1]->show();
- edit_scroll[1]->set_min(0);
- edit_scroll[1]->set_max(1);
- edit_scroll[1]->set_step(0.01);
- edit_scroll[1]->set_value(anim_tree->blend4_node_get_amount(edited_node).y);
- edit_scroll[1]->set_begin(Point2(15, 75));
- edit_scroll[1]->show();
- edit_dialog->set_size(Size2(150, 100));
-
- break;
-
- case AnimationTreePlayer::NODE_TRANSITION: {
-
- edit_label[0]->set_text(TTR("X-Fade Time (s):"));
- edit_label[0]->set_position(Point2(5, 5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15, 25));
- edit_line[0]->set_text(rtos(anim_tree->transition_node_get_xfade_time(edited_node)));
- edit_line[0]->show();
-
- edit_label[1]->set_text(TTR("Current:"));
- edit_label[1]->set_position(Point2(5, 55));
- edit_label[1]->show();
- edit_option->set_begin(Point2(15, 75));
-
- edit_option->clear();
-
- for (int i = 0; i < anim_tree->transition_node_get_input_count(edited_node); i++) {
- edit_option->add_item(itos(i), i);
- }
-
- edit_option->select(anim_tree->transition_node_get_current(edited_node));
- edit_option->show();
- edit_dialog->set_size(Size2(150, 100));
-
- } break;
- default: {
- }
- }
- }
-
- edit_dialog->set_position(popup_pos);
- edit_dialog->popup();
-
- updating_edit = false;
-}
-
-void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
-
- RID ci = get_canvas_item();
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
- Color font_color = get_color("font_color", "PopupMenu");
- Color font_color_title = get_color("font_color_hover", "PopupMenu");
- font_color_title.a *= 0.8;
- Ref<Texture> slot_icon = get_icon("VisualShaderPort", "EditorIcons");
-
- Size2 size = get_node_size(p_node);
- Point2 pos = anim_tree->node_get_position(p_node);
- if (click_type == CLICK_NODE && click_node == p_node) {
-
- pos += click_motion - click_pos;
- if (pos.x < 5)
- pos.x = 5;
- if (pos.y < 5)
- pos.y = 5;
- }
-
- pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
-
- style->draw(ci, Rect2(pos, size));
-
- float w = size.width - style->get_minimum_size().width;
- float h = font->get_height() + get_constant("vseparation", "PopupMenu");
-
- Point2 ofs = style->get_offset() + pos;
- Point2 ascofs(0, font->get_ascent());
-
- Color bx = font_color_title;
- bx.a *= 0.1;
- draw_rect(Rect2(ofs, Size2(size.width - style->get_minimum_size().width, font->get_height())), bx);
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, String(_node_type_names[type]), font_color_title);
-
- ofs.y += h;
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, p_node, font_color);
- ofs.y += h;
-
- int inputs = anim_tree->node_get_input_count(p_node);
-
- float icon_h_ofs = Math::floor((font->get_height() - slot_icon->get_height()) / 2.0) + 1;
-
- if (type != AnimationTreePlayer::NODE_OUTPUT)
- slot_icon->draw(ci, ofs + Point2(w, icon_h_ofs)); //output
-
- if (inputs) {
- for (int i = 0; i < inputs; i++) {
-
- slot_icon->draw(ci, ofs + Point2(-slot_icon->get_width(), icon_h_ofs));
- String text;
- switch (type) {
-
- case AnimationTreePlayer::NODE_TIMESCALE:
- case AnimationTreePlayer::NODE_TIMESEEK: text = "in"; break;
- case AnimationTreePlayer::NODE_OUTPUT: text = "out"; break;
- case AnimationTreePlayer::NODE_ANIMATION: break;
- case AnimationTreePlayer::NODE_ONESHOT: text = (i == 0 ? "in" : "add"); break;
- case AnimationTreePlayer::NODE_BLEND2:
- case AnimationTreePlayer::NODE_MIX: text = (i == 0 ? "a" : "b"); break;
- case AnimationTreePlayer::NODE_BLEND3:
- switch (i) {
- case 0: text = "b-"; break;
- case 1: text = "a"; break;
- case 2: text = "b+"; break;
- }
- break;
-
- case AnimationTreePlayer::NODE_BLEND4:
- switch (i) {
- case 0: text = "a0"; break;
- case 1: text = "b0"; break;
- case 2: text = "a1"; break;
- case 3: text = "b1"; break;
- }
- break;
-
- case AnimationTreePlayer::NODE_TRANSITION:
- text = itos(i);
- if (anim_tree->transition_node_has_input_auto_advance(p_node, i))
- text += "->";
-
- break;
- default: {
- }
- }
- font->draw(ci, ofs + ascofs + Point2(3, 0), text, font_color);
-
- ofs.y += h;
- }
- } else {
- ofs.y += h;
- }
-
- Ref<StyleBox> pg_bg = get_stylebox("bg", "ProgressBar");
- Ref<StyleBox> pg_fill = get_stylebox("fill", "ProgressBar");
- Rect2 pg_rect(ofs, Size2(w, h));
-
- bool editable = true;
- switch (type) {
- case AnimationTreePlayer::NODE_ANIMATION: {
-
- Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
- String text;
- if (anim_tree->animation_node_get_master_animation(p_node) != "")
- text = anim_tree->animation_node_get_master_animation(p_node);
- else if (anim.is_null())
- text = "load...";
- else
- text = anim->get_name();
-
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, text, font_color_title);
-
- } break;
- case AnimationTreePlayer::NODE_ONESHOT:
- case AnimationTreePlayer::NODE_MIX:
- case AnimationTreePlayer::NODE_BLEND2:
- case AnimationTreePlayer::NODE_BLEND3:
- case AnimationTreePlayer::NODE_BLEND4:
- case AnimationTreePlayer::NODE_TIMESCALE:
- case AnimationTreePlayer::NODE_TRANSITION: {
-
- font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, "edit...", font_color_title);
- } break;
- default: editable = false;
- }
-
- if (editable) {
-
- Ref<Texture> arrow = get_icon("GuiDropdown", "EditorIcons");
- Point2 arrow_ofs(w - arrow->get_width(), Math::floor((h - arrow->get_height()) / 2));
- arrow->draw(ci, ofs + arrow_ofs);
- }
-}
-
-AnimationTreePlayerEditor::ClickType AnimationTreePlayerEditor::_locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const {
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
-
- float h = (font->get_height() + get_constant("vseparation", "PopupMenu"));
-
- for (const List<StringName>::Element *E = order.back(); E; E = E->prev()) {
-
- const StringName &node = E->get();
-
- AnimationTreePlayer::NodeType type = anim_tree->node_get_type(node);
-
- Point2 pos = anim_tree->node_get_position(node);
- Size2 size = get_node_size(node);
-
- pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
-
- if (!Rect2(pos, size).has_point(p_click))
- continue;
-
- if (p_node_id)
- *p_node_id = node;
-
- pos = p_click - pos;
-
- float y = pos.y - style->get_offset().height;
-
- if (y < 2 * h)
- return CLICK_NODE;
- y -= 2 * h;
-
- int inputs = anim_tree->node_get_input_count(node);
- int count = MAX(inputs, 1);
-
- if (inputs == 0 || (pos.x > size.width / 2 && type != AnimationTreePlayer::NODE_OUTPUT)) {
-
- if (y < count * h) {
-
- if (p_slot_index)
- *p_slot_index = 0;
- return CLICK_OUTPUT_SLOT;
- }
- }
-
- for (int i = 0; i < count; i++) {
-
- if (y < h) {
- if (p_slot_index)
- *p_slot_index = i;
- return CLICK_INPUT_SLOT;
- }
- y -= h;
- }
-
- bool has_parameters = type != AnimationTreePlayer::NODE_OUTPUT && type != AnimationTreePlayer::NODE_TIMESEEK;
- return has_parameters ? CLICK_PARAMETER : CLICK_NODE;
- }
-
- return CLICK_NONE;
-}
-
-Point2 AnimationTreePlayerEditor::_get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot) {
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- Ref<Font> font = get_font("font", "PopupMenu");
- Ref<Texture> slot_icon = get_icon("VisualShaderPort", "EditorIcons");
-
- Size2 size = get_node_size(p_node_id);
- Point2 pos = anim_tree->node_get_position(p_node_id);
-
- if (click_type == CLICK_NODE && click_node == p_node_id) {
-
- pos += click_motion - click_pos;
- if (pos.x < 5)
- pos.x = 5;
- if (pos.y < 5)
- pos.y = 5;
- }
-
- pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
-
- float w = size.width - style->get_minimum_size().width;
- float h = font->get_height() + get_constant("vseparation", "PopupMenu");
-
- pos += style->get_offset();
-
- pos.y += h * 2;
-
- pos.y += h * p_slot;
-
- pos += Point2(-slot_icon->get_width() / 2.0, h / 2.0).floor();
-
- if (!p_input) {
- pos.x += w + slot_icon->get_width();
- }
-
- return pos;
-}
-
-void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
-
- Ref<InputEventMouseButton> mb = p_event;
-
- if (mb.is_valid()) {
-
- if (mb->is_pressed()) {
-
- if (mb->get_button_index() == 1) {
- click_pos = Point2(mb->get_position().x, mb->get_position().y);
- click_motion = click_pos;
- click_type = _locate_click(click_pos, &click_node, &click_slot);
- if (click_type != CLICK_NONE) {
-
- order.erase(click_node);
- order.push_back(click_node);
- update();
- }
-
- switch (click_type) {
- case CLICK_INPUT_SLOT: {
- click_pos = _get_slot_pos(click_node, true, click_slot);
- } break;
- case CLICK_OUTPUT_SLOT: {
- click_pos = _get_slot_pos(click_node, false, click_slot);
- } break;
- case CLICK_PARAMETER: {
-
- edited_node = click_node;
- renaming_edit = false;
- _popup_edit_dialog();
- //open editor
- //_node_edit_property(click_node);
- } break;
- default: {
- }
- }
- }
- if (mb->get_button_index() == 2) {
-
- if (click_type != CLICK_NONE) {
- click_type = CLICK_NONE;
- update();
- } else {
- // try to disconnect/remove
-
- Point2 rclick_pos = Point2(mb->get_position().x, mb->get_position().y);
- rclick_type = _locate_click(rclick_pos, &rclick_node, &rclick_slot);
- if (rclick_type == CLICK_INPUT_SLOT || rclick_type == CLICK_OUTPUT_SLOT) {
-
- node_popup->clear();
- node_popup->set_size(Size2(1, 1));
- node_popup->add_item(TTR("Disconnect"), NODE_DISCONNECT);
- if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION) {
- node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT);
- if (rclick_type == CLICK_INPUT_SLOT) {
- if (anim_tree->transition_node_has_input_auto_advance(rclick_node, rclick_slot))
- node_popup->add_item(TTR("Clear Auto-Advance"), NODE_CLEAR_AUTOADVANCE);
- else
- node_popup->add_item(TTR("Set Auto-Advance"), NODE_SET_AUTOADVANCE);
- node_popup->add_item(TTR("Delete Input"), NODE_DELETE_INPUT);
- }
- }
-
- node_popup->set_position(rclick_pos + get_global_position());
- node_popup->popup();
- }
-
- if (rclick_type == CLICK_NODE) {
- node_popup->clear();
- node_popup->set_size(Size2(1, 1));
- node_popup->add_item(TTR("Rename"), NODE_RENAME);
- node_popup->add_item(TTR("Remove"), NODE_ERASE);
- if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION)
- node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT);
- node_popup->set_position(rclick_pos + get_global_position());
- node_popup->popup();
- }
- }
- }
- } else {
-
- if (mb->get_button_index() == 1 && click_type != CLICK_NONE) {
-
- switch (click_type) {
- case CLICK_INPUT_SLOT:
- case CLICK_OUTPUT_SLOT: {
-
- Point2 dst_click_pos = Point2(mb->get_position().x, mb->get_position().y);
- StringName id;
- int slot;
- ClickType dst_click_type = _locate_click(dst_click_pos, &id, &slot);
-
- if (dst_click_type == CLICK_INPUT_SLOT && click_type == CLICK_OUTPUT_SLOT) {
-
- anim_tree->connect_nodes(click_node, id, slot);
- }
- if (click_type == CLICK_INPUT_SLOT && dst_click_type == CLICK_OUTPUT_SLOT) {
-
- anim_tree->connect_nodes(id, click_node, click_slot);
- }
-
- } break;
- case CLICK_NODE: {
- Point2 new_pos = anim_tree->node_get_position(click_node) + (click_motion - click_pos);
- if (new_pos.x < 5)
- new_pos.x = 5;
- if (new_pos.y < 5)
- new_pos.y = 5;
- anim_tree->node_set_position(click_node, new_pos);
-
- } break;
- default: {
- }
- }
-
- click_type = CLICK_NONE;
- update();
- }
- }
- }
-
- Ref<InputEventMouseMotion> mm = p_event;
-
- if (mm.is_valid()) {
-
- if (mm->get_button_mask() & 1 && click_type != CLICK_NONE) {
-
- click_motion = Point2(mm->get_position().x, mm->get_position().y);
- update();
- }
- if (mm->get_button_mask() & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
-
- h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
- v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
- update();
- }
- }
-}
-
-void AnimationTreePlayerEditor::_draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color) {
-
- static const int steps = 20;
-
- Rect2 r;
- r.position = p_from;
- r.expand_to(p_to);
- Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1);
- bool flip = sign.x * sign.y < 0;
-
- Vector2 prev;
- for (int i = 0; i <= steps; i++) {
-
- float d = i / float(steps);
- float c = -Math::cos(d * Math_PI) * 0.5 + 0.5;
- if (flip)
- c = 1.0 - c;
- Vector2 p = r.position + Vector2(d * r.size.width, c * r.size.height);
-
- if (i > 0) {
-
- draw_line(prev, p, p_color, 2);
- }
-
- prev = p;
- }
-}
-
-void AnimationTreePlayerEditor::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- play_button->set_icon(get_icon("Play", "EditorIcons"));
- add_menu->set_icon(get_icon("Add", "EditorIcons"));
- } break;
- case NOTIFICATION_DRAW: {
-
- _update_scrollbars();
- //VisualServer::get_singleton()->canvas_item_add_rect(get_canvas_item(),Rect2(Point2(),get_size()),Color(0,0,0,1));
- get_stylebox("bg", "Tree")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
-
- for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
-
- _draw_node(E->get());
- }
-
- if (click_type == CLICK_INPUT_SLOT || click_type == CLICK_OUTPUT_SLOT) {
-
- _draw_cos_line(click_pos, click_motion, Color(0.5, 1, 0.5, 0.8));
- }
-
- List<AnimationTreePlayer::Connection> connections;
- anim_tree->get_connection_list(&connections);
-
- for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
-
- const AnimationTreePlayer::Connection &c = E->get();
- Point2 source = _get_slot_pos(c.src_node, false, 0);
- Point2 dest = _get_slot_pos(c.dst_node, true, c.dst_input);
- Color col = Color(1, 1, 0.5, 0.8);
- /*
- if (click_type==CLICK_NODE && click_node==c.src_node) {
-
- source+=click_motion-click_pos;
- }
-
- if (click_type==CLICK_NODE && click_node==c.dst_node) {
-
- dest+=click_motion-click_pos;
- }*/
-
- _draw_cos_line(source, dest, col);
- }
-
- const Ref<Font> f = get_font("font", "Label");
- const Point2 status_offset = Point2(5, 25) * EDSCALE + Point2(0, f->get_ascent());
-
- switch (anim_tree->get_last_error()) {
-
- case AnimationTreePlayer::CONNECT_OK: {
-
- f->draw(get_canvas_item(), status_offset, TTR("Animation tree is valid."), Color(0, 1, 0.6, 0.8));
- } break;
- default: {
-
- f->draw(get_canvas_item(), status_offset, TTR("Animation tree is invalid."), Color(1, 0.6, 0.0, 0.8));
- } break;
- }
-
- } break;
- }
-}
-
-void AnimationTreePlayerEditor::_update_scrollbars() {
-
- Size2 size = get_size();
- Size2 hmin = h_scroll->get_combined_minimum_size();
- Size2 vmin = v_scroll->get_combined_minimum_size();
-
- v_scroll->set_begin(Point2(size.width - vmin.width, 0));
- v_scroll->set_end(Point2(size.width, size.height));
-
- h_scroll->set_begin(Point2(0, size.height - hmin.height));
- h_scroll->set_end(Point2(size.width - vmin.width, size.height));
-
- Size2 min = _get_maximum_size();
-
- if (min.height < size.height - hmin.height) {
-
- v_scroll->hide();
- offset.y = 0;
- } else {
-
- v_scroll->show();
- v_scroll->set_max(min.height);
- v_scroll->set_page(size.height - hmin.height);
- offset.y = v_scroll->get_value();
- }
-
- if (min.width < size.width - vmin.width) {
-
- h_scroll->hide();
- offset.x = 0;
- } else {
-
- h_scroll->show();
- h_scroll->set_max(min.width);
- h_scroll->set_page(size.width - vmin.width);
- offset.x = h_scroll->get_value();
- }
-}
-
-void AnimationTreePlayerEditor::_scroll_moved(float) {
-
- offset.x = h_scroll->get_value();
- offset.y = v_scroll->get_value();
- update();
-}
-
-void AnimationTreePlayerEditor::_node_menu_item(int p_item) {
-
- switch (p_item) {
-
- case NODE_DISCONNECT: {
-
- if (rclick_type == CLICK_INPUT_SLOT) {
-
- anim_tree->disconnect_nodes(rclick_node, rclick_slot);
- update();
- }
-
- if (rclick_type == CLICK_OUTPUT_SLOT) {
-
- List<AnimationTreePlayer::Connection> connections;
- anim_tree->get_connection_list(&connections);
-
- for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
-
- const AnimationTreePlayer::Connection &c = E->get();
- if (c.dst_node == rclick_node) {
-
- anim_tree->disconnect_nodes(c.dst_node, c.dst_input);
- }
- }
- update();
- }
-
- } break;
- case NODE_RENAME: {
-
- renaming_edit = true;
- edited_node = rclick_node;
- _popup_edit_dialog();
-
- } break;
- case NODE_ADD_INPUT: {
-
- anim_tree->transition_node_set_input_count(rclick_node, anim_tree->transition_node_get_input_count(rclick_node) + 1);
- update();
- } break;
- case NODE_DELETE_INPUT: {
-
- anim_tree->transition_node_delete_input(rclick_node, rclick_slot);
- update();
- } break;
- case NODE_SET_AUTOADVANCE: {
-
- anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, true);
- update();
-
- } break;
- case NODE_CLEAR_AUTOADVANCE: {
-
- anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, false);
- update();
-
- } break;
-
- case NODE_ERASE: {
-
- if (rclick_node == "out")
- break;
- order.erase(rclick_node);
- anim_tree->remove_node(rclick_node);
- update();
- } break;
- }
-}
-
-StringName AnimationTreePlayerEditor::_add_node(int p_item) {
-
- static const char *bname[] = {
- "out",
- "anim",
- "oneshot",
- "mix",
- "blend2",
- "blend3",
- "blend4",
- "scale",
- "seek",
- "transition"
- };
-
- String name;
- int idx = 1;
-
- while (true) {
-
- name = bname[p_item];
- if (idx > 1)
- name += " " + itos(idx);
- if (anim_tree->node_exists(name))
- idx++;
- else
- break;
- }
-
- anim_tree->add_node((AnimationTreePlayer::NodeType)p_item, name);
- anim_tree->node_set_position(name, Point2(last_x, last_y));
- order.push_back(name);
- last_x += 10;
- last_y += 10;
- last_x = last_x % (int)get_size().width;
- last_y = last_y % (int)get_size().height;
- update();
-
- return name;
-};
-
-void AnimationTreePlayerEditor::_file_dialog_selected(String p_path) {
-
- switch (file_op) {
-
- case MENU_IMPORT_ANIMATIONS: {
- Vector<String> files = file_dialog->get_selected_files();
-
- for (int i = 0; i < files.size(); i++) {
-
- StringName node = _add_node(AnimationTreePlayer::NODE_ANIMATION);
-
- RES anim = ResourceLoader::load(files[i]);
- anim_tree->animation_node_set_animation(node, anim);
- //anim_tree->node_set_name(node, files[i].get_file());
- };
- } break;
-
- default:
- break;
- };
-};
-
-void AnimationTreePlayerEditor::_add_menu_item(int p_item) {
-
- if (p_item == MENU_GRAPH_CLEAR) {
-
- //clear
- } else if (p_item == MENU_IMPORT_ANIMATIONS) {
-
- file_op = MENU_IMPORT_ANIMATIONS;
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- file_dialog->popup_centered_ratio();
-
- } else {
-
- _add_node(p_item);
- }
-}
-
-Size2 AnimationTreePlayerEditor::get_minimum_size() const {
-
- return Size2(10, 200);
-}
-
-void AnimationTreePlayerEditor::_find_paths_for_filter(const StringName &p_node, Set<String> &paths) {
-
- ERR_FAIL_COND(!anim_tree->node_exists(p_node));
-
- for (int i = 0; i < anim_tree->node_get_input_count(p_node); i++) {
-
- StringName port = anim_tree->node_get_input_source(p_node, i);
- if (port == StringName())
- continue;
- _find_paths_for_filter(port, paths);
- }
-
- if (anim_tree->node_get_type(p_node) == AnimationTreePlayer::NODE_ANIMATION) {
-
- Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
- if (anim.is_valid()) {
-
- for (int i = 0; i < anim->get_track_count(); i++) {
- paths.insert(anim->track_get_path(i));
- }
- }
- }
-}
-
-void AnimationTreePlayerEditor::_filter_edited() {
-
- TreeItem *ed = filter->get_edited();
- if (!ed)
- return;
-
- if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ONESHOT) {
- anim_tree->oneshot_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_BLEND2) {
- anim_tree->blend2_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ANIMATION) {
- anim_tree->animation_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
- }
-}
-
-void AnimationTreePlayerEditor::_edit_filters() {
-
- filter_dialog->popup_centered_ratio();
- filter->clear();
-
- Set<String> npb;
- _find_paths_for_filter(edited_node, npb);
-
- TreeItem *root = filter->create_item();
- filter->set_hide_root(true);
- Map<String, TreeItem *> pm;
-
- Node *base = anim_tree->get_node(anim_tree->get_base_path());
-
- for (Set<String>::Element *E = npb.front(); E; E = E->next()) {
-
- TreeItem *parent = root;
- String descr = E->get();
- if (base) {
- NodePath np = E->get();
-
- if (np.get_subname_count() == 1) {
- Node *n = base->get_node(np);
- Skeleton *s = Object::cast_to<Skeleton>(n);
- if (s) {
-
- String skelbase = E->get().substr(0, E->get().find(":"));
-
- int bidx = s->find_bone(np.get_subname(0));
-
- if (bidx != -1) {
- int bparent = s->get_bone_parent(bidx);
- //
- if (bparent != -1) {
-
- String bpn = skelbase + ":" + s->get_bone_name(bparent);
- if (pm.has(bpn)) {
- parent = pm[bpn];
- descr = np.get_subname(0);
- }
- } else {
-
- if (pm.has(skelbase)) {
- parent = pm[skelbase];
- }
- }
- }
- }
- }
- }
-
- TreeItem *it = filter->create_item(parent);
- it->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
- it->set_text(0, descr);
- it->set_metadata(0, NodePath(E->get()));
- it->set_editable(0, true);
- if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ONESHOT) {
- it->set_checked(0, anim_tree->oneshot_node_is_path_filtered(edited_node, E->get()));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_BLEND2) {
- it->set_checked(0, anim_tree->blend2_node_is_path_filtered(edited_node, E->get()));
- } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ANIMATION) {
- it->set_checked(0, anim_tree->animation_node_is_path_filtered(edited_node, E->get()));
- }
- pm[E->get()] = it;
- }
-}
-
-void AnimationTreePlayerEditor::_bind_methods() {
-
- ClassDB::bind_method("_add_menu_item", &AnimationTreePlayerEditor::_add_menu_item);
- ClassDB::bind_method("_node_menu_item", &AnimationTreePlayerEditor::_node_menu_item);
- ClassDB::bind_method("_gui_input", &AnimationTreePlayerEditor::_gui_input);
- //ClassDB::bind_method( "_node_param_changed", &AnimationTreeEditor::_node_param_changed );
- ClassDB::bind_method("_scroll_moved", &AnimationTreePlayerEditor::_scroll_moved);
- ClassDB::bind_method("_edit_dialog_changeds", &AnimationTreePlayerEditor::_edit_dialog_changeds);
- ClassDB::bind_method("_edit_dialog_changede", &AnimationTreePlayerEditor::_edit_dialog_changede);
- ClassDB::bind_method("_edit_dialog_changedf", &AnimationTreePlayerEditor::_edit_dialog_changedf);
- ClassDB::bind_method("_edit_dialog_changed", &AnimationTreePlayerEditor::_edit_dialog_changed);
- ClassDB::bind_method("_edit_dialog_animation_changed", &AnimationTreePlayerEditor::_edit_dialog_animation_changed);
- ClassDB::bind_method("_edit_dialog_edit_animation", &AnimationTreePlayerEditor::_edit_dialog_edit_animation);
- ClassDB::bind_method("_play_toggled", &AnimationTreePlayerEditor::_play_toggled);
- ClassDB::bind_method("_edit_oneshot_start", &AnimationTreePlayerEditor::_edit_oneshot_start);
- ClassDB::bind_method("_file_dialog_selected", &AnimationTreePlayerEditor::_file_dialog_selected);
- ClassDB::bind_method("_master_anim_menu_item", &AnimationTreePlayerEditor::_master_anim_menu_item);
- ClassDB::bind_method("_edit_filters", &AnimationTreePlayerEditor::_edit_filters);
- ClassDB::bind_method("_filter_edited", &AnimationTreePlayerEditor::_filter_edited);
-}
-
-AnimationTreePlayerEditor::AnimationTreePlayerEditor() {
-
- set_focus_mode(FOCUS_ALL);
-
- PopupMenu *p;
- List<PropertyInfo> defaults;
-
- add_menu = memnew(MenuButton);
- //add_menu->set_
- add_menu->set_position(Point2(0, 0));
- add_menu->set_size(Point2(25, 15));
- add_child(add_menu);
-
- p = add_menu->get_popup();
- p->add_item(TTR("Animation Node"), AnimationTreePlayer::NODE_ANIMATION);
- p->add_item(TTR("OneShot Node"), AnimationTreePlayer::NODE_ONESHOT);
- p->add_item(TTR("Mix Node"), AnimationTreePlayer::NODE_MIX);
- p->add_item(TTR("Blend2 Node"), AnimationTreePlayer::NODE_BLEND2);
- p->add_item(TTR("Blend3 Node"), AnimationTreePlayer::NODE_BLEND3);
- p->add_item(TTR("Blend4 Node"), AnimationTreePlayer::NODE_BLEND4);
- p->add_item(TTR("TimeScale Node"), AnimationTreePlayer::NODE_TIMESCALE);
- p->add_item(TTR("TimeSeek Node"), AnimationTreePlayer::NODE_TIMESEEK);
- p->add_item(TTR("Transition Node"), AnimationTreePlayer::NODE_TRANSITION);
- p->add_separator();
- p->add_item(TTR("Import Animations..."), MENU_IMPORT_ANIMATIONS); // wtf
- p->add_separator();
- p->add_item(TTR("Clear"), MENU_GRAPH_CLEAR);
-
- p->connect("id_pressed", this, "_add_menu_item");
-
- play_button = memnew(Button);
- play_button->set_position(Point2(25, 0) * EDSCALE);
- play_button->set_size(Point2(25, 15));
- add_child(play_button);
- play_button->set_toggle_mode(true);
- play_button->connect("pressed", this, "_play_toggled");
-
- last_x = 50;
- last_y = 50;
-
- property_editor = memnew(CustomPropertyEditor);
- add_child(property_editor);
- property_editor->connect("variant_changed", this, "_edit_dialog_animation_changed");
- property_editor->connect("resource_edit_request", this, "_edit_dialog_edit_animation");
-
- h_scroll = memnew(HScrollBar);
- v_scroll = memnew(VScrollBar);
-
- add_child(h_scroll);
- add_child(v_scroll);
-
- h_scroll->connect("value_changed", this, "_scroll_moved");
- v_scroll->connect("value_changed", this, "_scroll_moved");
-
- node_popup = memnew(PopupMenu);
- add_child(node_popup);
- node_popup->set_as_toplevel(true);
-
- master_anim_popup = memnew(PopupMenu);
- add_child(master_anim_popup);
- master_anim_popup->connect("id_pressed", this, "_master_anim_menu_item");
-
- node_popup->connect("id_pressed", this, "_node_menu_item");
-
- updating_edit = false;
-
- edit_dialog = memnew(PopupPanel);
- //edit_dialog->get_ok()->hide();
- //edit_dialog->get_cancel()->hide();
- add_child(edit_dialog);
-
- edit_option = memnew(OptionButton);
- edit_option->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_option->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_option);
- edit_option->connect("item_selected", this, "_edit_dialog_changedf");
- edit_option->hide();
-
- for (int i = 0; i < 2; i++) {
- edit_scroll[i] = memnew(HSlider);
- edit_scroll[i]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_scroll[i]->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_scroll[i]);
- edit_scroll[i]->hide();
- edit_scroll[i]->connect("value_changed", this, "_edit_dialog_changedf");
- }
- for (int i = 0; i < 4; i++) {
- edit_line[i] = memnew(LineEdit);
- edit_line[i]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_line[i]->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_line[i]);
- edit_line[i]->hide();
- edit_line[i]->connect("text_changed", this, "_edit_dialog_changeds");
- edit_line[i]->connect("text_entered", this, "_edit_dialog_changede");
- edit_label[i] = memnew(Label);
- edit_dialog->add_child(edit_label[i]);
- edit_label[i]->hide();
- }
-
- edit_button = memnew(Button);
- edit_button->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_button->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_button);
- edit_button->hide();
- edit_button->connect("pressed", this, "_edit_oneshot_start");
-
- edit_check = memnew(CheckButton);
- edit_check->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- edit_check->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(edit_check);
- edit_check->hide();
- edit_check->connect("pressed", this, "_edit_dialog_changed");
-
- file_dialog = memnew(EditorFileDialog);
- file_dialog->set_enable_multiple_selection(true);
- file_dialog->set_current_dir(ProjectSettings::get_singleton()->get_resource_path());
- add_child(file_dialog);
- file_dialog->connect("file_selected", this, "_file_dialog_selected");
-
- filter_dialog = memnew(AcceptDialog);
- filter_dialog->set_title(TTR("Edit Node Filters"));
- add_child(filter_dialog);
-
- filter = memnew(Tree);
- filter_dialog->add_child(filter);
- //filter_dialog->set_child_rect(filter);
- filter->connect("item_edited", this, "_filter_edited");
-
- filter_button = memnew(Button);
- filter_button->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- filter_button->set_margin(MARGIN_RIGHT, -10);
- edit_dialog->add_child(filter_button);
- filter_button->hide();
- filter_button->set_text(TTR("Filters..."));
- filter_button->connect("pressed", this, "_edit_filters");
-
- set_clip_contents(true);
-}
-
-void AnimationTreePlayerEditorPlugin::edit(Object *p_object) {
-
- anim_tree_editor->edit(Object::cast_to<AnimationTreePlayer>(p_object));
-}
-
-bool AnimationTreePlayerEditorPlugin::handles(Object *p_object) const {
-
- return p_object->is_class("AnimationTreePlayer");
-}
-
-void AnimationTreePlayerEditorPlugin::make_visible(bool p_visible) {
-
- if (p_visible) {
- //editor->hide_animation_player_editors();
- //editor->animation_panel_make_visible(true);
- button->show();
- editor->make_bottom_panel_item_visible(anim_tree_editor);
- anim_tree_editor->set_physics_process(true);
- } else {
-
- if (anim_tree_editor->is_visible_in_tree())
- editor->hide_bottom_panel();
- button->hide();
- anim_tree_editor->set_physics_process(false);
- }
-}
-
-AnimationTreePlayerEditorPlugin::AnimationTreePlayerEditorPlugin(EditorNode *p_node) {
-
- editor = p_node;
- anim_tree_editor = memnew(AnimationTreePlayerEditor);
- anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
-
- button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor);
- button->hide();
-}
-
-AnimationTreePlayerEditorPlugin::~AnimationTreePlayerEditorPlugin() {
-}
diff --git a/editor/plugins/animation_tree_player_editor_plugin.h b/editor/plugins/animation_tree_player_editor_plugin.h
deleted file mode 100644
index d3fd6ae362..0000000000
--- a/editor/plugins/animation_tree_player_editor_plugin.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*************************************************************************/
-/* animation_tree_player_editor_plugin.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 ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H
-#define ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H
-
-#include "editor/editor_node.h"
-#include "editor/editor_plugin.h"
-#include "editor/property_editor.h"
-#include "scene/animation/animation_tree_player.h"
-#include "scene/gui/button.h"
-#include "scene/gui/popup.h"
-#include "scene/gui/tree.h"
-
-class AnimationTreePlayerEditor : public Control {
-
- GDCLASS(AnimationTreePlayerEditor, Control);
-
- static const char *_node_type_names[];
-
- enum ClickType {
- CLICK_NONE,
- CLICK_NAME,
- CLICK_NODE,
- CLICK_INPUT_SLOT,
- CLICK_OUTPUT_SLOT,
- CLICK_PARAMETER
- };
-
- enum {
-
- MENU_GRAPH_CLEAR = 100,
- MENU_IMPORT_ANIMATIONS = 101,
- NODE_DISCONNECT,
- NODE_RENAME,
- NODE_ERASE,
- NODE_ADD_INPUT,
- NODE_DELETE_INPUT,
- NODE_SET_AUTOADVANCE,
- NODE_CLEAR_AUTOADVANCE
- };
-
- bool renaming_edit;
- StringName edited_node;
- bool updating_edit;
- Popup *edit_dialog;
- HSlider *edit_scroll[2];
- LineEdit *edit_line[4];
- OptionButton *edit_option;
- Label *edit_label[4];
- Button *edit_button;
- Button *filter_button;
- CheckButton *edit_check;
- EditorFileDialog *file_dialog;
- int file_op;
-
- void _popup_edit_dialog();
-
- void _setup_edit_dialog(const StringName &p_node);
- PopupMenu *master_anim_popup;
- PopupMenu *node_popup;
- PopupMenu *add_popup;
- HScrollBar *h_scroll;
- VScrollBar *v_scroll;
- MenuButton *add_menu;
-
- CustomPropertyEditor *property_editor;
-
- AnimationTreePlayer *anim_tree;
- List<StringName> order;
- Set<StringName> active_nodes;
-
- int last_x, last_y;
-
- Point2 offset;
- ClickType click_type;
- Point2 click_pos;
- StringName click_node;
- int click_slot;
- Point2 click_motion;
- ClickType rclick_type;
- StringName rclick_node;
- int rclick_slot;
-
- Button *play_button;
-
- Size2 _get_maximum_size();
- Size2 get_node_size(const StringName &p_node) const;
- void _draw_node(const StringName &p_node);
-
- AcceptDialog *filter_dialog;
- Tree *filter;
-
- void _draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color);
- void _update_scrollbars();
- void _scroll_moved(float);
- void _play_toggled();
- /*
- void _node_param_changed();
- void _node_add_callback();
- void _node_add(VisualServer::AnimationTreeNodeType p_type);
- void _node_edit_property(const StringName& p_node);
-*/
-
- void _master_anim_menu_item(int p_item);
- void _node_menu_item(int p_item);
- void _add_menu_item(int p_item);
-
- void _filter_edited();
- void _find_paths_for_filter(const StringName &p_node, Set<String> &paths);
- void _edit_filters();
-
- void _edit_oneshot_start();
- void _edit_dialog_animation_changed();
- void _edit_dialog_edit_animation();
- void _edit_dialog_changeds(String);
- void _edit_dialog_changede(String);
- void _edit_dialog_changedf(float);
- void _edit_dialog_changed();
- void _dialog_changed() const;
- ClickType _locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const;
- Point2 _get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot);
-
- StringName _add_node(int p_item);
- void _file_dialog_selected(String p_path);
-
-protected:
- void _notification(int p_what);
- void _gui_input(Ref<InputEvent> p_event);
- static void _bind_methods();
-
-public:
- virtual Size2 get_minimum_size() const;
- void edit(AnimationTreePlayer *p_anim_tree);
- AnimationTreePlayerEditor();
-};
-
-class AnimationTreePlayerEditorPlugin : public EditorPlugin {
-
- GDCLASS(AnimationTreePlayerEditorPlugin, EditorPlugin);
-
- AnimationTreePlayerEditor *anim_tree_editor;
- EditorNode *editor;
- Button *button;
-
-public:
- virtual String get_name() const { return "AnimTree"; }
- bool has_main_screen() const { return false; }
- virtual void edit(Object *p_object);
- virtual bool handles(Object *p_object) const;
- virtual void make_visible(bool p_visible);
-
- AnimationTreePlayerEditorPlugin(EditorNode *p_node);
- ~AnimationTreePlayerEditorPlugin();
-};
-
-#endif // ANIMATION_TREE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 2428bf82d4..a479703527 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -31,6 +31,8 @@
#include "asset_library_editor_plugin.h"
#include "core/io/json.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
#include "core/version.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
@@ -48,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);
@@ -143,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) {
@@ -391,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);
@@ -620,6 +622,21 @@ void EditorAssetLibrary::_notification(int p_what) {
}
}
+void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) {
+
+ const Ref<InputEventKey> key = p_event;
+
+ if (key.is_valid() && key->is_pressed()) {
+
+ if (key->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) {
+
+ filter->grab_focus();
+ filter->select_all();
+ accept_event();
+ }
+ }
+}
+
void EditorAssetLibrary::_install_asset() {
ERR_FAIL_COND(!description);
@@ -1320,6 +1337,7 @@ void EditorAssetLibrary::disable_community_support() {
void EditorAssetLibrary::_bind_methods() {
+ ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input);
ClassDB::bind_method("_http_request_completed", &EditorAssetLibrary::_http_request_completed);
ClassDB::bind_method("_select_asset", &EditorAssetLibrary::_select_asset);
ClassDB::bind_method("_select_author", &EditorAssetLibrary::_select_author);
@@ -1502,6 +1520,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
description = NULL;
set_process(true);
+ set_process_unhandled_input(true);
downloads_scroll = memnew(ScrollContainer);
downloads_scroll->set_enable_h_scroll(true);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index aa3c735810..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();
};
@@ -300,6 +300,7 @@ class EditorAssetLibrary : public PanelContainer {
protected:
static void _bind_methods();
void _notification(int p_what);
+ void _unhandled_input(const Ref<InputEvent> &p_event);
public:
void disable_community_support();
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 bf21abb455..f7a3b50052 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -606,7 +606,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
}
}
-void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items) {
+void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, bool p_allow_locked) {
Node *scene = editor->get_edited_scene();
@@ -621,14 +621,16 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
node = node->get_parent();
};
- // Replace the node by the group if grouped
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(node);
- while (node && node != scene->get_parent()) {
- CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
- if (canvas_item_tmp && node->has_meta("_edit_group_")) {
- canvas_item = canvas_item_tmp;
+ if (!p_allow_locked) {
+ // Replace the node by the group if grouped
+ while (node && node != scene->get_parent()) {
+ CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
+ if (canvas_item_tmp && node->has_meta("_edit_group_")) {
+ canvas_item = canvas_item_tmp;
+ }
+ node = node->get_parent();
}
- node = node->get_parent();
}
// Check if the canvas item is already in the list (for groups or scenes)
@@ -641,7 +643,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
}
//Remove the item if invalid
- if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || _is_node_locked(canvas_item)) {
+ if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (!p_allow_locked && _is_node_locked(canvas_item))) {
r_items.remove(i);
i--;
} else {
@@ -1987,7 +1989,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if (selection.size() > 0) {
drag_type = DRAG_MOVE;
- CanvasItem *canvas_item = drag_selection[0];
+ CanvasItem *canvas_item = selection[0];
Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse();
Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
@@ -2106,7 +2108,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
// Move the canvas items with the arrow keys
- if (k.is_valid() && k->is_pressed() && tool == TOOL_SELECT &&
+ if (k.is_valid() && k->is_pressed() && (tool == TOOL_SELECT || tool == TOOL_MOVE) &&
(k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)) {
if (!k->is_echo()) {
// Start moving the canvas items with the keyboard
@@ -2223,7 +2225,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
// Popup the selection menu list
Point2 click = transform.affine_inverse().xform(b->get_position());
- _get_canvas_items_at_pos(click, selection_results);
+ _get_canvas_items_at_pos(click, selection_results, b->get_alt() && tool != TOOL_LIST_SELECT);
if (selection_results.size() == 1) {
CanvasItem *item = selection_results[0].item;
@@ -2242,10 +2244,32 @@ 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());
- selection_menu->add_item(item->get_name());
+ int locked = 0;
+ if (_is_node_locked(item)) {
+ locked = 1;
+ } else {
+ Node *scene = editor->get_edited_scene();
+ Node *node = item;
+
+ while (node && node != scene->get_parent()) {
+ CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
+ if (canvas_item_tmp && node->has_meta("_edit_group_")) {
+ locked = 2;
+ }
+ node = node->get_parent();
+ }
+ }
+
+ String suffix = String();
+ if (locked == 1) {
+ suffix = " (" + TTR("Locked") + ")";
+ } else if (locked == 2) {
+ suffix = " (" + TTR("Grouped") + ")";
+ }
+ selection_menu->add_item((String)item->get_name() + suffix);
selection_menu->set_item_icon(i, icon);
selection_menu->set_item_metadata(i, node_path);
selection_menu->set_item_tooltip(i, String(item->get_name()) + "\nType: " + item->get_class() + "\nPath: " + node_path);
@@ -2835,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));
@@ -2942,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);
}
}
@@ -3155,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();
@@ -3186,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());
@@ -3208,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 {
@@ -3281,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));
@@ -3289,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());
}
@@ -3320,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());
}
@@ -3354,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));
}
}
@@ -3516,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);
@@ -3530,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");
@@ -3584,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;
@@ -3636,7 +3659,7 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
// Add a last bone if the Bone2D has no Bone2D child
BoneKey bk;
bk.from = canvas_item->get_instance_id();
- bk.to = 0;
+ bk.to = ObjectID();
if (!bone_list.has(bk)) {
BoneList b;
b.length = 0;
@@ -5863,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) {
@@ -5920,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) {
@@ -6057,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")
@@ -6112,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" ||
@@ -6120,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 37bc47ecd4..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;
@@ -418,7 +418,7 @@ private:
bool _is_node_locked(const Node *p_node);
bool _is_node_movable(const Node *p_node, bool p_popup_warning = false);
void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
- void _get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items);
+ void _get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, bool p_allow_locked = false);
void _get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items);
void _find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_node, List<CanvasItem *> *r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
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 be9e5b0e3a..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();
@@ -448,8 +448,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
float radius = shape->get_radius();
float height = shape->get_height() / 2;
- handles.write[0] = Point2(radius, -height);
- handles.write[1] = Point2(0, -(height + radius));
+ handles.write[0] = Point2(radius, height);
+ handles.write[1] = Point2(0, height + radius);
p_overlay->draw_texture(h, gt.xform(handles[0]) - size);
p_overlay->draw_texture(h, gt.xform(handles[1]) - size);
@@ -502,8 +502,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
handles.resize(3);
Vector2 ext = shape->get_extents();
handles.write[0] = Point2(ext.x, 0);
- handles.write[1] = Point2(0, -ext.y);
- handles.write[2] = Point2(ext.x, -ext.y);
+ handles.write[1] = Point2(0, ext.y);
+ handles.write[2] = Point2(ext.x, ext.y);
p_overlay->draw_texture(h, gt.xform(handles[0]) - size);
p_overlay->draw_texture(h, gt.xform(handles[1]) - size);
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_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index 25329906a9..aaba6406c7 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -32,7 +32,7 @@
#include "editor/editor_scale.h"
#include "scene/3d/collision_shape.h"
-#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/navigation_mesh_instance.h"
#include "scene/3d/physics_body.h"
#include "scene/gui/box_container.h"
#include "spatial_editor_plugin.h"
@@ -60,10 +60,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
}
switch (p_option) {
- case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY:
- case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: {
-
- bool trimesh_shape = (p_option == MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
+ case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: {
EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
@@ -71,9 +68,12 @@ void MeshInstanceEditor::_menu_option(int p_option) {
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
- Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape();
- if (shape.is_null())
+ Ref<Shape> shape = mesh->create_trimesh_shape();
+ if (shape.is_null()) {
+ err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
+ err_dialog->popup_centered_minsize();
return;
+ }
CollisionShape *cshape = memnew(CollisionShape);
cshape->set_shape(shape);
@@ -82,11 +82,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
- if (trimesh_shape)
- ur->create_action(TTR("Create Static Trimesh Body"));
- else
- ur->create_action(TTR("Create Static Convex Body"));
-
+ ur->create_action(TTR("Create Static Trimesh Body"));
ur->add_do_method(node, "add_child", body);
ur->add_do_method(body, "set_owner", owner);
ur->add_do_method(cshape, "set_owner", owner);
@@ -108,7 +104,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (m.is_null())
continue;
- Ref<Shape> shape = trimesh_shape ? m->create_trimesh_shape() : m->create_convex_shape();
+ Ref<Shape> shape = m->create_trimesh_shape();
if (shape.is_null())
continue;
@@ -158,10 +154,44 @@ void MeshInstanceEditor::_menu_option(int p_option) {
ur->add_undo_method(node->get_parent(), "remove_child", cshape);
ur->commit_action();
} break;
- case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: {
+ case MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE: {
if (node == get_tree()->get_edited_scene_root()) {
- err_dialog->set_text(TTR("This doesn't work on scene root!"));
+ err_dialog->set_text(TTR("Can't create a single convex collision shape for the scene root."));
+ err_dialog->popup_centered_minsize();
+ return;
+ }
+
+ Ref<Shape> shape = mesh->create_convex_shape();
+
+ if (shape.is_null()) {
+ err_dialog->set_text(TTR("Couldn't create a single convex collision shape."));
+ err_dialog->popup_centered_minsize();
+ return;
+ }
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+
+ ur->create_action(TTR("Create Single Convex Shape"));
+
+ CollisionShape *cshape = memnew(CollisionShape);
+ cshape->set_shape(shape);
+ cshape->set_transform(node->get_transform());
+
+ Node *owner = node->get_owner();
+
+ ur->add_do_method(node->get_parent(), "add_child", cshape);
+ ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1);
+ ur->add_do_method(cshape, "set_owner", owner);
+ ur->add_do_reference(cshape);
+ ur->add_undo_method(node->get_parent(), "remove_child", cshape);
+
+ ur->commit_action();
+
+ } break;
+ case MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES: {
+
+ if (node == get_tree()->get_edited_scene_root()) {
+ err_dialog->set_text(TTR("Can't create multiple convex collision shapes for the scene root."));
err_dialog->popup_centered_minsize();
return;
}
@@ -169,13 +199,13 @@ void MeshInstanceEditor::_menu_option(int p_option) {
Vector<Ref<Shape> > shapes = mesh->convex_decompose();
if (!shapes.size()) {
- err_dialog->set_text(TTR("Failed creating shapes!"));
+ err_dialog->set_text(TTR("Couldn't create any collision shapes."));
err_dialog->popup_centered_minsize();
return;
}
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action(TTR("Create Convex Shape(s)"));
+ ur->create_action(TTR("Create Multiple Convex Shapes"));
for (int i = 0; i < shapes.size(); i++) {
@@ -421,13 +451,19 @@ MeshInstanceEditor::MeshInstanceEditor() {
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance", "EditorIcons"));
options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
- options->get_popup()->add_item(TTR("Create Convex Collision Sibling(s)"), MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection."));
+ options->get_popup()->add_item(TTR("Create Single Convex Collision Siblings"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a single convex collision shape.\nThis is the fastest (but least accurate) option for collision detection."));
+ options->get_popup()->add_item(TTR("Create Multiple Convex Collision Siblings"), MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between the two above options."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH);
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the SpatialMaterial Grow property when using that property isn't possible."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1);
options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2);
diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_editor_plugin.h
index 5c95676fc4..5ca9aa3fec 100644
--- a/editor/plugins/mesh_instance_editor_plugin.h
+++ b/editor/plugins/mesh_instance_editor_plugin.h
@@ -43,9 +43,9 @@ class MeshInstanceEditor : public Control {
enum Menu {
MENU_OPTION_CREATE_STATIC_TRIMESH_BODY,
- MENU_OPTION_CREATE_STATIC_CONVEX_BODY,
MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE,
- MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE,
+ MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE,
+ MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES,
MENU_OPTION_CREATE_NAVMESH,
MENU_OPTION_CREATE_OUTLINE_MESH,
MENU_OPTION_CREATE_UV2,
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index 92898ff9c3..b77cb6453f 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -34,7 +34,7 @@
#include "editor/editor_settings.h"
#include "main/main.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/navigation_mesh_instance.h"
#include "scene/3d/physics_body.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
@@ -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 31e6b65640..e916f6f028 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -250,9 +250,9 @@ void SpatialEditorViewport::_clear_selected() {
editor_selection->clear();
}
-void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
+void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) {
- if (!clicked)
+ if (clicked.is_null())
return;
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked));
@@ -260,17 +260,20 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
if (!selected)
return;
- // Replace the node by the group if grouped
- while (node && node != editor->get_edited_scene()->get_parent()) {
- Spatial *selected_tmp = Object::cast_to<Spatial>(node);
- if (selected_tmp && node->has_meta("_edit_group_")) {
- selected = selected_tmp;
+ if (!p_allow_locked) {
+ // Replace the node by the group if grouped
+ while (node && node != editor->get_edited_scene()->get_parent()) {
+ Spatial *selected_tmp = Object::cast_to<Spatial>(node);
+ if (selected_tmp && node->has_meta("_edit_group_")) {
+ selected = selected_tmp;
+ }
+ node = node->get_parent();
}
- node = node->get_parent();
}
- if (!_is_node_locked(selected))
+ if (p_allow_locked || !_is_node_locked(selected)) {
_select(selected, clicked_wants_append, true);
+ }
}
void SpatialEditorViewport::_select(Node *p_node, bool p_append, bool p_single) {
@@ -306,7 +309,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Set<Ref<EditorSpatialGizmo> > found_gizmos;
Node *edited_scene = get_tree()->get_edited_scene_root();
- ObjectID closest = 0;
+ ObjectID closest;
Node *item = NULL;
float closest_dist = 1e20;
int selected_handle = -1;
@@ -353,7 +356,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
}
if (!item)
- return 0;
+ return ObjectID();
if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) {
@@ -847,9 +850,9 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
clicked = selection_results[0].item->get_instance_id();
selection_results.clear();
- if (clicked) {
- _select_clicked(clicked_wants_append, true);
- clicked = 0;
+ if (clicked.is_valid()) {
+ _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
+ clicked = ObjectID();
}
} else if (!selection_results.empty()) {
@@ -861,11 +864,33 @@ 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());
- selection_menu->add_item(spat->get_name());
+ int locked = 0;
+ if (_is_node_locked(spat)) {
+ locked = 1;
+ } else {
+ Node *ed_scene = editor->get_edited_scene();
+ Node *node = spat;
+
+ while (node && node != ed_scene->get_parent()) {
+ Spatial *selected_tmp = Object::cast_to<Spatial>(node);
+ if (selected_tmp && node->has_meta("_edit_group_")) {
+ locked = 2;
+ }
+ node = node->get_parent();
+ }
+ }
+
+ String suffix = String();
+ if (locked == 1) {
+ suffix = " (" + TTR("Locked") + ")";
+ } else if (locked == 2) {
+ suffix = " (" + TTR("Grouped") + ")";
+ }
+ selection_menu->add_item((String)spat->get_name() + suffix);
selection_menu->set_item_icon(i, icon);
selection_menu->set_item_metadata(i, node_path);
selection_menu->set_item_tooltip(i, String(spat->get_name()) + "\nType: " + spat->get_class() + "\nPath: " + node_path);
@@ -1070,7 +1095,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (_gizmo_select(_edit.mouse_pos))
break;
- clicked = 0;
+ clicked = ObjectID();
clicked_includes_current = false;
if ((spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) {
@@ -1114,7 +1139,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
clicked_wants_append = b->get_shift();
- if (!clicked) {
+ if (clicked.is_null()) {
if (!clicked_wants_append)
_clear_selected();
@@ -1125,7 +1150,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
cursor.region_end = b->get_position();
}
- if (clicked && gizmo_handle >= 0) {
+ if (clicked.is_valid() && gizmo_handle >= 0) {
Spatial *spa = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
if (spa) {
@@ -1150,10 +1175,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_edit.gizmo = Ref<EditorSpatialGizmo>();
break;
}
- if (clicked) {
+ if (clicked.is_valid()) {
_select_clicked(clicked_wants_append, true);
// Processing was deferred.
- clicked = 0;
+ clicked = ObjectID();
}
if (cursor.region_select) {
@@ -1254,7 +1279,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else if (nav_scheme == NAVIGATION_MODO && m->get_alt()) {
nav_mode = NAVIGATION_ORBIT;
} else {
- if (clicked) {
+ if (clicked.is_valid()) {
if (!clicked_includes_current) {
@@ -1263,7 +1288,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
_compute_edit(_edit.mouse_pos);
- clicked = 0;
+ clicked = ObjectID();
_edit.mode = TRANSFORM_TRANSLATE;
}
@@ -2247,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);
@@ -2346,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();
@@ -2417,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) {
@@ -2738,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;
}
}
@@ -2891,9 +2945,9 @@ void SpatialEditorViewport::_selection_result_pressed(int p_result) {
clicked = selection_results[p_result].item->get_instance_id();
- if (clicked) {
- _select_clicked(clicked_wants_append, true);
- clicked = 0;
+ if (clicked.is_valid()) {
+ _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
+ clicked = ObjectID();
}
}
@@ -3527,7 +3581,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
editor_data = editor->get_scene_tree_dock()->get_editor_data();
editor_selection = editor->get_editor_selection();
undo_redo = editor->get_undo_redo();
- clicked = 0;
+
clicked_includes_current = false;
orthogonal = false;
lock_rotation = false;
@@ -3569,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);
@@ -3585,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);
@@ -3609,11 +3683,11 @@ 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) {
- // Alternate display modes only work when using the GLES3 renderer; make this explicit.
+ // Alternate display modes only work when using the Vulkan renderer; make this explicit.
const int normal_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL);
const int wireframe_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME);
const int overdraw_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW);
@@ -3816,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();
@@ -4173,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();
}
@@ -4732,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;
@@ -4817,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;
@@ -4912,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
}
@@ -5042,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
}
@@ -5566,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)));
@@ -6118,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;
@@ -6133,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) {
@@ -6156,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;
@@ -6176,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();
@@ -6198,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 5cc2b24cbb..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;
@@ -234,7 +246,7 @@ private:
void _update_name();
void _compute_edit(const Point2 &p_point);
void _clear_selected();
- void _select_clicked(bool p_append, bool p_single);
+ void _select_clicked(bool p_append, bool p_single, bool p_allow_locked = false);
void _select(Node *p_node, bool p_append, bool p_single);
ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false);
void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false);
@@ -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 f889228f87..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;
@@ -2026,13 +2026,13 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
toolbar->add_child(bucket_fill_button);
picker_button = memnew(ToolButton);
- picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_CONTROL));
+ picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_I));
picker_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_PICKING));
picker_button->set_toggle_mode(true);
toolbar->add_child(picker_button);
select_button = memnew(ToolButton);
- select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD + KEY_B));
+ select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_M));
select_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_SELECTING));
select_button->set_toggle_mode(true);
toolbar->add_child(select_button);
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index b24d5add9f..ce865510b4 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);
@@ -1794,13 +1794,13 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
Array sd = tileset->call("tile_get_shapes", get_current_tile());
if (convex.is_valid()) {
- // Make concave
+ // Make concave.
undo_redo->create_action(TTR("Make Polygon Concave"));
Ref<ConcavePolygonShape2D> _concave = memnew(ConcavePolygonShape2D);
edited_collision_shape = _concave;
_set_edited_shape_points(_get_collision_shape_points(convex));
} else if (concave.is_valid()) {
- // Make convex
+ // Make convex.
undo_redo->create_action(TTR("Make Polygon Convex"));
Ref<ConvexPolygonShape2D> _convex = memnew(ConvexPolygonShape2D);
edited_collision_shape = _convex;
@@ -1810,14 +1810,20 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
if (sd[i].get("shape") == previous_shape) {
undo_redo->add_undo_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd.duplicate());
sd.remove(i);
- sd.insert(i, edited_collision_shape);
- undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd);
- undo_redo->add_do_method(this, "_select_edited_shape_coord");
- undo_redo->add_undo_method(this, "_select_edited_shape_coord");
- undo_redo->commit_action();
break;
}
}
+
+ undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd);
+ if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) {
+ undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), edited_collision_shape, Transform2D(), false, edited_shape_coord);
+ } else {
+ undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), edited_collision_shape, Transform2D());
+ }
+ undo_redo->add_do_method(this, "_select_edited_shape_coord");
+ undo_redo->add_undo_method(this, "_select_edited_shape_coord");
+ undo_redo->commit_action();
+
_update_toggle_shape_button();
workspace->update();
workspace_container->update();
@@ -1984,11 +1990,8 @@ void TileSetEditor::_set_edited_shape_points(const Vector<Vector2> &points) {
}
segments.push_back(points[points.size() - 1]);
segments.push_back(points[0]);
- concave->set_segments(segments);
undo_redo->add_do_method(concave.ptr(), "set_segments", segments);
undo_redo->add_undo_method(concave.ptr(), "set_segments", concave->get_segments());
- } else {
- // Invalid shape
}
}
@@ -2662,9 +2665,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 +2703,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 +2752,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 +2792,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 +2841,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 +2859,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 +3101,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 +3120,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 +3329,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 +3490,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..d9bccc35f4 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -116,7 +116,7 @@ void VisualShaderEditor::clear_custom_types() {
}
}
-void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, const String &p_subcategory) {
+void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, const String &p_subcategory, bool p_highend) {
ERR_FAIL_COND(!p_name.is_valid_identifier());
ERR_FAIL_COND(!p_script.is_valid());
@@ -135,6 +135,7 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script>
ao.description = p_description;
ao.category = p_category;
ao.sub_category = p_subcategory;
+ ao.highend = p_highend;
ao.is_custom = true;
bool begin = false;
@@ -247,6 +248,11 @@ void VisualShaderEditor::update_custom_nodes() {
subcategory = (String)ref->call("_get_subcategory");
}
+ bool highend = false;
+ if (ref->has_method("_is_highend")) {
+ highend = (bool)ref->call("_is_highend");
+ }
+
Dictionary dict;
dict["name"] = name;
dict["script"] = script;
@@ -254,6 +260,7 @@ void VisualShaderEditor::update_custom_nodes() {
dict["return_icon_type"] = return_icon_type;
dict["category"] = category;
dict["subcategory"] = subcategory;
+ dict["highend"] = highend;
String key;
key = category;
@@ -277,18 +284,14 @@ void VisualShaderEditor::update_custom_nodes() {
const Dictionary &value = (Dictionary)added[key];
- add_custom_type(value["name"], value["script"], value["description"], value["return_icon_type"], value["category"], value["subcategory"]);
+ add_custom_type(value["name"], value["script"], value["description"], value["return_icon_type"], value["category"], value["subcategory"], value["highend"]);
}
_update_options_menu();
}
String VisualShaderEditor::_get_description(int p_idx) {
- if (add_options[p_idx].highend) {
- return TTR("(GLES3 only)") + " " + add_options[p_idx].description; // TODO: change it to (Vulkan Only) when its ready
- } else {
- return add_options[p_idx].description;
- }
+ return add_options[p_idx].description;
}
void VisualShaderEditor::_update_options_menu() {
@@ -1680,6 +1683,8 @@ void VisualShaderEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
+ highend_label->set_modulate(get_color("vulkan_color", "Editor"));
+
error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
error_label->add_color_override("font_color", get_color("error_color", "Editor"));
@@ -2037,8 +2042,10 @@ void VisualShaderEditor::_member_selected() {
if (item != NULL && item->has_meta("id")) {
members_dialog->get_ok()->set_disabled(false);
+ highend_label->set_visible(add_options[item->get_meta("id")].highend);
node_desc->set_text(_get_description(item->get_meta("id")));
} else {
+ highend_label->set_visible(false);
members_dialog->get_ok()->set_disabled(true);
node_desc->set_text("");
}
@@ -2172,7 +2179,7 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
_add_custom_node(arr[i]);
j++;
}
- } else if (ClassDB::get_parent_class(type) == "Texture") {
+ } else if (ClassDB::get_parent_class(type) == "Texture2D") {
saved_node_pos = p_point + Vector2(0, j * 210 * EDSCALE);
saved_node_pos_dirty = true;
_add_texture_node(arr[i]);
@@ -2425,10 +2432,22 @@ VisualShaderEditor::VisualShaderEditor() {
members->connect("item_selected", this, "_member_selected");
members->connect("nothing_selected", this, "_member_unselected");
+ HBoxContainer *desc_hbox = memnew(HBoxContainer);
+ members_vb->add_child(desc_hbox);
+
Label *desc_label = memnew(Label);
- members_vb->add_child(desc_label);
+ desc_hbox->add_child(desc_label);
desc_label->set_text(TTR("Description:"));
+ desc_hbox->add_spacer();
+
+ highend_label = memnew(Label);
+ desc_hbox->add_child(highend_label);
+ highend_label->set_visible(false);
+ highend_label->set_text("Vulkan");
+ highend_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
+ highend_label->set_tooltip(TTR("High-end node"));
+
node_desc = memnew(RichTextLabel);
members_vb->add_child(node_desc);
node_desc->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -2691,11 +2710,10 @@ VisualShaderEditor::VisualShaderEditor() {
// TEXTURES
- add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, -1));
+ 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("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform 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 +2912,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/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 8c5dd8e82f..150cf16167 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -94,6 +94,7 @@ class VisualShaderEditor : public VBoxContainer {
AcceptDialog *alert;
LineEdit *node_filter;
RichTextLabel *node_desc;
+ Label *highend_label;
void _tools_menu_option(int p_idx);
void _show_members_dialog(bool at_mouse_pos);
@@ -264,7 +265,7 @@ public:
static VisualShaderEditor *get_singleton() { return singleton; }
void clear_custom_types();
- void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, const String &p_subcategory);
+ void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, const String &p_subcategory, bool p_highend);
virtual Size2 get_minimum_size() const;
void edit(VisualShader *p_visual_shader);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index ee434aaac2..a1032130f8 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) {
@@ -484,8 +484,8 @@ private:
if (mode == MODE_NEW) {
ProjectSettings::CustomMap initial_settings;
- if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "GLES3") {
- initial_settings["rendering/quality/driver/driver_name"] = "GLES3";
+ if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") {
+ initial_settings["rendering/quality/driver/driver_name"] = "Vulkan";
} else {
initial_settings["rendering/quality/driver/driver_name"] = "GLES2";
initial_settings["rendering/vram_compression/import_etc2"] = false;
@@ -880,31 +880,46 @@ public:
rshb->add_child(rvb);
Button *rs_button = memnew(CheckBox);
rs_button->set_button_group(rasterizer_button_group);
- rs_button->set_text(TTR("OpenGL ES 3.0"));
- rs_button->set_meta("driver_name", "GLES3");
+ rs_button->set_text(TTR("Vulkan"));
+ rs_button->set_meta("driver_name", "Vulkan");
rs_button->set_pressed(true);
rvb->add_child(rs_button);
l = memnew(Label);
- l->set_text(TTR("Higher visual quality\nAll features available\nIncompatible with older hardware\nNot recommended for web games"));
+ l->set_text(TTR("- Higher visual quality\n- More accurate API, which produces very fast code\n- Some features not implemented yet - work in progress\n- Incompatible with older hardware\n- Not recommended for web and mobile games"));
+ l->set_modulate(Color(1, 1, 1, 0.7));
rvb->add_child(l);
rshb->add_child(memnew(VSeparator));
+ const String gles2_unsupported_tooltip =
+ TTR("The GLES2 renderer is currently unavailable, as it needs to be reworked for Godot 4.0.\nUse Godot 3.2 if you need GLES2 support.");
+
rvb = memnew(VBoxContainer);
rvb->set_h_size_flags(SIZE_EXPAND_FILL);
rshb->add_child(rvb);
rs_button = memnew(CheckBox);
rs_button->set_button_group(rasterizer_button_group);
- rs_button->set_text(TTR("OpenGL ES 2.0"));
+ rs_button->set_text(TTR("OpenGL ES 2.0 (currently unavailable)"));
rs_button->set_meta("driver_name", "GLES2");
+ rs_button->set_disabled(true);
+ rs_button->set_tooltip(gles2_unsupported_tooltip);
rvb->add_child(rs_button);
l = memnew(Label);
- l->set_text(TTR("Lower visual quality\nSome features not available\nWorks on most hardware\nRecommended for web games"));
+ l->set_text(TTR("- Lower visual quality\n- Some features not available\n- Works on most hardware\n- Recommended for web and mobile games"));
+ l->set_modulate(Color(1, 1, 1, 0.7));
+ // Also set the tooltip on the label so it appears when hovering either the checkbox or label.
+ l->set_tooltip(gles2_unsupported_tooltip);
+ // Required for the tooltip to show.
+ l->set_mouse_filter(MOUSE_FILTER_STOP);
rvb->add_child(l);
l = memnew(Label);
- l->set_text(TTR("Renderer can be changed later, but scenes may need to be adjusted."));
+ l->set_text(TTR("The renderer can be changed later, but scenes may need to be adjusted."));
+ // Add some extra spacing to separate it from the list above and the buttons below.
+ l->set_custom_minimum_size(Size2(0, 40) * EDSCALE);
l->set_align(Label::ALIGN_CENTER);
+ l->set_valign(Label::VALIGN_CENTER);
+ l->set_modulate(Color(1, 1, 1, 0.7));
rasterizer_container->add_child(l);
fdialog = memnew(FileDialog);
@@ -986,7 +1001,7 @@ public:
String path;
String icon;
String main_scene;
- uint64_t last_modified;
+ uint64_t last_edited;
bool favorite;
bool grayed;
bool missing;
@@ -1002,7 +1017,7 @@ public:
const String &p_path,
const String &p_icon,
const String &p_main_scene,
- uint64_t p_last_modified,
+ uint64_t p_last_edited,
bool p_favorite,
bool p_grayed,
bool p_missing,
@@ -1014,7 +1029,7 @@ public:
path = p_path;
icon = p_icon;
main_scene = p_main_scene;
- last_modified = p_last_modified;
+ last_edited = p_last_edited;
favorite = p_favorite;
grayed = p_grayed;
missing = p_missing;
@@ -1037,6 +1052,7 @@ public:
void sort_projects();
int get_project_count() const;
void select_project(int p_index);
+ void select_first_visible_project();
void erase_selected_projects();
Vector<Item> get_selected_projects() const;
const Set<String> &get_selected_project_keys() const;
@@ -1088,8 +1104,8 @@ struct ProjectListComparator {
switch (order_option) {
case ProjectListFilter::FILTER_PATH:
return a.project_key < b.project_key;
- case ProjectListFilter::FILTER_MODIFIED:
- return a.last_modified > b.last_modified;
+ case ProjectListFilter::FILTER_EDIT_DATE:
+ return a.last_edited > b.last_edited;
default:
return a.project_name < b.project_name;
}
@@ -1097,7 +1113,7 @@ struct ProjectListComparator {
};
ProjectList::ProjectList() {
- _order_option = ProjectListFilter::FILTER_MODIFIED;
+ _order_option = ProjectListFilter::FILTER_EDIT_DATE;
_scroll_children = memnew(VBoxContainer);
_scroll_children->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1134,8 +1150,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();
@@ -1184,15 +1200,18 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String icon = cf->get_value("application", "config/icon", "");
String main_scene = cf->get_value("application", "run/main_scene", "");
- uint64_t last_modified = 0;
+ uint64_t last_edited = 0;
if (FileAccess::exists(conf)) {
- last_modified = FileAccess::get_modified_time(conf);
+ // The modification date marks the date the project was last edited.
+ // This is because the `project.godot` file will always be modified
+ // when editing a project (but not when running it).
+ last_edited = FileAccess::get_modified_time(conf);
String fscache = path.plus_file(".fscache");
if (FileAccess::exists(fscache)) {
uint64_t cache_modified = FileAccess::get_modified_time(fscache);
- if (cache_modified > last_modified)
- last_modified = cache_modified;
+ if (cache_modified > last_edited)
+ last_edited = cache_modified;
}
} else {
grayed = true;
@@ -1202,7 +1221,7 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String project_key = p_property_key.get_slice("/", 1);
- p_item = Item(project_key, project_name, description, path, icon, main_scene, last_modified, p_favorite, grayed, missing, config_version);
+ p_item = Item(project_key, project_name, description, path, icon, main_scene, last_edited, p_favorite, grayed, missing, config_version);
}
void ProjectList::load_projects() {
@@ -1297,7 +1316,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);
@@ -1629,6 +1648,23 @@ void ProjectList::select_project(int p_index) {
toggle_select(p_index);
}
+void ProjectList::select_first_visible_project() {
+ bool found = false;
+
+ for (int i = 0; i < _projects.size(); i++) {
+ if (_projects[i].control->is_visible()) {
+ select_project(i);
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ // Deselect all projects if there are no visible projects in the list.
+ _selected_project_keys.clear();
+ }
+}
+
inline void sort(int &a, int &b) {
if (a > b) {
int temp = a;
@@ -2347,6 +2383,12 @@ void ProjectManager::_on_order_option_changed() {
void ProjectManager::_on_filter_option_changed() {
_project_list->set_search_term(project_filter->get_search_term());
_project_list->sort_projects();
+
+ // Select the first visible project in the list.
+ // This makes it possible to open a project without ever touching the mouse,
+ // as the search field is automatically focused on startup.
+ _project_list->select_first_visible_project();
+ _update_project_buttons();
}
void ProjectManager::_bind_methods() {
@@ -2476,7 +2518,7 @@ ProjectManager::ProjectManager() {
Vector<String> sort_filter_titles;
sort_filter_titles.push_back(TTR("Name"));
sort_filter_titles.push_back(TTR("Path"));
- sort_filter_titles.push_back(TTR("Last Modified"));
+ sort_filter_titles.push_back(TTR("Last Edited"));
project_order_filter = memnew(ProjectListFilter);
project_order_filter->add_filter_option();
project_order_filter->_setup_filters(sort_filter_titles);
diff --git a/editor/project_manager.h b/editor/project_manager.h
index b8f7403e27..feeea9695d 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -134,7 +134,7 @@ public:
enum FilterOption {
FILTER_NAME,
FILTER_PATH,
- FILTER_MODIFIED,
+ FILTER_EDIT_DATE,
};
private:
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index b656fd647f..6635f5cb47 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -719,9 +719,18 @@ void ProjectSettingsEditor::_update_actions() {
item->set_range(1, action["deadzone"]);
item->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
+ const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != NULL;
+ const String tooltip = is_builtin_input ? TTR("Built-in actions can't be removed as they're used for UI navigation.") : TTR("Remove");
item->add_button(2, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
- if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) {
- item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
+ item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, tooltip);
+
+ if (is_builtin_input) {
+ // Built-in action (like `ui_up`). Make the action not removable,
+ // but still display the button so the "Add" button is at the same
+ // horizontal position as for custom actions.
+ item->set_button_disabled(2, 1, true);
+ } else {
+ // Not a built-in action. Make the action name editable.
item->set_editable(0, true);
}
@@ -747,10 +756,9 @@ void ProjectSettingsEditor::_update_actions() {
if (jb.is_valid()) {
String str = _get_device_string(jb->get_device()) + ", " + TTR("Button") + " " + itos(jb->get_button_index());
- if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX)
- str += String() + " (" + _button_names[jb->get_button_index()] + ").";
- else
- str += ".";
+ if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX) {
+ str += String() + " (" + _button_names[jb->get_button_index()] + ")";
+ }
action2->set_text(0, str);
action2->set_icon(0, get_icon("JoyButton", "EditorIcons"));
@@ -761,12 +769,12 @@ void ProjectSettingsEditor::_update_actions() {
if (mb.is_valid()) {
String str = _get_device_string(mb->get_device()) + ", ";
switch (mb->get_button_index()) {
- case BUTTON_LEFT: str += TTR("Left Button."); break;
- case BUTTON_RIGHT: str += TTR("Right Button."); break;
- case BUTTON_MIDDLE: str += TTR("Middle Button."); break;
- case BUTTON_WHEEL_UP: str += TTR("Wheel Up."); break;
- case BUTTON_WHEEL_DOWN: str += TTR("Wheel Down."); break;
- default: str += TTR("Button") + " " + itos(mb->get_button_index()) + ".";
+ case BUTTON_LEFT: str += TTR("Left Button"); break;
+ case BUTTON_RIGHT: str += TTR("Right Button"); break;
+ case BUTTON_MIDDLE: str += TTR("Middle Button"); break;
+ case BUTTON_WHEEL_UP: str += TTR("Wheel Up"); break;
+ case BUTTON_WHEEL_DOWN: str += TTR("Wheel Down"); break;
+ default: str += vformat(TTR("%d Button"), mb->get_button_index());
}
action2->set_text(0, str);
@@ -780,7 +788,7 @@ void ProjectSettingsEditor::_update_actions() {
int ax = jm->get_axis();
int n = 2 * ax + (jm->get_axis_value() < 0 ? 0 : 1);
String desc = _axis_names[n];
- String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc + ".";
+ String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc;
action2->set_text(0, str);
action2->set_icon(0, get_icon("JoyAxis", "EditorIcons"));
}
@@ -789,6 +797,10 @@ void ProjectSettingsEditor::_update_actions() {
action2->add_button(2, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit"));
action2->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
+ // Fade out the individual event buttons slightly to make the
+ // Add/Remove buttons stand out more.
+ action2->set_button_color(2, 0, Color(1, 1, 1, 0.75));
+ action2->set_button_color(2, 1, Color(1, 1, 1, 0.75));
}
}
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 2dcbc4c14c..1691ce3a63 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -639,7 +639,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
property_select->select_method_from_instance(instance, v);
updating = false;
@@ -648,7 +648,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
}
@@ -688,7 +688,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (instance)
property_select->select_property_from_instance(instance, v);
@@ -698,7 +698,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
}
@@ -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..1de5099c4a 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") {
@@ -404,7 +404,7 @@ void PropertySelector::select_method_from_base_type(const String &p_base, const
base_type = p_base;
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
properties = false;
instance = NULL;
virtuals_only = p_virtuals_only;
@@ -437,7 +437,7 @@ void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const
base_type = "";
selected = p_current;
type = p_type;
- script = 0;
+ script = ObjectID();
properties = false;
instance = NULL;
virtuals_only = false;
@@ -453,7 +453,7 @@ void PropertySelector::select_method_from_instance(Object *p_instance, const Str
base_type = p_instance->get_class();
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
{
Ref<Script> scr = p_instance->get_script();
if (scr.is_valid())
@@ -474,7 +474,7 @@ void PropertySelector::select_property_from_base_type(const String &p_base, cons
base_type = p_base;
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
properties = true;
instance = NULL;
virtuals_only = false;
@@ -509,7 +509,7 @@ void PropertySelector::select_property_from_basic_type(Variant::Type p_type, con
base_type = "";
selected = p_current;
type = p_type;
- script = 0;
+ script = ObjectID();
properties = true;
instance = NULL;
virtuals_only = false;
@@ -525,7 +525,7 @@ void PropertySelector::select_property_from_instance(Object *p_instance, const S
base_type = "";
selected = p_current;
type = Variant::NIL;
- script = 0;
+ script = ObjectID();
properties = true;
instance = p_instance;
virtuals_only = false;
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..a0b846beb0 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -187,25 +187,17 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
TreeItem *item = tree->create_item(p_parent);
item->set_text(0, p_node->get_name());
- if (can_rename && !part_of_subscene /*(p_node->get_owner() == get_scene_node() || p_node==get_scene_node())*/)
+ if (can_rename && !part_of_subscene)
item->set_editable(0, true);
item->set_selectable(0, true);
if (can_rename) {
-#ifndef DISABLE_DEPRECATED
- if (p_node->has_meta("_editor_collapsed")) {
- //remove previous way of storing folding, which did not get along with scene inheritance and instancing
- if ((bool)p_node->get_meta("_editor_collapsed"))
- p_node->set_display_folded(true);
- p_node->set_meta("_editor_collapsed", Variant());
- }
-#endif
bool collapsed = p_node->is_displayed_folded();
if (collapsed)
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());
@@ -497,21 +489,6 @@ void SceneTreeEditor::_node_script_changed(Node *p_node) {
MessageQueue::get_singleton()->push_call(this, "_update_tree");
tree_dirty = true;
- /*
- changes the order :|
- TreeItem* item=p_node?_find(tree->get_root(),p_node->get_path()):NULL;
- if (p_node->get_script().is_null()) {
-
- int idx=item->get_button_by_id(0,2);
- if (idx>=0)
- item->erase_button(0,idx);
- } else {
-
- int idx=item->get_button_by_id(0,2);
- if (idx<0)
- item->add_button(0,get_icon("Script","EditorIcons"),2);
-
- }*/
}
void SceneTreeEditor::_node_removed(Node *p_node) {
@@ -929,7 +906,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..2b28aa87a3 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"
@@ -171,7 +172,7 @@ public:
}
String get_title() {
- if (remote_object_id)
+ if (remote_object_id.is_valid())
return TTR("Remote ") + String(type_name) + ": " + itos(remote_object_id);
else
return "<null>";
@@ -196,7 +197,6 @@ public:
}
ScriptEditorDebuggerInspectedObject() {
- remote_object_id = 0;
}
};
@@ -301,7 +301,7 @@ void ScriptEditorDebugger::_scene_tree_selected() {
return;
}
- inspected_object_id = item->get_metadata(0);
+ inspected_object_id = item->get_metadata(0).operator ObjectID();
Array msg;
msg.push_back("inspect_object");
@@ -433,8 +433,8 @@ int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &node
TreeItem *item = inspect_scene_tree->create_item(parent);
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], "");
+ ObjectID id = nodes[current_index + 3].operator ObjectID();
+ Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], "");
if (icon.is_valid()) {
item->set_icon(0, icon);
}
@@ -833,6 +833,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") {
@@ -1080,7 +1106,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
int frame_size = 6;
for (int i = 0; i < p_data.size(); i += frame_size) {
MultiplayerAPI::ProfilingInfo pi;
- pi.node = p_data[i + 0];
+ pi.node = p_data[i + 0].operator ObjectID();
pi.node_path = p_data[i + 1];
pi.incoming_rpc = p_data[i + 2];
pi.incoming_rset = p_data[i + 3];
@@ -1178,7 +1204,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;
@@ -1226,7 +1252,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
inspect_edited_object_timeout -= get_process_delta_time();
if (inspect_edited_object_timeout < 0) {
inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
- if (inspected_object_id) {
+ if (inspected_object_id.is_valid()) {
if (ScriptEditorDebuggerInspectedObject *obj = Object::cast_to<ScriptEditorDebuggerInspectedObject>(ObjectDB::get_instance(editor->get_editor_history()->get_current()))) {
if (obj->remote_object_id == inspected_object_id) {
//take the chance and re-inspect selected object
@@ -1281,8 +1307,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 +1591,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 +2271,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);
@@ -2437,7 +2485,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
auto_switch_remote_scene_tree = EDITOR_DEF("debugger/auto_switch_to_remote_scene_tree", false);
inspect_scene_tree_timeout = EDITOR_DEF("debugger/remote_scene_tree_refresh_interval", 1.0);
inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
- inspected_object_id = 0;
+ inspected_object_id = ObjectID();
updating_scene_tree = false;
}
@@ -2455,11 +2503,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 c94b0eeab0..1163621815 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -41,7 +41,7 @@
#include "scene/3d/light.h"
#include "scene/3d/listener.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/navigation_mesh_instance.h"
#include "scene/3d/particles.h"
#include "scene/3d/physics_joint.h"
#include "scene/3d/position_3d.h"
@@ -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);