@@ -318,12 +318,19 @@ void SceneTreeFTI::_update_dirty_nodes(Node *p_node, uint32_t p_current_frame, f
318318 return ;
319319 }
320320
321+ // Temporary direct access to children cache for speed.
322+ // Maybe replaced later by a more generic fast access method
323+ // for children.
324+ p_node->_update_children_cache ();
325+ Span<Node *> children = p_node->data .children_cache .span ();
326+ uint32_t num_children = children.size ();
327+
321328 // Not a Node3D.
322329 // Could be e.g. a viewport or something
323330 // so we should still recurse to children.
324331 if (!s) {
325- for (int n = 0 ; n < p_node-> get_child_count () ; n++) {
326- _update_dirty_nodes (p_node-> get_child (n) , p_current_frame, p_interpolation_fraction, p_active, nullptr , p_depth + 1 );
332+ for (uint32_t n = 0 ; n < num_children ; n++) {
333+ _update_dirty_nodes (children. ptr ()[n] , p_current_frame, p_interpolation_fraction, p_active, nullptr , p_depth + 1 );
327334 }
328335 return ;
329336 }
@@ -424,8 +431,8 @@ void SceneTreeFTI::_update_dirty_nodes(Node *p_node, uint32_t p_current_frame, f
424431 s->_clear_dirty_bits (Node3D::DIRTY_GLOBAL_INTERPOLATED_TRANSFORM);
425432
426433 // Recurse to children.
427- for (int n = 0 ; n < p_node-> get_child_count () ; n++) {
428- _update_dirty_nodes (p_node-> get_child (n) , p_current_frame, p_interpolation_fraction, p_active, s->data .fti_global_xform_interp_set ? &s->data .global_transform_interpolated : &s->data .global_transform , p_depth + 1 );
434+ for (uint32_t n = 0 ; n < num_children ; n++) {
435+ _update_dirty_nodes (children. ptr ()[n] , p_current_frame, p_interpolation_fraction, p_active, s->data .fti_global_xform_interp_set ? &s->data .global_transform_interpolated : &s->data .global_transform , p_depth + 1 );
429436 }
430437}
431438
0 commit comments