summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/classes/TabContainer.xml2
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp10
-rw-r--r--editor/animation_bezier_editor.cpp62
-rw-r--r--editor/animation_bezier_editor.h7
-rw-r--r--editor/editor_node.cpp10
-rw-r--r--editor/editor_themes.cpp7
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp10
-rw-r--r--editor/scene_tree_dock.cpp10
-rw-r--r--scene/debugger/scene_debugger.cpp6
-rw-r--r--scene/gui/tab_bar.cpp104
-rw-r--r--scene/gui/tab_bar.h6
-rw-r--r--scene/gui/tab_container.cpp167
-rw-r--r--scene/gui/tab_container.h6
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp104
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h3
-rw-r--r--servers/rendering/renderer_rd/storage_rd/forward_id_storage.h2
-rw-r--r--servers/rendering/renderer_rd/storage_rd/light_storage.cpp4
-rw-r--r--servers/rendering/renderer_rd/storage_rd/texture_storage.cpp2
18 files changed, 273 insertions, 249 deletions
diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml
index b08e075a23..1b0054ef25 100644
--- a/doc/classes/TabContainer.xml
+++ b/doc/classes/TabContainer.xml
@@ -243,7 +243,7 @@
<signal name="tab_selected">
<param index="0" name="tab" type="int" />
<description>
- Emitted when a tab is selected, even if it is the current tab.
+ Emitted when a tab is selected via click or script, even if it is the current tab.
</description>
</signal>
</signals>
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index fc08f1cf38..1f10f4b353 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1254,9 +1254,14 @@ void RasterizerSceneGLES3::_fill_render_list(RenderListType p_render_list, const
inst->light_passes.clear();
inst->spot_light_gl_cache.clear();
inst->omni_light_gl_cache.clear();
+ uint64_t current_frame = RSG::rasterizer->get_frame_number();
+
if (inst->paired_omni_light_count) {
for (uint32_t j = 0; j < inst->paired_omni_light_count; j++) {
RID light_instance = inst->paired_omni_lights[j];
+ if (GLES3::LightStorage::get_singleton()->light_instance_get_render_pass(light_instance) != current_frame) {
+ continue;
+ }
RID light = GLES3::LightStorage::get_singleton()->light_instance_get_base_light(light_instance);
int32_t shadow_id = GLES3::LightStorage::get_singleton()->light_instance_get_shadow_id(light_instance);
@@ -1277,6 +1282,9 @@ void RasterizerSceneGLES3::_fill_render_list(RenderListType p_render_list, const
if (inst->paired_spot_light_count) {
for (uint32_t j = 0; j < inst->paired_spot_light_count; j++) {
RID light_instance = inst->paired_spot_lights[j];
+ if (GLES3::LightStorage::get_singleton()->light_instance_get_render_pass(light_instance) != current_frame) {
+ continue;
+ }
RID light = GLES3::LightStorage::get_singleton()->light_instance_get_base_light(light_instance);
int32_t shadow_id = GLES3::LightStorage::get_singleton()->light_instance_get_shadow_id(light_instance);
@@ -1712,6 +1720,8 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b
r_spot_light_count++;
} break;
}
+
+ li->last_pass = RSG::rasterizer->get_frame_number();
}
if (r_omni_light_count) {
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index 23c1665cad..d6d3e34678 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -42,7 +42,7 @@
float AnimationBezierTrackEdit::_bezier_h_to_pixel(float p_h) {
float h = p_h;
- h = (h - v_scroll) / v_zoom;
+ h = (h - timeline_v_scroll) / timeline_v_zoom;
h = (get_size().height / 2.0) - h;
return h;
}
@@ -251,7 +251,9 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
int right_limit = get_size().width;
- int vofs = vsep;
+ track_v_scroll_max = vsep;
+
+ int vofs = vsep + track_v_scroll;
int margin = 0;
RBMap<int, Color> subtrack_colors;
@@ -328,6 +330,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
text_buf.draw(get_canvas_item(), string_pos, color);
vofs += h + vsep;
+ track_v_scroll_max += h + vsep;
}
}
@@ -439,6 +442,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
subtrack_icons[current_track] = track_icons;
vofs += text_buf.get_size().y + vsep;
+ track_v_scroll_max += text_buf.get_size().y + vsep;
}
}
@@ -447,11 +451,11 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
{ //guides
float min_left_scale = font->get_height(font_size) + vsep;
- float scale = (min_left_scale * 2) * v_zoom;
+ float scale = (min_left_scale * 2) * timeline_v_zoom;
float step = Math::pow(10.0, Math::round(Math::log(scale / 5.0) / Math::log(10.0))) * 5.0;
scale = Math::snapped(scale, step);
- while (scale / v_zoom < min_left_scale * 2) {
+ while (scale / timeline_v_zoom < min_left_scale * 2) {
scale += step;
}
@@ -459,8 +463,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
int prev_iv = 0;
for (int i = font->get_height(font_size); i < get_size().height; i++) {
float ofs = get_size().height / 2.0 - i;
- ofs *= v_zoom;
- ofs += v_scroll;
+ ofs *= timeline_v_zoom;
+ ofs += timeline_v_scroll;
int iv = int(ofs / scale);
if (ofs < 0) {
@@ -908,9 +912,9 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
if (Math::is_finite(minimum_value) && Math::is_finite(maximum_value)) {
- v_scroll = (maximum_value + minimum_value) / 2.0;
+ timeline_v_scroll = (maximum_value + minimum_value) / 2.0;
if (maximum_value - minimum_value > CMP_EPSILON) {
- v_zoom = (maximum_value - minimum_value) / ((get_size().height - timeline->get_size().height) * 0.9);
+ timeline_v_zoom = (maximum_value - minimum_value) / ((get_size().height - timeline->get_size().height) * 0.9);
}
}
@@ -1160,7 +1164,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
Array new_point;
new_point.resize(5);
- float h = (get_size().height / 2.0 - mb->get_position().y) * v_zoom + v_scroll;
+ float h = (get_size().height / 2.0 - mb->get_position().y) * timeline_v_zoom + timeline_v_scroll;
new_point[0] = h;
new_point[1] = -0.25;
@@ -1393,7 +1397,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
select_single_attempt = IntPair(-1, -1);
}
- float y = (get_size().height / 2.0 - mm->get_position().y) * v_zoom + v_scroll;
+ float y = (get_size().height / 2.0 - mm->get_position().y) * timeline_v_zoom + timeline_v_scroll;
float x = editor->snap_time(((mm->get_position().x - limit) / timeline->get_zoom_scale()) + timeline->get_value());
if (!read_only) {
@@ -1422,7 +1426,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
if ((moving_handle == 1 || moving_handle == -1) && mm.is_valid()) {
- float y = (get_size().height / 2.0 - mm->get_position().y) * v_zoom + v_scroll;
+ float y = (get_size().height / 2.0 - mm->get_position().y) * timeline_v_zoom + timeline_v_scroll;
float x = editor->snap_time((mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale()) + timeline->get_value();
Vector2 key_pos = Vector2(animation->track_get_key_time(selected_track, moving_handle_key), animation->bezier_track_get_key_value(selected_track, moving_handle_key));
@@ -1438,7 +1442,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
Animation::HandleMode handle_mode = animation->bezier_track_get_key_handle_mode(moving_handle_track, moving_handle_key);
if (handle_mode == Animation::HANDLE_MODE_BALANCED) {
- real_t ratio = timeline->get_zoom_scale() * v_zoom;
+ real_t ratio = timeline->get_zoom_scale() * timeline_v_zoom;
Transform2D xform;
xform.set_scale(Vector2(1.0, 1.0 / ratio));
@@ -1455,7 +1459,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
Animation::HandleMode handle_mode = animation->bezier_track_get_key_handle_mode(moving_handle_track, moving_handle_key);
if (handle_mode == Animation::HANDLE_MODE_BALANCED) {
- real_t ratio = timeline->get_zoom_scale() * v_zoom;
+ real_t ratio = timeline->get_zoom_scale() * timeline_v_zoom;
Transform2D xform;
xform.set_scale(Vector2(1.0, 1.0 / ratio));
@@ -1475,11 +1479,11 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Move Bezier Points"));
if (moving_handle == -1) {
- real_t ratio = timeline->get_zoom_scale() * v_zoom;
+ real_t ratio = timeline->get_zoom_scale() * timeline_v_zoom;
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", moving_handle_track, moving_handle_key, moving_handle_left, ratio);
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", moving_handle_track, moving_handle_key, animation->bezier_track_get_key_in_handle(moving_handle_track, moving_handle_key), ratio);
} else if (moving_handle == 1) {
- real_t ratio = timeline->get_zoom_scale() * v_zoom;
+ real_t ratio = timeline->get_zoom_scale() * timeline_v_zoom;
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, moving_handle_right, ratio);
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, animation->bezier_track_get_key_out_handle(moving_handle_track, moving_handle_key), ratio);
}
@@ -1491,22 +1495,34 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
void AnimationBezierTrackEdit::_pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event) {
- v_scroll += p_scroll_vec.y * v_zoom;
- v_scroll = CLAMP(v_scroll, -100000, 100000);
- timeline->set_value(timeline->get_value() - p_scroll_vec.x / timeline->get_zoom_scale());
- queue_redraw();
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ if (mm->get_position().x > timeline->get_name_limit()) {
+ timeline_v_scroll += p_scroll_vec.y * timeline_v_zoom;
+ timeline_v_scroll = CLAMP(timeline_v_scroll, -100000, 100000);
+ timeline->set_value(timeline->get_value() - p_scroll_vec.x / timeline->get_zoom_scale());
+ } else {
+ track_v_scroll += p_scroll_vec.y;
+ if (track_v_scroll < -track_v_scroll_max) {
+ track_v_scroll = -track_v_scroll_max;
+ } else if (track_v_scroll > 0) {
+ track_v_scroll = 0;
+ }
+ }
+ queue_redraw();
+ }
}
void AnimationBezierTrackEdit::_zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event) {
- const float v_zoom_orig = v_zoom;
+ const float v_zoom_orig = timeline_v_zoom;
Ref<InputEventWithModifiers> iewm = p_event;
if (iewm.is_valid() && iewm->is_alt_pressed()) {
// Alternate zoom (doesn't affect timeline).
- v_zoom = CLAMP(v_zoom * p_zoom_factor, 0.000001, 100000);
+ timeline_v_zoom = CLAMP(timeline_v_zoom * p_zoom_factor, 0.000001, 100000);
} else {
timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() / p_zoom_factor);
}
- v_scroll = v_scroll + (p_origin.y - get_size().y / 2.0) * (v_zoom - v_zoom_orig);
+ timeline_v_scroll = timeline_v_scroll + (p_origin.y - get_size().y / 2.0) * (timeline_v_zoom - v_zoom_orig);
queue_redraw();
}
@@ -1517,7 +1533,7 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) {
Array new_point;
new_point.resize(5);
- float h = (get_size().height / 2.0 - menu_insert_key.y) * v_zoom + v_scroll;
+ float h = (get_size().height / 2.0 - menu_insert_key.y) * timeline_v_zoom + timeline_v_scroll;
new_point[0] = h;
new_point[1] = -0.25;
diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h
index dbc231ccac..4952869943 100644
--- a/editor/animation_bezier_editor.h
+++ b/editor/animation_bezier_editor.h
@@ -81,8 +81,11 @@ class AnimationBezierTrackEdit : public Control {
int solo_track = -1;
bool is_filtered = false;
- float v_scroll = 0;
- float v_zoom = 1;
+ float track_v_scroll = 0;
+ float track_v_scroll_max = 0;
+
+ float timeline_v_scroll = 0;
+ float timeline_v_zoom = 1;
PopupMenu *menu = nullptr;
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 30872f0288..8e749f4def 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4770,21 +4770,15 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = me;
if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed() && dock_popup_selected_idx != nrect) {
- Control *dock = dock_slot[dock_popup_selected_idx]->get_current_tab_control();
- if (dock) {
- dock_slot[dock_popup_selected_idx]->remove_child(dock);
- }
+ dock_slot[nrect]->move_tab_from_tab_container(dock_slot[dock_popup_selected_idx], dock_slot[dock_popup_selected_idx]->get_current_tab(), dock_slot[nrect]->get_tab_count());
+
if (dock_slot[dock_popup_selected_idx]->get_tab_count() == 0) {
dock_slot[dock_popup_selected_idx]->hide();
-
} else {
dock_slot[dock_popup_selected_idx]->set_current_tab(0);
}
- dock_slot[nrect]->add_child(dock);
dock_popup_selected_idx = nrect;
- dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count() - 1);
- dock_slot[nrect]->set_tab_title(dock_slot[nrect]->get_tab_count() - 1, TTRGET(dock->get_name()));
dock_slot[nrect]->show();
dock_select->queue_redraw();
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index bf0c5392c1..2a42224c87 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -2046,12 +2046,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
graphn_sb_panel_selected->set_corner_radius_individual(0, 0, corner_radius * EDSCALE, corner_radius * EDSCALE);
graphn_sb_panel_selected->set_expand_margin(SIDE_TOP, 17 * EDSCALE);
- const int gn_titlebar_margin_side = 12;
- Ref<StyleBoxFlat> graphn_sb_titlebar = make_flat_stylebox(graphnode_bg, gn_titlebar_margin_side, gn_margin_top, gn_titlebar_margin_side, 0, corner_width);
+ const int gn_titlebar_margin_left = 12;
+ const int gn_titlebar_margin_right = 4; // The rest is for the close button.
+ Ref<StyleBoxFlat> graphn_sb_titlebar = make_flat_stylebox(graphnode_bg, gn_titlebar_margin_left, gn_margin_top, gn_titlebar_margin_right, 0, corner_width);
graphn_sb_titlebar->set_expand_margin(SIDE_TOP, 2 * EDSCALE);
graphn_sb_titlebar->set_corner_radius_individual(corner_radius * EDSCALE, corner_radius * EDSCALE, 0, 0);
- Ref<StyleBoxFlat> graphn_sb_titlebar_selected = make_flat_stylebox(graph_node_selected_border_color, gn_titlebar_margin_side, gn_margin_top, gn_titlebar_margin_side, 0, corner_width);
+ Ref<StyleBoxFlat> graphn_sb_titlebar_selected = make_flat_stylebox(graph_node_selected_border_color, gn_titlebar_margin_left, gn_margin_top, gn_titlebar_margin_right, 0, corner_width);
graphn_sb_titlebar_selected->set_corner_radius_individual(corner_radius * EDSCALE, corner_radius * EDSCALE, 0, 0);
graphn_sb_titlebar_selected->set_expand_margin(SIDE_TOP, 2 * EDSCALE);
Ref<StyleBoxEmpty> graphn_sb_slot = make_empty_stylebox(12, 0, 12, 0);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 772957bc55..4a17fd89ff 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -170,7 +170,15 @@ void AnimationNodeBlendTreeEditor::update_graph() {
name->connect("text_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_rename_lineedit_changed), CONNECT_DEFERRED);
base = 1;
agnode->set_closable(true);
- node->connect("delete_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_node_request).bind(E), CONNECT_DEFERRED);
+
+ if (!read_only) {
+ Button *delete_button = memnew(Button);
+ delete_button->set_flat(true);
+ delete_button->set_focus_mode(FOCUS_NONE);
+ delete_button->set_icon(get_editor_theme_icon(SNAME("Close")));
+ delete_button->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_node_request).bind(E), CONNECT_DEFERRED);
+ node->get_titlebar_hbox()->add_child(delete_button);
+ }
}
for (int i = 0; i < agnode->get_input_count(); i++) {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index d1e2ba0fe0..5afd2d6e1b 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1550,6 +1550,14 @@ void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<Stri
}
bool SceneTreeDock::_has_tracks_to_delete(Node *p_node, List<Node *> &p_to_delete) const {
+ // Skip if this node will be deleted.
+ for (const Node *F : p_to_delete) {
+ if (F == p_node || F->is_ancestor_of(p_node)) {
+ return false;
+ }
+ }
+
+ // This is an AnimationPlayer that survives the deletion.
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
Node *root = ap->get_node(ap->get_root_node());
@@ -1578,11 +1586,13 @@ bool SceneTreeDock::_has_tracks_to_delete(Node *p_node, List<Node *> &p_to_delet
}
}
+ // Recursively check child nodes.
for (int i = 0; i < p_node->get_child_count(); i++) {
if (_has_tracks_to_delete(p_node->get_child(i), p_to_delete)) {
return true;
}
}
+
return false;
}
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 4b097412d6..79cd1056dd 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -336,6 +336,12 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) {
}
if (Node *node = Object::cast_to<Node>(obj)) {
+ // For debugging multiplayer.
+ {
+ PropertyInfo pi(Variant::INT, String("Node/multiplayer_authority"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY);
+ properties.push_back(SceneDebuggerProperty(pi, node->get_multiplayer_authority()));
+ }
+
// Add specialized NodePath info (if inside tree).
if (node->is_inside_tree()) {
PropertyInfo pi(Variant::NODE_PATH, String("Node/path"));
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp
index 8af73deefb..29e6d3d10d 100644
--- a/scene/gui/tab_bar.cpp
+++ b/scene/gui/tab_bar.cpp
@@ -321,7 +321,6 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {
}
void TabBar::_shape(int p_tab) {
- tabs.write[p_tab].xl_text = atr(tabs[p_tab].text);
tabs.write[p_tab].text_buf->clear();
tabs.write[p_tab].text_buf->set_width(-1);
if (tabs[p_tab].text_direction == Control::TEXT_DIRECTION_INHERITED) {
@@ -330,7 +329,7 @@ void TabBar::_shape(int p_tab) {
tabs.write[p_tab].text_buf->set_direction((TextServer::Direction)tabs[p_tab].text_direction);
}
- tabs.write[p_tab].text_buf->add_string(tabs[p_tab].xl_text, theme_cache.font, theme_cache.font_size, tabs[p_tab].language);
+ tabs.write[p_tab].text_buf->add_string(atr(tabs[p_tab].text), theme_cache.font, theme_cache.font_size, tabs[p_tab].language);
}
void TabBar::_notification(int p_what) {
@@ -1118,7 +1117,26 @@ Variant TabBar::get_drag_data(const Point2 &p_point) {
if (!drag_to_rearrange_enabled) {
return Control::get_drag_data(p_point); // Allow stuff like TabContainer to override it.
}
+ return _handle_get_drag_data("tab_bar_tab", p_point);
+}
+
+bool TabBar::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
+ if (!drag_to_rearrange_enabled) {
+ return Control::can_drop_data(p_point, p_data); // Allow stuff like TabContainer to override it.
+ }
+ return _handle_can_drop_data("tab_bar_tab", p_point, p_data);
+}
+
+void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) {
+ if (!drag_to_rearrange_enabled) {
+ Control::drop_data(p_point, p_data); // Allow stuff like TabContainer to override it.
+ return;
+ }
+ _handle_drop_data("tab_bar_tab", p_point, p_data, callable_mp(this, &TabBar::move_tab), callable_mp(this, &TabBar::_move_tab_from));
+}
+
+Variant TabBar::_handle_get_drag_data(const String &p_type, const Point2 &p_point) {
int tab_over = get_tab_idx_at_point(p_point);
if (tab_over < 0) {
return Variant();
@@ -1138,30 +1156,26 @@ Variant TabBar::get_drag_data(const Point2 &p_point) {
drag_preview->add_child(tf);
}
- Label *label = memnew(Label(tabs[tab_over].xl_text));
+ Label *label = memnew(Label(get_tab_title(tab_over)));
drag_preview->add_child(label);
set_drag_preview(drag_preview);
Dictionary drag_data;
- drag_data["type"] = "tab_element";
- drag_data["tab_element"] = tab_over;
+ drag_data["type"] = p_type;
+ drag_data["tab_index"] = tab_over;
drag_data["from_path"] = get_path();
return drag_data;
}
-bool TabBar::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
- if (!drag_to_rearrange_enabled) {
- return Control::can_drop_data(p_point, p_data); // Allow stuff like TabContainer to override it.
- }
-
+bool TabBar::_handle_can_drop_data(const String &p_type, const Point2 &p_point, const Variant &p_data) const {
Dictionary d = p_data;
if (!d.has("type")) {
return false;
}
- if (String(d["type"]) == "tab_element") {
+ if (String(d["type"]) == p_type) {
NodePath from_path = d["from_path"];
NodePath to_path = get_path();
if (from_path == to_path) {
@@ -1179,19 +1193,14 @@ bool TabBar::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
return false;
}
-void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) {
- if (!drag_to_rearrange_enabled) {
- Control::drop_data(p_point, p_data); // Allow stuff like TabContainer to override it.
- return;
- }
-
+void TabBar::_handle_drop_data(const String &p_type, const Point2 &p_point, const Variant &p_data, const Callable &p_move_tab_callback, const Callable &p_move_tab_from_other_callback) {
Dictionary d = p_data;
if (!d.has("type")) {
return;
}
- if (String(d["type"]) == "tab_element") {
- int tab_from_id = d["tab_element"];
+ if (String(d["type"]) == p_type) {
+ int tab_from_id = d["tab_index"];
int hover_now = get_tab_idx_at_point(p_point);
NodePath from_path = d["from_path"];
NodePath to_path = get_path();
@@ -1216,7 +1225,7 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) {
hover_now = is_layout_rtl() ^ (p_point.x < x) ? 0 : get_tab_count() - 1;
}
- move_tab(tab_from_id, hover_now);
+ p_move_tab_callback.call(tab_from_id, hover_now);
if (!is_tab_disabled(hover_now)) {
emit_signal(SNAME("active_tab_rearranged"), hover_now);
set_current_tab(hover_now);
@@ -1242,35 +1251,42 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) {
hover_now = tabs.is_empty() || (is_layout_rtl() ^ (p_point.x < get_tab_rect(0).position.x)) ? 0 : get_tab_count();
}
- Tab moving_tab = from_tabs->tabs[tab_from_id];
- from_tabs->remove_tab(tab_from_id);
- tabs.insert(hover_now, moving_tab);
-
- if (tabs.size() > 1) {
- if (current >= hover_now) {
- current++;
- }
- if (previous >= hover_now) {
- previous++;
- }
- }
+ p_move_tab_from_other_callback.call(from_tabs, tab_from_id, hover_now);
+ }
+ }
+ }
+}
- if (!is_tab_disabled(hover_now)) {
- set_current_tab(hover_now);
- } else {
- _update_cache();
- queue_redraw();
- }
+void TabBar::_move_tab_from(TabBar *p_from_tabbar, int p_from_index, int p_to_index) {
+ Tab moving_tab = p_from_tabbar->tabs[p_from_index];
+ p_from_tabbar->remove_tab(p_from_index);
+ tabs.insert(p_to_index, moving_tab);
- update_minimum_size();
+ if (tabs.size() > 1) {
+ if (current >= p_to_index) {
+ current++;
+ }
+ if (previous >= p_to_index) {
+ previous++;
+ }
+ }
- if (tabs.size() == 1) {
- emit_signal(SNAME("tab_selected"), 0);
- emit_signal(SNAME("tab_changed"), 0);
- }
- }
+ if (!is_tab_disabled(p_to_index)) {
+ set_current_tab(p_to_index);
+ if (tabs.size() == 1) {
+ _update_cache();
+ queue_redraw();
+ emit_signal(SNAME("tab_changed"), 0);
+ }
+ } else {
+ _update_cache();
+ queue_redraw();
+ if (tabs.size() == 1) {
+ emit_signal(SNAME("tab_changed"), 0);
}
}
+
+ update_minimum_size();
}
int TabBar::get_tab_idx_at_point(const Point2 &p_point) const {
diff --git a/scene/gui/tab_bar.h b/scene/gui/tab_bar.h
index 4bce30ea52..28e3411f3d 100644
--- a/scene/gui/tab_bar.h
+++ b/scene/gui/tab_bar.h
@@ -55,7 +55,6 @@ public:
private:
struct Tab {
String text;
- String xl_text;
String language;
Control::TextDirection text_direction = Control::TEXT_DIRECTION_INHERITED;
@@ -167,8 +166,13 @@ protected:
Variant get_drag_data(const Point2 &p_point) override;
bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
void drop_data(const Point2 &p_point, const Variant &p_data) override;
+ void _move_tab_from(TabBar *p_from_tabbar, int p_from_index, int p_to_index);
public:
+ Variant _handle_get_drag_data(const String &p_type, const Point2 &p_point);
+ bool _handle_can_drop_data(const String &p_type, const Point2 &p_point, const Variant &p_data) const;
+ void _handle_drop_data(const String &p_type, const Point2 &p_point, const Variant &p_data, const Callable &p_move_tab_callback, const Callable &p_move_tab_from_other_callback);
+
void add_tab(const String &p_str = "", const Ref<Texture2D> &p_icon = Ref<Texture2D>());
void set_tab_title(int p_tab, const String &p_title);
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 481f8f4131..c21a9d14cb 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -330,143 +330,59 @@ Vector<Control *> TabContainer::_get_tab_controls() const {
}
Variant TabContainer::_get_drag_data_fw(const Point2 &p_point, Control *p_from_control) {
- if (!drag_to_rearrange_enabled) {
- return Variant();
- }
-
- int tab_over = get_tab_idx_at_point(p_point);
- if (tab_over < 0) {
- return Variant();
- }
-
- HBoxContainer *drag_preview = memnew(HBoxContainer);
-
- Ref<Texture2D> icon = get_tab_icon(tab_over);
- if (!icon.is_null()) {
- TextureRect *tf = memnew(TextureRect);
- tf->set_texture(icon);
- drag_preview->add_child(tf);
- }
-
- Label *label = memnew(Label(get_tab_title(tab_over)));
- set_drag_preview(drag_preview);
- drag_preview->add_child(label);
-
- Dictionary drag_data;
- drag_data["type"] = "tabc_element";
- drag_data["tabc_element"] = tab_over;
- drag_data["from_path"] = get_path();
-
- return drag_data;
+ return tab_bar->_handle_get_drag_data("tab_container_tab", p_point);
}
bool TabContainer::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) const {
- if (!drag_to_rearrange_enabled) {
- return false;
- }
-
- Dictionary d = p_data;
- if (!d.has("type")) {
- return false;
- }
+ return tab_bar->_handle_can_drop_data("tab_container_tab", p_point, p_data);
+}
- if (String(d["type"]) == "tabc_element") {
- NodePath from_path = d["from_path"];
- NodePath to_path = get_path();
- if (from_path == to_path) {
- return true;
- } else if (get_tabs_rearrange_group() != -1) {
- // Drag and drop between other TabContainers.
- Node *from_node = get_node(from_path);
- TabContainer *from_tabc = Object::cast_to<TabContainer>(from_node);
- if (from_tabc && from_tabc->get_tabs_rearrange_group() == get_tabs_rearrange_group()) {
- return true;
- }
- }
- }
+void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) {
+ return tab_bar->_handle_drop_data("tab_container_tab", p_point, p_data, callable_mp(this, &TabContainer::_drag_move_tab), callable_mp(this, &TabContainer::_drag_move_tab_from));
+}
- return false;
+void TabContainer::_drag_move_tab(int p_from_index, int p_to_index) {
+ move_child(get_tab_control(p_from_index), get_tab_control(p_to_index)->get_index(false));
}
-void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) {
- if (!drag_to_rearrange_enabled) {
+void TabContainer::_drag_move_tab_from(TabBar *p_from_tabbar, int p_from_index, int p_to_index) {
+ Node *parent = p_from_tabbar->get_parent();
+ if (!parent) {
return;
}
-
- Dictionary d = p_data;
- if (!d.has("type")) {
+ TabContainer *from_tab_container = Object::cast_to<TabContainer>(parent);
+ if (!from_tab_container) {
return;
}
+ move_tab_from_tab_container(from_tab_container, p_from_index, p_to_index);
+}
- if (String(d["type"]) == "tabc_element") {
- int tab_from_id = d["tabc_element"];
- int hover_now = get_tab_idx_at_point(p_point);
- NodePath from_path = d["from_path"];
- NodePath to_path = get_path();
-
- if (from_path == to_path) {
- if (tab_from_id == hover_now) {
- return;
- }
-
- // Drop the new tab to the left or right depending on where the target tab is being hovered.
- if (hover_now != -1) {
- Rect2 tab_rect = tab_bar->get_tab_rect(hover_now);
- if (is_layout_rtl() ^ (p_point.x <= tab_rect.position.x + tab_rect.size.width / 2)) {
- if (hover_now > tab_from_id) {
- hover_now -= 1;
- }
- } else if (tab_from_id > hover_now) {
- hover_now += 1;
- }
- } else {
- hover_now = is_layout_rtl() ^ (p_point.x < tab_bar->get_tab_rect(0).position.x) ? 0 : get_tab_count() - 1;
- }
-
- move_child(get_tab_control(tab_from_id), get_tab_control(hover_now)->get_index(false));
- if (!is_tab_disabled(hover_now)) {
- emit_signal(SNAME("active_tab_rearranged"), hover_now);
- set_current_tab(hover_now);
- }
-
- } else if (get_tabs_rearrange_group() != -1) {
- // Drag and drop between TabContainers.
-
- Node *from_node = get_node(from_path);
- TabContainer *from_tabc = Object::cast_to<TabContainer>(from_node);
-
- if (from_tabc && from_tabc->get_tabs_rearrange_group() == get_tabs_rearrange_group()) {
- // Get the tab properties before they get erased by the child removal.
- String tab_title = from_tabc->get_tab_title(tab_from_id);
- Ref<Texture2D> tab_icon = from_tabc->get_tab_icon(tab_from_id);
- bool tab_disabled = from_tabc->is_tab_disabled(tab_from_id);
- Variant tab_metadata = from_tabc->get_tab_metadata(tab_from_id);
+void TabContainer::move_tab_from_tab_container(TabContainer *p_from, int p_from_index, int p_to_index) {
+ ERR_FAIL_NULL(p_from);
+ ERR_FAIL_INDEX(p_from_index, p_from->get_tab_count());
+ ERR_FAIL_INDEX(p_to_index, get_tab_count() + 1);
- // Drop the new tab to the left or right depending on where the target tab is being hovered.
- if (hover_now != -1) {
- Rect2 tab_rect = tab_bar->get_tab_rect(hover_now);
- if (is_layout_rtl() ^ (p_point.x > tab_rect.position.x + tab_rect.size.width / 2)) {
- hover_now += 1;
- }
- } else {
- hover_now = is_layout_rtl() ^ (p_point.x < tab_bar->get_tab_rect(0).position.x) ? 0 : get_tab_count();
- }
+ // Get the tab properties before they get erased by the child removal.
+ String tab_title = p_from->get_tab_title(p_from_index);
+ Ref<Texture2D> tab_icon = p_from->get_tab_icon(p_from_index);
+ bool tab_disabled = p_from->is_tab_disabled(p_from_index);
+ Variant tab_metadata = p_from->get_tab_metadata(p_from_index);
- Control *moving_tabc = from_tabc->get_tab_control(tab_from_id);
- from_tabc->remove_child(moving_tabc);
- add_child(moving_tabc, true);
+ Control *moving_tabc = p_from->get_tab_control(p_from_index);
+ p_from->remove_child(moving_tabc);
+ add_child(moving_tabc, true);
- set_tab_title(get_tab_count() - 1, tab_title);
- set_tab_icon(get_tab_count() - 1, tab_icon);
- set_tab_disabled(get_tab_count() - 1, tab_disabled);
- set_tab_metadata(get_tab_count() - 1, tab_metadata);
+ set_tab_title(get_tab_count() - 1, tab_title);
+ set_tab_icon(get_tab_count() - 1, tab_icon);
+ set_tab_disabled(get_tab_count() - 1, tab_disabled);
+ set_tab_metadata(get_tab_count() - 1, tab_metadata);
- move_child(moving_tabc, get_tab_control(hover_now)->get_index(false));
- if (!is_tab_disabled(hover_now)) {
- set_current_tab(hover_now);
- }
- }
- }
+ if (p_to_index < 0 || p_to_index > get_tab_count() - 1) {
+ p_to_index = get_tab_count() - 1;
+ }
+ move_child(moving_tabc, get_tab_control(p_to_index)->get_index(false));
+ if (!is_tab_disabled(p_to_index)) {
+ set_current_tab(p_to_index);
}
}
@@ -496,6 +412,10 @@ void TabContainer::_on_tab_button_pressed(int p_tab) {
emit_signal(SNAME("tab_button_pressed"), p_tab);
}
+void TabContainer::_on_active_tab_rearranged(int p_tab) {
+ emit_signal(SNAME("active_tab_rearranged"), p_tab);
+}
+
void TabContainer::_refresh_tab_names() {
Vector<Control *> controls = _get_tab_controls();
for (int i = 0; i < controls.size(); i++) {
@@ -895,11 +815,11 @@ Popup *TabContainer::get_popup() const {
}
void TabContainer::set_drag_to_rearrange_enabled(bool p_enabled) {
- drag_to_rearrange_enabled = p_enabled;
+ tab_bar->set_drag_to_rearrange_enabled(p_enabled);
}
bool TabContainer::get_drag_to_rearrange_enabled() const {
- return drag_to_rearrange_enabled;
+ return tab_bar->get_drag_to_rearrange_enabled();
}
void TabContainer::set_tabs_rearrange_group(int p_group_id) {
@@ -1038,6 +958,7 @@ TabContainer::TabContainer() {
tab_bar->connect("tab_hovered", callable_mp(this, &TabContainer::_on_tab_hovered));
tab_bar->connect("tab_selected", callable_mp(this, &TabContainer::_on_tab_selected));
tab_bar->connect("tab_button_pressed", callable_mp(this, &TabContainer::_on_tab_button_pressed));
+ tab_bar->connect("active_tab_rearranged", callable_mp(this, &TabContainer::_on_active_tab_rearranged));
connect("mouse_exited", callable_mp(this, &TabContainer::_on_mouse_exited));
}
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index a831416612..5750c6b82e 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -43,7 +43,6 @@ class TabContainer : public Container {
bool all_tabs_in_front = false;
bool menu_hovered = false;
mutable ObjectID popup_obj_id;
- bool drag_to_rearrange_enabled = false;
bool use_hidden_tabs_for_min_size = false;
bool theme_changing = false;
Vector<Control *> children_removing;
@@ -97,10 +96,13 @@ class TabContainer : public Container {
void _on_tab_hovered(int p_tab);
void _on_tab_selected(int p_tab);
void _on_tab_button_pressed(int p_tab);
+ void _on_active_tab_rearranged(int p_tab);
Variant _get_drag_data_fw(const Point2 &p_point, Control *p_from_control);
bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) const;
void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control);
+ void _drag_move_tab(int p_from_index, int p_to_index);
+ void _drag_move_tab_from(TabBar *p_from_tabbar, int p_from_index, int p_to_index);
protected:
virtual void gui_input(const Ref<InputEvent> &p_event) override;
@@ -166,6 +168,8 @@ public:
void set_popup(Node *p_popup);
Popup *get_popup() const;
+ void move_tab_from_tab_container(TabContainer *p_from, int p_from_index, int p_to_index = -1);
+
void set_drag_to_rearrange_enabled(bool p_enabled);
bool get_drag_to_rearrange_enabled() const;
void set_tabs_rearrange_group(int p_group_id);
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index 8a672d8628..9e8d654b4e 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -53,6 +53,7 @@ RendererRD::ForwardID RenderForwardMobile::ForwardIDStorageMobile::allocate_forw
index = forward_id_allocators[p_type].allocations.size();
forward_id_allocators[p_type].allocations.push_back(true);
forward_id_allocators[p_type].map.push_back(0xFF);
+ forward_id_allocators[p_type].last_pass.push_back(0);
} else {
forward_id_allocators[p_type].allocations[index] = true;
}
@@ -64,44 +65,72 @@ void RenderForwardMobile::ForwardIDStorageMobile::free_forward_id(RendererRD::Fo
forward_id_allocators[p_type].allocations[p_id] = false;
}
-void RenderForwardMobile::ForwardIDStorageMobile::map_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id, uint32_t p_index) {
+void RenderForwardMobile::ForwardIDStorageMobile::map_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id, uint32_t p_index, uint64_t p_last_pass) {
forward_id_allocators[p_type].map[p_id] = p_index;
+ forward_id_allocators[p_type].last_pass[p_id] = p_last_pass;
}
void RenderForwardMobile::fill_push_constant_instance_indices(SceneState::InstanceData *p_instance_data, const GeometryInstanceForwardMobile *p_instance) {
- // First zero out our indices.
+ uint64_t current_frame = RSG::rasterizer->get_frame_number();
p_instance_data->omni_lights[0] = 0xFFFFFFFF;
p_instance_data->omni_lights[1] = 0xFFFFFFFF;
- p_instance_data->spot_lights[0] = 0xFFFFFFFF;
- p_instance_data->spot_lights[1] = 0xFFFFFFFF;
-
- p_instance_data->decals[0] = 0xFFFFFFFF;
- p_instance_data->decals[1] = 0xFFFFFFFF;
-
- p_instance_data->reflection_probes[0] = 0xFFFFFFFF;
- p_instance_data->reflection_probes[1] = 0xFFFFFFFF;
-
- for (uint32_t i = 0; i < MAX_RDL_CULL; i++) {
- uint32_t ofs = i < 4 ? 0 : 1;
- uint32_t shift = (i & 0x3) << 3;
+ uint32_t idx = 0;
+ for (uint32_t i = 0; i < p_instance->omni_light_count; i++) {
+ uint32_t ofs = idx < 4 ? 0 : 1;
+ uint32_t shift = (idx & 0x3) << 3;
uint32_t mask = ~(0xFF << shift);
- if (i < p_instance->omni_light_count) {
+
+ if (forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_OMNI_LIGHT].last_pass[p_instance->omni_lights[i]] == current_frame) {
p_instance_data->omni_lights[ofs] &= mask;
p_instance_data->omni_lights[ofs] |= uint32_t(forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_OMNI_LIGHT].map[p_instance->omni_lights[i]]) << shift;
+ idx++;
}
- if (i < p_instance->spot_light_count) {
+ }
+
+ p_instance_data->spot_lights[0] = 0xFFFFFFFF;
+ p_instance_data->spot_lights[1] = 0xFFFFFFFF;
+
+ idx = 0;
+ for (uint32_t i = 0; i < p_instance->spot_light_count; i++) {
+ uint32_t ofs = idx < 4 ? 0 : 1;
+ uint32_t shift = (idx & 0x3) << 3;
+ uint32_t mask = ~(0xFF << shift);
+ if (forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_SPOT_LIGHT].last_pass[p_instance->spot_lights[i]] == current_frame) {
p_instance_data->spot_lights[ofs] &= mask;
p_instance_data->spot_lights[ofs] |= uint32_t(forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_SPOT_LIGHT].map[p_instance->spot_lights[i]]) << shift;
+ idx++;
}
- if (i < p_instance->decals_count) {
+ }
+
+ p_instance_data->decals[0] = 0xFFFFFFFF;
+ p_instance_data->decals[1] = 0xFFFFFFFF;
+
+ idx = 0;
+ for (uint32_t i = 0; i < p_instance->decals_count; i++) {
+ uint32_t ofs = idx < 4 ? 0 : 1;
+ uint32_t shift = (idx & 0x3) << 3;
+ uint32_t mask = ~(0xFF << shift);
+ if (forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_DECAL].last_pass[p_instance->decals[i]] == current_frame) {
p_instance_data->decals[ofs] &= mask;
p_instance_data->decals[ofs] |= uint32_t(forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_DECAL].map[p_instance->decals[i]]) << shift;
+ idx++;
}
- if (i < p_instance->reflection_probe_count) {
+ }
+
+ p_instance_data->reflection_probes[0] = 0xFFFFFFFF;
+ p_instance_data->reflection_probes[1] = 0xFFFFFFFF;
+
+ idx = 0;
+ for (uint32_t i = 0; i < p_instance->reflection_probe_count; i++) {
+ uint32_t ofs = idx < 4 ? 0 : 1;
+ uint32_t shift = (idx & 0x3) << 3;
+ uint32_t mask = ~(0xFF << shift);
+ if (forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_REFLECTION_PROBE].last_pass[p_instance->reflection_probes[i]] == current_frame) {
p_instance_data->reflection_probes[ofs] &= mask;
p_instance_data->reflection_probes[ofs] |= uint32_t(forward_id_storage_mobile->forward_id_allocators[RendererRD::FORWARD_ID_TYPE_REFLECTION_PROBE].map[p_instance->reflection_probes[i]]) << shift;
+ idx++;
}
}
}
@@ -539,7 +568,6 @@ void RenderForwardMobile::_setup_lightmaps(const RenderDataRD *p_render_data, co
void RenderForwardMobile::_pre_opaque_render(RenderDataRD *p_render_data) {
RendererRD::LightStorage *light_storage = RendererRD::LightStorage::get_singleton();
- RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton();
p_render_data->cube_shadows.clear();
p_render_data->shadows.clear();
@@ -598,28 +626,11 @@ void RenderForwardMobile::_pre_opaque_render(RenderDataRD *p_render_data) {
//full barrier here, we need raster, transfer and compute and it depends from the previous work
RD::get_singleton()->barrier(RD::BARRIER_MASK_ALL_BARRIERS, RD::BARRIER_MASK_ALL_BARRIERS);
-
- bool using_shadows = true;
-
- if (p_render_data->reflection_probe.is_valid()) {
- if (!RSG::light_storage->reflection_probe_renders_shadows(light_storage->reflection_probe_instance_get_probe(p_render_data->reflection_probe))) {
- using_shadows = false;
- }
- } else {
- //do not render reflections when rendering a reflection probe
- light_storage->update_reflection_probe_buffer(p_render_data, *p_render_data->reflection_probes, p_render_data->scene_data->cam_transform.affine_inverse(), p_render_data->environment);
- }
-
- uint32_t directional_light_count = 0;
- uint32_t positional_light_count = 0;
- light_storage->update_light_buffers(p_render_data, *p_render_data->lights, p_render_data->scene_data->cam_transform, p_render_data->shadow_atlas, using_shadows, directional_light_count, positional_light_count, p_render_data->directional_light_soft_shadows);
- texture_storage->update_decal_buffer(*p_render_data->decals, p_render_data->scene_data->cam_transform);
-
- p_render_data->directional_light_count = directional_light_count;
}
void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color &p_default_bg_color) {
RendererRD::LightStorage *light_storage = RendererRD::LightStorage::get_singleton();
+ RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton();
ERR_FAIL_NULL(p_render_data);
@@ -668,6 +679,25 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
bool using_subpass_transparent = true;
bool using_subpass_post_process = true;
+ bool using_shadows = true;
+
+ if (p_render_data->reflection_probe.is_valid()) {
+ if (!RSG::light_storage->reflection_probe_renders_shadows(light_storage->reflection_probe_instance_get_probe(p_render_data->reflection_probe))) {
+ using_shadows = false;
+ }
+ } else {
+ //do not render reflections when rendering a reflection probe
+ light_storage->update_reflection_probe_buffer(p_render_data, *p_render_data->reflection_probes, p_render_data->scene_data->cam_transform.affine_inverse(), p_render_data->environment);
+ }
+
+ // Update light and decal buffer first so we know what lights and decals are safe to pair with.
+ uint32_t directional_light_count = 0;
+ uint32_t positional_light_count = 0;
+ light_storage->update_light_buffers(p_render_data, *p_render_data->lights, p_render_data->scene_data->cam_transform, p_render_data->shadow_atlas, using_shadows, directional_light_count, positional_light_count, p_render_data->directional_light_soft_shadows);
+ texture_storage->update_decal_buffer(*p_render_data->decals, p_render_data->scene_data->cam_transform);
+
+ p_render_data->directional_light_count = directional_light_count;
+
// fill our render lists early so we can find out if we use various features
_fill_render_list(RENDER_LIST_OPAQUE, p_render_data, PASS_MODE_COLOR);
render_list[RENDER_LIST_OPAQUE].sort_by_key();
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h
index 50bf83b612..c8e42e2cf1 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h
@@ -535,6 +535,7 @@ protected:
struct ForwardIDAllocator {
LocalVector<bool> allocations;
LocalVector<uint8_t> map;
+ LocalVector<uint64_t> last_pass;
};
ForwardIDAllocator forward_id_allocators[RendererRD::FORWARD_ID_MAX];
@@ -542,7 +543,7 @@ protected:
public:
virtual RendererRD::ForwardID allocate_forward_id(RendererRD::ForwardIDType p_type) override;
virtual void free_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id) override;
- virtual void map_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id, uint32_t p_index) override;
+ virtual void map_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id, uint32_t p_index, uint64_t p_last_pass) override;
virtual bool uses_forward_ids() const override { return true; }
};
diff --git a/servers/rendering/renderer_rd/storage_rd/forward_id_storage.h b/servers/rendering/renderer_rd/storage_rd/forward_id_storage.h
index bedf5e80c7..c8f8d4f7f2 100644
--- a/servers/rendering/renderer_rd/storage_rd/forward_id_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/forward_id_storage.h
@@ -59,7 +59,7 @@ public:
virtual RendererRD::ForwardID allocate_forward_id(RendererRD::ForwardIDType p_type) { return -1; }
virtual void free_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id) {}
- virtual void map_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id, uint32_t p_index) {}
+ virtual void map_forward_id(RendererRD::ForwardIDType p_type, RendererRD::ForwardID p_id, uint32_t p_index, uint64_t p_last_pass) {}
virtual bool uses_forward_ids() const { return false; }
};
diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
index 4fd33ad71a..1f6d1021f4 100644
--- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp
@@ -793,7 +793,7 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged
real_t distance = (i < omni_light_count) ? omni_light_sort[index].depth : spot_light_sort[index].depth;
if (using_forward_ids) {
- forward_id_storage->map_forward_id(type == RS::LIGHT_OMNI ? RendererRD::FORWARD_ID_TYPE_OMNI_LIGHT : RendererRD::FORWARD_ID_TYPE_SPOT_LIGHT, light_instance->forward_id, index);
+ forward_id_storage->map_forward_id(type == RS::LIGHT_OMNI ? RendererRD::FORWARD_ID_TYPE_OMNI_LIGHT : RendererRD::FORWARD_ID_TYPE_SPOT_LIGHT, light_instance->forward_id, index, light_instance->last_pass);
}
Transform3D light_transform = light_instance->transform;
@@ -1670,7 +1670,7 @@ void LightStorage::update_reflection_probe_buffer(RenderDataRD *p_render_data, c
ReflectionProbeInstance *rpi = reflection_sort[i].probe_instance;
if (using_forward_ids) {
- forward_id_storage->map_forward_id(FORWARD_ID_TYPE_REFLECTION_PROBE, rpi->forward_id, i);
+ forward_id_storage->map_forward_id(FORWARD_ID_TYPE_REFLECTION_PROBE, rpi->forward_id, i, rpi->last_pass);
}
ReflectionProbe *probe = reflection_probe_owner.get_or_null(rpi->probe);
diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
index 166b850864..474ec897ef 100644
--- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
@@ -2862,7 +2862,7 @@ void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const
Decal *decal = decal_sort[i].decal;
if (using_forward_ids) {
- forward_id_storage->map_forward_id(FORWARD_ID_TYPE_DECAL, decal_instance->forward_id, i);
+ forward_id_storage->map_forward_id(FORWARD_ID_TYPE_DECAL, decal_instance->forward_id, i, RSG::rasterizer->get_frame_number());
}
decal_instance->cull_mask = decal->cull_mask;