Commit Graph

120055 Commits

Author SHA1 Message Date
Bastien Montagne
9db53b8dca Add assert regarding consistency of ID type info.
Followup to @e09ccc9b3599c134e/@2b2963e2903, would have prevented the
issue by asserting immediately on Blender startup.

Would love to find a more static way to check that (i.e. error at
compile time), but think it would require quite a few more changes.
2025-05-07 16:40:22 +02:00
Sergey Sharybin
18110744a2 Sequencer: Support HDR in Sequencer Preview
The title is pretty self-explanatory: this change brings support of
displaying HDR content in the sequencer preview. Before this change
it was clamped to the 0..1 range, now it is unclamped sRGB, similar
to how image editor, viewport, and nodes backdrop works.

The general idea is to draw the sequencer content on a non-overlay
frame-buffer and tag viewport as having non-standard input color
space as the sequencer operates in a different space.

The way it is done mimics what happens from the draw manager side
for the nodes backdrop, but bypassing the image engine. Partially
because the image engine expects the Image data-block to be displayed,
but also because of performance: there are a lot of things going on
like float buffer creation, clamping etc. Overall the image engine is
not fast enough for the sequencer needs.

Code-side changes that worth mentioning to highlight the overall
direction for the possible future refactors in the area:

- Decouple arguments from the scene: editing, render data, color
  management etc are now passed as individual arguments.

  This is an anticipation of story tools project where this data
  might be coming from a different place.

- Move the entire preview region drawing to sequencer_preview_draw.cc

  Previously logic was split across sequencer_preview_draw.cc and
  space_sequencer.cc which was quite tricky to know what should go
  where.

- Split functions which had boolean argument to define their behavior
  into individual functions.

  Generally if a function has boolean argument used in a way

    if(foo) { do_something_(); } else { do_something_else() }

  it is a good indication that the function is to be split.

Pull Request: https://projects.blender.org/blender/blender/pulls/138094
2025-05-07 16:21:07 +02:00
Sergey Sharybin
ee9b5532bd Cleanup: Const-correctness in various sequencer utilities 2025-05-07 16:21:06 +02:00
Sergey Sharybin
24a28ea38d Cleanup: Const-correctness in ImBuf metadata drawing 2025-05-07 16:21:06 +02:00
Sergey Sharybin
5668cf0524 Cleanup: Simplify sequencer_ibuf_get() function call
Pass timeline frame. If an offset is needed handle it in the caller.
2025-05-07 16:21:06 +02:00
Sergey Sharybin
d7aa98d07f Sequencer: Remove backdrop drawing in timeline
It always was functionality which got committed without proper review
by the module or UI/UX team. It has all sort of UX problems, but it is
also something that will be tricky to support for HDR drawing.

To brings things to a more manageable state the functionality is now
removed.
2025-05-07 16:21:06 +02:00
Laurynas Duburas
071c9f0929 Curves: Add custom knots to split operator
Adds custom knots support to Split operator. Works very well if the
selection starts and ends with clamped control points (knots repeated
`order - 1` times). In other cases some geometry is lost compared to
the original curve.

Pull Request: https://projects.blender.org/blender/blender/pulls/138230
2025-05-07 16:13:09 +02:00
Clément Foucault
dd205ab7f3 Fix: EEVEE: Flickering display of position pass
This is because the non-update branch in the display
shader was not updated to support the position pass.
2025-05-07 15:56:49 +02:00
Clément Foucault
ae652e4a09 Fix #138516: EEVEE: Viewport doesn't update when render pass is changed
The updates need to be manually detected since 2131ef0a20
because the depsgraph doesn't track the UI updates.
2025-05-07 15:56:49 +02:00
Sebastian Parborg
308f6032c8 Sound: Make Blender control when we open and close sound devices
On Windows and Mac (and with certain backends on Linux), Blender would
always appear to be playing back audio even if there was no timeline
playback. This would sometimes prevent devices from going to sleep or
going into lower power state modes when idling.

For the affected audio backends, we now automatically close the audio
backend after 30 seconds of inactivity.

Pull Request: https://projects.blender.org/blender/blender/pulls/136845
2025-05-07 15:00:55 +02:00
Bastien Montagne
2b2963e290 Fix (studio-reported) broken Lattice ID management.
Typo-mistake in e09ccc9b35. Carefully rechecked all ID types,
could not spot any other error, so hopefully we'll only have this single
glitch.
2025-05-07 14:51:27 +02:00
Clément Foucault
669a51904e Fix #138521: Overlay: Edit Mode Curves display in front of meshes
The lines were not drawn inside a depth aware framebuffer.

Splitting the display into 2 draw pass fixes the issue.
2025-05-07 13:57:02 +02:00
Clément Foucault
72e50a0285 Fix: EEVEE: Warning in shader C++ compilation 2025-05-07 13:38:52 +02:00
Clément Foucault
c5e9bc4113 Fix #138159: EEVEE: Crash when rendering points with volume shader
This is caused by the pointcloud attribute header not being added
to the volume shader.

The fix is to make volume shaders not require volume attribute
for geometry types that do not support it.

Pull Request: https://projects.blender.org/blender/blender/pulls/138212
2025-05-07 11:36:18 +02:00
Clément Foucault
5055770f5b GPU: Shader: Add support for basic namespace through preprocessor
Allows basic support for using `namespace X {}` and `X::symbol`
syntax.

Benefit:
- More sharing possible with host C++ code.
- Isolation of symbols when including shader files as C++.

Requirements:
- Nesting must be done using `namespace A::B{}` rather than
  `namespace A{ namespace B {}}`, which is unsupported.
- No support for `using namespace`.
- Support of `using X` and `using X = Y` inside of function scope.
- Support of `using X` and `using X = Y` inside of namespace scope.
  However, this is only to bring symbols from the same namespace
  declared in another block (potentially inside another file).
- Only support namespace elision for symbols defined and used
  inside of the same namespace scope.

Note that this is currently limited to blender GLSL files and
not for the shared headers. This is because we need to port a lot
of code to use namespaces before allowing this.

### Follow Up:
Nesting like `namespace A{ namespace B {}}` shouldn't be hard to
support and could be added if needed.

Rel #137446

Pull Request: https://projects.blender.org/blender/blender/pulls/137445
2025-05-07 10:41:47 +02:00
Pratik Borhade
ea439fdf0c Fix #91188: Change identifier prefix for some sculpt mode operations
With `MESH_OT` prefix, the shortcut was added to wrong
keymap ("object mode", see: `WM_keymap_guess_opname`).
idname of following operations has been changed, they are
only exposed in sculpt mode UI (also see their poll function:
`geometry_extract_poll`):
- `face_set_extract`
- `paint_mask_extract`
- `paint_mask_slice`

Pull Request: https://projects.blender.org/blender/blender/pulls/133852
2025-05-07 10:30:58 +02:00
Campbell Barton
8069bf801b Cleanup: use toolsettings variable in scene defaults versioning 2025-05-07 17:40:54 +10:00
Campbell Barton
8cc63c6848 Refactor: add a version of EDBM_selectmode_set_multi that takes objects
Support setting the select mode when the object array has already
been created, needed for #131642.
2025-05-07 17:03:29 +10:00
Eitan Traurig
dd43ea4e9e UI: Add "Remove All Materials" operator
Added a new operator `OBJECT_OT_material_slot_remove_all`
that removes all materials from the material slots of selected objects

This was inspired by a request proposal on RCS.

Pull Request: https://projects.blender.org/blender/blender/pulls/138402
2025-05-07 08:06:52 +02:00
Jacques Lucke
72f7d3dec7 Fix: Nodes: draw frame labels on top of links
A frame label that is hidden by links is not all that helpful.
On the other hand, if a link is partially hidden by a frame label,
that's typically not a problem at all.
2025-05-07 05:56:10 +02:00
Jacques Lucke
5fb8c8caa5 Cleanup: use new Mutex in file cache 2025-05-07 05:04:45 +02:00
Jacques Lucke
b7a1325c3c BLI: use blender::Mutex by default which wraps tbb::mutex
This patch adds a new `BLI_mutex.hh` header which adds `blender::Mutex` as alias
for either `tbb::mutex` or `std::mutex` depending on whether TBB is enabled.

Description copied from the patch:
```
/**
 * blender::Mutex should be used as the default mutex in Blender. It implements a subset of the API
 * of std::mutex but has overall better guaranteed properties. It can be used with RAII helpers
 * like std::lock_guard. However, it is not compatible with e.g. std::condition_variable. So one
 * still has to use std::mutex for that case.
 *
 * The mutex provided by TBB has these properties:
 * - It's as fast as a spin-lock in the non-contended case, i.e. when no other thread is trying to
 *   lock the mutex at the same time.
 * - In the contended case, it spins a couple of times but then blocks to avoid draining system
 *   resources by spinning for a long time.
 * - It's only 1 byte large, compared to e.g. 40 bytes when using the std::mutex of GCC. This makes
 *   it more feasible to have many smaller mutexes which can improve scalability of algorithms
 *   compared to using fewer larger mutexes. Also it just reduces "memory slop" across Blender.
 * - It is *not* a fair mutex, i.e. it's not guaranteed that a thread will ever be able to lock the
 *   mutex when there are always more than one threads that try to lock it. In the majority of
 *   cases, using a fair mutex just causes extra overhead without any benefit. std::mutex is not
 *   guaranteed to be fair either.
 */
 ```

The performance benchmark suggests that the impact is negilible in almost
all cases. The only benchmarks that show interesting behavior are the once
testing foreach zones in Geometry Nodes. These tests are explicitly testing
overhead, which I still have to reduce over time. So it's not unexpected that
changing the mutex has an impact there. What's interesting is that on macos the
performance improves a lot while on linux it gets worse. Since that overhead
should eventually be removed almost entirely, I don't really consider that
blocking.

Links:
* Documentation of different mutex flavors in TBB:
  https://www.intel.com/content/www/us/en/docs/onetbb/developer-guide-api-reference/2021-12/mutex-flavors.html
* Older implementation of a similar mutex by me:
  https://archive.blender.org/developer/differential/0016/0016711/index.html
* Interesting read regarding how a mutex can be this small:
  https://webkit.org/blog/6161/locking-in-webkit/

Pull Request: https://projects.blender.org/blender/blender/pulls/138370
2025-05-07 04:53:16 +02:00
Jacques Lucke
ed29ab303c Blenloader: extract blenloader core library for use in blendthumb
We recently started using blenloader code in blendthumb to avoid having to
reimplement some parts of .blend file parsing. While this works, it has the side
effect that on Windows referencing blenloader code increased the binary size of
blendthumb from < 1MB to ~75 MB. That happens because this dependency drags
along lots of other code which effectively is unused, but the compiler is unable
to remove it.

There didn't seem to be a simple solution to make msvc optimize the unused code
away. This patch solves the issue by extracting the shared code into a separate
`blenloader_core` module which does not depend on the rest of Blender (except
blenlib). Therefore, using this new module in blendthumb does not drag along all
the other dependencies, bring its file size back down.

In the future, more code may be moved from blenloader to blenloader_core, but
for now I extracted these two headers:
* `BLO_core_bhead.hh`: Various `BHead` types and related parsing functions.
* `BLO_core_blend_header.hh`: Parsing of the header at the beginning of .blend
  files.

Pull Request: https://projects.blender.org/blender/blender/pulls/138371
2025-05-07 04:51:50 +02:00
Campbell Barton
7669d1db5d Revert "[1/4] UI Experiment: Hover Increment/Decrement More Button Types"
This reverts commit 5b2fe07f64.

This commti with this patch applied by accident.
2025-05-07 11:58:25 +10:00
Campbell Barton
440274d42e WM: revert change to the hot-spot size (use the value from 4.4v)
Based on !138406 it seems the issue this was intended to resolve remains
so revert the increase in hot-spot size from [0].

[0]: a043a0e74d
2025-05-07 11:35:07 +10:00
Harley Acheson
5b2fe07f64 [1/4] UI Experiment: Hover Increment/Decrement More Button Types
This is loosely related to #136285, which allows changing numerical
values while in text entry mode. Outside of that, just hovering over
numerical inputs we are currently able to increment and decrement by
Ctrl + Mouse Wheel. This works for integers, floats, sliders. Current
code also allows cycling through expanded enums. This PR extends that
so Ctrl + Mouse Wheel also changes toggles and checkboxes and also
changes values inside of strings.

---

[2/4] Don't increment string if blank

---

[3/4] Use dynamic strings.

---

[4/4] Use ui_but_string_get_ex and ui_but_string_get_dynamic

Ref: !138344
2025-05-07 11:27:41 +10:00
Campbell Barton
a1efa167aa Cleanup: replace inline viewport dist calculation with a function
While the function `ED_view3d_dist_range_get` was meant to calculate
the range for `RegionView3D::dist` the minimum value was often clamped
by the clip-start instead.

Move this into a function and improve doc-strings in this area
to clarify the conventions viewport zoom is expected to follow.

- Rename `ED_view3d_dist_range_get` to `ED_view3d_dist_soft_range_get`
  since it's not an error when the `dist` is outside this range.
- Return `Bounds<float>` instead of taking a return argument.
- Take a `use_persp_range` argument to avoid re-assigning
  the minimum in some cases.
- Add `ED_view3d_dist_soft_min_get` since it's common for
  only the minimum to be used (replace inline `v3d->clip_start * 1.5f`).
2025-05-07 01:15:22 +00:00
Campbell Barton
8dccfd2f8b Cleanup: use _new as a suffix for viewport calculation
Both were used, prefer the suffix as it fits better with
other names used in the code such as `dist_{min/max/old}`.
2025-05-07 11:02:56 +10:00
Guillermo Venegas
b83fe22703 Refactor: UI: Replace uiLayoutPanelPropWithBoolHeader with class method
This converts the public uiLayoutPanelPropWithBoolHeader function to an
object oriented API (`uiLayout::panel_prop_with_bool_header`), following
similar changes to the uiLayout API.

Pull Request: https://projects.blender.org/blender/blender/pulls/138523
2025-05-07 02:55:25 +02:00
Leon Schittek
d66b171996 Fix #112402: Improve search menu layout
Several small improvements to the layout of the search menu:
* Avoid the separator arrow on highlighted items being cutoff
* Properly center and prevent overlap of the scroll indicator
  arrows at the top and bottom
* Improve robustness with different zoom levels
* Overall more unified spacing and margins
This patch was originally authored by Yevgeny Makarov (@jenkm).

Pull Request: https://projects.blender.org/blender/blender/pulls/112422
2025-05-07 02:32:13 +02:00
Hans Goudey
92de7a4cbf Fix #138279: Realize instances node with depth input can crash
When not all the meshes referenced by the instances recursively
are realized because of the limit of the depth input, and those
meshes have vertex groups, a crash is possible because of an
un-checked VectorSet lookup. `all_meshes_info.order` includes
all meshes regardless of the depth and mask arguments.

Pull Request: https://projects.blender.org/blender/blender/pulls/138519
2025-05-07 02:15:04 +02:00
Harley Acheson
022c85fec3 UI: Consistent File/Asset Drag Size
The size of preview images while dragging from File or Asset Browser is
currently related to the size that they are shown in the thumbnail
lists, sort of, but also based on the column size and with an incorrect
scaling. This PR just makes them a consistent size while dragging,
regardless of their thumbnail size.

Pull Request: https://projects.blender.org/blender/blender/pulls/138350
2025-05-06 22:35:26 +02:00
Sean Kim
424242115f Cleanup: Fix typo in detail_percent RNA description
Pull Request: https://projects.blender.org/blender/blender/pulls/138473
2025-05-06 21:03:08 +02:00
John Kiril Swenson
28b1a33e16 Fix #138180: VSE zoom left-aligned for old files
Patch #137802 made VSE zoom levels constant when resizing the area,
choosing to also align the V2D to the left when horizontally resizing.
This had the added side-effect of causing zooming to be left-aligned. The
fix was attempted in #138041 (and subsequent commit 385a8a4d6a).

However, the versioning code to add the fix (`V2D_ZOOM_IGNORE_KEEPOFS` flag)
was included in the original versioning block instead of a new one. This
meant that newly saved files during the bug did not get the fix applied.

Fix by moving that flag application to a new versioning block.

Pull Request: https://projects.blender.org/blender/blender/pulls/138424
2025-05-06 19:54:14 +02:00
sentharn
69610383b9 Fix #138301: Rename GLSL "select" for Intel GPUs
The GLSL processor appears to dislike a member named "select" when a function named "select" exists.

The member has been renamed to object_select to avoid collisions.

Pull Request: https://projects.blender.org/blender/blender/pulls/138466
2025-05-06 19:42:09 +02:00
Bartosz Kosiorek
899f8e370f UI: Further tweak fluid settings labels
Following #137490

Pull Request: https://projects.blender.org/blender/blender/pulls/138225
2025-05-06 19:02:57 +02:00
Clément Foucault
f6a6358836 EEVEE: Use enum instead of defines for ClosureType
This reduces the amount of macros and avoid `using` in shader
code (see #137445).
Also make sure that all switches have cases for all the closures.

Pull Request: https://projects.blender.org/blender/blender/pulls/138502
2025-05-06 18:34:46 +02:00
Hans Goudey
86ce88f25c Cleanup: Add missing include to avoid need for transitive includes 2025-05-06 12:09:53 -04:00
Hans Goudey
3445a191cb Fix: Potential use after free in realize instances node
These attributes are handled specifically in execute_instances_tasks
anyway so the generic code path doesn't make sense. Referencing
those attributes is incorrect since the temporary geometry set built
for collections goes out of scope after foreach_geometry_in_reference.

Part of #138279

Pull Request: https://projects.blender.org/blender/blender/pulls/138508
2025-05-06 18:08:28 +02:00
Hans Goudey
62fb003fc7 Fix #138460: Points of Curve node wrong output on point domain
The special case that just returns a span was incorrect on the point
domain. It shouldn't apply in that case since the input indices are
meant to be curve indices.

Pull Request: https://projects.blender.org/blender/blender/pulls/138506
2025-05-06 18:07:21 +02:00
Philipp Oeser
34050dc865 Fix #138423: Some drivers remain active after deleting single
Symptoms were drivers still being active while others seemingly
disabled. Indices in the RNA path up to the `ANIM_remove_driver` call
are correct, so it is not entirely clear to me why this goes wrong, but
forcing an update by tagging animation resolves the issue.

NOTE from @dr.sybren : Without this fix, the old copy-for-evaluation
is still there, which still has the driver (because it's a copy)

NOTE: seems we are not handling ND_FCURVES_ORDER anywhere?
Pull Request: https://projects.blender.org/blender/blender/pulls/138490
2025-05-06 17:46:52 +02:00
Guillermo Venegas
c55b3fef02 Refactor: UI: Replace uiLayoutPanelProp with class method uiLayout::panel_prop
This converts the public `uiLayoutPanelProp` function to an object oriented
API (`uiLayout::panel_prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Pull Request: https://projects.blender.org/blender/blender/pulls/138501
2025-05-06 17:13:30 +02:00
Miguel Pozo
c0d6675c84 Overlay: Skip passes not needed
Avoid initializing passes (and requesting their shaders) unless they're
actually needed.
Reduces the number of compiled Overlay shaders at startup
from 70 to 22.
Improves startup times.

Pull Request: https://projects.blender.org/blender/blender/pulls/138457
2025-05-06 16:09:12 +02:00
Lukas Tönne
ce8f30f92c Fix #138447: Invalid voxel size due to arbitrary threshold
OpenVDB has a voxel size limit defined by the determinant of the grid
transform, which is equivalent to a uniform voxel size of
`sqrt3(3e-15) ~= 1.44e-5`.
The `mesh_to_density_grid` function was using an arbitrary threshold of
`1.0e-5` for the uniform voxel size.
In this case the voxel size is `~1.343e-5` so it passes the Blender
threshold but crashes in OpenVDB.

This fix adds some convenience functions to check for valid grid voxel
size and transform based on the same determinant metric. This is now
employed consistently in the mesh_to_density_grid, mesh_to_sdf_grid, and
points_to_sdf_grid functions to avoid exceptions in OpenVDB.

MOD_volume_to_mesh, node_geo_volume_to_mesh, BKE_mesh_remesh_voxel have
not been modified, since they have their own error checks with larger
thresholds.

Pull Request: https://projects.blender.org/blender/blender/pulls/138481
2025-05-06 16:08:24 +02:00
Falk David
ff240d9117 Fix #138478: Node Tools: Incorrect Active layer index outside Edit Mode
The "Active Element" node would return early if the mode was
not `OB_MODE_EDIT`.

For Grease Pencil, we want to be able to  query the active layer index
from any mode.

This changes the logic to only return early for the `Point`, `Edge`,
and `Face` element if the mode is not edit mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/138491
2025-05-06 15:40:40 +02:00
Clément Foucault
c2dc45ce5e GPU: Shader: Add support for function default arguments
This avoid manual code duplication and readability issues.

This is implemented as simple copy pasting of the function
with the different argument count, calling the overload with
the next argument count for each overload.

A `#line` directive is added to each line make sure errors
still make sense and refer to the original line.

Example:
```cpp
int func(int a, int b = 0, const int2 c = int2(1, 0))
{
  /* ... */
}
```
Gets expanded to:
```cpp
int func(int a, int b, const int c)
{
  /* ... */
}
int func(int a, int b)
{
  return func(a, b, int2(1, 0));
}
int func(int a)
{
  return func(a, 0);
}
```

Rel #137446

Pull Request: https://projects.blender.org/blender/blender/pulls/138254
2025-05-06 15:25:16 +02:00
Clément Foucault
9bef8741a9 Fix: GPU: Shader Preprocess: Undefined behavior in variable_reference_mutation
This is because the `match` can be referenced by the
`report_error` callback. If the string is reallocated,
the callback could read freed memory.
2025-05-06 15:02:45 +02:00
Kamil Galik
e8402f2759 Fix #134732: NDOF zooming stops far away from the object
Changing the ndof-center without changing `rv3d->dist` can cause a
strange situation when ndof-center can move from a closer object to
orbiting around an object that's farther away - however it's impossible
to zoom to that object.

Ref: !138096
2025-05-06 23:00:36 +10:00
Hans Goudey
d094812709 Vulkan: Inline more trivial methods
These functions are trivial and shouldn't add the cost of a call.
They appeared in profiles, which they shouldn't since they mostly
just return access to member variables. Inlining them reduces
the backend's overhead when sculpting.

Also reserve a Vector before repeated appending.

Pull Request: https://projects.blender.org/blender/blender/pulls/138349
2025-05-06 14:27:43 +02:00
Falk David
01fb09b240 Fix #136091: Grease Pencil: Broken wireframe rendering
In the `grease_pencil_wire_batch_ensure` when computing the indices,
the function was using `points_by_curve` instead of
`evaluated_points_by_curve`.
Now the correct indices are used.

Pull Request: https://projects.blender.org/blender/blender/pulls/138489
2025-05-06 14:16:57 +02:00