100 Commits

Author SHA1 Message Date
Lukas Tönne
443ced685e Merge branch 'blender-v5.0-release' 2025-10-16 12:15:44 +02:00
Lukas Tönne
2588ea685a Fix #147860: Default input setting for node declarations is unintialized
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
2025-10-16 12:14:29 +02:00
Omar Emara
3aa674966f Nodes: Support disabling outputs in built-in nodes
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
2025-10-15 15:57:56 +02:00
Hans Goudey
4339a60f78 Geometry Nodes: Add volume grid name search
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
2025-10-02 13:46:12 +02:00
Jacques Lucke
469a70dba9 Cleanup: Nodes: rename hide_label to optional_label internally
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.
2025-09-28 17:30:21 +02:00
Jacques Lucke
1fd6d9263c Nodes: menu switch labels in index switch nodes
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
2025-09-27 21:49:47 +02:00
Omar Emara
149a47ba57 Compositor: Turn Menu options to inputs
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
2025-08-28 08:45:23 +02:00
Jacques Lucke
f7f18cd0c7 Nodes: initial support for built-in menu sockets
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
2025-07-16 08:31:59 +02:00
Omar Emara
3b1d252431 Compositor: Support structure type
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
2025-06-25 11:54:48 +02:00
Campbell Barton
479d1f1d16 Cleanup: use doxygen doc-strings, spelling (make check_spelling_*) 2025-05-29 11:00:53 +10:00
Hans Goudey
b80f1f5322 Geometry Nodes: Socket structure type and display changes
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
2025-05-28 02:33:47 +02:00
Jacques Lucke
87c011f8bb Nodes: minify value input nodes
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
2025-05-26 15:47:54 +02:00
Damien Picard
9ce0a2d1d5 I18n: Add translation contexts to node panels
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
2025-05-21 13:54:11 +02:00
Jacques Lucke
c55ffb5258 Nodes: improve implicit inputs
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
2025-05-20 17:54:49 +02:00
Falk David
69a722cee5 Geometry Nodes: Add Grease Pencil layer name search
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
2025-04-18 12:35:49 +02:00
Omar Emara
c0fe2ef766 Compositor: Use input order for unset domain priority
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.
2025-03-26 16:14:05 +02:00
Jacques Lucke
6624cc5634 Nodes: take panel toggles in builtin nodes into account in socket usage inferencing
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
2025-03-24 19:08:03 +01:00
Jacques Lucke
e297e6dab3 Fix #135815: missing instance attribute propagation 2025-03-14 12:41:17 +01:00
Falk David
2822777f13 Nodes: support boolean inputs as toggles in panel headers
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
2025-02-28 19:07:02 +01:00
Hans Goudey
582cdc0cf2 Cleanup: Use Array for FieldInferencingInterface
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
2025-02-27 17:32:51 +01:00
Hans Goudey
0c04952a76 Cleanup: Specify backing type for node enums
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.
2025-02-27 10:14:29 -05:00
Brecht Van Lommel
315d07bd12 Cleanup: Various clang-tidy warnings in nodes
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Omar Emara
028506712d Fix #133807: File Output node ignores transforms
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
2025-01-31 10:14:54 +01:00
Aras Pranckevicius
496a3749d7 Cleanup: rename namespace realtime_compositor->compositor
Pull Request: https://projects.blender.org/blender/blender/pulls/132008
2024-12-17 11:39:04 +01:00
Sergey Sharybin
630c3ce94e Cleanup: Compiler warning on the buildbot
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
2024-12-16 16:18:20 +01:00
Campbell Barton
b9f055459a Cleanup: ensure trailing space around comment blocks 2024-11-27 19:01:00 +11:00
Jacques Lucke
b4fc5754fd Cleanup: avoid constructing std::string from nullptr
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.
2024-11-16 23:48:49 +01:00
Sergey Sharybin
cad2830006 Cleanup: Fix strict compiler warning about unused typeinfo_
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
2024-11-06 17:05:36 +01:00
Jacques Lucke
a239bfc4dd Refactor: Nodes: improve drawing of nodes based on node declaration
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
2024-10-11 12:20:58 +02:00
Jacques Lucke
6ffc585fb8 Refactor: Geometry Nodes: recursive node declarations
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
2024-10-09 15:45:43 +02:00
Campbell Barton
c6fd26a3f5 Cleanup: spelling in comments 2024-10-01 09:59:33 +10:00
Jacques Lucke
f839266b78 Geometry Nodes: support dynamic sockets and separators in panels 2024-09-30 16:07:36 +02:00
Jacques Lucke
4a45ae7393 Nodes: rename "unavailable" to "available" in node declaration
This simplifies future use of this method by avoiding double negations.
2024-09-18 16:08:05 +02:00
Jacques Lucke
246c513f92 Nodes: add support for line separators in nodes
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.

![image](/attachments/74f44b2a-9996-461a-a3eb-d0f546d2305e)

Pull Request: https://projects.blender.org/blender/blender/pulls/127501
2024-09-12 17:38:51 +02:00
Jacques Lucke
cd5eb4aa03 Geometry Nodes: support renaming some sockets in the node directly
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
2024-05-30 10:41:05 +02:00
Iliya Katueshenock
75d17b1db5 Cleanup: Move BKE_node to namespace
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
2024-05-13 16:07:12 +02:00
Iliya Katueshenock
8249c09f3a Geometry Nodes: add implicit input for Instance Transform
`instance_transform` is the basic transformation attribute of instances.
This will be used in separate patches.

Pull Request: https://projects.blender.org/blender/blender/pulls/120340
2024-05-06 17:22:24 +02:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
Jacques Lucke
25a10c211f Nodes: support accessing socket type directly from declaration
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
2024-03-20 12:37:37 +01:00
Jacques Lucke
82f434f444 Nodes: cleanup node declaration finalization
* Extract function for building anonymous attribute references.
* Use is-function-node state directly during building instead of during finalization.

Pull Request: https://projects.blender.org/blender/blender/pulls/119677
2024-03-19 19:54:27 +01:00
Jacques Lucke
42093bbe3d Nodes: have either input or output socket in declaration
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
2024-03-18 14:36:03 +01:00
Jacques Lucke
1f30f41af8 Geometry Nodes: align input and output sockets in simulation and repeat zone nodes
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
2024-02-19 13:32:01 +01:00
Bastien Montagne
45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Hans Goudey
d6cfd7d1f4 Cleanup: Remove unnecessary keywords from C++ headers
- Remove unnecessary `struct`
- Use `using` instead of `typedef`
- Remove `void` from `(void)` as function arguments
2024-01-04 15:07:48 -05:00
Hans Goudey
6a1009c9f8 Cleanup: Remove const for Span and by-value types in headers 2023-12-13 09:39:03 -05:00
Jacques Lucke
a976cf4876 Cleanup: reduce boilerplate for equality operators for structs
Pull Request: https://projects.blender.org/blender/blender/pulls/115088
2023-11-20 09:39:13 +01:00
Iliya Katueshenock
8149678d5e Geometry Nodes: use dynamic declaration for some nodes
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
2023-11-17 16:23:34 +01:00
Jacques Lucke
38813a7441 Nodes: unify static and dynamic declarations
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
2023-10-15 20:28:23 +02:00
Jacques Lucke
14fa963910 Cleanup: move node declaration code out of header 2023-10-15 12:43:02 +02:00
Bastien Montagne
86fb43d57a Merge commit '2d703e9200985122b4b953be67b452f7679bf113'
Conflicts:
	source/blender/nodes/NOD_node_declaration.hh
2023-10-12 18:56:12 +02:00