The goal of this patch is to provide a way to ship node groups with Blender.
This is important for the Particle Nodes project to make them more convenient
Hopefully, this solution can be replaced with something else as part of the
asset manager eventually, but that might take a long time...
Instead of shipping the node groups as .json file, we can also consider
bundling them as .blend files. However, afaik we cannot use the normal
linking or appending functionality. If we would link the node groups,
the user generated .blend would become harder to share. Appending is
problematic, because the user might append the same node group multiple
times. That can happen easily when there are dependencies between the
node groups. I want to avoid having many duplicates of the same node
tree in a .blend file.
The solution presented in this patch solves both issues. Files that use
builtin node group do not depend on any other .blend file via linking.
Furthermore, duplicate node groups are prevented automatically. This
works by comparing existing node groups to the json data of the group
that is supposed to be loaded.
Dependencies between node groups are resolved as well. So when a user
wants to add a node group that depends on some other builtin node group,
this other one will be added as well (if it does not exist already).
If the user changes a builtin node group, a new node group without that
edit will be added.
The system is robust in the sense that errors can only happen for node
groups that are newly added. Once a node group has been added, it is
not modified by the system anymore and behaves like any other node group.
Builtin node groups are stored in release/datafiles/node_groups/. This
patch also comes with an operator to create new builtin node groups based
on a node group in Blender.
For demonstrational purposes, this patch comes with two builtin node groups.
Whether we really want to have those specific nodes as groups or builtin nodes
is yet to be decided, but they are very helpful for testing.
The .json files could certainly be compressed more if that is necessary, but
I'd say < 10kb per node group is well within the bounds.
Note, I could not test these specific node groups yet, so they might not be completely correct.