Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize SceneTreeEditor filtering #61371

Merged
merged 1 commit into from
May 27, 2022

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented May 24, 2022

This PR integrates #60061 into SceneTreeEditor. When you filter, it will no longer rebuild the whole tree, but instead hide nodes that don't match the filter.

According to my crappy benchmark, before this change my test scene would filter in 7000μs to 11000μs depending on filter text, now it takes around 550μs, so it's ~20x faster.

Please test if there aren't any bugs (I found one, but it's in Tree: #61372).

@KoBeWi KoBeWi force-pushed the stealth_tree_editor branch from a77572e to b923cc8 Compare May 24, 2022 16:07
@akien-mga akien-mga merged commit 92b337a into godotengine:master May 27, 2022
@akien-mga
Copy link
Member

Thanks!

}

if (!keep) {
keep = filter.is_subsequence_ofn(p_parent->get_text(0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KoBeWi I have a question regard this PR's effect on my #58377. After this PR being merged, the p_parent->get_class() will no longer return the type of node, ( it will return something like "Node3D" before this PR).

I'm actually new to godot's development, do I used a wrong function? Is there any new way to implement #58377 ?
Thank you!

Copy link
Member Author

@KoBeWi KoBeWi Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like p_parent was ever anything else than TreeItem. Not sure how to get node from a tree item, maybe it's stored in some metadata.

Do you have the old code from your PR somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the node pointer by using get_node(p_parent->get_metadata(0)) and then use get_class() on that node.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, thank you very much!

}
item->set_as_cursor(0);
}

bool keep = (filter.is_subsequence_ofn(String(p_node->get_name())));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code I rememberd is only change L451 to:
image
(sorry I have only this screenshot for old commit, the code works in godot master this Feb 13th.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants