From 624b325aa6a5838d8e8106865c7f92d3a36edeaf Mon Sep 17 00:00:00 2001 From: Johnny Wang Date: Tue, 17 Dec 2024 13:18:38 -0800 Subject: [PATCH] Add parameter to detect_changes to specify the ancestor of updated bindinsg Fixes #2 --- addons/DataBindControls/DataBindingsGlobal.gd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/DataBindControls/DataBindingsGlobal.gd b/addons/DataBindControls/DataBindingsGlobal.gd index 2b483bb..0aaae2c 100644 --- a/addons/DataBindControls/DataBindingsGlobal.gd +++ b/addons/DataBindControls/DataBindingsGlobal.gd @@ -9,14 +9,14 @@ var _change_detection_queued := false ## queue change detection -func detect_changes() -> void: +func detect_changes(ancestor: Node = null) -> void: if _change_detection_queued: return _change_detection_queued = true - call_deferred("_detect_changes") + call_deferred("_detect_changes", ancestor) -func _detect_changes(): +func _detect_changes(ancestor: Node): # TODO: queue change detection per viewport root or control root? # each piece of 2d UI change detection could happen on a separate frame, spreading out the load.. # 50 binds can take 1ms to check @@ -38,6 +38,8 @@ func _detect_changes(): result = true break var binds := get_tree().get_nodes_in_group(Util.BIND_GROUP) + if ancestor: + binds = binds.filter(ancestor.is_ancestor_of) for bind in binds: var cd := bind.detect_changes() as bool if cd: