Skip to content

Commit

Permalink
Add parameter to detect_changes to specify the ancestor of updated
Browse files Browse the repository at this point in the history
bindinsg

Fixes #2
  • Loading branch information
Johnny Wang committed Dec 17, 2024
1 parent a8a313d commit 7ac2d48
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions addons/DataBindControls/DataBindingsGlobal.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 7ac2d48

Please sign in to comment.