Page MenuHome

UI/Nodes: Adding node groups via drag & drop (e.g. from Asset Browser)
ClosedPublic

Authored by Julian Eisel (Severin) on Feb 12 2021, 2:40 PM.

Details

Summary

Adds NODE_OT_add_group operator to add a node group from a given name, and
uses that to register a node editor drop-box.
When dropping a node-group asset, the ID will be appended. This is what we do
for other ID assets too.

Should the node group insertion fail (e.g. the group is not compatible with the
current tree, as checked by the poll), the appended data-block is removed.

Diff Detail

Repository
rB Blender
Branch
temp-dragdrop-node-groups (branched from master)
Build Status
Buildable 12895
Build 12895: arc lint + arc unit

Event Timeline

Julian Eisel (Severin) requested review of this revision.Feb 12 2021, 2:40 PM
Julian Eisel (Severin) created this revision.

Node groups for custom (add-on defined) node tree types need to be checked. It seems we don't actually support these properly? node_group_idname() would have to return their custom group name then, maybe other changes are needed too.

@Jacques Lucke (JacquesLucke) probably knows this :)

Jacques Lucke (JacquesLucke) requested changes to this revision.Feb 12 2021, 3:41 PM

I haven't used Blenders node groups in a custom node group yet, so I'm not sure to what degree it is supported. I think I've seen them being used a couple of times by now though. If there is a an issue with how node_group_idname handles custom node groups, it should probably be solved separately from this patch.

source/blender/editors/space_node/node_add.c
359

This is missing user counting.
Without id_us_plus(&node_group->id); it crashes for me when I delete the inserted group node again.

This revision now requires changes to proceed.Feb 12 2021, 3:41 PM
source/blender/editors/space_node/node_add.c
359

Meh true, I used to use WM_operator_drop_load_path() which already sets the user (but requires unsetting on delete).

  • Fix missing user increment after node group is assigned to node
source/blender/editors/space_node/node_add.c
326–328

I'll actually remove this free_id_on_error prop again. The drop-box can handle this in a cancel() callback or such.
But this is a general change and I'll do that in master (maybe after committing this first even).

Seems to work fine in my simple test.

Appending node groups like this is obviously not ideal in all cases, but it will do for now. Also I noticed that geometry node groups are still listed in the Shader tab, but that is a separate issue as well.

source/blender/editors/space_node/node_add.c
377

Comment style.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 15 2021, 7:41 PM
This revision was automatically updated to reflect the committed changes.