Commit Graph

120134 Commits

Author SHA1 Message Date
Jacques Lucke
fd58d730b0 Fix #139516: crash when enabling shader node previews 2025-05-29 13:56:28 +02:00
Omar Emara
43110fc7a3 Compositor: Take virtual sockets into consideration
This patch takes virtual sockets into consideration in the compositor
code base. This mostly involves ignoring them as if they were
unavailable.

This is needed for use with nodes that use Extend sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/139582
2025-05-29 13:32:30 +02:00
Jacques Lucke
367b7b240f Nodes: support creating wrapper node group that keeps original interface
Previously, when using `ctrl+G` on a single node, the newly created node group
always had a flat list of inputs and outputs. This is somewhat annoying when the
node has a lot of inputs that were already organized in panels.

This patch makes it so that when grouping a single node, it will attempt to keep
the same node interface as the original node. This works for group nodes but
also for built-in nodes. For example, when creating a group from the Principled
BSDF node, the group will still have all the same panels. Default values are
taken from the node that is being grouped.

When grouping more than one node, the behavior is exactly the same as before. In
this case there isn't really an obvious way for how to create panels
automatically.

Internally, this works by taking by creating the new node group directly from
the node declaration.

Pull Request: https://projects.blender.org/blender/blender/pulls/139351
2025-05-29 13:32:02 +02: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
Jeroen Bakker
cd3bd7774f Fix #139546: Vulkan: Race condition during rendering resulting in a stall
Race condition between the main thread and worker thread. In this case
the worker thread was waiting for a device idle, but the main thread was
waiting on a specific timeline. As long as the timeline didn't pass the
device was locked.

Releaved the race condition to check on queue idle as the timeline event
isn't part of the queue.

On windows drivers could be reset and could lead to other crashes as handles
were not used anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/139579
2025-05-29 12:13:43 +02:00
Jeroen Bakker
c8dd396f54 Cleanup: Vulkan: Silence logging
This change will move some detailed logging to a higher level as it
isn't important for issue tracking.

Pull Request: https://projects.blender.org/blender/blender/pulls/139575
2025-05-29 11:13:25 +02:00
Jeroen Bakker
283a267c13 Fix #139558: Incorrect shader when using edge slide even
In this case a triangle shader was used to render points.

This change entails:
- Using point shaders in this case
- Add support for `GPU_point_size` to update the uniform of the point
  shader.

Pull Request: https://projects.blender.org/blender/blender/pulls/139574
2025-05-29 10:12:33 +02:00
Hans Goudey
11dc71b258 Spreadsheet: Add option to display internal attributes
Previously the only way to see these attributes and their values
was the Python API. It's helpful for both users and developers to
be able to know all the data attached to the geometry.

This commit adds an option to the spreadsheet's "View" menu
to display attributes starting with a period that are normally hidden.
The option is off by default. Anonymous attributes are still hidden.

---

![image.png](/attachments/3fbb8544-c13d-469c-ae7d-3ade68b0bcb3)

Pull Request: https://projects.blender.org/blender/blender/pulls/139559
2025-05-29 04:12:28 +02:00
Hans Goudey
a7e3a81c84 Cleanup: Use functional style case for eCustomDataType 2025-05-28 22:05:03 -04:00
Campbell Barton
ebca01274f Cleanup: unused parameter warning 2025-05-29 11:01:29 +10:00
Campbell Barton
479d1f1d16 Cleanup: use doxygen doc-strings, spelling (make check_spelling_*) 2025-05-29 11:00:53 +10:00
Sean Kim
71330894b7 Cleanup: Remove unused variables in sculpt_undo.cc
Previously, the undo type was stored at the node level, so undo pushes
inside sculpt mode that didn't need nodes still appended this data so
that they could be appropriately filtered out. This commit removes
instances where this was the case and clarifies other checks that used
the vector of undo nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/130479
2025-05-29 00:57:44 +02:00
Hans Goudey
c725bf324d Cleanup: Use functional style cast for node socket type enum 2025-05-28 15:47:26 -04:00
Harley Acheson
fbace1066d Fix #139157: Fix Movement of Numbers in animation editors
Both horizontal and vertical scale indicators rely on string measuring
for proper positioning. But in order to always do this reliably the
font's size needs to be set explicitly. Otherwise the font size could
be incorrect from prior use so the measurement is wrong, but then the
size is correctly set when drawing occurs. It draws at the right size
but at wrong position.

Pull Request: https://projects.blender.org/blender/blender/pulls/139549
2025-05-28 21:39:50 +02:00
Sean Kim
5de2d48921 Cleanup: Use C++ style casts for Brush type
In most cases this is a simple switch for `reinterpret_cast` or
`static_cast`, but for `BKE_paint_brush` and `BKE_paint_eraser_brush`
code is duplicated to avoid a `const_cast`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139119
2025-05-28 21:37:12 +02:00
Clément Foucault
7245262de8 GPU: Metal: Add --profile-gpu support for CPU timing
The GPU implementation is a bit too complex
to implement for now.

As we are improving shader loading, having the
CPU timings is already helpful.

Note that `Map<size_t, int>` does not compile
on Clang.

This is exposing the `--profile-gpu` option on
all backends as the vulkan backend should follow
shortly.

Pull Request: https://projects.blender.org/blender/blender/pulls/139551
2025-05-28 21:08:38 +02:00
Sebastian Parborg
5106c4e655 JACK: Fix a mutex deadlock when trying to start/stop playback 2025-05-28 19:32:34 +02:00
Jesse Yurkovich
8d22407ca0 Fix: USD: Set midlevel and scale inputs for constant displacement
Explicitly set the Midlevel and Scale values for Displacement material
nodes during Import. This is necessary for "constant" displacement,
where the incoming UsdPreviewSurface does not have midlevel or scale
data associated with any part of the node graph. We default to Midlevel
and Scale values of 0.5 and 1.0 respectively; as that's what the prior
code assumed, and will closely match what is seen in `usdview`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139510
2025-05-28 19:23:19 +02:00
Miguel Pozo
cfa8c9d4ad Fix: Core: VectorList iterator after clear
Check for `used_vectors_` instead of the allocated size.
Improve iterator tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/139541
2025-05-28 18:59:44 +02:00
Lukas Tönne
2a317bad3e Fix #139471: Grease Pencil: Trace materials must be created on main thread
Creating materials in worker threads does not work, this relies on BKE functions
which must only be called from the main thread. Create the foreground/background
materials in advance before starting the trace job.

Pull Request: https://projects.blender.org/blender/blender/pulls/139532
2025-05-28 18:23:25 +02:00
Bastien Montagne
20eff58509 Fix: Assets Browser: asserts on unknown import method values.
Since code expects only known values of
`FileAssetSelectParams::import_method`, ensure forward compatibility on
file read by defaulting to `FILE_ASSET_IMPORT_FOLLOW_PREFS` when the
value is unkown to the current code.

------

Found out while working on forward compatibility for embedded linked IDs
project, which introduces a new 'Link Embed' import method.

Pull Request: https://projects.blender.org/blender/blender/pulls/139537
2025-05-28 17:45:31 +02:00
Bastien Montagne
3f97206781 Cleanup: Fix incorrect reference to MAX_ID_NAME-2 for Mask's layer name. 2025-05-28 17:39:02 +02:00
Bastien Montagne
ff63f81eb4 Fix: BLO: Invalid handling of duplicated libraries in readfile code.
The issue was the usage of `change_link_placeholder_to_real_ID_pointer`
to remap the removed duplicate Library ID pointer to its first instance.

Library ID pointers are _not_ placeholder ones, and therefore the check
on entries in `change_link_placeholder_to_real_ID_pointer_fd` would
fail, leading to never actually remapping this removed Library ID
pointer.

Added a dedicated separate util functions for this usage, as it is
important to keep it clearly distinct from the more usual remapping of
placeholder IDs to their real linked counterparts.

-----

This issue was likely never noticed before, because:
* 'Standard' Library ID pointers are rare, nowadays they are mostly
  coming from the Outliner tree items. (`ID.lib` pointers and the like
  are set by readfile code outside of/before the lib-linking process.)
* Files with duplicate libraries should not be possible to create for
  quite a few years already.

Found out while working on forward compatibility for the Embedded Linked
IDs, since in this project 'duplicates' of libraries (from older code PoV)
are expected: the 'archive' Library IDs.
2025-05-28 17:10:21 +02:00
Philipp Oeser
5d7967fed8 Fix #139314: Copy Keyframes copies a frame if only a handle is selected
This might be up for debate, but for the purpose of copy/pasting
keyframes, I think including keyframes that only have a handle selected
is not what most users expect.

The more pressing issue of #139314 is probably already addressed with
!139349 (that one fixes cases where handles would be included in [box]
selection even though they are not visible), but handles -- e.g.
overshooting handles -- can easily get included in [box]selection
without the user actually wanting to copy/paste the whole keyframe.

This is now resolved by swapping the check for skipping a keyframe from
`BEZT_ISSEL_ANY` to `BEZT_ISSEL_IDX`.
Additionally, a bit of code was added so we can do the "early out" in
`copy_animedit_keys` under the same condition.

Pull Request: https://projects.blender.org/blender/blender/pulls/139352
2025-05-28 16:39:27 +02:00
RedMser
24a2da62b3 Movie Clip Editor: Show preview range
Overall the goal of the PR is to show the preview range in the
clip editor's dopesheet and graph mode.

To accomplish this, some cleanup and refactor were needed:

- Clip editor had a nearly 1:1 copy paste of the timeline draw code,
  which has been replaced with `ANIM_draw_framerange`.
- Preview range draw code required `bContext`, which was only used to
  access scene. Now scene is passed explicitly, without need to know the
  context.
- The macro to access the preview range was removed. This is because the
  code is within `PRVRANGEON` check, so `PSFRA`/`PEFRA` were doing
  redundant checks.

Pull Request: https://projects.blender.org/blender/blender/pulls/138678
2025-05-28 16:28:38 +02:00
Miguel Pozo
ab3dfba8dd Cleanup: GPU: Simplify GLCompilerWorker management 2025-05-28 16:21:15 +02:00
Guillermo Venegas
390254c05f Refactor: UI: Remove uiItemStringO API
This function has no Python equivalent. Using the
returned pointer to write properties is enough, and
is equivalent to how it is done in Python.

Pull Request: https://projects.blender.org/blender/blender/pulls/139448
2025-05-28 14:38:54 +02:00
Christoph Neuhauser
282d703f6b Fix #139443: WM: Clear draw region framebuffers to avoid corruption
This PR adds a clear on creation for draw region framebuffers, which
fixes issue https://projects.blender.org/blender/blender/issues/139443.
When using the "Lock Interface" option, redrawing is disabled until the
rendering process has finished. When the GPU driver does not initialize
framebuffer textures with zero, this means that visual corruption can
be perceived when resizing the main window while rendering.
This fix makes sure that framebuffer textures are initialized with zero
on all GPU platforms.

Pull Request: https://projects.blender.org/blender/blender/pulls/139445
2025-05-28 13:17:37 +02:00
Campbell Barton
be2b8aca91 Fix out of bounds read from recent undo optimization
Error in [0] could read past the array bounds for small arrays
containing uniform values.

For tests this wasn't reporting issues with ASAN unless `malloc` was
used (instead of `MEM_malloc_arrayN`).

Resolve and add tests that run with different alignments.

[0]: f9842107aa
2025-05-28 08:38:56 +00:00
Philipp Oeser
1345ed9214 ANIM: optimize proportional editing many keys in the Graph Editor
Part one.

We have to determine distances for proportional editing for all three
`TransData` (representing the key as well as both handles). The way
#bezt_to_transdata sets up the `TransData`, the `td->center[0]` will
always be based on the **key** (bezt->vec[1]) which means that
#graph_key_shortest_dist will return the same for all of them and we can
reuse that (expensive) result if needed.

Depending on the situation, we can save two thirds of the time spent
here... (42sec >> 14sec before we can actually start transforming keys
in the file from #139042)

Might be worth looking into using a 2D KDTree in the future as well.

(also corrects a code comment about what is actually done in a
particular code path)

Noticed while looking into #139042

Pull Request: https://projects.blender.org/blender/blender/pulls/139164
2025-05-28 08:33:57 +02:00
Philipp Oeser
795f589989 Fix #139466: Grease Pencil: Face Project / Face Nearest snapping broken
Reported for Grease Pencil, but also true for Curves.

This was simply missing the call to
`transform_snap_project_individual_apply`.

Even though we cannot snap **onto** Grease Pencil / Curves faces, we can
snap Grease Pencil / Curves onto other suitable face geometry.

So to resolve, just add the calls to
`transform_snap_project_individual_apply` in both
`recalcData_grease_pencil` and `recalcData_curves`

Pull Request: https://projects.blender.org/blender/blender/pulls/139489
2025-05-28 08:32:00 +02:00
Jacques Lucke
bdf1c2c583 Fix: Nodes: cannot make menu input expanded 2025-05-28 08:03:37 +02:00
Jacques Lucke
e3a9566cc0 Nodes: improve usage inferencing in Vector Math node with unknown inputs
This extends #139331 for the vector math node. These cases are handled now:
* `vec(0) * x = vec(0)`
* `x * vec(0) = vec(0)`

This applies to both the Multiply and Scale operation.

Pull Request: https://projects.blender.org/blender/blender/pulls/139515
2025-05-28 07:47:46 +02:00
Jacques Lucke
281886cfdc Nodes: improve mix node usage inference when some inputs are unknown
This is similar to #139331. If the mix factor is 0 or 1, we can sometimes
compute the output value even if an input of the mix node is unknown.

Pull Request: https://projects.blender.org/blender/blender/pulls/139513
2025-05-28 07:33:39 +02:00
Jacques Lucke
d1c1c58945 Spreadsheet: reuse same table for Viewer nodes in different loop iterations
Previously, each Viewer node in a different loop iteration would have a separate
table with a separate column ordering. This is annoying when using the
inspection index to look at different iterations.

This patch changes it so that the iteration index of the table identifier is
ignored.

Pull Request: https://projects.blender.org/blender/blender/pulls/139511
2025-05-28 06:53:25 +02:00
Jacques Lucke
6066ef8802 Spreadsheet: make active table lookup slightly more efficient
Move the active table to the front of the tables array, so that it
is easier to find in subsequent searches.
2025-05-28 06:20:37 +02:00
Jacques Lucke
16cd798f8d Geometry Nodes: add error message when simulations are not supported
This mainly results in an error when trying to use the a simulation zone in
a node tool which is not supported yet. It might become supported in the
future though.
2025-05-28 05:52:16 +02:00
Mattias Fredriksson
92d83e136a Curves: Unit tests for curves::nurbs::calculate_knots
Unit tests veryfying expectation for curves::nurbs::calculate_knots.
While useful to avoid regressions, they might be more valuable as
reference of the output from the knot vector generator for different
options.

Pull Request: https://projects.blender.org/blender/blender/pulls/139508
2025-05-28 04:27:34 +02:00
Jacques Lucke
e950d4f24d Nodes: improve usage inferencing when some inputs are unknown
Function nodes can be evaluated when determining which inputs are used. However,
for general function nodes the output value is considered to be unknown if any
of the inputs is considered to be unknown. For some built-in nodes we can do
better than that.

This patch improves the behavior for the following cases, previously the output
was always unknown:
* Float Math:
  * `0.0 * x = 0.0`
  * `x * 0.0 = 0.0`
* Integer Math:
  * `0 * x = 0`
  * `x * 0 = 0`
* Boolean Math:
  * `false AND x = false`
  * `x AND false = false`
  * `true OR x  = true`
  * `x OR true = true`
  * `false NAND x = true`
  * `x NAND false = true`
  * `true NOR x = false`
  * `x NOR true = false`
  * `false IMPLY x = true`
  * `x IMPLY true = true`
  * `false NIMPLY x = false`
  * `x NIMPLY true = false`

This helps the inferencing code to be smarter on some cases.

This partially solves #139319. Although in the provided file even more complex
reasoning is necessary to fully support it. For integers it would need to keep
track of the current possible values e.g. `{0, 1}` so that when the integer is
compared to 2, it can be determined that this will always be false. This kind of
inferencing is a bit out of reach for the time being, it's not impossible
though.

Pull Request: https://projects.blender.org/blender/blender/pulls/139331
2025-05-28 04:15:33 +02: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
Hans Goudey
e19fead49d Cleanup: Nodes: Remove always-null arguments
Pull Request: https://projects.blender.org/blender/blender/pulls/139505
2025-05-27 23:05:38 +02:00
Brecht Van Lommel
453c2a296b UI: Make light exposure soft limits match color management exposure
In particular, holding ctrl now changes exactly one stop.

Ref #134528
2025-05-27 21:13:20 +02:00
Jeroen Bakker
425e8743fb Hydra: Add selection of Vulkan HGI
When using Vulkan HgiOpenGL was still selected. This PR changes the Hgi selectiong
to be based on the active GPU backend.

With this PR the correct Hgi could be selected, this requires the USD/Hydra libs to be
compiled with Vulkan support.

The previous implementation used `HGI_ENABLE_VULKAN` but had an issue:
- Depending on the platform the environment variable was stored inside a global
  and initialized when loading blender (even before our main entry point is triggered)
- Storm render engine in Blender has been adapted to do not do any detection.

Ref #133717

Pull Request: https://projects.blender.org/blender/blender/pulls/135780
2025-05-27 20:50:18 +02:00
Habib Gahbiche
2c271e2442 Compositor: set crop node default size to 1920x1080
The crop node default values produces an image of size 100x100. While
this is better than 0x0, it still makes the backdrop image look like it
disappeared after adding a crop node when the new image happens to be
behind a node.

Ideally, the default should be the render resolution, but we don't have
this information at node declaration time, so initialize width and
height to 1920 x 1080 such that the node has no apparent effect for the
default blend file.

<img width="216" alt="default.png" src="attachments/a904a92c-3c0c-4075-80ea-f6168bfb0966">

Pull Request: https://projects.blender.org/blender/blender/pulls/139493
2025-05-27 18:55:06 +02:00
Bastien Montagne
9af8d8af21 Cleanup: Fix comment (update reference to ID_NEW_SET macro). 2025-05-27 18:45:46 +02:00
Bastien Montagne
155e540eb7 Fix (unreported) ID copied in libs making their depencies directly linked.
Not really critical in current main, since such 'copying in library'
behavior is fairly rare, but once it start being applied to e.g.
geometry IDs owning shape keys, it would make Blender unhappy because
unlinkable IDs (the shape keys) would be tagged as directly linked.
2025-05-27 18:34:51 +02:00
Jacques Lucke
1a4c16a784 Geometry Nodes: initialize String node when using link-drag-search
This is similar to how Value/Vector/Integer/... nodes are automatically
initialized when they are created using link-drag-search.

Strings require some special case handling here but that seems fine. The
`node_socket_move_default_value` function is already fairly specific for the
different value nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/139478
2025-05-27 17:05:32 +02:00
Jacques Lucke
43617743af Geometry Nodes: add error message when simulation is in loop or closure
This is not something we support currently. Before, the simulation would just
not do anything. Now there is an error message.

In theory, a limited version of that could be supported eventually but it does
not have high priority currently. The tricky aspect of supporting this is that
each simulation has a cache, can be baked etc and we need a persistent identify
for those. That's not possible if simulations can be added and removed
dynamically all the time.

Pull Request: https://projects.blender.org/blender/blender/pulls/139479
2025-05-27 15:03:06 +02:00
Habib Gahbiche
06d8cd74a7 Fix: compositor gizmos sometimes have no effect
After exposing options as inputs, the following gizmos may be drawn but
have no effect when tweaked:

- Sun beams
- Ellipse mask
- Box mask
- Split

This patch hides the gizmo when the relevant node inputs are linked

Pull Request: https://projects.blender.org/blender/blender/pulls/139491
2025-05-27 14:58:26 +02:00
Habib Gahbiche
5f6f5d28df Fix: Gizmo for Crop Node is broken
The wrong cursor is drawn and the gizmo is never shown.

Also fixes the warning `Gizmo .. has matrix that could not be inverted`
when using the crop node.

Pull Request: https://projects.blender.org/blender/blender/pulls/139394
2025-05-27 14:05:13 +02:00