Cleanup: Use utility function to find groups in node tree #104465
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#104465
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:is_contains"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add
contains_group
method in python api forNodeTree
type, cleanupntreeHasTree
function, reusentreeHasTree
in more place in code.The algorithm has been changed to not recheck trees by using set.
Performance gains from avoiding already checked node trees:
Based on tests, can say that for large files with a huge number
of trees, the response speed of opening the searc menu in the
node editor increased by ~200 times (for really large projects
with 16 individual groups in 6 levels of nesting). Group insert
operations are also accelerated, but this is different in some cases.
The usual recursive option:
Using a set:
NOTE: Opening search checks all nodes. They have different levels of nesting, but this is reproducible, so it gives an average result in different cases.
I had accepted this in its previous form: https://archive.blender.org/developer/D16870
Use ntreeContainsTree in more placesto Cleanup: Use utility function to find groups in node tree@ -3456,3 +3456,3 @@
}
bool ntreeHasTree(const bNodeTree *ntree, const bNodeTree *lookup)
bool ntreeContainsTree(const bNodeTree *parent_tree, const bNodeTree *sub_tree)
This should internally avoid to enter the same node group multiple times. For very large node trees, with lots of nesting that could be quite heavy.
When i was upload this as diff (https://archive.blender.org/developer/D16870) i pointed, that map (set) for avoiding already checked groups and output of groups stack can be added in future as speed improvement. You want to i do that in this request?
Ah I see, well either add this to the pull request description or just do the code change now already. Don't see much of a reason not to do it now already.
@ -12722,0 +12729,4 @@
func,
"Check if the node tree contains another. Used to avoid creating recursive node groups");
parm = RNA_def_pointer(
func, "sub_tree", "NodeTree", "Node Group", "Node group for recursive check");
Currently this uses the term
group
andtree
. While we generally use those terms synonymously, it would be better to be consistent within a single function declaration.Also, would be good if you start build test for me here
@blender-bot build
I'm not sure how best to format the request description, so it seems to be easy to just leave that until it's possible. For a commit, I can add a separate, shorter description of the test results.I've removed the meaningless metrics (because they are reproducible, come from over 100 tests, and correlate across versions, I've seen them useful), but without formatting, it still looks...
Got some minor naming/grammer requests, but other than that this looks fine now.
@ -507,1 +507,3 @@
bool ntreeHasTree(const struct bNodeTree *ntree, const struct bNodeTree *lookup);
/**
* Check recursively whether a sub node tree contain in host tree.
Check recursively if a node tree contains another.
@ -508,0 +508,4 @@
/**
* Check recursively whether a sub node tree contain in host tree.
*/
bool ntreeContainsTree(const struct bNodeTree *parent_tree, const struct bNodeTree *sub_tree);
I think it would be better to use names like
tree_to_search_in
andtree_to_search_for
. I find that the most clear.This only for backend part, or in python is too?
parm = RNA_def_pointer(func, "sub_tree", "NodeTree", "Node Tree", "Node tree for recursive check");
@ -3468,0 +3461,4 @@
{
parent_tree->ensure_topology_cache();
for (const bNode *node_group : parent_tree->group_nodes()) {
const bNodeTree *tree = reinterpret_cast<bNodeTree *>(node_group->id);
reinterpret_cast<bNodeTree *>
->reinterpret_cast<const bNodeTree *>