Enhancing Groups Feature #9230
Marcus0170
started this conversation in
General Discussions
Replies: 1 comment
-
The "pseudo-code" should have been something like this: in Node::add_to_group( path = this.get_path() while(path != ""){ node.data.grouped[p_identifier].nodes.push_back(this); path.omit(last) <- we have "node/node/node" this function will change path to "node/node" until it will become "" with the while combo node = get_node(path) } Then node.call_group and node.get_nodes_in_group would be called over node.data.grouped[p_identifier].nodes "list" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
when I started using Godot 3.5 and found out about group function I was amazed how great feature it is, yet I was always wondering why you can only use them in "global" scope as get_tree().get_nodes_in_group("guards")...or get_tree().call_group("guards", "enter_alert_mode")
If you could call node.get_nodes_in_group("guards") or node.call_group("guards", "enter_alert_mode") on any node in SceneTree, while getting only nodes, that are in the given group and at same time in given node and its children(descendants)...meant as filtering groups by "parent node", this would greatly enhance the Groups feature...
Now Im using Godot 4.2 and the Groups feature didnt get this improvement yet...
And as I can see in SceneTree files it doesnt give much of options to make use of current implementation...guess it would have to be reworked as it is...
On other hand, when I checked Node files, I found out something "strange"...it seems each node is storing in "its data" full "list of members of groups" the given node is part of, while these data are never used/accessed...
By least it seems Nodes are storing pointlessly "extra data" thats unnecessary...while at same time this implementation actually could give us hand to solve the "enhancing groups feature"...
When node is added to group, the node is added to this list there, there could be called something like this:
in Node::add_to_group(
path = this.get_path()
node = this
list
while(path != ""){
list.add(gd)
for(list){
node.data.grouped[p_identifier] = gd;
}
path.omit(last) <- we have "node/node/node" this function will change path to "node/node" until it will become "" with the while combo
node = get_node(path)
}
This way each node can have different node.data.grouped[p_identifier] "list".
Then node.call_group and node.get_nodes_in_group would be called over node.data.grouped[p_identifier] while depending on which node it was called over, number of nodes with be returned/will function be called(we would get our filtered behaviour)
I will think about better soultion if possible, but for now this one seems plausible...
Beta Was this translation helpful? Give feedback.
All reactions