Commit Graph

119796 Commits

Author SHA1 Message Date
Hans Goudey
cbcf421db7 Cleanup: Draw: Use StringRef for attribute names
Avoid the need to measure string length potentially many times.
2025-05-15 14:53:51 -04:00
Jacques Lucke
8ec093a2d8 Nodes: new operator to simplify adding named frames
Currently, the steps required to add a named frame in the node editor are quite
cumbersome:
* Press ctrl+J, which is hard to reach.
* Press F2, to rename.

This is bad, because frames are a key part of making node trees understandable.
Therefore, we should lower the barrier to adding them as much as possible.
Additionally, named frames help significantly more with readability. Therefore,
it's good to lower the barrier to adding those even more. Of course it's still
possible to click in empty space to avoid having to give a frame a name.

This patch adds a new operator to join nodes in a named frame. When triggered,
it adds the frame and automatically opens the rename menu to set the name.

Keymap changes:
* Remove `ctrl+J` which was creating a frame without label.
* Move existing functionality of `F` key to `J` key
  (including `shift+F -> shift+J`).
* Use `F` for this new operator to create a named frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/138390
2025-05-15 20:51:54 +02:00
Hans Goudey
760cf70d63 Draw: Use VectorSet for generic attribute requests
Replace `DRW_Attributes` with a VectorSet of std::string. The max number of
attributes is still the same. The inline buffer size is 4, and std::string's inline
buffer is smaller than the previous char array size of 64, but it seems
reasonable to save those optimizations for shorter attribute names and
fewer attributes. In return we significantly decrease the size of the batch
caches, simplify the code, and remove the attribute name length limit.

I observed roughly an 8% increase in the 30k cube objects file, a change from
12 to 13 FPS. I'm guessing this is mostly because `VectorSet<std::string>` is
smaller than `DRW_Attributes`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138946
2025-05-15 20:43:31 +02:00
Sergey Sharybin
a3748b549b Fix #138868: Slow start up on when using certain OCIO config
Regression caused by #138433

Somehow the lazy nature of the is_linear and is_srgb got lost in
the refactor and the fields were greedily initialized on startup
and it is not a cheap operation.

Pull Request: https://projects.blender.org/blender/blender/pulls/138945
2025-05-15 20:26:02 +02:00
Sean Kim
906a27bdb2 Fix #138887: Clay Strips brush ignores automask settings
Caused by 33bef53c3e

The change to return an empty IndexMask early from the clay strips brush
breaks some previous assumptions about data flow. To fix this, and
improve the overall resilance of related code to such changes, avoid
checking for a specific stroke step when initializing this data and
delay it in processing until needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/138921
2025-05-15 20:11:42 +02:00
Clément Foucault
97a1e1501b DRW: Add a new GPU context for rendering preview jobs
This avoid stalling the viewport when a preview job is running.
This is because both were fighting for the same GPU context.

This doesn't remove the blocking but allows to remove it using #136991.

Pull Request: https://projects.blender.org/blender/blender/pulls/138882
2025-05-15 20:09:37 +02:00
Brecht Van Lommel
a94a911e10 Fix: Slow USD import with certain OpenColorIO configs
As evidenced by #138868, checking all colorspaces to see if they are sRGB
can be very slow, due to loading all LUTs into memory. Instead use a simpler
check by a list of names only, which is still better than the hardcoded
single name used in Blender 4.4.

Ideally recent configs will use the ColorInterop Forum alias so we can
find the sRGB colorspace reliably.
2025-05-15 19:33:37 +02:00
Hans Goudey
011b3f5cb3 Cleanup: Remove unused field from mesh draw batch cache 2025-05-15 13:14:47 -04:00
Michael B Johnson
af0cfcb01c MaterialX: Export Principled BSDF as OpenPBR Surface
Switch from Standard Surface to OpenPBR as the exported MaterialX surface,
since this is the new standard more renderers are adopting and it more closely
matches the Principled BSDF implementation.

Anisotropy support is improved though still not quite the same, as formulas
are different. Nodes are generated to apply anisotropic rotation to the
tangent vector, as there is no corresponding parameter in OpenPBR.

Fixes #138164

Authored by Apple: Lee Kerley

Pull Request: https://projects.blender.org/blender/blender/pulls/138165
2025-05-15 19:13:36 +02:00
Sybren A. Stüvel
54a7b0bc61 Fix: crash when determining RNA data path of driver F-Curve
The F-Curve RNA path function assumed that the F-Curve would be owned by
an Action, which is not the case for drivers, NLA control curves, and
potentially other "free-floating" F-Curves.

This is now checked for, and if the owner is not an Action, the function
refuses to produce a data path. In the future this could be extended to
search through the aforementioned places as well.
2025-05-15 16:32:15 +02:00
Hans Goudey
b13bdcfaeb Fix #138910: Crash with sculpt mode and "Texture" shading type
Using the wrong `std::string` constructor through an alias, oops..
2025-05-15 10:13:34 -04:00
Habib Gahbiche
df6e65dd93 Compositor: add viewer node to the default node tree
Users almost always need a viewer node, so add one to the default node
tree.

Note that the backdrop is already enabled by default, so the backdrop
image will be visible as soon as a render is available (no need to
manually add viewer node or click `cltr+shift+LMB` to show a backdrop
image.

Pull Request: https://projects.blender.org/blender/blender/pulls/138890
2025-05-15 16:08:19 +02:00
Hans Goudey
91627b3d47 GPU: Remove int float fetch mode combination
This commit finishes removing the uses of the integer to float
vertex buffer fetch mode. Previous commits noted below already started
that process. The last usage was geometry attributes. Now integers are
converted to floats as part of the existing upload process.

The change makes the Vulkan vertex buffer type conversion unused, so
it's removed. That's nice because Vulkan vertex buffers go from 1040 to
568 bytes in size and have significantly less overhead on creation.

Related:
- 153abc372e
- 1e1ac2bb9b
- 617858e453

Pull Request: https://projects.blender.org/blender/blender/pulls/138873
2025-05-15 15:29:12 +02:00
Habib Gahbiche
eaa1e34eca Compositor: improve default node position
The node tree is partially covered by default. This patch updates the
position of the nodes to a better default.

Pull Request: https://projects.blender.org/blender/blender/pulls/138889
2025-05-15 15:13:19 +02:00
Pratik Borhade
3c726aaa6b Fix: Grease Pencil: Check lock status in assign/remove vgroup API
Skip editing vertex group from `vertex_group_assign/remove` API call
of GreasePencilDrawing, when vgroup is locked. Noticed this while
reviewing !127216

Pull Request: https://projects.blender.org/blender/blender/pulls/138932
2025-05-15 14:53:44 +02:00
Nathan Vegdahl
8a984f4f4e Anim: Add "replace" mix mode to the Action Constraint
The available mix modes on the Action Constraint only allowed
*combining* the Action's transforms with the input transforms, but
unlike most other constraints lacked a way to completely
override/replace those transforms.

This PR adds a "Replace" mix mode to the Action Constraint, bringing it
in line with most of the other constraints already in Blender.

![action_constraint_replace_mode_screenshot.png](/attachments/51fb09d6-0a87-42dc-a75e-9ae81c856796)

----

Test file: [action_constraint_replace_mode.blend](/attachments/fc3417a8-b60a-4212-9840-5b59191e9ed9)

- The small bone at the top is the action constraint target (translating it right-left triggers the action constraint).
- Both two-bone chains are set up with action constraints.  The base bones of each chain additionally have a copy location constraint to the small sideways bone, placed before the action constraint in their constraint stack.
- The chain on the left has the default mix mode, which allows you to manipulate the bones on top of what the action constraint does, and allows the copy location constraint on the base bone to work.
- The bones on the right have the new "Replace" mix mode, and therefore manipulating them does not affect the final constrained transformation, and the copy location on the base bone is overridden by the action constraint.

Pull Request: https://projects.blender.org/blender/blender/pulls/138316
2025-05-15 14:30:01 +02:00
Jacques Lucke
e4e49e1634 Nodes: don't jump viewer node if it's still visible
The goal is to make the viewer node jump less often because each unnecessary
jump feels annoying. Previously, we already had a heuristic that would disable
the jumping if the new viewer location was further away than the old one. Now
the viewer never jumps when it's still visible in the node editor and already to
the right of the node-to-view.

As a byproduct this also fixes an issue where the initial viewer position does
not work properly, because the node does not have known draw-bounds yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/138744
2025-05-15 12:11:07 +02:00
Jeroen Bakker
1c72dca726 Cleanup: Remove unused code 2025-05-15 12:00:09 +02:00
Jeroen Bakker
3b3cab471a Fix #138843: Vulkan: Swapchain issues
- Reduce artifacts during resizing to also recreate the swapchain
  when acquire image is suboptimal
- Do not stretch when backbuffer and swapchain have a different size

Pull Request: https://projects.blender.org/blender/blender/pulls/138925
2025-05-15 11:57:44 +02:00
Falk David
c07dfca81a Cleanup: Grease Pencil: Simplify get_bone_mat utility function 2025-05-15 11:41:35 +02:00
Jeroen Bakker
74e244d9b7 Fix: Vulkan: memory leak when rendering animations
Always discard the context discard pile even when not submitted
When rendering animation it is not guaranteed that the submission
flag will ever be set.
2025-05-15 09:06:37 +02:00
Jeroen Bakker
4365a0015f Vulkan: Add render discard pile to debug
Recently we introduced a new discard pile, but it wasn't
reported inside the debug information.
2025-05-15 09:06:37 +02:00
Omar Emara
499dcc3ae2 Compositor: Avoid clamping after HSVA conversion
This patch avoid clamping HSVA colors after being combined using a
Combine HSVA node in the GPU compositor. This is consistent with the CPU
compositor and other node editors.
2025-05-15 09:58:32 +03:00
Jacques Lucke
a33df684c4 Cleanup: Nodes: use StringRefNull in socket item accessors
This mainly helps avoid accidentally comparing char pointers instead of the
strings they point to.

Pull Request: https://projects.blender.org/blender/blender/pulls/138917
2025-05-15 08:41:21 +02:00
Omar Emara
79d37720de Nodes: Add Factor and Percentage subtypes for vector sockets
This patch adds support for the Factor and Percentage subtypes for
vector sockets. This is needed by the compositor, since it has some node
inputs that specify locations and sizes relative to image size, and
having factor and percentage subtypes for those improves the UX quite a
bit according to user feedback.

Pull Request: https://projects.blender.org/blender/blender/pulls/138805
2025-05-15 08:29:41 +02:00
Jacques Lucke
1a7b53ec0b Geometry Nodes: don't trigger evaluation when adding a frame
A frame never affects the computed output, so it can be added without
causing an evaluation.
2025-05-15 06:52:43 +02:00
Sean Kim
15c80a29a8 Cleanup: Various non-functional changes for sculpt raycast methods
* Removes `SculptSession` from being passed to the raycast callbacks,
  it was only used to determine the existence of the `StrokeCache` and
  has been replaced with a boolean.
* Use C++ math library where possible.
* Use const where possible.
* Moves most related `SCULPT_` prefixed methods into the corresponding
  namespace.
  * Renames `SCULPT_stroke_get_location` to `stroke_get_location_bvh`
    to avoid potential collisions in the `sculpt_paint` namespace with
    other editors & be more clear about the usage.

Pull Request: https://projects.blender.org/blender/blender/pulls/138796
2025-05-15 05:22:46 +02:00
Jacques Lucke
b84e790b81 Spreadsheet: show column name in column header tooltip
This is similar to how the value is shown when hovering over a value.
It's useful when the name does not fit into the column width.

Requested by Simon.
2025-05-15 05:15:54 +02:00
John Kiril Swenson
41781df1a6 Cleanup: VSE: Rename seq1 and seq2 references
This patch renames `seq1` and `seq2` to `input1` and `input2` in `Strip`
and `StripSelection` structs to consist with recent refactors in
#132179.  It also renames other instances of `seq1` and `seq2` (e.g.
local variables) to `strip1` and `strip2` instead.

There is only one small breaking change to the Python API with
`strips.new_effect()` taking in the new names now. There should be
no other functional changes involved.

Pull Request: https://projects.blender.org/blender/blender/pulls/138296
2025-05-15 05:01:39 +02:00
Sean Kim
0b6f774c90 Fix: Avoid precomputing factor cache in certain cases
When using the View Normal automasking mode, the per-vertex calculation
is not prohibitively expensive, unlike the topology and boundary modes.
Additionally, we do not populate the view normal values in the cache
when the brush stroke starts.

Pull Request: https://projects.blender.org/blender/blender/pulls/138906
2025-05-15 04:37:36 +02:00
Sean Kim
5d0df1f052 Cleanup: Move Surface Smooth brush initialization into brush file
Pull Request: https://projects.blender.org/blender/blender/pulls/138905
2025-05-15 04:36:51 +02:00
Campbell Barton
e97e9c2904 Cleanup: various non functional changes for C++ 2025-05-15 10:26:47 +10:00
Campbell Barton
3ec7748485 Cleanup: spelling in comments (make check_spelling_*)
Also replace term "playhead" with "current-frame".
2025-05-15 10:13:23 +10:00
Guillermo Venegas
351fbff95b Refactor: UI: Replace uiItemM_ptr and uiItemM with uiLayout::menu
This converts the public `uiItemM_ptr` and `uiItemM` functions
to an object oriented API (an `uiLayout::menu` overloads),
matching the python API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138895
2025-05-14 23:22:56 +02:00
Sean Kim
8ce4d737fa Fix: Various brush features do not use sampled area normal
When performing a raycast into the paint BVH inside Sculpt Mode, there
are two possible values for the cursor's normal: the current vertex's
normal, or a sampled average of the normals in the cursor radius.

The "Grab Silhouette" option of the Grab brush and the "Area Normal"
option of brush automasking both use an initial normal value to
determine a relative influence factor. However, this normal was only
ever using the active vertex normal, not the sampled normal, leading to
a stronger than normal falloff on areas of a mesh that have a high
variance between individual vertex normals.

To further complicate matters, the "Area Normal" setting uses the
sampled normal when the Mesh Filter tool is used, but sculpt brushes
behave as described above. This commit aligns the behavior across all
tool types.

To fix this, check for the existence of this sampled normal when
populating the initial value and use it if found.

Pull Request: https://projects.blender.org/blender/blender/pulls/137692
2025-05-14 23:20:17 +02:00
Nicola
0cf8066284 Fix #138827: Line Project tool not working on scaled objects
Introduced with `a9e29bea94`

The normal wasn't normalized after being converted to object space.

Pull Request: https://projects.blender.org/blender/blender/pulls/138848
2025-05-14 23:08:21 +02:00
Sean Kim
2e3debc4ca Assets: Enable asset metadata operators for brush shelf context menu
Currently, depending on whether or not a brush asset is part of a
library, the context menu shown for it changes significantly.

To better support local brush asset modifications, and make the UI more
consistent, this commit exposes the following operators:

* `brush.asset_edit_metadata`
* `brush.asset_load_preview`
* `brush.asset_save`
* `brush.asset_revert`

Of these four operators, the first two are allowed to execute, whereas
the latter two are always disabled on local assets via the corresponding
`poll` methods, as neither is applicable for this usecase.

Related to #138105

Pull Request: https://projects.blender.org/blender/blender/pulls/138376
2025-05-14 23:01:31 +02:00
Jesse Yurkovich
5336246855 Fix: Call finish() for mutable attribute writers in new FBX importer
Otherwise the following is traced to the console:
```
Warning: Call `save()` to make sure that changes persist in all cases.
```

Pull Request: https://projects.blender.org/blender/blender/pulls/138893
2025-05-14 21:40:27 +02:00
Sean Kim
745582ee01 Fix #138851: Assert on entering Sculpting workspace
Introduced with 617858e453

Pull Request: https://projects.blender.org/blender/blender/pulls/138852
2025-05-14 20:47:31 +02:00
Philipp Oeser
b8d82c510f Fix #138782: "Set Origin > Geometry to Origin" can be inaccurate
"Origin to Geometry" was also affected

With very large meshes (report was about this failing for imported
terrain data), we lack precision in `BKE_mesh_center_median`.

First intuition was to just use doubles, but based on the work done
in !132759 to get a more numerically stable way to compute a mean,
we can use that instead.

So this PR moves `compute_sum` into `blender::array_utils`
and re-uses that for `BKE_mesh_center_median`

Pull Request: https://projects.blender.org/blender/blender/pulls/138813
2025-05-14 17:56:07 +02:00
quackarooni
dd698d4f24 Fix: Geometry Nodes: Asset catalog "Unassigned" does not show in menu
The Node Editor Add menu has filters for not drawing asset catalogs in
the root level. This is done so that catalogs that share names with
built-in menus are appended to said menus.

There is no "Unassigned" built-in menu, just a root level asset menu for
unassigned assets. This menu does not currently have the behavior to
support appending catalogs to it, so assigning assets to a catalog named
"Unassigned" renders said assets unaccessible in the Add Menu.

This patch removes that filter as it was deemed better to just allow the
user to have a root level catalog menu named "Unassigned" instead of
mushing it with the menu for unassigned assets.

Pull Request: https://projects.blender.org/blender/blender/pulls/138874
2025-05-14 16:50:29 +02:00
Aaron Carlisle
6329e00cd1 UI: Improvements to shading layout
Improve labels and UI consistency.

- Update color labels: Object, Wireframe, Background
- Rename 'Single' shading color to 'Custom'. Move to the end.
- Rename 'Viewport' color to 'Custom' for consistency.
- Fix alignment of Object Color item labels

Pull Request: https://projects.blender.org/blender/blender/pulls/137408
2025-05-14 16:24:51 +02:00
quackarooni
8f232517f0 Fix: Nodes: Missing builtin categories for handling asset catalogs
The current behavior for the Node Editor's Add menu is to list the
user's asset catalogs at the root level of the menu. However, an
exception is made if the catalog has the same name as a builtin menu.
In such case, the asset catalog is appended to that builtin menu,
instead of being drawn at the root level.

How this is currently implemented right now is to have a hard-coded set
of builtin menus in `add_menu_assets.cc`. Certain menus are missing from
this set, particularly newer ones, which may be an oversight during the
creation of these menus.

This patch adds those menus to that list, which are as follows:
- Input/Gizmo
- Input/Import
- Grease Pencil (and all its submenus)
- Texture (in Compositor Nodes)

Pull Request: https://projects.blender.org/blender/blender/pulls/138870
2025-05-14 16:12:29 +02:00
Hans Goudey
a224ba806d Mesh: Rewrite face corner normals calculation
This PR intends to replace the current face corner normals calculation.
Compared to the existing code it has a few benefits:
- It's much easier to understand.
- It doesn't require edges, ideally helping to remove them from caches
  and eventually to make them optional.
- It is completely multithreaded using the vert to face map, which is
  already used for vertex normals and domain interpolation. The previous
  code has a significant single threaded portion that scales with the
  size of the mesh.
- Lower peak memory usage: It doesn't require a temporary edge to corner
  map, the corner to face map, or a corner domain sized bit vector.
- The code sorting corners around a vertex should be easy to reuse.
- It's over twice as fast. On a test file with custom normals I observe
  an overall FPS increase of 2.56x, from 37 to 95.

Pull Request: https://projects.blender.org/blender/blender/pulls/138013
2025-05-14 15:35:48 +02:00
Jacques Lucke
4d2aa7d828 Fix #138769: crash when baking
The issue appears to have been that the same depsgraph is evaluated twice at the
same time. Once by the bake code in a background thread and once by gizmo
related event handler.

This patch fixes it by not running event handlers in locked regions. Generally,
accessing evaluated data while the interface is locked (and thus some baking is
usually going on), is not safe.

Pull Request: https://projects.blender.org/blender/blender/pulls/138806
2025-05-14 15:19:29 +02:00
Jacques Lucke
c77b93f49d Nodes: use modifier's persistent UID in context and viewer path
Previously, the modifier name was used to identify it in a compute context or
viewer path. Using `ModifierData.persistent_uid` (which was only introduced
later) has two main benefits: * It is stable even when the modifier name
changes. * It's cheaper and easier to work with since it's just an integer
instead of a string.

Note: Pinned viewer nodes will need to be re-pinned after the change.

Pull Request: https://projects.blender.org/blender/blender/pulls/138864
2025-05-14 15:18:36 +02:00
Hans Goudey
153abc372e GPU: Replace U32/I32 combination with GPU_FETCH_INT_TO_FLOAT in UI code
The conversion from int to float is not supported natively
so it ends up happening beforehand on the CPU or as a
step before the vertex buffer can be used. It's better to just
upload floats in the first place.

Related to:
- 1e1ac2bb9b
- 617858e453

Pull Request: https://projects.blender.org/blender/blender/pulls/138855
2025-05-14 15:15:21 +02:00
Jacques Lucke
fdfd1de9a8 Fix: Geometry Nodes: empty expanded menu entries in modifier
Work around an issue with expanded menus that exists for a long time
already. I briefly tried fixing it, but does not seem straight forward unfortunately
without breaking stuff.

Also see the comment in `ui_item_enum_expand_exec`.
2025-05-14 14:04:15 +02:00
Campbell Barton
2bc284975b Refactor: remove the do_history argument from UV selection functions
Storing the selection history complicated the selection functions,
especially for situations when functions were called indirectly &
multiple times.

Remove the argument in favor of explicit calls to store elements
in the selection history.

Needed to avoid even more complexity with UV sync-select: see #131642.
2025-05-14 11:48:42 +00:00
Jacques Lucke
afd760f2b7 UI: Ghost: support horizontal scrolling for 2D editors
Some mice have an additional horizontal scroll wheel. This patch adds support
for receiving such events. By default it is used to scroll 2D editors left and right.

I originally developed this because I was missing it in the spreadsheet, but it
seems to be useful in many other editors too.

It's supported on Linux (Wayland), Windows and macos.

Pull Request: https://projects.blender.org/blender/blender/pulls/138758
2025-05-14 13:33:10 +02:00