Commit Graph

66 Commits

Author SHA1 Message Date
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
Jacques Lucke
8ec9c62d3e Geometry Nodes: add Closures and Bundles behind experimental feature flag
This implements bundles and closures which are described in more detail in this
blog post: https://code.blender.org/2024/11/geometry-nodes-workshop-october-2024/

tl;dr:
* Bundles are containers that allow storing multiple socket values in a single
  value. Each value in the bundle is identified by a name. Bundles can be
  nested.
* Closures are functions that are created with the Closure Zone and can be
  evaluated with the Evaluate Closure node.

To use the patch, the `Bundle and Closure Nodes` experimental feature has to be
enabled. This is necessary, because these features are not fully done yet and
still need iterations to improve the workflow before they can be officially
released. These iterations are easier to do in `main` than in a separate branch
though. That's because this patch is quite large and somewhat prone to merge
conflicts. Also other work we want to do, depends on this.

This adds the following new nodes:
* Combine Bundle: can pack multiple values into one.
* Separate Bundle: extracts values from a bundle.
* Closure Zone: outputs a closure zone for use in the `Evaluate Closure` node.
* Evaluate Closure: evaluates the passed in closure.

Things that will be added soon after this lands:
* Fields in bundles and closures. The way this is done changes with #134811, so
  I rather implement this once both are in `main`.
* UI features for keeping sockets in sync (right now there are warnings only).

One bigger issue is the limited support for lazyness. For example, all inputs of
a Combine Bundle node will be evaluated, even if they are not all needed. The
same is true for all captured values of a closure. This is a deeper limitation
that needs to be resolved at some point. This will likely be done after an
initial version of this patch is done.

Pull Request: https://projects.blender.org/blender/blender/pulls/128340
2025-04-03 15:44:06 +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
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
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
Bastien Montagne
9c237af041 Refactor: RNA: add discrete suffix to RNA_pointer_create.
This is a noisy preliminary step to the 'RNA ancestors' change. The
rename helps clearly tell what each `pointer_create` function does.

Pull Request: https://projects.blender.org/blender/blender/pulls/133475
2025-01-24 16:45:32 +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
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
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
Campbell Barton
806d1fd1fa Cleanup: quiet set but unused warning 2024-10-10 18:36:08 +11: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
Jacques Lucke
67c7485bfd Refactor: Geometry Nodes: improve lifetime analysis for anonymous attributes
This refactors the lifetime analysis of anonymous attributes in geometry nodes.
The refactor has a couple of goals:
* Use a better and simpler abstraction that can be used when building the
  lazy-function graph. We currently have a bunch of duplicate code to handle
  "field source" and "caller propagation" attributes. This is now unified so
  that one only has to worry about one kind of "reference sets".
* Make the abstraction compatible with handling bundles and closures in case we
  want to support them in the future. Both types can contain geometries and
  fields so they need to be taken into account when determining lifetimes.
* Make more parts independent of the concept of "anonymous attributes". In
  theory, there could be more kinds of referenced data whose lifetimes need to
  be managed. I don't have any concrete plans for adding any though.

At its core, deterministic anonymous attributes still work the same they have
been since they became deterministic [0]. Even the generated lazy-function graph
is still pretty much or even exactly the same as before.

The patch renames `AnonymousAttributeSet` to the more general
`GeometryNodesReferenceSet` which is more. This also makes more places
independent of the concept of anonymous attributes. Functionally, this still the
same though. It's only used in the internals of geometry nodes nowadays. Most
code just gets an `AttributeFilter` that is based on it.

[0]: https://archive.blender.org/developer/D16858

Pull Request: https://projects.blender.org/blender/blender/pulls/128667
2024-10-07 12:59:39 +02:00
Jacques Lucke
f839266b78 Geometry Nodes: support dynamic sockets and separators in panels 2024-09-30 16:07:36 +02:00
Jacques Lucke
fc2b9e3a6b Cleanup: deduplicate switch over socket types to create declarations 2024-09-30 15:39:11 +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
2d93671778 Fix: unnecessary node updates
It looks like the check introduced in e071288ab2 is the
wrong way around.

Pull Request: https://projects.blender.org/blender/blender/pulls/127426
2024-09-11 13:59:16 +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
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
Hans Goudey
1cfe9dd08c Geometry Nodes: Matrix socket type, attribute type, and initial nodes
Implements the design from #116067.
The socket type is called "Matrix" but it is often referred to as "Transform"
when that's what it is semantically. The attribute type is "4x4 Matrix" since
that's a lower level choice. Currently matrix sockets are always passed
around internally as `float4x4`, but that can be optimized in the future
when smaller types would give the same behavior.

A new "Matrix" utilities category has the following set of initial nodes"
- **Combine Transform**
- **Separate Transform**
- **Multiply Matrices**
- **Transform Direction**
- **Transform Vector**
- **Invert Matrix**
- **Transpose Matrix**

The nodes and socket type are behind an experimental flag for now,
which will give us time to make sure it's the right set of initial nodes.
The viewer node overlay doesn't support matrices-- they aren't supported
for rendering in general. They also aren't supported in the modifier interface
currently. But they are supported in the spreadsheet, where the value is
displayed in a tooltip.

Pull Request: https://projects.blender.org/blender/blender/pulls/116166
2024-02-13 18:59:36 +01:00
Lukas Tönne
5ad49f4142 Geometry Nodes: Menu Switch Node
This patch adds support for _Menu Switch_ nodes and enum definitions in
node trees more generally. The design is based on the outcome of the
[2022 Nodes Workshop](https://code.blender.org/2022/11/geometry-nodes-workshop-2022/#menu-switch).

The _Menu Switch_ node is an advanced version of the _Switch_ node which
has a customizable **menu input socket** instead of a simple boolean.
The _items_ of this menu are owned by the node itself. Each item has a
name and description and unique identifier that is used internally. A
menu _socket_ represents a concrete value out of the list of items.

To enable selection of an enum value for unconnected sockets the menu is
presented as a dropdown list like built-in enums. When the socket is
connected a shared pointer to the enum definition is propagated along
links and stored in socket default values. This allows node groups to
expose a menu from an internal menu switch as a parameter. The enum
definition is a runtime copy of the enum items in DNA that allows
sharing.

A menu socket can have multiple connections, which can lead to
ambiguity. If two or more different menu source nodes are connected to a
socket it gets marked as _undefined_. Any connection to an undefined
menu socket is invalid as a hint to users that there is a problem. A
warning/error is also shown on nodes with undefined menu sockets.

At runtime the value of a menu socket is the simple integer identifier.
This can also be a field in geometry nodes. The identifier is unique
within each enum definition, and it is persistent even when items are
added, removed, or changed. Changing the name of an item does not affect
the internal identifier, so users can rename enum items without breaking
existing input values. This also persists if, for example, a linked node
group is temporarily unavailable.

Pull Request: https://projects.blender.org/blender/blender/pulls/113445
2024-01-26 12:40:01 +01:00
Jacques Lucke
e1d0d70911 Geometry Nodes: refactor storage for socket values
This refactors `SocketValueVariant` with the following goals in mind:
* Support type erasure so that not all users of `SocketValueVariant` have
  to know about all the types sockets can have.
* Move towards supporting "rainbow sockets" which are sockets whoose
  type is only known at run-time.
* Reduce complexity when dealing with socket values in general. Previously,
  one had to use `SocketValueVariantCPPType` a lot to manage uninitialized
  memory. This is better abstracted away now.

One related change that I had to do that I didn't see coming at first was that
I had to refactor `set_default_remaining_outputs` because now the default value
of a `SocketValueVariant` would not contain any value. Previously, it was
initialized the zero-value of the template parameter. Similarly, I had to change
how implicit conversions are created, because comparing the `CPPType` of linked
sockets was not enough anymore to determine if a conversion is necessary.

We could potentially use `SocketValueVariant` for the remaining socket types in the
future as well. Not entirely sure if that helps yet. `SocketValueVariant` can easily be
adapted to make that work though. That would also justify the name
"SocketValueVariant" better.

Pull Request: https://projects.blender.org/blender/blender/pulls/116231
2023-12-17 14:00:07 +01:00
Jacques Lucke
3370228ae8 Geometry Nodes: rename ValueOrField to SocketValueVariant
Doing this in preparation for also supporting volume
grids in the same type (#115270).

At some point we could also actually use an `std::variant` in this
type, but that would change behavior without futher changes.
2023-12-13 13:40:40 +01: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
Lukas Tönne
c845233d1c Nodes: Move ValueOrField struct into blenkernel
This struct is currently defined in the `functions` module but not actually used there. It's only used by the geometry nodes module, with an indirect dependency from blenkernel via simulation zone baking. This scope is problematic when adding grids as socket data, which should not be part of the functions module.

The `ValueOrField` struct is now moved to blenkernel, so it can be more easily extended to other kinds of data that might be passed around by geometry nodes sockets in future. No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115087
2023-11-18 13:11:39 +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
Hans Goudey
20d8f27ed2 Geometry Nodes: Add default input option for node groups
In order to recreate the behavior of some builtin nodes
which have implicit inputs for ID/Index or positions, provide
a hard-coded list of default/unconnected fields for sockets.

The point is to let assets recreate the behavior of builtin
nodes in a simple way that's easy to change in the future if
this becomes a more generalized feature. A hardcoded list
makes this predictable and simple in the meantime.

When the option is set to something besides "Default Value"
it overrides the "Hide Value" option. Otherwise the default
input would conflict with the visible default value button.

This makes it possible to add #109846 as an asset in the
essentials bundle. The design is meant to be easily
extendable for shader nodes, though that isn't included
in this commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/113175
2023-10-12 14:04:44 +02:00
Jacques Lucke
1ecc315d34 Nodes: pass node declaration builder to dynamic declaration function
Generally, one should use the declaration builder instead of trying to
do it manually which is more error prone and verbose.
2023-10-08 14:38:28 +02:00
Jacques Lucke
b6a3ac5a12 Geometry Nodes: use declaration builder for repeat zone 2023-10-08 13:58:22 +02:00
Jacques Lucke
f3a1dd1eb5 Nodes: move socket declaration methods to base declaration builder
The goal here is to make it easier to use the socket declaration builder
for cases where the actual socket type is not known at compile time.
For that purpose, all the methods that are not dependent on the specific
socket type are moved to the base socket declaration builder.

A nice side effect of this is reduced templated boilerplate and that more
code can be moved out of the header.

With this patch, one is now forced to put type specific method calls before
generic method calls in a chain. For example `.default_value(...).supports_field()`
instead of `supports_field().default_value(...)`. In theory, we could keep
support for both orders but that would involve a lot of additional boilerplate
code. Enforcing this order is simple enough. Note that this limitation only
applies when chaining multiple method calls. This is still possible:
```
auto &decl = b.add_input<decl::Vector>("Value");
decl.supports_field();
decl.default_value(...);
```

Pull Request: https://projects.blender.org/blender/blender/pulls/113410
2023-10-08 13:30:31 +02:00
Jacques Lucke
d6f4a9a09b Merge branch 'blender-v4.0-release' 2023-10-06 18:38:07 +02:00
Jacques Lucke
b04f006a4c Fix: dynamic node declaration is not resetting update-skip flag 2023-10-06 18:37:46 +02:00
Jacques Lucke
beac6599fb Nodes: deduplicate code to create declarations for socket type 2023-10-04 13:01:45 +02:00
Lukas Tönne
354915cf3c Nodes: revert the inline (pass-through) socket feature
Inlined sockets in the same vertical space are no longer supported.
This removes `input_output` socket declarations, the inlining feature in
node drawing, and the `Both` option for node group interface sockets.

Versioning code splits existing node group sockets into individual
sockets again. Unfortunately some links may get lost in versioning files
using the feature, because of an unnoticed bug: Socket identifiers have
to be unique in the node group items list but inlined input/output
sockets have the same identifier. This still works for most situations
because uniqueness is only required within input/output lists. Creating
proper unique identifiers will discard any link from the previous output
socket. This cannot easily be fixed without `after_linking` versioning
code, which should be avoided.

Pull Request: https://projects.blender.org/blender/blender/pulls/112560
2023-09-22 16:56:59 +02:00
Lukas Tönne
9433a1701a Nodes: Support for input/output sockets in same vertical space
Declarations can use the `add_input_output` method to create a combined input/output socket. The drawing code supports moving sockets up one vertical slot to align them with the predecessor.

Closes #112235

Pull Request: https://projects.blender.org/blender/blender/pulls/112250
2023-09-14 16:08:04 +02:00
Lukas Tönne
ee14c4aa34 Nodes: Add PanelDeclarationBuilder for panels in builtin nodes
Node groups already have panels, but they modify the node declaration
directly, which is not something we want to do for builtin nodes. For
those the `PanelDeclarationBuilder` should be used.

`PanelDeclarationBuilder` has `add_input`/`add_output` methods just like `NodeDeclarationBuilder`. Adding sockets to a panel increases its size by one. All sockets must be added in order: Adding sockets or panels to the root `NodeDeclarationBuilder` after a panel will complete the panel and adding more sockets to it after that will fail. This is to enforce a stable item order where indices don't change after adding a socket, which is important for things like field dependencies.

Example:
```cpp
static void node_declare(NodeDeclarationBuilder &b)
{
  // Currently this is necessary to enable custom layouts and panels.
  // Will go away eventually when most nodes uses custom layout.
  b.use_custom_socket_order();

  // Create a panel.
  PanelDeclarationBuilder &pb = b.add_panel("My Panel").description("A demo panel").default_closed(true);
  // Add to the panel instead of the root layout.
  pb.add_input<decl::Color>("Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
  pb.add_input<decl::Float>("Weight").unavailable();

  // Continue socket declarations as usual.
  b.add_output<decl::Shader>("BSDF");

  // !!! Warning: continuing the panel after other items is not allowed and will show an error.
  pb.add_output<decl::Float>("Bad Socket");
}
```

Pull Request: https://projects.blender.org/blender/blender/pulls/111695
2023-09-11 13:39:28 +02:00
Lukas Tönne
e071288ab2 Nodes: Panels integration with blend files and UI
Part 3/3 of #109135, #110272

Switch to new node group interfaces and deprecate old DNA and API.
This completes support for panels in node drawing and in node group
interface declarations in particular.

The new node group interface DNA and RNA code has been added in parts
1 and 2 (#110885, #110952) but has not be enabled yet. This commit
completes the integration by
* enabling the new RNA API
* using the new API in UI
* read/write new interfaces from blend files
* add versioning for backward compatibility
* add forward-compatible writing code to reconstruct old interfaces

All places accessing node group interface declarations should now be
using the new API. A runtime cache has been added that allows simple
linear access to socket inputs and outputs even when a panel hierarchy
is used.

Old DNA has been deprecated and should only be accessed for versioning
(inputs/outputs renamed to inputs_legacy/outputs_legacy to catch
errors). Versioning code ensures both backward and forward
compatibility of existing files.

The API for old interfaces is removed. The new API is very similar but
is defined on the `ntree.interface` instead of the `ntree` directly.
Breaking change notifications and detailed instructions for migrating
will be added.

A python test has been added for the node group API functions. This
includes new functionality such as creating panels and moving items
between different levels.

This patch does not yet contain panel representations in the modifier
UI. This has been tested in a separate branch and will be added with a
later PR (#108565).

Pull Request: https://projects.blender.org/blender/blender/pulls/111348
2023-08-30 12:37:21 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00