Merge pull request #107369 from Ivorforce/node-iter-children

Core: Add `Node::iterate_children` as a fast way to iterate a node's children
This commit is contained in:
Thaddeus Crews
2025-09-30 18:35:21 -05:00
4 changed files with 101 additions and 13 deletions

View File

@ -476,19 +476,12 @@ void SceneTreeFTI::_update_dirty_nodes(Node *p_node, uint32_t p_current_half_fra
return;
}
// Temporary direct access to children cache for speed.
// Maybe replaced later by a more generic fast access method
// for children.
p_node->_update_children_cache();
Span<Node *> children = p_node->data.children_cache.span();
uint32_t num_children = children.size();
// Not a Node3D.
// Could be e.g. a viewport or something
// so we should still recurse to children.
if (!s) {
for (uint32_t n = 0; n < num_children; n++) {
_update_dirty_nodes(children.ptr()[n], p_current_half_frame, p_interpolation_fraction, p_active, nullptr, p_depth + 1);
for (Node *node : p_node->iterate_children()) {
_update_dirty_nodes(node, p_current_half_frame, p_interpolation_fraction, p_active, nullptr, p_depth + 1);
}
return;
}
@ -603,8 +596,8 @@ void SceneTreeFTI::_update_dirty_nodes(Node *p_node, uint32_t p_current_half_fra
s->_clear_dirty_bits(Node3D::DIRTY_GLOBAL_INTERPOLATED_TRANSFORM);
// Recurse to children.
for (uint32_t n = 0; n < num_children; n++) {
_update_dirty_nodes(children.ptr()[n], p_current_half_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);
for (Node *node : p_node->iterate_children()) {
_update_dirty_nodes(node, p_current_half_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);
}
}