Commit Graph

150077 Commits

Author SHA1 Message Date
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
Sergey Sharybin
d0bc85487a Cleanup: Formatting of make_update.py 2025-05-06 13:47:41 +02:00
Clément Foucault
2513fbedca GPU: Shader: Add support for references
Implementation of #137341

This adds support for using references to any variable in a local scope
inside the shader codebase.

Example:
```cpp
int a = 0;
int &b = a;
b++; /* a == 1 */
```
Using `auto` is supported for reference definition as the type is not
preserved by the copy paste procedure. Type checking is done by the
C++ shader compilation or after the copy paste procedure during shader
compilation. `auto` is still unsupported for other variable declarations.

Reference to opaque types (`image`, `sampler`) are supported since
they are never really assigned to a temp variable.

This implements all safety feature related to the implementation being
copy pasting the definition string. That is:
- No `--`, `++` operators.
- No function calls.
- Array subscript index needs to be int constants or constant variable.

The copy pasting does not replace member access:
`auto &a = b; a.a = c;` becomes  `b.a = c;`
The copy pasting does not replace function calls:
`auto &a = b; a = a();` becomes  `b = a();`

While limited, this already allows for nicer syntax (aliasing) for
accessing SSBOs and the potential overhead of a copy semantic:
```cpp
ViewMatrices matrices  = drw_view_buf[0];
matrices.viewmat = float4x4(1);
drw_view_buf[0] = matrices;
```
Can now be written as;
```cpp
ViewMatrices &matrices  = drw_view_buf[0];
matrices.viewmat = float4x4(1);
```
Which expands to;
```cpp
drw_view_buf[0].viewmat = float4x4(1);
```

Note that the reference semantic is not carried through function call
because arguments are transformed to `inout` in GLSL. `inout` has
copy semantic but it is often implemented as reference by some
implementations.

Another important note is that this copy-pasting doesn't check if a
symbol is a variable. It can match a typename. But given that our
typenames have different capitalizations style this is unlikely to be
an issue. If that issue arise, we can add a check for it.

Rel #137446

Pull Request: https://projects.blender.org/blender/blender/pulls/138412
2025-05-06 13:36:59 +02:00
Sergey Sharybin
0b59d9f00d Fix: make format to expand tabs
There is similar issue as what was fixed in autopep8 with the initial
LFS migration: `git ls-tree` running to gather all files contains files
with non-ascii names, such as some non-latin utf-8 files in the tests.

Decode the ls-tree using utf-8 for C code format as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/138488
2025-05-06 12:39:20 +02:00
Sergey Sharybin
1ec9aa1cf1 Fix: make update does not update benchmark data
A mistake in the #137219 which cleanup too much code.

Pull Request: https://projects.blender.org/blender/blender/pulls/138483
2025-05-06 12:21:41 +02:00
Falk David
6c092909ab Fix: Grease Pencil: Crash in Set Spline Resolution node
Blender would crash in the "Set Spline Resolution" when the
Grease Pencil object had a bezier curve and the resolution is
changed.

This was because the triangle cache of the drawing wasn't
recomputed after the number of evaluated points changed.
2025-05-06 12:16:44 +02:00
Blastframe
bc6b2a98fb Fix #138420: Grease Pencil: "Add" Operator Applies 'Show In Front' and 'Use Lights' to all object types
This patch ensures that the "Show In Front" and "Use Lights" options
in the Grease Pencil Add operator are respected for all object types,
not just those using the Line Art modifier (e.g. GREASE_PENCIL_LINEART_*).

Pull Request: https://projects.blender.org/blender/blender/pulls/138422
2025-05-06 11:17:39 +02:00
Clément Foucault
41ed07d55e GPU: Shader: Add support for basic template support through preprocessor
Allows basic usage of templated functions.
There is no support for templated struct.

Benefit:
- More readable than macros in shader sources.
- Compatible with C++ tools.
- More sharing possible with host C++ code.

Requirements/Limitations:
- No default arguments to template parameters.
- Must use explicit instantiation for all variant needed.
- Explicit instantiation needs to **not** use argument deduction.
- Calls to template needs to have all template argument explicit
  or all implicit.
- Template overload is not supported (redefining the same template
  with different template argument or function argument types).

Currently implemented as Macros inside the build-time pre-pocessor,
but that could change to copy-paste to allow better error reporting.
However, the Macros keep the shader code reduced in the final binary
and allow different file to declare different instantiation.

The implementation is done by declaring overloads for each explicit
instantiation.

If a template has arguments not present in function
arguments, then all arguments **values** are appended to the
function name. The explicit template callsite is then modified to use
`TEMPLATE_GLUE` which will call the correct function. This is
why template argument deduction is not supported in this case.

Rel #137446

Pull Request: https://projects.blender.org/blender/blender/pulls/137441
2025-05-06 10:41:25 +02:00
YimingWu
2d1904d957 Fix #138439: Eraser/stabilizer brush cursor drawing correction
Correct small Eraser/stabilizer brush cursor drawing issues introduced
by typos in 7d97ba4c5f.

Pull Request: https://projects.blender.org/blender/blender/pulls/138443
2025-05-06 09:32:02 +02:00
Jacques Lucke
6ba9d4b21f Nodes: take the viewer node label into account in context path
Previously, only the node name was taken into account. However, this
is not practical, because the user usually renames the label instead of the
name and it makes sense to show the user-defined name in the context path.
2025-05-06 08:55:53 +02:00
Jacques Lucke
4469f850fe Fix: Nodes: missing viewer path name update
Previously, when the viewer node or node group name changes,
the change was not updated directly in the spreadsheet. It was
only updated later when the viewer path changed entirely.
2025-05-06 08:55:53 +02:00
Jacques Lucke
a7cce5abde Fix: Nodes: bring back node group name in viewer path
This worked in e.g. Blender 4.0 but was broken at some point accidentally.
Now, the context path in the spreadsheet contains the names of node
groups again.
2025-05-06 08:55:52 +02:00
Guillermo Venegas
4845ae8bf2 Refactor: UI: Replace uiLayoutPanel with class method uiLayout::panel
This converts the public `uiLayoutPanel` function to an object oriented
API (`uiLayout::panel`), 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/138461
2025-05-06 07:58:02 +02:00
Campbell Barton
7ab348bf06 Fix: low UV opacity hides UV selection in edge-select mode
In vertex & face modes the selection remained visible when the UV
opacity was zero (or near zero).

In those cases applying the opacity to the edge selection makes sense,
however in edge-select mode this caused UV's to become invisible.
2025-05-06 04:22:00 +00:00
Campbell Barton
4f18c5e389 Cleanup: naming for MeshUVs members
- Use "select_{vert/edge/face}_" convention for UV's
  matching edit-mesh naming.
- Rename `show_face_` to `show_face_overlay_` for 3D & UV views.
- Rename `show_face_dots_` to `select_face_dots_` since they're
  they display selection and aren't used in object mode.
2025-05-06 04:00:37 +00:00
Campbell Barton
490ab44e47 Cleanup: split private member for showing faces into two values
The same value was used to show selected UV faces & object mode face
overlays. This made logic a little more difficult to follow as the
same value was set & used differently based on the context.
2025-05-06 13:49:38 +10:00
Campbell Barton
429399fc1a Cleanup: use underscore suffix for private member in MeshUVs 2025-05-06 13:49:03 +10:00
Richard Antalik
6dcd732555 Fix #138321: Movieclip strip does not blend with background
Movieclip can output buffer with smaller resolution than scene
resolution, but this was not handled in `strip_raw_image_size_get()`.

Small downside of this change is, that if movieclip source file can not
be read, its width and height is initialized to `IMG_SIZE_FALLBACK`.
So this may be confusing to users, but this would be quite rare
scenario.

Pull Request: https://projects.blender.org/blender/blender/pulls/138352
2025-05-06 05:25:51 +02:00
Richard Antalik
4a11be2656 VSE: Add option to translate pivot point
This feature allows you to change postion of origin/pivot for images
without changing their position.

It is implemented as property of transform operator. It is activated
by pressing `Ctrl + .` shortcut.
Move Origin item was also added to transform menu.

Origin can be snapped to 3x3 grid on strip image. This represents
most usual anchor points.

Ref: #134251
Pull Request: https://projects.blender.org/blender/blender/pulls/134206
2025-05-06 05:16:56 +02:00
Campbell Barton
509b39f90e UV: support sticky modes when edge sync-select is enabled
Previously sync-select in edge-select mode behaved in much the same
way as vertex selection, since a selected edge could cause a vertex
on an a disconnected UV island to be selected.

Now single vertices are no longer considered selected when the
Sticky-Mode is set to "Location" (the default).

Notes on changes when sync-select is enabled:

- The main change from a user perspective is edge & face select modes
  show the selected edges.

- This resolves a problem in edge & face selection modes where it wasn't
  possible to differentiate between a selected edge and two selected
  vertices on either side of an unselected edge.
2025-05-06 02:59:40 +00:00
Jacques Lucke
1363319844 Geometry Nodes: add Import VDB node
This adds an Import VDB node. It loads all the grids from a .vdb file and hence
outputs a Volume geometry instead of an individual grid.

The grids are cached through the existing volume grid file cache, so they are
automatically deduplicated when volume grids are loaded from files in other
ways.

Pull Request: https://projects.blender.org/blender/blender/pulls/138380
2025-05-06 04:13:11 +02:00
Jacques Lucke
0553f96bec Fix: Nodes: missing node tree centering
When a new node tree becomes active based on the context, the node editor was
not centered on the new tree. This can easily lead to the situation where there
is no node visible, and the user first has to search for the nodes.

The reason for this is unexpectedly special:
* `snode_set_context` calls `ED_node_tree_start` which adds the `NC_SCENE |
  ND_NODES` notifier.
* Typically, this would update the `View2D` of the region in
  `node_area_listener`.
* However, `snode_set_context` is called from
  `wm_event_do_refresh_wm_and_depsgraph` which happens after(!) the listeners
  run. Therefore, the node editor is redrawn before the listener is handled.
* During redraw, the stored view center is overridden. When it is later used in
  the listener, the value is lost already.

This patch solves this by updating the view center eagerly when opening changing
what node tree is visible, instead of trying to it lazily where the required
information might be lost already.

Pull Request: https://projects.blender.org/blender/blender/pulls/138389
2025-05-06 04:12:03 +02:00
Campbell Barton
01d9b7b095 Cleanup: improve naming, simplify logic for UV face-dot check
Avoid setting non-sync-select values then overwriting with sync-select
as it makes the logic less straightforward.
2025-05-06 01:55:15 +00:00
Campbell Barton
7827286620 Fix: UV face-dots not showing in face select mode
Regression in [0] which missed a rename.

[0]: 3f11d16501
2025-05-06 11:47:30 +10:00
Sean Kim
fd8728c596 Cleanup: Reorganize eUnifiedPaintSettingsFlags
Pull Request: https://projects.blender.org/blender/blender/pulls/138468
2025-05-06 03:42:14 +02:00
Sean Kim
9747e9072d Cleanup: Move dyntopo brush check macro to method
Pull Request: https://projects.blender.org/blender/blender/pulls/138470
2025-05-06 03:36:39 +02:00
Campbell Barton
fd6ac498b0 Cleanup: spelling in comments, strings (make check_spelling_*)
Also replace some triple-quoted non-doc-string strings with commented
blocks in examples.
2025-05-06 00:18:39 +00:00
Sean Kim
b47332c40d Fix: brush.asset_edit_metadata truncates author and description
Both fields have the RNA value defined with a max size of `MAX_NAME`,
despite the underlying DNA value being a dynamic length string.

To fix this, remove the length restriction for the operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/138377
2025-05-05 21:19:31 +02:00
Miguel Pozo
7aeadd397d Workbench: Lazy subpasses initialization
Avoid initializing supbasses (and requesting their shaders) unless
they're actually needed.
Reduces the number of compiled Workbench shaders at startup
from 27 to 9.
Improves startup times.

Pull Request: https://projects.blender.org/blender/blender/pulls/138456
2025-05-05 20:24:16 +02:00
Aras Pranckevicius
aad7b2390b FBX: Speedup new importer
1. Do most of the work in creating meshes in parallel (i.e. everything that
   can happen on the non-Main mesh object)
2. Faster creation of transform F-Curves using the same machinery as
   !137004 (mostly speeds up animated characters import)
3. Make ufbx do FBX file parsing itself in parallel

Generally makes import 2x-5x faster, more detailed timings in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/138367
2025-05-05 19:55:55 +02:00
Jesse Yurkovich
0a3e4b0fd4 Fix #138365: Define and use 'use_filter_orderby_invert' for UIList example
The property in question was undefined since the first commit[1]

[1] b7e2cd5948

Pull Request: https://projects.blender.org/blender/blender/pulls/138373
2025-05-05 19:40:59 +02:00
Jacques Lucke
1b61e419a6 Geometry Nodes: support caching imported files
Currently, the import nodes always reimport on each evaluation. This patch adds
support for caching the loaded geometries. This is integrated with
`BLI_memory_cache.hh` and thus also takes the cache size limit into account. If
an imported file is modified on disk, the cache is invalidated. However,
Geometry Nodes will not automatically reevaluate when a file changes, so the
user would have to trigger the evaluation in some other way.

This is an alternative solution to #124369. The main benefits are that the cache
invalidation happens automatically and that the cache system is more general and
does not have to know about e.g. the different file types.

Caching speeds up node setups that heavily rely on import nodes significantly.

Pull Request: https://projects.blender.org/blender/blender/pulls/138425
2025-05-05 19:25:05 +02:00
YimingWu
3cd15d70b2 Fix #138398: Physics: Re-init rbw->shared->runtime loading old files
`RigidBodyWorld_Shared::runtime` is always expected to be valid. This
fix does this versioning for old files.

Pull Request: https://projects.blender.org/blender/blender/pulls/138418
2025-05-05 19:18:32 +02:00
Hans Goudey
c108d7bfd4 Cleanup: Missing include for integer type in BLI_generic_key.hh 2025-05-05 12:41:36 -04:00
Jacques Lucke
e09ccc9b35 Core: add templated version of BKE_id_new_nomain to reduce explicit casting
This adds a version of `BKE_id_new_nomain` that takes the ID type parameter as
template argument. This allows the function the return the newly created ID with
the correct type, removing the need to use `static_cast` on the call-site.

To make this work, I added a static `id_type` member to every ID struct. This
can also be used to create a similar API for other id management functions in
future patches.

```cpp
// Old
Mesh *mesh = static_cast<Mesh *>(BKE_id_new_nomain(ID_ME, "Mesh"));

// New
Mesh *mesh = BKE_id_new_nomain<Mesh>("Mesh");
```

Pull Request: https://projects.blender.org/blender/blender/pulls/138383
2025-05-05 18:41:03 +02:00
Clément Foucault
dd52130f92 Fix: Vulkan: Broken shader compilation
Was missing a newline after the shader stage define.
2025-05-05 18:38:37 +02:00
Weizhen Huang
64dc9cc98c Fix: Cycles: Inconsistency in transparent bounces for NEE and forward path
Note: this is a partial fix, that makes NEE and forward path consistent
only when `max_transparent_bounce > 0`. It is much more involved to make
forward path tracing support a max transparent bounce of 0, but since we
don't expect people to set up a very low number of transparent bounces,
it is less important to support that specific case.

Pull Request: https://projects.blender.org/blender/blender/pulls/138098
2025-05-05 18:38:02 +02:00
Weizhen Huang
3021d34b8c Cleanup: remove unused volume_shadow_homogeneous() function
Pull Request: https://projects.blender.org/blender/blender/pulls/138342
2025-05-05 18:37:19 +02:00
Weizhen Huang
1f01a1aee9 Cleanup: remove unnecessary defined(__KERNEL_METAL__)
The top level guard is already `#ifndef __KERNEL_METAL__`, additional
guard is not only unnecessary but also confusing.
2025-05-05 18:35:24 +02:00
Weizhen Huang
1e394f7973 Cleanup: Cycles: Fix typo 2025-05-05 18:35:24 +02:00