Commit Graph

150473 Commits

Author SHA1 Message Date
Campbell Barton
5c8193bf1e Fix memory leak from builds without XR enabled
Even when built without XR, the window-manager properties
could be accessed & created but weren't freed.

Exposed by !140098.
2025-06-11 15:59:55 +10:00
Sean Kim
47523a4192 Fix #140153: Cavity automasking with hidden faces can corrupt mesh
When calculating the cavity factor, it is possible for the relative
distance of all traversed connected vertices to be zero. This results in
a division by zero which does not get clamped correctly to the expected
[0.0, 1.0] bounds. Prior to 4.2, this would have had no effect, as the
processing of this vertex would be have been skipped entirely. Due to
changes during the brush refactor, this flaw in the existing code was
exposed.

Pull Request: https://projects.blender.org/blender/blender/pulls/140168
2025-06-11 07:38:45 +02:00
Campbell Barton
2a1be1f704 Fix memory leaks in Python argument parsing
Resolve some of the leaks exposed by running tests with guarded-alloc
checks enabled.
2025-06-11 15:15:20 +10:00
Sean Kim
339abe76d0 Tests: Reset sculpt performance test state between every run
Prior to this commit, the sculpt scene and object was only initialized
once, at the very beginning of the test. This has the downside of slowly
changing the performance characteristics as more and more strokes are
performed, as the number of vertices within a given stroke may
eventually approach 1. To ensure a consistent measurement each time,
rebuild the scene between each brush stroke.

Pull Request: https://projects.blender.org/blender/blender/pulls/139960
2025-06-11 05:06:44 +02:00
Sean Kim
c8d0e76ebd Tests: Lower Sculpt Dyntopo mesh size to 250000 in performance test
This commit lowers the size of the mesh from approximately 2 million
verts to 250 thousand verts. This brings the graph more in line with the
mesh and multires usecase, and is more helpful in measuring and
detecting real performance issues.

While the upper end of dyntopo can certainly be massively improved,
strokes that take in the seconds to complete are already unusable from a
user perspective,
2025-06-11 05:06:43 +02:00
John Kiril Swenson
82d20f6a22 Fix: VSE: Remove Playhead Snapping menu from Preview
The other snapping menu in the preview is specific to that view type,
so it doesn't really make sense to have a timeline-specific snap
mode listed here.

Pull Request: https://projects.blender.org/blender/blender/pulls/140171
2025-06-11 03:57:25 +02:00
John Kiril Swenson
f16cc57409 Cleanup: VSE: Ensure strip->type check uses equals comparison
Usually, this enum should only ever be compared with `==`.
Confusingly, however, to check if a strip is an effect, one must
'bitwise-and' it instead. This can backfire if e.g. one tries to do
(strip->type & STRIP_TYPE_IMAGE) which doesn't work.

Make sure we only ever 'and' against the type enum when checking if
it is an effect. There was only this one case that didn't adhere.
2025-06-10 20:50:16 -05:00
John Kiril Swenson
5c9e7f52b5 Fix: VSE: Prevent slipping single image strips
This was possible even before the slip 2.0 refactor (#137072) but the
behavior doesn't make sense.
Allow slipping only if it is an image sequence.
2025-06-10 20:46:30 -05:00
Sean Kim
ee67c098d9 Fix #110879: Multires relative subdivide navigation subdivides mesh
Prior to this commit, the `object.subdivision_set` would prevent
actually applying a subdivision to a multires modifier when the relative
option was set. This is commonly accessed via Alt-1 / Alt-2 or D / Shift
D in Sculpt mode.

However, when the multires modifier did not already exist, pressing
these keybinds would still create the modifier and further subdivide the
mesh.

To fix this, this commit adds a hidden property to the operator:
`ensure_modifier` to indicate if the keybind should create the modifier
or not.

Pull Request: https://projects.blender.org/blender/blender/pulls/130254
2025-06-11 01:34:08 +02:00
Harley Acheson
3e58016c13 UI: Remove Modulation of Drag Threshold with Pen Pressure
Partial revert of 5102880f51. That commit decreased pen tablet drag
threshold as pressure is added. Unfortunately, although this allowed a
quicker response to start of drag, this also increased the difficultly
of initiating a press when both actions are available. With numerical
inputs for example, although dragging is more responsive clicking into
the input to edit was more difficult.

Pull Request: https://projects.blender.org/blender/blender/pulls/140066
2025-06-11 00:38:54 +02:00
Sean Kim
42b75c2cc4 Fix #140120: Multiplane Scrape behaves incorrectly
Introduced with 23951e1b12

The multiplane scrape brush uses two separate distances, one in world
space and the other in local brush space. Both need to be filtered on
for determining the brush strength.

Pull Request: https://projects.blender.org/blender/blender/pulls/140143
2025-06-10 22:35:44 +02:00
Jesse Yurkovich
9381caf484 Fix: USD: Pass correct frame time when checking ORCO evaluation
Similar to the recent fix 457cccd964.
There was another code path which could pass in the wrong time into USD
for certain Mesh Sequence Cache scenarios.

I was not able to craft a faulty scenario by hand to observe a real
problem though. The scenario begins by importing a USD file needing a
Mesh Sequence Cache modifier and then attaching a particle system  (like
Hair) to the object. This will trigger the specific check calling into
`can_use_mesh_for_orco_evaluation` with the wrong time.

This makes the code path more explicit and passes in the correct time to
USD regardless now e.g. frame 28 vs time 1.166666666666667 (24fps)

Pull Request: https://projects.blender.org/blender/blender/pulls/140092
2025-06-10 20:20:00 +02:00
Bastien Montagne
f76ca0e144 Cleanup: Remove left-over debug prints. 2025-06-10 18:12:48 +02:00
Miguel Pozo
fca4a16975 Fix: GPU: GPUWorker lock
Prevent race conditions caused by calling `GPUWorker::wake_up` when the
worker is not waiting.
Found to be an issue in #139627, since `wake_up` is likely to be called
before the thread has fully started.

Pull Request: https://projects.blender.org/blender/blender/pulls/139842
2025-06-10 17:24:18 +02:00
Christoph Lendenfeld
27d2d0a23a Fix: Crash when snapping to first key using subframes
When pressing Ctrl to snap the playhead while scrubbing,
Blender could crash while trying to snap to the first key.
This would happen if the current frame was higher than the
left keyframe, but the difference was less than the `BEZT_BINARYSEARCH_THRESH`.

Pull Request: https://projects.blender.org/blender/blender/pulls/140122
2025-06-10 16:40:07 +02:00
quackarooni
633463c586 Fix: Nodes: Add menu entries not in alphabetical order
It is generally expected that items within the same section in the Node
Add menu appear in alphabetical order.

However, certain handful of places in the different node editor menus
don't seem to follow this convention. This patch simply re-arranges the
items in some places to follow alphabetical order.

Pull Request: https://projects.blender.org/blender/blender/pulls/140070
2025-06-10 15:49:31 +02:00
Sietse Brouwer
ab1b451250 Fix: Grease Pencil: Wrong check on editable layer and keyframe in Sculpt Mode and Vertex Paint mode
In Grease Pencil, when using the tools in Sculpt Mode and Vertex Paint
mode, the check on editable layers wasn't entirely accurate. There was
a strict check on an editable _active_ layer, but since the tools work
on _all_ editable layers, the check should be wider: if there is _any_
editable layer, the tool can work.
That is fixed in this PR. Now the tools can be used when, for example,
a layer group is active or when the active layer is hidden, but there
are other editable layers present.

In Vertex Paint mode there was an additional issue: with Auto Keying
enabled, a new keyframe was created for the active layer only. A new
keyframe should be created for _every_ editable layer. As is the case
now with this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/140119
2025-06-10 15:45:44 +02:00
Philipp Oeser
5c1eb99279 Fix #140109: Grease Pencil - Lasso Erase does not delete single points
By definition, Bounds for single points (size zero) are empty (this
matches BLI_rct behavior), so doing an intersect will actually fail.

So to resolve, use the existing `is_point_inside_bounds` for single-
point-curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/140124
2025-06-10 15:42:27 +02:00
Jeroen Bakker
f23f498864 Fix #139815: Vulkan: Infinite loop when loading minimized windows
e934792169 introduced a workaround for
NVIDIA windows where NVIDIA drivers fail to allocate swapchain images
of minimized windows. The fix was to clamp it to 1,1. With this clamping
AMD driver seems to tell Blender that the created swapchain is suboptimal,
and needs to be recreated. This results in over and over creation of
swapchains as they are all considered sub-optimal.

This PR limits the clamping to NVIDIA drivers only.

Pull Request: https://projects.blender.org/blender/blender/pulls/140112
2025-06-10 14:39:51 +02:00
Falk David
ee3fdbf110 Fix: Assets: Grease Pencil fill defaults
The `Visual Aid` feature was enabled by default on the `Fill` brush
asset. It should have been disabled by default.
2025-06-10 13:12:31 +02:00
Falk David
7007482553 Fix: Assets: Grease Pencil erasers
The `Eraser Hard` and `Eraser Point` were almost identical in behavior.
* `Eraser Hard` was set to `Disslove` making the edges soft, not hard.
   Now this is set to `Point` mode to delete the points and make actual
   hard edges.
* The `Eraser Point` is obsolete and was removed.
2025-06-10 13:06:57 +02:00
Clément Foucault
4bee4a456a Fix #139553: EEVEE: Vulkan raytracing denoising pink propagation
This was caused by precision issue that made `sqrt(1.0f - NV2)`
evaluate to NaN. Making sure the input is saturated fixes the
issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/140071
2025-06-10 12:37:54 +02:00
Bastien Montagne
5d07055b0f Fix #137238: Collection asset placement not working with collection hierarchies.
Code selecting objects in collections that have been instanced was only
handling objects directly owned by the collection, not the objects in
the hierarchy of children collections.

The objects from the whole hierarchy need to be hanlded here, since
children collections will not be processed (as they are already
instanced by their parent one).

Pull Request: https://projects.blender.org/blender/blender/pulls/140068
2025-06-10 12:26:26 +02:00
Clément Foucault
62251cad5f Fix #140072: Overlay: UV Stretch ANGLE Overlay always shows green in 4.5
Was caused by the angle being scaled for USHORT storage.
2025-06-10 12:15:58 +02:00
Jacques Lucke
7810bbc199 Cleanup: quiet unused variable warning 2025-06-10 12:15:10 +02:00
Jacques Lucke
2e44db85d2 Fix #138511: support dropping material asset into Set Material node
The `Drop Name` operator previously only worked for local data-blocks and not for assets.
This makes it possible to drop assets with this operator too.

Pull Request: https://projects.blender.org/blender/blender/pulls/140053
2025-06-10 12:10:15 +02:00
Jeroen Bakker
a14a844a99 Fix: #140028: Vulkan: Incorrect move of resources
Previous implementation allows to move VKBuffers, but didn't do a
proper std::move. On second thought it is a bad idea to be able to move
GPU resources. This PR removes the ability to move the buffer and
replace the usages with a unique ptr.

Pull Request: https://projects.blender.org/blender/blender/pulls/140103
2025-06-10 10:24:04 +02:00
Jeroen Bakker
cffafda2ff Fix #139898: Vulkan: Read out of bounds with color picking
The color picking reads 3 channels from a 4 channel texture. In the
common case the data conversion is required. Data conversion happens on
all 4 channels, but the backed memory only has 3 channels.

This is a workaround as the actual solution needs to work in many
different situations. Previous solution had to many issues that we
reverted the solution. This PR adds a local workaround specific to color
picking.

In Blender 5.0 we want to add test cases for all situations and
implement a solution that works better.

Pull Request: https://projects.blender.org/blender/blender/pulls/140101
2025-06-10 10:22:50 +02:00
Jacques Lucke
3eab86588c Core: add id_cast function as more type-safe reinterpret_cast alternative
Currently, we are forced to use `reinterpret_cast` (or c-style-casts) when
converting between `ID` and the actual data-block types like `Object` and
`Mesh`. While `reinterpret_cast` does preserve constness, it does nothing to
make sure that a cast is actually valid. This patch adds `blender::id_cast`
which can be used as a drop-in replacement of `reinterpret_cast` in supported
cases.

It supports a couple of cases (using `Object` as example for all data-block
types):
* Convert `ID *` to `Object *`. This asserts that the conversion is valid at
  run-time if the pointer is not null.
* Convert `ID &` to `Object &`. This always asserts that the conversion is valid
  at run-time.
* Convert `Object *` to `ID *`. This is preferred over `&object->id` even if the
  result is the same because the latter results in ASAN warnings if `object` is
  null.
* Convert `Object &` to `ID &`. Added for good measure. There isn't really much
  of a benefit of this over using `object.id` except for maybe in generic code
  where the source type can be an `Object &` or `ID &`.
* Identity cast identical id types (e.g. `Object *` to `Object *`). Not really
  necessary to add a cast in such a case but may be useful in generic code where
  the input can be an `Object *` or `ID *`.

Some additional notes:
* Const-correctness is preserved with this cast.
* When attempting to do a non-id-cast, the function triggers a `static_assert`.
* The data-block types must not be just forward declarations because the actual
  type information is necessary.
* Casting to and from `void *` is not supported because that can't provide any
  additional type-safety over `static_cast`.
* Casting between different data-block types like `Object` and `Mesh` is not
  allowed.
* It does not support casting double-pointer types currently  (e.g. `ID **` to
  `Object **`).

The new cast is added in `DNA_ID.h`. As part of this patch, I also sprinkled in
a couple of `id_cast` in various places for testing (it's surprisingly tricky to
have the type checks working for all the different combinations of
pointer/referenced/constness/etc.). Replacing more existing `reinterpret_cast`
can be done separately afterwards.

It's nice that `blender::id_cast` has exactly the same length as
`reinterpret_cast`. So formatting should never change when using it in global
scope. Using just `id_cast` when inside of the `blender::` namespace is
preferable of course.

Pull Request: https://projects.blender.org/blender/blender/pulls/139820
2025-06-10 09:49:43 +02:00
Guillermo Venegas
23ff021d58 Fix #139214: Wrong FBX file imported when dropping with a preset
Exclude operator paths from the preset.

Ref !139309
2025-06-10 07:34:10 +00:00
Campbell Barton
6ed8e1dd96 Fix wm.operator_presets_cleanup failing to exclude collections
Only the collection clearing was removed, adding an item
and assigning values to it was kept - breaking the preset.

Detect collections and removed all lines which add & manipulate items.

Based on the fix from !139309 with fewer changes.

Also include FBX operators when cleaning up presets.

Co-authored-by: Guillermo Venegas <guillermovcra@gmail.com>
2025-06-10 17:32:31 +10:00
Campbell Barton
2e8793b38f WM: prevent the same value being written multiple times in a preset
Presets would write a property multiple times in the case both the class
and it's parent defined a property.

While not a bug, it looks like an error. Only write values once.
2025-06-10 17:32:31 +10:00
Omar Emara
a48e599bea Fix #139856: Ellipse/Box mask size is clamped
The Ellipse/Box Mask nodes recently got their size clamped by their soft
limit, which was not previously the case, breaking compatibility and
limiting the node's use in some setups. The same goes for their
position. We fix this by allowing any size and position.
2025-06-10 09:45:30 +03:00
Sean Kim
ddcd314df4 Fix: Silence warning in BKE_brush_calc_curve_factors
Introduced in 23951e1b12

Pull Request: https://projects.blender.org/blender/blender/pulls/139977
2025-06-10 03:07:36 +02:00
Sean Kim
12f4e17044 Sculpt: Assert when applying a translation that contains NaN
There have been a number of commits that have introduced regressions
in Sculpt mode where NaN begins to be propagated. While it is visually
very obvious that this is happening, this commit adds an assert so that
any automated testing with asserts on will also catch this issue.

Related to 23951e1b12

Pull Request: https://projects.blender.org/blender/blender/pulls/133992
2025-06-10 01:48:21 +02:00
Sean Kim
44bfeb2214 Fix #140078: Sculpt Paint brushes can apply NaN
Introduced with 23951e1b12

The paint brush uses either absolute or local distance values, mapping
this distance to a brush strength requires using different values for
`BKE_brush_calc_curve_factors` and cannot just use
`calc_brush_strength_factors`. To fix this, use the more generic method
instead to allow passing the correct radius.

Pull Request: https://projects.blender.org/blender/blender/pulls/140084
2025-06-10 01:46:09 +02:00
Sean Kim
1131254644 Fix #139969: Clay Strips brush can corrupt mesh
Introduced with 23951e1b12.

When using brushes that use a cube distance, some distances are set to
be float::max(). This breaks assumptions made inside the previously
linked commit, as the operations inside `BKE_brush_calc_curve_factors`
can easily cause this distance value to become infinity, which when
multiplied with the factor value of 0 results in NaN propagation in the
mesh.

To fix this, set the max distance in `calc_cube_distance` to 1.0f.

Pull Request: https://projects.blender.org/blender/blender/pulls/139965
2025-06-09 22:06:23 +02:00
Harley Acheson
7c013f9ea8 Fix #134599: Win32 Automatically Detect Language for Chinese Variations
On the Windows platform if you select "Automatic" for language, it
won't actually select correctly for the Chinese languages. This is
because our Windows code returns a locale like ""zh_CN" or "zh_TW",
not the "zh_HANS" and "zh_HANT" expected. This PR checks for language
code "zh" and will then will append "_HANT" if your 2-letter region
is TW (Taiwan), HK (Hong Kong), or MO (Macau), and "_HANS" for other
regions (like China, Malaysia, Singapore, etc).

Pull Request: https://projects.blender.org/blender/blender/pulls/140027
2025-06-09 18:00:16 +02:00
Bastien Montagne
675438d331 Fix: Append: Error message when appending liboverrides.
Depending on things like order or processing etc., appending
liboverrides data could generate error message in the console regarding
invalid override hierarchy data.

While this could probably be solved, it feels fairly brittle and risky
to directly make linked liboverride hierarchies locale anyway, so just
alsways make local copies of these on append.
2025-06-09 17:11:50 +02:00
Jacques Lucke
d9138d6689 Fix #133738: missing update when input of zone without link changes
Some zones implicitly pass inputs through to the output, even if there is no
actual link from the zone input to the zone output node.

Pull Request: https://projects.blender.org/blender/blender/pulls/140055
2025-06-09 16:39:31 +02:00
Jacques Lucke
af3f9ac66e Fix #138085: Nodes: allow panel toggles in panels with outputs
Currently, there is the general rule that outputs must be above inputs in any
given panel. Since internally a panel toggle input is part of the panel that it
toggles and has to be the first item in a panel, it was not possible to have a
panel toggle for a panel with outputs.

This patch relaxes the rule for ordering of inputs and outputs for the special
case of panel toggles.

Pull Request: https://projects.blender.org/blender/blender/pulls/140054
2025-06-09 16:09:27 +02:00
Clément Foucault
24ee70553a Fix: Overlay: Shader compilation warnings
This is because we now use enums instead of defines.

Pull Request: https://projects.blender.org/blender/blender/pulls/140044
2025-06-09 15:33:13 +02:00
Jacques Lucke
1e39da6e98 Fix #139752: missing update when changing camera parameters
Not only depend on the camera position but also on the other camera parameters.
This is important because otherwise Geometry Nodes won't be updated when e.g.
the focal length changes which is important when implementing e.g. camera
culling.

This already works when depending on a specific camera directly, but not when
depending on the active camera.

Pull Request: https://projects.blender.org/blender/blender/pulls/140046
2025-06-09 15:17:58 +02:00
Jacques Lucke
9a56d1a13f Fix #138654: reset menu socket to default value does not work
To make this work, I had to add a new rna callback to get the default value for
an enum property at run-time. The same exists for other property types like
float and bool already.

Pull Request: https://projects.blender.org/blender/blender/pulls/140050
2025-06-09 15:17:11 +02:00
casey-bianco-davis
672d8cfc6f Fix #130597: Grease Pencil: Brush cursor radius not working in perspective projection.
This fix make it so that the brush cursor is always the same size as
the drawn strokes.

The code logic is modified from `pixel_radius_to_world_space_radius`
in `grease_pencil_utils.cc`

Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/139964
2025-06-09 14:14:31 +02:00
Campbell Barton
bcbdd4adb0 Fix #140034: Unhandled Python exception in the spreadsheet UI
Ref !140035
2025-06-09 21:21:22 +10:00
Clément Foucault
1c47e31367 GPU: Enable GL multithreaded compilation by default
This allows to reduce the waiting time caused by
shader compilation on some GPU-driver combo.

A new settings in the User Preferences make it
possible to override the default amount of worker
threads and optionally use subprocesses.

We still use only one worker thread in cases where
there is no benefit with adding more workers
(like AMD pro driver and Intel windows).

It doesn't scale as much as subprocesses for material
shader compilation but that is for other reasons
explained in #139818.

Add some heuristic to avoid too much memory usage
and / or too many stalls.

Also add some heuristic to the default number of subprocess for
the platform that shows scalling.

Historically, multithreaded compilation was prevented by the
need of context per thread inside `DRWShader` module.
Also there was no good scaling at that time. But
nowadays numbers shows different results with
good scaling with reasonable amount of threads on many
platforms.

Even if we are going for vulkan in the next release
most of the legacy hardware will still use OpenGL for
a few other releases. So it is relevant to make this
easy improvement.

See pull request for measurements.

Pull Request: https://projects.blender.org/blender/blender/pulls/139821
2025-06-09 12:36:06 +02:00
Jacques Lucke
b58c5f6e77 Fix #139172: group outputs show up in link-drag-search incorrectly 2025-06-09 12:15:15 +02:00
Jacques Lucke
9efc23bb69 Fix #140018: no warning when using bake node or simulation in zone
Baking and storing simulation state within loops or closures is not supported.
Previously, attempting to use the bake node or simulation zone in such a zone
would just silently fail. Now there is an error on the node and the bake
settings are grayed out.

Pull Request: https://projects.blender.org/blender/blender/pulls/140041
2025-06-09 12:08:24 +02:00
Jacques Lucke
a8e461f2de Fix #139985: refit column width when data type changes 2025-06-09 10:03:16 +02:00