Stabilize runtime validation under dynamic UI load

This commit is contained in:
Alexander Sellite 2026-08-30 22:32:27 -04:00
parent 983e4d0ec3
commit d2dce7f900
5 changed files with 46 additions and 11 deletions

View file

@ -15,8 +15,12 @@ func _enter_tree() -> void:
func _on_node_added(node: Node) -> void:
enforce_node(node)
# Some runtime presenters assign their mesh or material immediately after
# add_child(). Recheck once deferred so those resources are covered too.
call_deferred("_enforce_deferred_node", weakref(node))
# add_child(). Recheck those 3D resource owners once deferred so the newly
# assigned resources are covered too. CanvasItems keep their filter setting
# when their texture changes, so deferring every dynamic UI node only floods
# the message queue during large inventory and catalog refreshes.
if _needs_deferred_resource_check(node):
call_deferred("_enforce_deferred_node", weakref(node))
func _enforce_existing_tree() -> void:
@ -29,6 +33,15 @@ func _enforce_deferred_node(node_ref: WeakRef) -> void:
enforce_node(node)
static func _needs_deferred_resource_check(node: Node) -> bool:
return (
node is GeometryInstance3D
or node is MultiMeshInstance3D
or node is GPUParticles3D
or node is CPUParticles3D
)
static func enforce_subtree(node: Node) -> void:
enforce_node(node)
for child: Node in node.get_children():