Commit Graph

118678 Commits

Author SHA1 Message Date
Nicola
d001e143a9 Sculpt: Avoid use of BKE_pbvh_redraw_BB
When sculpting high-res meshes, the total number of nodes in the BVH
tree can get quite high and — especially when the brush radius is low —
comparable to the number of vertices influenced by the brush. Under
these conditions, algorithms that run on each node of the BVH,
especially if single-threaded, can become a bottleneck. This issue is
particularly prominent in multires, where the leaf limit is 2500.

The main culprit is `BKE_pbvh_redraw_BB`, which is used when flushing an
update to calculate the redraw bounds. Because partial drawing is
currently broken, and because a future reimplementation of partial
drawing is unlikely to adopt the existing approach, this PR removes the
partial drawing logic from `flush_update_step`.

This patch provides a speedup ranging from 1.25x to 1.45x, depending on
the brush size, when sculpting a small portion of a multires mesh with
roughly 8.1 million faces and 12.6 million vertices using the draw
brush.

Pull Request: https://projects.blender.org/blender/blender/pulls/136471
2025-04-03 00:14:41 +02:00
Sean Kim
bb7e889888 Sculpt: Allow negative values for tilt_strength_factor
Part of #82877

* Adds to description to indicate new functionality.

Pull Request: https://projects.blender.org/blender/blender/pulls/136856
2025-04-02 21:39:54 +02:00
Sean Kim
5546fe9848 Cleanup: Various non-functional pbvh_bmesh.cc changes
* Change #define constant value to static constexpr
* Adds const where possible
* Uses reference instead of pointer where possible
* Uses `float3` instead of raw float array where possible
* Uses std::optional to indicate value that may be null
* Reduces scope of variables where possible
* Uses `std::array` instead of raw arrays where possible
* Combines assignment and declaration where possible
* Lengthens some names from single letters

Pull Request: https://projects.blender.org/blender/blender/pulls/135486
2025-04-02 21:28:19 +02:00
Harley Acheson
3cb1749c31 UI: Status Bar Feedback at Corner Zone While Still
Changes only noticeable to pen users, this PR changes the status bar
information while pressing down on the corner zones but before moving
more than the threshold to start. Split-specific is not shown until
the threshold is met. Most mouse users are dead-still at this point,
but pen users have more movement which currently causes a status bar
change.

Pull Request: https://projects.blender.org/blender/blender/pulls/136900
2025-04-02 21:22:51 +02:00
Hans Goudey
e3f9f36681 Fix #136891: Diffuse BSDF node legacy enum name changed mistakenly
Mistake in b43e2168e3
2025-04-02 15:12:04 -04:00
Hans Goudey
84b6c30317 Fix #136835: Sculpting with certain modifiers uses original positions
Mistake in 4d7274b7f4.
The Previous code:
```
    float(*deformedVerts)[3] = *deformcos;
    float(*origVerts)[3] = static_cast<float(*)[3]>(MEM_dupallocN(deformedVerts));
```
Didn't create a copy of the positions for the `deformedVerts` variable.
It's meant to modify the input position array. It was probably done that way
since dealing with pointers to pointers in C was annoying. With `Array`,
it's not annoying anymore, we can just use that directly.
2025-04-02 14:32:27 -04:00
Sean Kim
1bf520e452 Cleanup: Remove unnecessary qualifiers in BLI_listbase.h
* Removes the `struct` prefix entirely for function parameters and
  return types.
* Removes an instance of `const` applied to a parameter passed by value

Pull Request: https://projects.blender.org/blender/blender/pulls/136591
2025-04-02 20:02:40 +02:00
Hans Goudey
f3aa425d81 Fix #136873: Edit mesh knife crash with no valid evaluated edit mesh
When the evaluated mesh doesn't have an edit mesh that corresponds
to the original edit mesh, don't use evaluated deformed positions, just
use the mesh's original positions instead.
2025-04-02 12:45:47 -04:00
Miguel Pozo
1be036d883 Fix #136346: Workbench: Smoke simulation renders artifacts
Precent division by zero.
Unclear why this wasn't an issue before,
or why is not an issue outside OpenGL.
2025-04-02 17:03:34 +02:00
Brecht Van Lommel
1ea89c82d4 Build: Remove OpenMP
It's better for performance to use a single thread pool for all areas of
Blender, and this gets us closer to that.

Bullet, Quadriflow, Mantaflow and Ceres still contain OpenMP code, but it
was already disabled.

On macOS, our OpenMP libraries are no longer compatible with the latest
Xcode 16.3. By removing OpenMP we no longer have to solve that problem.

OpenMP was disabled for bpy module builds on Windows ARM64, which also no
longer needs to be solved.

Pull Request: https://projects.blender.org/blender/blender/pulls/136865
2025-04-02 16:50:50 +02:00
Brecht Van Lommel
2905652578 Refactor: Cloth: Switch from OpenMP to TBB
This only really needed parallel_invoke. But to keep commented out code
working this also adds parallel_deterministic_reduce.

Pull Request: https://projects.blender.org/blender/blender/pulls/136865
2025-04-02 16:50:50 +02:00
Brecht Van Lommel
98b3b36411 Refactor: Build: Add bf::dependencies::eigen target
To make adding a dependeny on TBB easier.

Additional changes:
* Using LIB for libmv tests, as it now brings in includes
* Removing Eigen header listing in iTaSC

Pull Request: https://projects.blender.org/blender/blender/pulls/136865
2025-04-02 16:50:46 +02:00
Christoph Neuhauser
056fa85699 Fix #132196: UI: Camera gizmo cannot be shifted on Intel GPUs
GPU_DEPTH_NONE leads to issues with Intel GPU drivers on Windows
where camera gizmos cannot be shifted. glGetQueryObjectuiv for
GL_SAMPLES_PASSED seems to return zero in all cases.

This might be due to undefined behavior of OpenGL when the depth
test is disabled and rendering to a depth render target-only
framebuffer. Using GPU_DEPTH_ALWAYS fixes the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/136607
2025-04-02 15:51:24 +02:00
Brecht Van Lommel
e2d58e33a0 Cleanup: Remove unused OpenEXR code 2025-04-02 15:15:27 +02:00
YimingWu
79c1bb67d9 Fix #136867: Modeling: Knife cut through toggle should refresh cuts
Previously pressing `c` to cut through mesh will only update knife cuts
when mouse is moved again, this means if you press `c` at the end of
mouse stroke, it will not update cuts and you end up still only cutting
front faces. This fix makes it that the toggle refreshes knife cuts
immediately.

Pull Request: https://projects.blender.org/blender/blender/pulls/136870
2025-04-02 14:44:36 +02:00
YimingWu
78c0ca1efb Fix #136829: UI: Reset win->ime_data when creating system window.
`win->ime_data` could be non-null when it's read from a file, and
subsequent dependence of this value would crash on interface handlers.
Now always clear it when ghost window is ensured after reading the file.

The actual reset is put in `wm_window_ensure_eventstate`, since it's
also conceptually a part of "event state".

Pull Request: https://projects.blender.org/blender/blender/pulls/136833
2025-04-02 12:41:40 +02:00
Lukas Tönne
4b2fc36671 Fix missing topology cache in during node tree updates
Under some circumstances the `value_task` run by node tree updates
needs access to a node group topology cache. Unlike the `usage_task`
it was not ensuring the cache for the node group, so a stale cache
could be used (triggers assert).

Pull Request: https://projects.blender.org/blender/blender/pulls/136878
2025-04-02 12:02:41 +02:00
YimingWu
3522e2bd26 Fix #136868: Line Art: Wrong index when transferring vertex weight
This was an issue previously not noticed. There were two bugs:

- When an out of range index was somehow detected, line art discards the
  entire stroke after the point, which causes remaining point positions
  to be invalid. In fact the index should never go out of range unless
  total points in the scene exceeds `size_t`.
- Line art point index is global, not local to objects, previously the
  "object starting index" was not subtracted from the final point index
  when transferring weights, this will lead to incorrect weight being
  transferred/discarded.

Now both problems have been properly taken care of.

Pull Request: https://projects.blender.org/blender/blender/pulls/136869
2025-04-02 10:58:49 +02:00
Habib Gahbiche
a4c8a1235b Fix 136825: Can't deactivate Geometry Nodes viewer
Unlike the compositor, geometry nodes is allowed to have no active viewers in the node tree.

Pull Request: https://projects.blender.org/blender/blender/pulls/136874
2025-04-02 10:38:36 +02:00
Kamil Galik
b9801e4aea Fix: incorrect NDOF pan speed in "Free" navigation mode
Ref: !136875
2025-04-02 19:31:07 +11:00
Sergey Sharybin
ccb493b805 Libmv: Abstract parallel range in camera intrinsics
The goal is to be able to switch away from OpenMP by default.

In order to achieve this a new parallel_for() function is added,
which follows the same declaration as the one from TBB. For now
the simplest formulation is used where range is provided by start
and last indices (the last one is excluded from the range).

The side effect is that Libmv now expects the threading limits
to be imposed by the default thread area (or have an explicit
thread area with the limit in the caller). In a way this is
similar to other external libraries.

Pull Request: https://projects.blender.org/blender/blender/pulls/136834
2025-04-02 10:25:49 +02:00
Campbell Barton
37ac685854 Fix: potential use of invalid IME window pointer on Wayland 2025-04-02 16:45:32 +11:00
Campbell Barton
cf7d119e94 PyDoc: clarify the "capsule" return type 2025-04-02 03:02:04 +00:00
Campbell Barton
e58574e1aa Cleanup: minor corrections to code-comments 2025-04-02 03:02:03 +00:00
Campbell Barton
90fd070c28 Cleanup: spelling in comments (make check_spelling_*) 2025-04-02 03:02:01 +00:00
Campbell Barton
f89cf19ba6 Cleanup: indentation for CMake files, strip trailing space 2025-04-02 03:01:59 +00:00
Richard Antalik
144b1a7d56 Fix: VSE crash when moving retiming key
Caused by not checking against key array size. The issue was introduced
in ee9e4ead8d. It looks like mistake done during refactoring, because
the code was supposed to fix previous transition segment, not only the
next one.

The previously code attempted to reduce levels of indentation, but it
was less readable and error prone. Now it should be more obvious what
the intent is.

Pull Request: https://projects.blender.org/blender/blender/pulls/136743
2025-04-02 03:20:51 +02:00
John Kiril Swenson
a1c7f6d3e1 Fix #136513: Add cursor snapping in VSE Preview
The bug was partially caused by the fact that
`translate_snap_increment_ex` would interpret sequencer-specific
snapping bit `SEQ_SNAP_TO_FRAME_RANGE` as `SCE_SNAP_TO_INCREMENT`. Add a
check to fix this.

Technically, #122759 never added snapping for cursors in the preview,
but we can take this opportunity to also add the support, which is
relatively simple.

Pull Request: https://projects.blender.org/blender/blender/pulls/136579
2025-04-02 00:21:17 +02:00
Sean Kim
ee62207e01 Cleanup: Various non-functional changes for sculpt tilt related methods
* Replace #define with constexpr
* Use float3 instead of float[3]
* Use C++ math library
* Use return values instead of r_ prefixed arguments
* Use const where possible

Pull Request: https://projects.blender.org/blender/blender/pulls/136851
2025-04-01 22:02:22 +02:00
Sean Kim
e1d3538980 Vertex Paint: Allow editor actions to create undo steps
Part of #131825

Currently, no change to an RNA property invoked from the UI while inside
Vertex Paint mode creates an undo step. This includes both tool
properties (e.g. brush size, tool settings) as well as mesh properties
(symmetry, active vertex group, selection mode).

This behavior was initially introduced to avoid creating extra undo
steps when painting or sculpting and changing tool settings, however,
it applied to all property changes performed while in any paint mode,
including changes to mesh datablock properties.

To fix this behavior, this commit removes the usage of the sculpt undo
system from Vertex Paint and removes it from the list of modes that
are incompatible with memfile undo.

This switch from Sculpt Undo to Memfile Undo improves the performance of
the undo operator from 90ms to 9ms, representing a 10x speedup.

This speedup is possible because Vertex Paint is not fully integrated
with the Paint BVH drawing system, which normally has the benefit of
skipping depsgraph reevaluation and subsequent BVH rebuilding on each
stroke.

Anecdotally, when painting with large strokes on a mesh of 2 million
vertices, this change to using Memfile undo also uses anywhere from
half as much to a third as much memory compared to the Sculpt Undo
implementation (6 GB vs 2 GB).

Pull Request: https://projects.blender.org/blender/blender/pulls/135830
2025-04-01 13:01:16 -07:00
Sean Kim
69f1e2e29d Revert "Vertex Paint: Allow editor actions to create undo steps"
This reverts commit 12bb22a130.
2025-04-01 13:00:11 -07:00
Sean Kim
12bb22a130 Vertex Paint: Allow editor actions to create undo steps
Part of #131825

Currently, no change to an RNA property invoked from the UI while inside
Vertex Paint mode creates an undo step. This includes both tool
properties (e.g. brush size, tool settings) as well as mesh properties
(symmetry, active vertex group, selection mode).

This behavior was initially introduced to avoid creating extra undo
steps when painting or sculpting and changing tool settings, however,
it applied to all property changes performed while in any paint mode,
including changes to mesh datablock properties.

To fix this behavior, this commit removes the usage of the sculpt undo
system from Vertex Paint and removes it from the list of modes that
are incompatible with memfile undo.

This switch from Sculpt Undo to Memfile Undo improves the performance of
the undo operator from 90ms to 9ms, representing a 10x speedup.

This speedup is possible because Vertex Paint is not fully integrated
with the Paint BVH drawing system, which normally has the benefit of
skipping depsgraph reevaluation and subsequent BVH rebuilding on each
stroke.

Anecdotally, when painting with large strokes on a mesh of 2 million
vertices, this change to using Memfile undo also uses anywhere from
half as much to a third as much memory compared to the Sculpt Undo
implementation (6 GB vs 2 GB).

---

Similar to !135758

### Implementation Notes / Thoughts
An alternate approach to getting similar if not better performance in Vertex Paint mode is to integrate it with  `BKE_sculptsession_use_pbvh_draw` and `flush_update_step`, however this represents an unknown amount of work and does not reduce the number of consumers of Sculpt Undo. Given that the general direction in the module right now is to reduce dependency upon this system and migrate more to using Memfile undo where possible, spending extra effort on integration does not seem like the correct decision to make.

### Testing
* Verified undo step is created when selection mode is changed
* Verified undo step is created when symmetry is changed
* Verified undo step is created when active color attribute is changed
* Verified undo step is created when color attribute underlying data is changed

Pull Request: https://projects.blender.org/blender/blender/pulls/135830
2025-04-01 21:58:36 +02:00
Hans Goudey
541002ad32 Cleanup: Resolve missing declaration in curves NURBS knots code
Also rename the functions to avoid an unnecessary prefix.
2025-04-01 15:10:00 -04:00
Hans Goudey
c7dd2131f6 Cleanup: Pass ReportList to shape key function instead of operator
The operator should be a separate abstraction level than this sort of function.
2025-04-01 15:05:41 -04:00
Hans Goudey
b811282fda Cleanup: Replace weird update tag in Join as Shape Keys implementation
The scene isn't being changed here, especially object selection. The mesh
is being changed though (or rather its shape key data-block, but that really
means the objects using it need to be reevaluated). For some reason this
doesn't make a functional difference currently though.
2025-04-01 15:05:41 -04:00
Hans Goudey
e818a52926 Refactor: Various cleanups to ED_mesh_shapes_join_objects_exec
- Remove useless wrapper function that checked redundant invariants
- Use Vector instead of looping over context variable twice
- Use references instead of pointers
- Make variable names non-cryptic
- Remove useless comment
- Use continue instead of indenting the rest of loops
- Fix grammar and improve text in comment
2025-04-01 15:05:41 -04:00
Sean Kim
bd99c2f7e9 Sculpt: Adjust list of brushes that can use tilt functionality
Part of #82877

* Removed 'Clay Thumb' brush, as it calculates the tilt on its own
* Added 'Plane' brush as the generic version of flatten, fill, and
  scrape

Pull Request: https://projects.blender.org/blender/blender/pulls/136849
2025-04-01 20:46:15 +02:00
Laurynas Duburas
8f6af72a3f Curves: Custom NURBS knots
Adds new NURBS knot mode NURBS_KNOT_MODE_FREE. Knots are stored in
`CurvesGeometry::custom_knots`. Knot offsets binding them to their
curves are calculated at runtime and held in a cache. This commit adds
custom knots support to OBJ import. It is the only way create such
curves for now. Legacy curve's tools don't support this knot mode,
thus on any modification knots get regenerated and whole shape changes.
If to convert imported legacy curve to new curves, point deletion,
duplicate and extrude preserve custom knots.

Rel #99891

Pull Request: https://projects.blender.org/blender/blender/pulls/130132
2025-04-01 20:22:47 +02:00
Brecht Van Lommel
15e88be3a5 Fix #136798: Crash with subdivision and shrinkwrap depsgraph evaluation
Missing double checked lock in subdivision wrapper access.

Pull Request: https://projects.blender.org/blender/blender/pulls/136841
2025-04-01 18:48:58 +02:00
Hans Goudey
7a4ce4184d Shape Keys: Add "Duplicate Shape Key" operator
Part of #135095.

This operator just adds a copy the active shape key, including its
data and settings.

Pull Request: https://projects.blender.org/blender/blender/pulls/136785
2025-04-01 18:24:00 +02:00
Sergey Sharybin
484c1b8cd1 Fix: Compilation error with XCode 16.3
Currently linking will fail if OpenMP is used. It will be addressed in a separate PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/136816
2025-04-01 18:13:42 +02:00
Clément Foucault
b06223d865 Fix #136831: GPU: Crash on Mac trying to draw an empty batch for shader
Cause by trying to deference a null batch.
In normal case, these calls never create a command
and are discarded early. 4.4 introduced the
polyline_draw_workaround to remove the use of geometry
shaders. These were not guarded against zero vertices
calls.

Adding an early out clause fixes the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/136840
2025-04-01 18:11:37 +02:00
Miguel Pozo
4499ae4505 GPU: Use guarded alloc for backends 2025-04-01 17:34:35 +02:00
Hans Goudey
83325d1fd3 Refactor: Depsgraph: Use StringRef, inline some simple methods
While profiling a scene with many objects, I noticed some unexpected
functions taking a significant time of depsgraph creation/evaluation.
String length calculation and equality comparison was taking longer than
it should, and some simple methods were appearing in profiles that should
be inlined instead.

There are more places where this sort of change would be helpful, this
commit just changes places using `OperationIDKey` and `ComponentIDKey`.

Pull Request: https://projects.blender.org/blender/blender/pulls/136795
2025-04-01 17:30:39 +02:00
Sybren A. Stüvel
853640c063 Cleanup: clarify comment & variable in BKE_blender_cli_command_exec()
Just a little clarification. No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/136776
2025-04-01 16:30:01 +02:00
Clément Foucault
4b2cbf5d6f Fix #136810: UV: Wrong UV channel used for displaying UV edges
This was caused by the deinterleaved format being
incorrectly decoded by the `bind_attribute_as_ssbo`
function.

Accumulating the offset should be done for all attributes
and not only the one being used. Furthermore, this needs
to happen only once per attribute and not once per name.

Moving the offset computation out of the name loop
fixes the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/136821
2025-04-01 16:16:20 +02:00
Philipp Oeser
f13bf270c6 Fix #136479: missing Image preview icons for certain render engines
If render engines dont specify `RE_USE_PREVIEW` / `bl_use_preview`, they
wont pass the `ED_check_engine_supports_preview` test.
That is mostly meant to tell blender this engine is capable of
generating (Material) previews and if it isnt, they will skip generating
button previews in `icon_preview_startjob_all_sizes`.

There are already exceptions for type of IDs that can still generate
previews (think Asset previews for Objects or Actions), so the same
exception can be made for Images and Brushes  as well (these previews
will just befulled from the Image buffer, that should not rely on the engine
whatsoever). We can also be permissive on Groups (they are treated
similar to Objects).

NOTE: this was reported for the Workbench engine, in another (future)
commit, we might even consider flagging that engine `RE_USE_PREVIEW` as
well (see comments in the PR)?

Pull Request: https://projects.blender.org/blender/blender/pulls/136824
2025-04-01 16:06:22 +02:00
Jeroen Bakker
aed9f22233 Refactor: Vulkan: swapchain
This PR refactors the way how swapchains are used.

Allow scaling of the swapchain content to the actual resolution of the swapchain.
can reduce artefacts when resizing windows when supported.

When frame rate is to fast the previous implementation could use a semaphore
that were still in use, leading to unwanted stuttering on certain platforms. Waiting
when the rendering has finished (GHOST_Frame.submission_fence), before the
next image is acquired from the swap chain.

Mailbox has been disabled as it can calculate more frames then actually been
presented, leading to a lag and increased  power usage on others.

Pull Request: https://projects.blender.org/blender/blender/pulls/136603
2025-04-01 16:01:22 +02:00
Jeroen Bakker
b3c4190cf7 Fix #134928: Vulkan: Out of bounds framebuffer region
When making a minimized window larger Blender can have negative regions.
This leads to out of bound writes when blitting to the framebuffer.

Easy reproducable on NVIDIA/Windows.

Pull Request: https://projects.blender.org/blender/blender/pulls/136832
2025-04-01 15:06:13 +02:00
Jacques Lucke
46fc5cb2cf Python: flush stdout and stderr after running Python script
When debugging with gdb in vscode, the stuff I print when executing a script in
the text editor does not show up in the terminal. It does work when I flush
explicitly though using `print(..., flush=True)`. This is quite annoying.

The solution is to always flush `stdout` and `stderr` automatically when running
a script. This is done using the CPython API, as just using
`fflush(stdout/stderr)` did not solve the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/136632
2025-04-01 12:41:38 +02:00