Commit Graph

220 Commits

Author SHA1 Message Date
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
Brecht Van Lommel
e0479e2fb4 Geometry Nodes: Use OpenColorIO for luminance
Color to grayscale conversions should take into account the colorspace,
and these are considered to be in scene linear colorspace.

No change with the default configuration.

Pull Request: https://projects.blender.org/blender/blender/pulls/133368
2025-01-21 18:05:56 +01:00
Jacques Lucke
476b7ded9e Nodes: make explicit legacy type optional
This makes specifying a legacy type for new node types optional (e.g.
`GEO_NODE_MESH_TO_CURVE`). Instead, only the `idname` is used as a stable
identifier for node types. So there is less redundancy for now.

This change helps with the decentralized definition of nodes and reduces the
number minimum number of files that need to be changed for a new node from 5 to
4. It especially helps when multiple nodes are worked on at the same time,
because the legacy type definition was very prone to have merge conflicts.

For compatibility reasons and because it's still used by existing code, the
`legacy_type` is not removed. All existing nodes keep their current
`legacy_type`. New nodes will receive an auto-incremented legacy type. It's
still necessary to give nodes unique legacy types, because some code checks if
two nodes have the same type by comparing their `legacy_type`. These types only
have to be unique at run-time though. Some randomness is used to avoid depending
on stable generated legacy types accidentally.

Pull Request: https://projects.blender.org/blender/blender/pulls/133044
2025-01-14 14:39:36 +01:00
Jacques Lucke
b32a5882c1 Cleanup: Nodes: move node class parameter out of node_type_base
The node class is hardly important enough (especially compared to the other parameters)
that it is justified to have to pass it to `node_type_base`.

Pull Request: https://projects.blender.org/blender/blender/pulls/133021
2025-01-14 11:03:28 +01:00
Hans Goudey
f2c9fccee0 Cleanup: Move legacy node integer types defines to separate header
Moving these defines to a separate header makes their "legacy" status
more obvious. This commit just adds the include wherever necessary.

Followup to 971c96a92c.

Pull Request: https://projects.blender.org/blender/blender/pulls/132875
2025-01-09 20:03:08 +01:00
Jacques Lucke
0fa4c6da18 Refactor: Nodes: avoid using NOD_static_types.hh when creating node types
This removes the second to last usage of `NOD_static_types.hh` which we intend
to remove. A nice benefit is that the idname is now finally more explicit when a
node is registered. Previously it was difficult to search for the definition of
a node in the code when one had only the idname, which is the main identifier
for nodes.

The main change is in `node_type_base`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132815
2025-01-09 12:19:57 +01:00
Hans Goudey
2afd946ba6 Refactor: Nodes: Move UI name out of NOD_static_types.h header
As part of an effort to remove this header, reducing the need for macro/
include magic and making node definitions more independent, move
the node UI name and description definitions to each node's file.
The UI name, description, and idname are also moved to std::string
instead of char arrays.

Similar to b43e2168e3.

Pull Request: https://projects.blender.org/blender/blender/pulls/132708
2025-01-08 18:07:11 +01:00
Ray Molenkamp
5783950ac5 Revert: 0dc484f9cc bf_rna modernisation
This caused build errors on the docs builder, I can't seem to reproduce
locally, so revert for now and have another look at some point in the
future.

Sadly as these changes usually go, this took 5c515e26bb and
2f0fc7fc9f with it as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/132559
2025-01-02 19:56:24 +01:00
Campbell Barton
f417c7ad2c Cleanup: sort cmake file lists 2025-01-02 15:11:21 +11:00
Ray Molenkamp
0dc484f9cc Cleanup: CMake: Modernize bf_rna dependencies
Pretty straightforward

- Remove any bf_rna paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132413
2024-12-31 18:23:25 +01:00
Ray Molenkamp
4dcef4421c Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132335
2024-12-25 19:46:31 +01:00
Ray Molenkamp
c331c6b50e Cleanup: CMake: Modernize bf_blentranslation dependencies
Pretty straightforward

- Remove any bf_blentranslation paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132311
2024-12-25 17:40:25 +01:00
Ray Molenkamp
54604efdfd Cleanup: CMake: Modernize bf_windowmanager dependencies
Pretty straightforward

- Remove any bf_windowmanager paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132310
2024-12-24 22:40:38 +01:00
SensArice
1098f434b0 Geometry Nodes: Find in String node
Add a node that finds the number of times a substring occurs in a string,
and the position of the start of the first match.

See the PR description for more rational and details.

Pull Request: https://projects.blender.org/blender/blender/pulls/129270
2024-12-24 17:12:19 +01:00
Ray Molenkamp
a7c39896c6 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any bf_blenkernel paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132282
2024-12-23 20:08:37 +01:00
Hans Goudey
b43e2168e3 Refactor: Nodes: Remove legacy enum name from NOD_static_types.h
A followup for 5e7f3e5c84.

Make the NOD_static_types.h file less important by moving `enum_name_legacy`
to be defined in the register function of every node. This helps our gradual transition
away from this file.

Also add a fallback to the node idname so that newly added nodes no longer need
to define the string value.

Pull Request: https://projects.blender.org/blender/blender/pulls/132131
2024-12-19 18:12:05 +01:00
Hans Goudey
21aef81714 Cleanup: Use StringRef and std::optional for UI string arguments
- Gives O(1) access to string length in more cases
- Convenient string manipulation functions
- Clarify difference between "no string" and "empty string"
- Avoid the need for raw pointers in the API
- Shows which API string arguments are optional

Pull Request: https://projects.blender.org/blender/blender/pulls/131473
2024-12-06 14:08:10 +01:00
Damien Picard
5f52c5ce46 Fix: I18n: Integer Math node title used wrong translation context
The integer math node items used the proper translation context, but
not the translation for the node label.

Reported by ziweidao.

Pull Request: https://projects.blender.org/blender/blender/pulls/130225
2024-11-13 13:53:57 +01:00
Damien Picard
edcc5e0e87 I18n: Translate and disambiguate a few messages
Translate
- Extract Grease Pencil modifier subpanel header messages.

Disambiguate
- Integer Math node operation (same as other existing math nodes).

Pull Request: https://projects.blender.org/blender/blender/pulls/128715
2024-11-04 11:15:48 +01:00
Campbell Barton
a9b977d256 Cleanup: sort CMake file lists 2024-10-03 14:46:26 +10:00
quackarooni
44fbd69317 Function Node: Value to String Integer subtype
This patch adds an `Integer` type to the Value to String node.
This allows for converting integer inputs into string outputs without
any loss of precision. Something which the original implementation is
not able to do.

This issue becomes evident at values greater than `2 ^ 24` or
`16,777,216`, where the precision loss is high enough that the float
implementation starts skipping certain integers.

Pull Request: https://projects.blender.org/blender/blender/pulls/128362
2024-09-30 23:10:41 +02:00
Colin Basnett
22d78c5a8e Geometry Nodes: add Matrix Determinant node
Pull Request: https://projects.blender.org/blender/blender/pulls/128212
2024-09-30 21:30:10 +02:00
Jacques Lucke
675606cbce Fix: wrong enum type in integer math node 2024-09-30 15:40:27 +02:00
Jacques Lucke
1b31a44935 Geometry Nodes: support inverse evaluation for Integer Math node for gizmos 2024-09-30 14:00:32 +02:00
Brady Johnston
e25405aeb7 Geometry Nodes: improve input labels on Integer Math node
This brings the labels for the Power operation on the integer math node
to align with the regular math node.

Pull Request: https://projects.blender.org/blender/blender/pulls/128222
2024-09-27 11:56:05 +02:00
Charlie Jolly
c0a864aaa3 Fix #128102: Integer Math division has only float precision
The additional division modes were implemented with float
division then rounding to match float > int conversion in
existing float to int node.

As pointed out in the bug report the precision here is limited.

This patch replaces the float division with integer math which
increases the precision to much higher numbers.
Divide Round by due to the way it is calculated has less precision
than Divide Floor and Divide Ceil.

Pull Request: https://projects.blender.org/blender/blender/pulls/128123
2024-09-26 14:44:09 +02:00
Jacques Lucke
a6d5652043 Geometry Nodes: use placeholder instead of label in some string sockets
This makes the input field much wider. I enabled this for most string sockets
except for a few where it is important to see the label even if the user has
inserted a string already (usually because there is more than one string input).

Pull Request: https://projects.blender.org/blender/blender/pulls/127992
2024-09-24 18:22:32 +02:00
Charlie Jolly
bf04513dec Geometry Nodes: new Integer Math node
Provide building block support for integer operations.

Manipulation of integer based data should not be limited to using float math nodes.
Using float math comes with accuracy issues for larger integers and requires unnecessary
type conversions.

The node also adds some integer specific operations like GCM and LCD.

Pull Request: https://projects.blender.org/blender/blender/pulls/110735
2024-09-23 15:01:31 +02:00
Charlie Jolly
294994e4b9 Geometry Nodes: new Hash Value node
This node hashes various types into an integer. Note that hashes
cannot generally used as unique identifiers because they are not
guaranteed to be unique. It can be used to generate somewhat
stable randomness though in cases where White Noise does not
offer enough flexibility.

It uses hash functions from BLI_noise.hh. These are also used in
the White Noise node.

Pull Request: https://projects.blender.org/blender/blender/pulls/110769
2024-08-30 16:42:29 +02:00
Iliya Katueshenock
1b67be14c6 Cleanup: BKE: Nodes: Functions renaming
Use snake style naming for all the kernel nodes functions.
Omit kernel prefix in the names since of the using namespace.
Use full forms of the terms
('iter' -> 'iterator', 'ntree' -> 'node_tree', 'rem' -> 'remove', ...).

Pull Request: https://projects.blender.org/blender/blender/pulls/126416
2024-08-19 20:27:37 +02:00
Jacques Lucke
9816dba416 Fix: compilation with clang on linux 2024-07-10 17:47:26 +02:00
Jacques Lucke
24dc9a21b1 Geometry Nodes: support attaching gizmos to input values
This adds support for attaching gizmos for input values. The goal is to make it
easier for users to set input values intuitively in the 3D viewport.

We went through multiple different possible designs until we settled on the one
implemented here. We picked it for it's flexibility and ease of use when using
geometry node assets. The core principle in the design is that **gizmos are
attached to existing input values instead of being the input value themselves**.
This actually fits the existing concept of gizmos in Blender well, but may be a
bit unintutitive in a node setup at first. The attachment is done using links in
the node editor.

The most basic usage of the node is to link a Value node to the new Linear Gizmo
node. This attaches the gizmo to the input value and allows you to change it
from the 3D view. The attachment is indicated by the gizmo icon in the sockets
which are controlled by a gizmo as well as the back-link (notice the double
link) when the gizmo is active.

The core principle makes it straight forward to control the same node setup from
the 3D view with gizmos, or by manually changing input values, or by driving the
input values procedurally.

If the input value is controlled indirectly by other inputs, it's often possible
to **automatically propagate** the gizmo to the actual input.

Backpropagation does not work for all nodes, although more nodes can be
supported over time.

This patch adds the first three gizmo nodes which cover common use cases:
* **Linear Gizmo**: Creates a gizmo that controls a float or integer value using
  a linear movement of e.g. an arrow in the 3D viewport.
* **Dial Gizmo**: Creates a circular gizmo in the 3D viewport that can be
  rotated to change the attached angle input.
* **Transform Gizmo**: Creates a simple gizmo for location, rotation and scale.

In the future, more built-in gizmos and potentially the ability for custom
gizmos could be added.

All gizmo nodes have a **Transform** geometry output. Using it is optional but
it is recommended when the gizmo is used to control inputs that affect a
geometry. When it is used, Blender will automatically transform the gizmos
together with the geometry that they control. To achieve this, the output should
be merged with the generated geometry using the *Join Geometry* node. The data
contained in *Transform* output is not visible geometry, but just internal
information that helps Blender to give a better user experience when using
gizmos.

The gizmo nodes have a multi-input socket. This allows **controlling multiple
values** with the same gizmo.

Only a small set of **gizmo shapes** is supported initially. It might be
extended in the future but one goal is to give the gizmos used by different node
group assets a familiar look and feel. A similar constraint exists for
**colors**. Currently, one can choose from a fixed set of colors which can be
modified in the theme settings.

The set of **visible gizmos** is determined by a multiple factors because it's
not really feasible to show all possible gizmos at all times. To see any of the
geometry nodes gizmos, the "Active Modifier" option has to be enabled in the
"Viewport Gizmos" popover. Then all gizmos are drawn for which at least one of
the following is true:
* The gizmo controls an input of the active modifier of the active object.
* The gizmo controls a value in a selected node in an open node editor.
* The gizmo controls a pinned value in an open node editor. Pinning works by
  clicking the gizmo icon next to the value.

Pull Request: https://projects.blender.org/blender/blender/pulls/112677
2024-07-10 16:18:47 +02:00
Crax97
5afd84b960 Fix #122763: ensure Vector socket is the default on 'Transform Point'
Ensure that the input socket `Vector` on node `Transform Point` is marked as the default socket.

Pull Request: https://projects.blender.org/blender/blender/pulls/123042
2024-06-14 12:45:58 +02:00
Damien Picard
b37d121e0a I18n: extract and disambiguate a few messages
Extract
- Add to Quick Favorites tooltip.
- "Mask", the name of a newly created mask (DATA_).
- "New" in the context of the new mask ID button.
- A few strings using BLI_STR_UTF8_ defines were not extracted.
  Take the special characters out of the translation macros.
- "External" menu items from the filebrowser's Files context
  menu (right-click on a file). These items were already extracted,
  but not translated.

Improve
- Separate formatted error message "%s is not compatible with
  ["the specified", "any"] 'refresh' options" into two messages.

Disambiguate
- Use Action context for new F-modifiers' names. This is already used
  for the "type" operator prop.
- Translate ImportHelper's default confirmation text using the
  Operator context, as it uses the operator name which is extracted
  with this context.
- "Scale" can be a noun, the scale of something, or a verb, to scale
  something. The latter mostly uses the Operator context, so apply
  this context to verbs, and the default contexts to nouns.
- "Scale Influence" can mean "Influence on Scale" (tracking
  stabilization) and "to Scale the Influence" (dynamic paint canvas).
- "Object Line Art" as type of Line Art to add, as opposed to the
  active object's Line Art settings.
- Float to Integer node: use NodeTree context for the node label, as
  this is already extracted and used for the enum.

Do not translate
- Sequencer labels containing only a string formatting field.

Some issues reported by Gabriel Gazzán and Ye Gui.

Pull Request: https://projects.blender.org/blender/blender/pulls/122283
2024-05-27 19:33:35 +02:00
Iliya Katueshenock
1904e2fc8d Geometry Nodes: treat rotation as vector data type in link-drag-search in some nodes
If there is implicit conversion between rotation and vector type, so these search items
make sense.

Pull Request: https://projects.blender.org/blender/blender/pulls/121754
2024-05-20 20:30:52 +02:00
Jacques Lucke
861cb8622d Geometry Nodes: change Location to Translation in Combine/Separate Transform nodes
Based on the context, both names can make sense, however "translation"
seems to be the more correct term and general here.

Pull Request: https://projects.blender.org/blender/blender/pulls/121656
2024-05-18 15:48:04 +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
Jacques Lucke
25c134fd08 Geometry Nodes: new Axes to Rotation node
This adds a new `Axes to Rotation` node which creates a new rotation.
In many cases, the primary and secondary axis inputs are a normal and
tangent of a mesh or curve. This provides a simpler and more direct way
to create this rotation compared to using two `Align Rotation to Vector` nodes.

This more direct way of computing the rotation also allows us to optimize
the case better.

The node rotates one axis (X, Y or Z) to the given primary axis direction. Then
 it rotates around that primary direction to align the second axis to the given
secondary direction. Ideally, both input axes are orthogonal. However, the node
still creates the "best" rotation when they are not orthogonal. If one or the axes
is zero or both are (close to) parallel, the resulting rotation is unstable. There is
not too much the node can do to make it more stable.

Pull Request: https://projects.blender.org/blender/blender/pulls/104416
2024-05-08 13:34:14 +02:00
Jacques Lucke
69625494ad Cleanup: add missing includes 2024-05-06 19:52:45 +02:00
Iliya Katueshenock
968b98be56 Geometry Nodes: new Input Rotation node
This adds a new node input node for a constant rotation.
Similar nodes exist for vector, integer, boolean, etc. already.

Pull Request: https://projects.blender.org/blender/blender/pulls/120345
2024-05-06 19:04:30 +02:00
Jacques Lucke
dca2faec33 Geometry Nodes: fix typo in Invert Matrix node
Also changing the identifier because this node is only just out of
experimental and has not been released yet.
2024-05-06 16:19:15 +02:00
Iliya Katueshenock
4732e7cda5 Cleanup: incorrect assertion
This assertion was added in assumption that sizes of input argument are always correct.
But this is not such. More correct is to depend on assertions of span access methods.

The size of the multi-function parameters is only guaranteed to be large enough so that
every index in the mask can be accessed. It may be larger.

Pull Request: https://projects.blender.org/blender/blender/pulls/121393
2024-05-03 15:05:48 +02:00
Iliya Katueshenock
831e91c357 Geometry Nodes: support working with raw matrix values
These nodes allow working with the raw values that make up a matrix.
This can be used to construct a 4x4 matrix directly, without using the
`Combine Transform` node. This allows building transforms with arbitrary
skew, or projection matrices.

Pull Request: https://projects.blender.org/blender/blender/pulls/121283
2024-05-01 21:31:08 +02:00
Hans Goudey
462e7aeedd Geometry Nodes: Add Align Rotation to Vector node
A version of "Align Euler to Vector" with the rotation socket
instead of the vector Euler socket. Other than that, and a few
cleanups to use newer math functions, the node is the same.

The old node is just "Deprecated" for now. We could remove
it with versioning, but we can also wait to do that.

In a simple test this node is about 1.7 times faster than the old one.

Pull Request: https://projects.blender.org/blender/blender/pulls/118565
2024-04-30 15:52:11 +02:00
Hans Goudey
3cd1c365c3 Geometry Nodes: Add Project point matrix node
With the matrix socket being introduced into geometry nodes, we
are starting to deal with more complex transforms like perspective
projection. For those matrices projecting a point is not as simple
as just matrix multiplication, there has to be an additional normalization
step after. To solve that in an intuitive way consistent with how it's
typically solved in code, add a new "Project Point" node.

The canonical use case for now is in combination with the mouse
position, viewport transform, and raycast nodes, to find where the
mouse clicked on the edited geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/120597
2024-04-24 15:56:33 +02:00
Jacques Lucke
d7d8cefd72 Fix: incorrect safe float4x4 to quaternion conversion
The issue was that when a 4x4 matrix is normalized, it does not
always mean that any inner 3x3 matrix is normalized too.
2024-04-22 19:52:47 +02:00
Jacques Lucke
c00c1b8e23 Geometry Nodes: remove experimental option for matrix socket and nodes
This makes the matrix socket and initial set of corresponding nodes non-experimental.
That means, they'll be part of the next release.

Pull Request: https://projects.blender.org/blender/blender/pulls/120539
2024-04-17 10:34:13 +02:00
Jacques Lucke
bd72562ff9 Geometry Nodes: handle matrix to rotation conversion more gracefully
Previously, this conversion would often result in invalid quaternions or
hit an assert in `normalized_to_quat_fast`. It's not super nice to convert
to euler as an intermediate step performance wise, but it seems to be
the easiest solution for now. Extracting rotations from matrices should
not be done all that often anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/120568
2024-04-15 18:04:19 +02:00
Jacques Lucke
486947398f Geometry Nodes: add invertable boolean output to invert matrix node
Not all matrices are invertable (e.g. when a transformation matrix is has
a scale of zero), and it's sometimes important when a matrix is.

This also better specifies the behavior when the matrix is not invertable:
the identity matrix is returned.

Pull Request: https://projects.blender.org/blender/blender/pulls/120530
2024-04-11 18:28:57 +02:00
Iliya Katueshenock
5319e6af7b Fix: Geometry Nodes: Separate Transform node
Fix of wrong destination for scale and non-normalized rotation matrix.

Pull Request: https://projects.blender.org/blender/blender/pulls/119602
2024-03-19 05:29:38 +01:00