Skip to content

Commit 730adf4

Browse files
committed
Merge pull request #105973 from lawnjelly/fti_fix_3d_exit_tree
FTI - Fix `SceneTreeFTI` behaviour on exit tree
2 parents b4c9602 + ba4ab2d commit 730adf4

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

scene/main/scene_tree_fti.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,20 @@
4141
// checks to ensure there aren't more than one object added to the lists.
4242
// #define GODOT_SCENE_TREE_FTI_EXTRA_CHECKS
4343

44+
void SceneTreeFTI::_reset_node3d_flags(Node3D &r_node) {
45+
r_node.data.fti_on_tick_xform_list = false;
46+
r_node.data.fti_on_tick_property_list = false;
47+
r_node.data.fti_on_frame_xform_list = false;
48+
r_node.data.fti_on_frame_property_list = false;
49+
r_node.data.fti_global_xform_interp_set = false;
50+
r_node.data.fti_frame_xform_force_update = false;
51+
}
52+
4453
void SceneTreeFTI::_reset_flags(Node *p_node) {
4554
Node3D *s = Object::cast_to<Node3D>(p_node);
4655

4756
if (s) {
48-
s->data.fti_on_tick_xform_list = false;
49-
s->data.fti_on_tick_property_list = false;
50-
s->data.fti_on_frame_xform_list = false;
51-
s->data.fti_on_frame_property_list = false;
52-
s->data.fti_global_xform_interp_set = false;
53-
s->data.fti_frame_xform_force_update = false;
57+
_reset_node3d_flags(*s);
5458

5559
// In most cases the later NOTIFICATION_RESET_PHYSICS_INTERPOLATION
5660
// will reset this, but this should help cover hidden nodes.
@@ -270,13 +274,15 @@ void SceneTreeFTI::node_3d_notify_delete(Node3D *p_node) {
270274

271275
MutexLock(data.mutex);
272276

273-
p_node->data.fti_on_frame_xform_list = false;
274-
275277
// Ensure this is kept in sync with the lists, in case a node
276278
// is removed and re-added to the scene tree multiple times
277279
// on the same frame / tick.
278280
p_node->_set_physics_interpolation_reset_requested(false);
279281

282+
// Keep flags consistent for the same as a new node,
283+
// because this node may re-enter the scene tree.
284+
_reset_node3d_flags(*p_node);
285+
280286
// This can potentially be optimized for large scenes with large churn,
281287
// as it will be doing a linear search through the lists.
282288
data.tick_xform_list[0].erase_unordered(p_node);

scene/main/scene_tree_fti.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class SceneTreeFTI {
9292
void _update_request_resets();
9393

9494
void _reset_flags(Node *p_node);
95+
void _reset_node3d_flags(Node3D &r_node);
9596
void _node_3d_notify_set_xform(Node3D &r_node);
9697
void _node_3d_notify_set_property(Node3D &r_node);
9798

0 commit comments

Comments
 (0)