|
41 | 41 | // checks to ensure there aren't more than one object added to the lists. |
42 | 42 | // #define GODOT_SCENE_TREE_FTI_EXTRA_CHECKS |
43 | 43 |
|
| 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 | + |
44 | 53 | void SceneTreeFTI::_reset_flags(Node *p_node) { |
45 | 54 | Node3D *s = Object::cast_to<Node3D>(p_node); |
46 | 55 |
|
47 | 56 | 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); |
54 | 58 |
|
55 | 59 | // In most cases the later NOTIFICATION_RESET_PHYSICS_INTERPOLATION |
56 | 60 | // will reset this, but this should help cover hidden nodes. |
@@ -270,13 +274,15 @@ void SceneTreeFTI::node_3d_notify_delete(Node3D *p_node) { |
270 | 274 |
|
271 | 275 | MutexLock(data.mutex); |
272 | 276 |
|
273 | | - p_node->data.fti_on_frame_xform_list = false; |
274 | | - |
275 | 277 | // Ensure this is kept in sync with the lists, in case a node |
276 | 278 | // is removed and re-added to the scene tree multiple times |
277 | 279 | // on the same frame / tick. |
278 | 280 | p_node->_set_physics_interpolation_reset_requested(false); |
279 | 281 |
|
| 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 | + |
280 | 286 | // This can potentially be optimized for large scenes with large churn, |
281 | 287 | // as it will be doing a linear search through the lists. |
282 | 288 | data.tick_xform_list[0].erase_unordered(p_node); |
|
0 commit comments