This has ripple effects by making the "hide value" setting ineffective and
always hiding socket values as well as graying out the "hide value" node group
option.
Pull Request: https://projects.blender.org/blender/blender/pulls/148188
This patch adds support for disabling outputs in built-in nodes based on
menu inputs using a custom usage_inference callback. This just
essentially calls usage_inference_fn for outputs as well, while it was
only being called for inputs. Additionally, the usage_by_menu methods
were adjusted to only consider outputs if it is being called on inputs.
Some types were renamed to be more general, and not just for inputs.
Pull Request: https://projects.blender.org/blender/blender/pulls/148132
Very similar to the layer name search added somewhat recently.
This just displays the names of existing grids in the "Name"
inputs to the Store and Get Named Grid nodes.
Pull Request: https://projects.blender.org/blender/blender/pulls/147163
The new name better represents the actual meaning of the value.
"hide_value" was wrong because it didn't even hide the label in
many cases.
This property just indicates that the input is still understandable
even if the label is not drawn. It's up to the drawing code to make
the final decision whether the label should be drawn or not. This
option just gives it the opportunity to skip the label if that results
in a cleaner UI.
The goal here is to simplify working with the common pattern where a Menu Switch
node is followed by an Index Switch node. This is achieved by detecting this
pattern and drawing the item names from the menu switch node in the index switch
node.
This slightly refactors the custom socket drawing callback to make it easier for
it indirectly call the default drawing function.
Pull Request: https://projects.blender.org/blender/blender/pulls/145710
This patch turns node Menu options into menu inputs. This patch only
covers node operations like Filter, Distort, and so on. Pixel nodes like
Color Balance, Matte, and so on will be done in a separate patch.
Pull Request: https://projects.blender.org/blender/blender/pulls/144495
So far, only node group were able to have menu input sockets. Built-in nodes did
not support them. Currently, all menus of built-in nodes are stored on the node
instead of on the sockets. This limits their flexibility because it's not
possible to expose these inputs.
This patch adds initial support for having menu inputs in built-in nodes. For
testing purposes, it also changes a couple built-in nodes to use an input socket
instead of a node property: Points to Volume, Transform Geometry, Triangulate,
Volume to Mesh and Match String.
### Compatibility
Forward and backward compatibility is maintained where possible (it's not
possible when the menu input is linked in 5.0). The overall compatibility
approach is the same as what was done for the compositor with two differences:
there are no wrapper RNA properties (not necessary for 5.0, those were removed
for the compositor already too), no need to version animation (animation on the
menu properties was already disabled).
This also makes menu sockets not animatable in general which is kind of brittle
(e.g. doesn't properly update when the menu definition changes). To animate a
menu it's better to animate an integer and to drive an index switch with it.
### Which nodes to update?
Many existing menu properties can become sockets, but it's currently not the
intention to convert all of them. In some cases, converting them might restrict
future improvements too much. This mainly affects Math nodes.
Other existing nodes should be updated but are a bit more tricky to update for
different reasons:
* We don't support dynamic output visibility yet. This is something I'll need to
look into at some point.
* They are shared with shader/compositor nodes, which may be more limited in
what can become a socket.
* There may be performance implications unless extra special cases are
implemented, especially for multi-function nodes.
* Some nodes use socket renaming instead of dynamic socket visibility which
isn't something we support more generally yet.
### Implementation
The core implementation is fairly straight forward. The heavy lifting is done by
the existing socket visibility inferencing. There is a new simple API that
allows individual nodes to implement custom input-usage-rules based on other
inputs in a decentralized way.
In most cases, the nodes to update just have a single menu, so there is a new
node-declaration utility that links a socket to a specific value of the menu
input. This internally handles the usage inferencing as well as making the
socket available when using link-drag-search.
In the modified nodes, I also had to explicitly set the "main input" now which
is used when inserting the node in a link. The automatic behavior doesn't work
currently when the first input is a menu. This is something we'll have to solve
more generally at some point but is out of scope for this patch.
Pull Request: https://projects.blender.org/blender/blender/pulls/140705
This patch adds support for the experimental structure types currently
used bu Geometry Nodes. Pixel nodes were declared as function nodes,
which gives dynamic structures for all their sockets. Other nodes now
explicitly declared their inputs as dynamic if not single value, while
the compositor_expects_single_value marker was removed in favor of the
StructureType::Single type.
Pull Request: https://projects.blender.org/blender/blender/pulls/140910
Implementation of #127106.
This is just a visual representation of the field/single/grid
status of sockets to make the workflow more intuitive. With
a visual representation for volume grid sockets, volume features
should be unblocked for further development. The structure type
will also be used to distinguish list sockets in the interface.
Group input nodes now have a "Structure Type" option instead of
the existing "Single Value Only". Usually the auto option should be
enough, but in some cases where the inferencing cannot (yet) make
a clear determination, it can be helpful to choose a specific type.
The new visualization and the group input structure type option
are hidden behind a new experimental option for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/134811
This removes redundant labels from various input nodes like the Value, Integer
and Object node.
Design wise, this is mostly straight forward except for two aspects:
* Some input nodes some have a gizmo icon. In this case I just added the gizmo
icon on the same row.
* The checkbox in the Boolean input node should probably still have a label, so
I kept that.
Implementation wise this adds a new function to socket declarations that allows
us to override the draw behavior of individual sockets per node.
Pull Request: https://projects.blender.org/blender/blender/pulls/139432
Node UIs can now have panels. Some of those may need to have their
labels translated using translation contexts. PanelDeclarations
already had a translation_context member, this commit adds a way to
specify this context, and to use it for translation on drawing the
node.
Pull Request: https://projects.blender.org/blender/blender/pulls/139124
This improves implicit node inputs in multiple ways:
* Fix crash when switching a group input socket type from e.g. vector to
integer, while the default input is set to "position". Now, the default input
type is reset automatically if it's invalid.
* Add Left/Right Handle as possible implicit vector inputs (next to Position and
Normal). Those were the only ones that we used internally that were not
exposed yet.
* When creating a new group input from an existing socket, also initialize the
default input based on the socket. E.g. when grouping a `Set Position` node,
the `Position` input of the group will now also use the position attribute by
default.
In addition to these user-level changes, some internal changes were done too:
* Use unified `NodeDefaultInputType` in node declaration instead of function
pointers which were hard to propagate to node groups.
* Use a new reusable `socket_type_supports_default_input_type` function in rna
to filter the list of possible input items.
Pull Request: https://projects.blender.org/blender/blender/pulls/139139
This makes it possible to search layer names in the
`Named Layer Selection` node as well as boolean
modifier inputs that are marked as a `Layer Selection`.
The layer selection UI is slightly updated:
* Use a slightly larger default width for the
`Named Layer Selection` node.
* Use the layer icon in the field that search for layer names.
* Use `Layer` placeholder string
Pull Request: https://projects.blender.org/blender/blender/pulls/137273
This patch makes it such that the compositor fallback to using the
order of the inputs to infer the domain priority if no domain priority
is specified. This is more robust since some nodes do not declare their
domain priorities and indirectly rely on the order of insertions in some
containers and thus might fail in the future.
We opt for this as opposed to requiting all nodes to declare their
priorities for code brevity.
If a panel has a toggle, then it's a best practice that everything inside it is
grayed out of the toggle is off. It's not something we can enforce for node
groups, but should enforce it for built-in nodes. Right now, we don't have
built-in nodes with panels, but that may change e.g. with #135990.
This patch makes it so that the socket usage inferencing takes panel toggles
into account when determining if an input socket in a built-in node in a panel
is used.
Pull Request: https://projects.blender.org/blender/blender/pulls/135993
Adds the option to create a boolean socket that can be used as a panel toggle.
This allows creating simpler and more compact node group UIs when a panel
can be "disabled".
The toggle input is a normal input socket that is just drawn a bit differently in
the UI. Whether a boolean is a toggle input or not does not affect evaluation.
Also see #133936 for guides on how to add and remove panel toggles.
Pull Request: https://projects.blender.org/blender/blender/pulls/133936
There is no need for amortized growth for the field interface.
Array seems slightly better than Vector because it's smaller and
doesn't give the impression that the size might change.
Pull Request: https://projects.blender.org/blender/blender/pulls/135257
Otherwise it defaults to int. This change can make a few structs
slightly smaller. Also use a signed integer type for the compositor
enum; that's the convention for non-flag enums.
The File Output node sometime ignores the transformations of their
inputs. That's due to the fact that transforms are now delayed and the
File Output node does not realize its inputs on its domain in case it
was not multi-layer.
To fix this, add another realization mode for transforms only. And use
that in the File Output node, as well as the Bokeh Blur, UV Map, and
Plane Track Deform, which also need this fix.
Pull Request: https://projects.blender.org/blender/blender/pulls/133850
The GCC version on the buildbot does not support attribute on
a class member, resulting in the following warning:
NOD_node_declaration.hh:577:42: warning: ‘maybe_unused’ attribute ignored [-Wattributes]
Use the `UNUSED_VARS` macro instead to solve the original warning
about member being unused in release builds without introducing
a warning when using older compiler.
Pull Request: https://projects.blender.org/blender/blender/pulls/131974
This probably never in practice in these cases.
Constructing a `std::string` from nullptr is invalid.
Starting with C++23, the `nullptr_t` is even explicitly deleted.
The NodeDeclarationBuilder::typeinfo_ is unused in release builds, but is
used in debug builds for assert.
Mark it as `[[maybe_unused]]` to silence strict compilation warning.
Pull Request: https://projects.blender.org/blender/blender/pulls/129912
The main goal is to simplify adding support for nested node panels. The patch
makes use of the updated recursive node declarations introduced in
6ffc585fb8.
The main changes are:
* Rewritten node drawing in a way that makes ui design decisions like panel
visibility and margins more explicit. Especially the handling of margins is
much better now imo. Previously, it was very hard to change the margin for
specific cases without accidentally breaking other situations. Now each
possible case has an explicit margin. This needs a few more lines of code but
is much easier to work with.
* Rewritten node drawing in panel (sidebar + material properties) using the new
ways to iterate over the declaration.
* It's possible to add custom layouts at any point in the node declaration now.
This also replaces the need for having a `draw_buttons` callback for panels.
Pull Request: https://projects.blender.org/blender/blender/pulls/128822
This refactor contains the following changes:
* Each `PanelDeclaration` contains its direct children. Previously, it only knew
how many children it had. That added complexity to wherever we iterate over
the node declaration.
* Adds a new `DeclarationListBuilder` that is a base class of
`NodeDeclarationBuilder` and `PanelDeclarationBuilder`. It makes sure that the
same API for adding sockets, panels and separators exist for both.
* Modified declare functions for group, group input and group output nodes to
use the normal node builder api instead of doing something custom.
No functional changes are expected.
The main reason for this refactor is to simplify working with nested panels in
node declarations which is useful when we want to support nested panels in the
node editor. The node drawing code is not simplified in this patch, but that
should be easier afterwards.
Pull Request: https://projects.blender.org/blender/blender/pulls/128799
This adds support for line separators in nodes. Currently this is only available for
built-in nodes and it's only used in the Simulation Zone. However, we also want
to use it in the For Each Geometry Element zone (#127331). Support for node groups
can be added separately too.

Pull Request: https://projects.blender.org/blender/blender/pulls/127501
This adds support for renaming some sockets in the node UI directly by Ctrl+Clicking
on them. This is sometimes more convenient than going to the sidebar. It affects the
Menu Switch and Bake node as well as the Simulation and Repeat zone.
Some related notes:
* The Group Input and Group Output node are not yet supported, because it currently
breaks the right-alignment on the Group Input node. I couldn't find a workaround for
this yet.
* Double-clicking on the socket name does not trigger renaming yet. This seems to
be a deeper issue in the interface code.
* The highlighting when hovering over sockets that can be renamed is very dim
making it hard to see. Alternatives like drawing a box around the label when hovering
it (like in list views) have been discussed but seem to be much more difficult to get to work.
Despite these limitations, it seems reasonable to add this already, as it shouldn't affect
anyone negatively. The nodes still look like before.
Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/121945
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.
Pull Request: https://projects.blender.org/blender/blender/pulls/121637
Previously, we haven't added this because there were plans to use these
declarations at a higher abstraction level where one declaration potentially
contains more than one socket. This hasn't happened yet, and we are also using
other ways to achieve dynamic socket amounts (using dynamic declarations).
Therefore, it is reasonable to simplify the code by storing the integer socket
type in the declaration directly.
Pull Request: https://projects.blender.org/blender/blender/pulls/119691
Support for having an input and output socket in the same socket declaration
builder was added for the original node panels to be able to support inline
sockets. However, those were generally disabled for now. As can be seen in the
simulation and repeat zone, inline sockets can work differently too. Having an
input and output in the same socket declaration builder builder makes some
things simpler but makes other things much harder. For example, the current
design wouldn't work all that well if the input and output socket has different
types. This is easier to do with the `align_with_previous_socket` approach.
I'm not yet entirely sure whether we want to use the same approach for
corresponding sockets in the node tree interface, but that can be tried and
decided separately.
Pull Request: https://projects.blender.org/blender/blender/pulls/119599
This changes the drawing of the zone nodes to align corresponding input
and output sockets. The resulting nodes are smaller and it's easier to see
how data is passed through them.
Drawing aligned sockets is already technically supported for quite a while
already, but we haven't used it so far. Using them for zone nodes seems to
provide benefits only. How we use aligned sockets in other nodes still has
to be discussed more.
This patch only changes run-time data. It doesn't affect what is written to
.blend files.
In the node declaration, aligned sockets are created by tagging a socket
so that it is aligned with the previous socket. This is a bit different from
what we had before where a single socket declaration would be used for
an input and output socket. I think the approach used here works better,
especially in a potential future scenario where the input and output socket
has a different type.
Pull Request: https://projects.blender.org/blender/blender/pulls/118335
This changes a bunch of nodes that have a data type drop-down to using a dynamic
node declaration that changes based on the selected data type instead of always having
all sockets. This greatly simplifies the code and is less weird than having suffixes on
socket identifiers.
Backward compatibility and forward compatibility remain due to #113497 and #113984.
One user-visible change is that changing the data type in these nodes does not break
the link anymore.
It may be necessary to bring back some functionality from link-drag-search afterwards.
Pull Request: https://projects.blender.org/blender/blender/pulls/113553
This helps solving the problem encountered in #113553. The problem is that we
currently can't support link-drag-search for nodes which have a dynamic declaration.
With this patch, there is only a single `declare` function per node type, instead of
the separate `declare` and `declare_dynamic` functions. The new `declare` function
has access to the node and tree. However, both are allowed to be null. The final
node declaration has a flag for whether it depends on the node context or not.
Nodes that previously had a dynamic declaration should now create as much of
the declaration as possible that does not depend on the node. This allows code
like for link-drag-search to take those sockets into account even if the other
sockets are dynamic.
For node declarations that have dynamic types (e.g. Switch node), we can also
add extra information to the static node declaration, like the identifier of the socket
with the dynamic type. This is not part of this patch though.
I can think of two main alternatives to the approach implemented here:
* Define two separate functions for dynamic nodes. One that creates the "static
declaration" without node context, and on that creates the actual declaration with
node context.
* Have a single declare function that generates "build instructions" for the actual
node declaration. So instead of building the final declaration directly, one can for
example add a socket whose type depends on a specific rna path in the node.
The actual node declaration is then automatically generated based on the build
instructions. This becomes quite a bit more tricky with dynamic amounts of sockets
and introduces another indirection between declarations and what sockets the node
actually has.
I found the approach implemented in this patch to lead to the least amount of
boilerplate (doesn't require a seperate "build instructions" data structure) and code
duplication (socket properties are still only defined in one place). At the same time,
it offers more flexibility to how nodes can be dynamic.
Pull Request: https://projects.blender.org/blender/blender/pulls/113742