Commit Graph

281 Commits

Author SHA1 Message Date
Damien Picard
f79165eb7c I18n: Manually extract many node socket menu items
Node menu sockets' items are not currently exposed to RNA, and need to
be extracted manually for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/147579
2025-10-10 11:24:17 +02:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Jacques Lucke
f79896f5b9 Refactor: Nodes: unify optional-label handling for sockets
Previously, the input socket drawing code did not cover all cases with required
and optional labels for all socket types. E.g. menu sockets were never drawn
with label (unless there was some error) regardless of whether `optional_label`
was set or not.

This patch unifies the handling of this flag, i.e. all socket types support
drawing with and without label. This is also required before we can expose this
functionality to users.

Since all menu inputs had optional labels by default before, this patch makes
labels optional explicitly by changing the declaration of all the nodes. This
way, there is no expected user-visible change with this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/146935
2025-09-28 19:38:14 +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
Campbell Barton
4a6268e092 Cleanup: various non functional changes for C++ 2025-09-20 16:28:02 +10:00
Campbell Barton
d1b76b6554 Cleanup: only use "r_" prefix for return arguments
Ref !146253
2025-09-14 11:08:50 +00:00
quackarooni
dacae33cbe Nodes: Add missing tooltip descriptions for various nodes
Add a description for function nodes and a few geometry nodes
and a few shader nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/145772
2025-09-11 20:03:35 +02:00
Brecht Van Lommel
ffa4f8c7ad Refactor: Split off lighter BLI_color_types.hh from BLI_color.hh
Functions for convert between the color types and ostream support are
now outside the classes.

Many files were changed to fix cases where direct includes for headers
were missing.

Pull Request: https://projects.blender.org/blender/blender/pulls/145756
2025-09-05 11:11:32 +02:00
David-Sebald
ad83a1017f Geometry Nodes: new String to Value node
An existing node converts a value (float) to string. This node is intended as a conversion in
the other direction. If parsing is unsuccessful, floating point 0 is output. This node also
outputs the length of the parsed string (i.e. the index of the first character where the
number stopped).

Pull Request: https://projects.blender.org/blender/blender/pulls/112174
2025-09-05 08:51:38 +02:00
Jacques Lucke
73b3107168 Fix: Nodes: incorrect structure types in Random Value node
This node is really just a function node. The main thing that's somewhat special about
it is the implicit input for the id, but that's supported for function nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/145549
2025-09-02 09:22:21 +02:00
Philipp Oeser
d7fa455e66 Fix #144760: Some (Input) Nodes not changeable in Properties Editor
A node would not show the "Collapse/Expand" arrows (caused by
87c011f8bb which moved the drawing code for the input nodes a new
`custom_draw_fn` callback on the socket declaration).

Related fix: 7f07124d30

So in order to resolve, make sure we have correct conditions to show the
expander and also make sure we draw the custo buttons in appropriate
places.

NOTE: not sure if there are better ways to achieve the correct UI split
alignment, since we draw with empty labels, I had to flag with
`UI_ITEM_R_SPLIT_EMPTY_NAME` in the new `custom_draw_fn` callbacks.

Pull Request: https://projects.blender.org/blender/blender/pulls/144993
2025-08-26 13:18:41 +02:00
W_Cloud
8d6c717e34 UI: Nodes: Add icons to data type menus
Add icons to more data type menus, similar to how it is done for
Switch, Index Switch, Compare, etc.

See PR for details and screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/143779
2025-08-20 16:14:32 +02:00
Hans Goudey
429dc0920c Fix #144362: Match string node crash after recent change
Caused by 76a861ab41
That commit used the wrong order internally for the "Operation" input.
2025-08-11 11:37:13 -04:00
Campbell Barton
558d1c4774 Cleanup: use the suffix "_maxncpy" instead of "_len" for string sizes
The term "_len" is too easily confused with the strlen(),
excluding the nil byte.
2025-08-07 06:18:21 +10:00
Damien Picard
5998795aa6 UI: Replace contractions with long-form text
Avoid using contractions for can't, aren't, doesn't, and shouldn't.
Following the writing style guide in the Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/143852
2025-08-05 11:16:22 +02:00
Jacques Lucke
9cb50ea83b Refactor: Nodes: pass tree type to supports_socket_type function for socket items
This allows us to support a different set of sockets per tree type in e.g. the
repeat zone as in #141936.
2025-08-02 11:13:38 +02:00
Jacques Lucke
97b5618911 Refactor: Nodes: pass params as struct to bNodeType::insert_link
This simplifies potentially adding a `bContext` argument which allows for more advanced behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/143732
2025-07-31 19:22:11 +02:00
Jacques Lucke
76a861ab41 Geometry Nodes: move more menu inputs to sockets
This is a continuation of #140705. It changes more menu node options to be input
sockets. It also changes the order of the input sockets in a few cases to make
the node look a bit better.

Forward and backward compatibility is preserved.

Pull Request: https://projects.blender.org/blender/blender/pulls/142220
2025-07-30 15:32:10 +02:00
Guillermo Venegas
230813f2ab Cleanup: UI: Remove redundant namespace prefixes
A follow-up from recent UI refactors.

Pull Request: https://projects.blender.org/blender/blender/pulls/141920
2025-07-21 15:08:12 +02:00
Bastien Montagne
899df7e3f0 Fix compilation after recent changes: missing include. 2025-07-16 18:53:10 +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
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Bastien Montagne
a345b83f1a Merge branch 'blender-v4.5-release' 2025-07-07 15:53:53 +02:00
Damien Picard
d16c9003d2 I18n: Translate link items for Integer Math node
Link items need to be gathered using the same translation context as
the actual enum prop they come from, in this case "Nodetree".

Reported by Ye Gui in #43295.
2025-07-07 12:02:25 +02:00
Damien Picard
ac8a3f98c2 I18n: Translate "Boolean" output in Boolean GN node
This node uses the recently-introduced uiLayout API to draw its UI.
This still needs to do manual translation using `IFACE_()`. This
commit adds this macro.

Reported by Ye Gui in #43295.
2025-07-07 12:02:25 +02:00
илья _
9c30e3577e Fix: Nodes: Correct label translation
Use `N_` for default labels in case value is invalid.
So no double translation.

Synchronize translation context with related property if exist.
So enum item translated like property with such enum.

Use nodes context for zone labels.

Pull Request: https://projects.blender.org/blender/blender/pulls/138393
2025-07-03 05:27:03 +02:00
Hans Goudey
09d34755f1 Merge branch 'blender-v4.5-release' 2025-06-30 09:01:53 -04:00
Hans Goudey
a06705f41a Fix #141160: String input node in link-drag-search for output sockets
Missing check in 6fb69eeb71
2025-06-30 08:48:41 -04:00
Guillermo Venegas
e300d44e69 Refactor: UI: Add uiLayout use_property_decorate methods
This replaces uiLayout use_property_decorate API with uiLayout
methods, following uiLayout refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140887
2025-06-24 03:52:17 +02:00
Guillermo Venegas
d600b1002a Refactor: UI: Add uiLayout use_property_split methods
This replaces uiLayout use_property_split API with uiLayout methods,
following uiLayout refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140874
2025-06-23 19:07:09 +02:00
Hans Goudey
86d60ae663 Cleanup: Build errors without unity builds after recent UI refactor
Caused by 091db9d52b
2025-06-20 13:03:49 -04:00
Guillermo Venegas
091db9d52b Cleanup: UI: Use UI_interface_layout.hh instead of UI_interface.hh
This removes the include `UI_interface_layout.hh` from
`UI_interface_c.hh`, and in many places this swaps the include
from `UI_interface.hh` to `UI_interface_layout.hh`.

Also, cleanups some `UI_interface.hh` includes with
`UI_interface_icons.hh` or `UI_interface_types.hh`
2025-06-20 18:07:47 +02:00
Guillermo Venegas
96dee123d1 Refactor: UI: Add uiLayout aligment methods
This replaces uiLayout aligment API with uiLayout methods,
following uiLayout refactors and the Python API naming.

Also this converts the layout aligment enum to a fixed enum class.

Pull Request: https://projects.blender.org/blender/blender/pulls/140622
2025-06-19 02:57:37 +02:00
Bastien Montagne
2d490d47a4 Merge branch 'blender-v4.5-release' 2025-06-16 12:43:46 +02:00
Bastien Montagne
6ccdb8c06e I18N: Add comment about required manual sync in nodes code.
Nodes code uses direct access to enum property values definition
(outside of the RNA API) to generate UI (translated) messages, this is
risky/messy since the i18n context potentailly defined for the actual
RNA property is not available in these cases.
2025-06-16 12:43:10 +02:00
Damien Picard
ec22a91233 I18n: Allow translation of Bitwise Math node label
The Bitwise Math node's label uses a formatted string, where the
operation name was not translated.
2025-06-16 12:39:02 +02:00
Jacques Lucke
a996490b83 Fix: use runtime format string
This is necessary to compile Blender with C++20.
2025-06-13 14:31:40 +02:00
Jacques Lucke
bbb64f0b9a Merge branch 'blender-v4.5-release' 2025-06-12 12:32:46 +02:00
Jacques Lucke
794cd8974b Fix #140240: overlapping buttons in color input node 2025-06-12 11:52:51 +02:00
Guillermo Venegas
2fbcf80413 Fix: Quiet unused variable warning
Error is expected to not happen, comment name since isn't used for debugging.

Pull Request: https://projects.blender.org/blender/blender/pulls/139945
2025-06-06 18:52:26 +02:00
Jacques Lucke
513c0494ba Fix #118207: avoid floating point calculations when computing random integer
This changes the way random integers are computed so that there is no
intermediate conversion to float which looses accuracy.

This change breaks compatibility because it changes the generated random
numbers. Therefore this is done in Blender 5.0.

Performance seems to be about ~6% better than before.

Pull Request: https://projects.blender.org/blender/blender/pulls/118795
2025-06-05 17:52:23 +02:00
Jacques Lucke
8fe7e62656 Refactor: Nodes: extract socket items accessor defaults
This simplifies adding more functionality to socket items accessors without
having to change all the existing accessors.

Pull Request: https://projects.blender.org/blender/blender/pulls/139714
2025-06-02 18:41:10 +02:00
Jacques Lucke
6fb69eeb71 Geometry Nodes: initialize String node width based on content
When a String node is created using link-drag-search, it's width is now based on
the width of the string it contains. This eliminates the common step to increase
the width manually after the node has been created.

Pull Request: https://projects.blender.org/blender/blender/pulls/139707
2025-06-02 14:56:18 +02:00
Campbell Barton
50f3240abd Cleanup: spelling & duplicate terms (check_spelling.py) 2025-05-30 11:03:56 +10:00
Jacques Lucke
182797ea61 Geometry Nodes: new Format String node
This adds a new Format String node which simplifies constructing strings from
multiple values. The node takes a format string and a dynamic number of
additional parameters as input. The format string determines how the other
inputs are inserted into the string. Only integer, float and string inputs are
supported for now.

It supports two different format syntaxes:
* Python compatible format syntax which also mostly matches the behavior of the
  `fmt` C++ library. Most of this is supported, but there are some small
  limitations.
* Syntax of the form `###.##` where each `#` stands for a digit. This is the
  syntax that was introduced in #134860.

This node greatly simplifies common string operations which would have required
potentially many nodes before to convert numbers to strings and to concatenate
them. It also makes new conversions possible that were not supported before.
This node can also be used to insert e.g. frame numbers into a file path which
was surprisingly complex before.

This node has special behavior for the name of new inputs. For the purpose of
the node, the name of the inputs must be valid identifiers and it's usually
helpful when they are short. New names are therefore initialized to be single
characters. If possible, the first character of the linked input is used. This
works well when connecting e.g. a Separate Vector/Color node. Otherwise, inputs
are named `a` to `z` by default. If that's not possible, the source socket name
is used instead (converted to be a valid identifier). If that still doesn't
work, the name is made unique using the normal `.001` mechanism except that `_`
instead of `.` is used as separator to make the name a valid identifier.

Python Syntax references:
* Python: https://docs.python.org/3/library/string.html#formatspec
* `fmt`: https://fmt.dev/latest/syntax/

More detailed notes about compatibility with the above syntax specifications:
* Conversion using e.g. `!r` like in Python is not supported (maybe the future).
* Sub-attribute access like `{vector.x}` is not supported (maybe the future).
* Using `%` like in Python is not supported (maybe in future).
* Using `#` for an alternate form is not supported. This might help in the
  future to make the syntax compatible with #134860.
* Using `L` like in the `fmt` library is not supported because it depends on the
  locale which is not good for determinism.
* Grouping with e.g. thousands separators using e.g. `,` or `_` like in Python
  is not supported (maybe in future). Need to think about the locale here too.
* Mixing of unnamed (`{}`) and named (`{x} or {0}`) specifiers is allowed.
  However, all unnamed specifiers must come before any named specifier.

The implementation uses the `fmt` library for the actual formatting. However,
the inputs are preprocessed to give us more control over the exact supported
syntax and error messages. The code is already somewhat written so that many
strings could be formatted with the same format but that's not actually used yet
because we don't have string fields yet.

Error messages are propagated using a new mechanism that allows a limited form
of error propagation from multi-functions to the node that evaluates them.
Currently, this only works in fairly limited circumstances, e.g. it does not
work during field evaluation. Since this node is never part of field evaluation
yet, that limitation seems ok, but it's something to work on at some point.
Properly supporting that requires some more changes to propagate enough context
information everywhere. Also showing errors of field evaluation on the field
node itself (instead of on the evaluation node) requires even more work because
our current logging system is not setup to support that yet.

This node comes with a few new requirements for the socket items system: names
must be valid identifiers and they are initialized in a non-trivial way.
Overall, this was fairly straight forward to implement but currently it requires
to adding a bunch of new members to all the accessors that don't really need it.
This is something that we should simplify at some point even if I'm not entirely
sure how yet. The same new requirements used in this node would probably also
exist in a potential future expression node.

Pull Request: https://projects.blender.org/blender/blender/pulls/138860
2025-05-29 13:17:03 +02:00
Hans Goudey
a7e3a81c84 Cleanup: Use functional style case for eCustomDataType 2025-05-28 22:05:03 -04:00
Hans Goudey
c725bf324d Cleanup: Use functional style cast for node socket type enum 2025-05-28 15:47:26 -04: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
Alberto Pilotto
e96e300099 Geometry Nodes: align sockets in Replace String and Slice string nodes
This is similar to f19f260ca8.

Pull Request: https://projects.blender.org/blender/blender/pulls/139219
2025-05-21 18:01:06 +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