Commit Graph

149292 Commits

Author SHA1 Message Date
Bastien Montagne
368c737fe7 Core: Fix/refactor invalid logic around handling of 'default materials'.
These were handled mostly completely outside of IDManagement code, yet
(ab)using the same ID management system in some cases, adding hacks to
address some issues, etc.

Also address a similar issue in the eevee lookdev `LookdevWorld` code.

Since initializing pre-allocated (or static) buffers as valid IDs is not
currently supported, and these use-cases do not seem common enough to be
worth supporting it currently, instead switch to storing allocated IDs
into static pointers.

This allows to use proper 'out-of-main' ID creation code API.

NOTE: There are still some remaining issues, especially in the GP
material BKE api. These are noted in comments for now, as it would be
out of scope to address them in this commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/138263
2025-05-02 14:09:53 +02:00
Julian Eisel
58247efc69 Refactor: Assets: Use weak reference comparison to lookup assets
Comparing paths is tricky, especially when different operating systems
are involved, with different slashes, encodings, etc. So often a string
comparison is not good enough. Use asset weak reference comparison for
this case, which performs more careful path comparisons.

Not sure if this makes a difference in practice. But it might solve some subtle
issues, and it makes some more sense semantically. So I think it's worth
trying. Originally I was hoping this would fix #123508, but apparently didn't

Pull Request: https://projects.blender.org/blender/blender/pulls/127685
2025-05-02 13:35:34 +02:00
Jeroen Bakker
098990b172 Fix: Vulkan: Revisited samplers
Implemented the VKSamplers based on the documentation in GPU_texture.hh.
They used to be reversed engineered from the OpenGL backend, however
Vulkan has better control over mipmap filtering and OpenGL needed to
combine some flexibility inside the min/mag filtering.

Changes:
- Mipmap filtering was always on, not only when `GPU_SAMPLER_FILTERING_MIPMAP`
  is used.
- Mipmap filter mode is always set to linear. This is not according to the
  documentation, but matches OpenGL and the render tests.

Fixes #136439, #138111
Partial fix #137436 - seam isn't there, inf can still be part of the
texture.

Pull Request: https://projects.blender.org/blender/blender/pulls/138313
2025-05-02 13:24:06 +02:00
Omar Emara
4cb69dafb0 Compositor: Remove Use Alpha option from Composite and Viewer node
This patch removes the Use Alpha option from Composite and Viewer nodes.
The reasoning for the removal is as follows:

- It has an unintuitive complicated design at the moment.
  - If the Alpha Input is unlinked, the output alpha is not adjusted
    even if Use Alpha is enabled, leaving users wondering why their
    adjustments have no effect.
  - Disabled Use Alpha means output an opaque image, that is, it
    actually means Ignore Alpha. Which is confusing because users might
    think that it controls alpha adjustments based on input.
- It always does alpha replacement without premultiplication, which is
  not clear to the user and is not what the user wants in most cases.
- Adding a Set Alpha node before the output is pretty easy and clear, so
  the option seems redundant considering the above.

Pull Request: https://projects.blender.org/blender/blender/pulls/138309
2025-05-02 12:50:58 +02:00
Jeroen Bakker
d77fb1fb0e Fix #138149: Vulkan: Update descriptor pool sizes
Update descriptor pool sizes to be better for smaller scenes. Creating,
resetting and destroying pools are expensive operations. In smaller
scenes this can lead to lower performance.

The  improvements may differ per platforms or not be visible.

Pull Request: https://projects.blender.org/blender/blender/pulls/138300
2025-05-02 12:42:20 +02:00
Lukas Tönne
deddc6f18c Fix #137913: Grease Pencil: Fallback for looking up material index attribute
The "material_index" attribute is expected to exist by many operations,
but that is not always the case. Using a fallback value prevents crashing
in case the attribute has been removed. A default material is already
supported when the index is not in range of the actual material slots on
an object or grease pencil data block respectively.

Pull Request: https://projects.blender.org/blender/blender/pulls/138303
2025-05-02 12:34:49 +02:00
Philipp Oeser
1a96c310d8 Fix #138272: Camera Ortho Scale adjustment wrong Background Image offset
Wrong since the Overlay Next implementation in ce28af7352

We cannot write to things like `.xy()`, these are for reading only.
Not aware of a version that is for writing, so for now, write to [0] and
[1] separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/138310
2025-05-02 12:05:40 +02:00
Pratik Borhade
68252ef77c Fix #138163: Autokey doesn't work when using trackpad to move locked camera
Navigating with mouse executes the respective modal function where it
handles autokeying the locked camera. But navigating with trackpad just
executes invoke function (for eg: see event_code in `viewrotate_invoke_impl`).
To fix this, Call `ED_view3d_camera_lock_autokey` inside invoke() to handle
autokeying.

Pull Request: https://projects.blender.org/blender/blender/pulls/138179
2025-05-02 11:56:24 +02:00
Pratik Borhade
3aea40b8cd Anim: Bone collection UI changes
Allow assign/select operators to execute when armature tab is pinned.
For assign operators, pinned armature should be active in 3D view
because we cannot assign bones of one armature to the bone collection of
different armature. Added extra condition in poll function to control
the above case.
For select operators, use `ED_armature_context` to obtain pinned Armature.
These operators are now hidden in object modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/137587
2025-05-02 11:52:33 +02:00
Sietse Brouwer
67bec541fa Fix: Grease Pencil: Undo layer drag-and-drop
Reordering layers via drag-and-drop in the layer tree couldn't be
undone. With this patch an undo step is pushed when the layer order
changes via drag-and-drop, so the action can be undone.

Pull Request: https://projects.blender.org/blender/blender/pulls/138214
2025-05-02 11:32:07 +02:00
Sergey Sharybin
806a633609 GPU: Implement blending mode for piercing a hole in alpha
The use-case of this blend mode is to be able to make parts of an
viewport overlay transparent.

The future user of this blend mode is sequencer preview drawing
where frame will be drawn to an HDR render frame-buffer, and overlays
drawn on-top. In a way it is similar to the image engine, but without
need to have custom shader.

Ref #138094

Pull Request: https://projects.blender.org/blender/blender/pulls/138307
2025-05-02 10:40:23 +02:00
Sergey Sharybin
a345c3db64 GPU: Add API to access render frame buffer
Currently unused, but allows areas outside of DRW to render to the
color render and depth texture.

The primary user of this new API will be Sequencer preview to draw
HDR images.

Ref #138094

Pull Request: https://projects.blender.org/blender/blender/pulls/138306
2025-05-02 10:38:28 +02:00
Sergey Sharybin
180770fe3f Draw: Scale checkerboard with pixel size
Solves the problem of checkerboard in the sequencer have much smaller
grid than in the 3D viewport.

Ref #138094

Pull Request: https://projects.blender.org/blender/blender/pulls/138305
2025-05-02 10:36:59 +02:00
Campbell Barton
614f3957fe Cleanup: suppress null-dereference warning
Resolve a theoretical null pointer de-reference. In practice this is
unlikely as the result of `fd->file->read()` would need to fail to read
the requested data from memory.

Also use `UNLIKELY(...)` with checks that the expected amount of data
could be read.
2025-05-02 07:23:54 +00:00
Campbell Barton
f6e3635c1c Fix: potential null pointer de-reference in 2.8x UI versioning
Since it's not guaranteed specific region types exist,
null check before accessing.

Quiet null-dereference warning.
2025-05-02 07:03:12 +00:00
Pratik Borhade
703fce10f9 Fix: Complier warning
Following warning triggered after 6a90382390
`C4312: conversion from 'const uint' to 'const void *' of greater size`
As Jacques mentioned in the chat, do additional casting to resolve the
error.

Pull Request: https://projects.blender.org/blender/blender/pulls/138190
2025-05-02 07:51:30 +02:00
Pratik Borhade
3a3265581b Fix: Code comment about ignoring scale/rotate lock flags in global orientation
After 5f7d5c0809, just translate gizmo is listening to protection flags
in global orientation. Commit doesn't specify the reason behind the
change. It intentionally ignores scale/rotate lock flags in global
orientation. Added a code comment to explicitly mention the reason
behind it.

Resolves #116666

Pull Request: https://projects.blender.org/blender/blender/pulls/133286
2025-05-02 07:01:57 +02:00
Campbell Barton
9eb9493ecd Fix: build error WITH_CYCLES_OSL & GCC 15.1
Ref !138238
2025-05-02 14:22:27 +10:00
Jesse Yurkovich
bf6c847464 Tests: USD: Run the compliance validator for the MaterialX export test
We recently pulled in the upstream patch to address the incorrect
validation error we were experiencing. This was the only test which
previously required the validator to be disabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/138289
2025-05-02 06:19:28 +02:00
Sean Kim
e5e7b6232a UI: Add labels for local and essentials assets in tooltip
This commit changes the asset tooltips for Local and Essential assets to
include a static string indicating their library type.

Related to #138105
2025-05-02 02:16:29 +02:00
Sean Kim
0491c2c233 Fix #136940: brush.asset_save_as crashes in background mode
Calling `brush.asset_save_as` both creates an asset and also activates
the corresponding brush. When run while Blender is in background mode,
the `active_tool->runtime` field may be null. To avoid crashing in this
case, check for null when comparing active tool data.

Pull Request: https://projects.blender.org/blender/blender/pulls/138245
2025-05-02 00:45:06 +02:00
Hans Goudey
20b471e851 Cleanup: Resolve missing declaration warning 2025-05-01 16:05:00 -04:00
Clément Foucault
877abbe9f7 Cleanup: EEVEE: Remove next from EEVEE-Next from tests suite
It makes no sense to keep this suffix now that eevee-next is default.

Pull Request: https://projects.blender.org/blender/blender/pulls/138271
2025-05-01 17:54:22 +02:00
Sietse Brouwer
668aed18e9 Grease Pencil: Viewport option for showing onion skins of the active object only
This PR adds an option to only show the onion skins of the active
object. The option is added to the Grease Pencil overlay menu in the
3D viewport.
When enabled, only the onion skins of the active object are shown.
This keeps the viewport a lot cleaner when working with multiple
Grease Pencil objects.

This resolves #136820.

Pull Request: https://projects.blender.org/blender/blender/pulls/137405
2025-05-01 17:43:17 +02:00
Guillermo Venegas
5e2a856566 UI: Add shortcut to show active sidebar tab
Add a keyboard shortcut  (numpad period) to show the active sidebar
tab, so users can locate the tab without scrolling.

Pull Request: https://projects.blender.org/blender/blender/pulls/107752
2025-05-01 17:32:51 +02:00
Nathan Vegdahl
4e7dfcbe3f Modeling: Add Auto Normalize when Assigning vertex weights
Part of #135062.

This PR adds an Auto Normalize option in the Vertex Group panel that
when checked will normalize the other deform-bone vertex groups' weights
when assigning the weight of a deform-bone vertex group. For example if
a selected vertex has the following weights:

| Name    | Weight |
|---------|--------|
| Group 1 | 0.2    |
| Group 2 | 0.2    |
| Group 3 | 0.6    |

And the user selects Group 3, checks the Auto Normalize checkbox, sets
the weight to 0.8, and clicks Assign, the new weights will be:

| Name    | Weight |
|---------|--------|
| Group 1 | 0.1    |
| Group 2 | 0.1    |
| Group 3 | 0.8    |

Co-authored-by: Andy Beers <acbeers1@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/138133
2025-05-01 16:08:10 +02:00
Jeroen Bakker
41a69b76a6 Partial Fix #129592: Vulkan: Add support for line size
Add-ons can call a batch draw command for lines using a surface shader.
This is not intended and polylines shaders should be used. This PR
lighten this restriction to automatically replace the shader with the
correct polyline shader, similar to immediate mode.

This change is done inside the python wrapper as internally we should
use the correct polyline shader.

For point shaders we don't have a work around in place and that needs
more discussion. Therefore this is only a partial fix.

Pull Request: https://projects.blender.org/blender/blender/pulls/138138
2025-05-01 15:44:40 +02:00
Mattias Fredriksson
b028384749 Cleanup: Pass pointer to get_item_as()
Overloaded version for utility function `get_item_as()` taking a pointer
as an argument (rather then reference) performs type verification,
avoiding the additional manual check.

Pull Request: https://projects.blender.org/blender/blender/pulls/138067
2025-05-01 15:40:14 +02:00
Habib Gahbiche
90ea4f88f3 Refactor: Use test fixtures and C++ style initialization
Initiliaze global context only once per test suite. Test data relevant
to the respective tests is still allocated and freed with every test
case.

Also, `scene->nodetree` will be deprecated in a future PR, so use
`material->nodetree` to test embedded trees instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/137895
2025-05-01 15:37:26 +02:00
Omar Emara
4d0a70f638 Compositor: Remove unused Defocus node options
This patch marks the Preview and Threshold options as deprecated and
removes them from the UI. They have been unused since 4.3.
2025-05-01 15:59:43 +03:00
Omar Emara
a31dcdf5b5 Compositor: Remove Variable Size blur option
This patch removes the Variable Size blur option from the Blur and Bokeh
Blur nodes. So now, whatever the user connects to the size input will be
used, be it variable or constant.

The option previously could be used to force the node to ignore variable
size inputs and assume a size of 1, so it was useless.

Versioning would be difficult, as we don't know if incoming links to the
size input is variable or single. So this is a breaking change. But I
can't think of a real reason why the user might use this option, so this
seems safe from a practical point of view.

Pull Request: https://projects.blender.org/blender/blender/pulls/138261
2025-05-01 14:58:10 +02:00
Pablo Vazquez
bb215a37e2 UI: Keymap: Show alert when operator or property not found
When a keymap operator is not found, color the label and input field
in red. This can help identify issues when migrating preferences and
some operators no longer exist.

Screenshots in the pull request.

Pull Request: https://projects.blender.org/blender/blender/pulls/130675
2025-05-01 14:50:49 +02:00
Philipp Oeser
a5967aae81 Fix #138177: Wrong rearranging channel groups in the Dope Sheet
Similar to !138193

We are going over the `bAnimListElem` nested / multiple times:
- once in `animchannels_rearrange_exec`
- then again in `rearrange_layered_action_channel_groups`

So we are basically just rearranging **multiple times** (unnecessarily
for unrelated actions)

So to resolve, pass the current action to
`rearrange_layered_action_channel_groups`, then skip `bAnimListElem` if
its action does not match the action passed in.

Pull Request: https://projects.blender.org/blender/blender/pulls/138196
2025-05-01 14:20:32 +02:00
Sybren A. Stüvel
781e15671b Fix #138177: Wrong rearranging channel groups in the Dope Sheet
Fix an issue where rearranging animation channels ("Move Up", "Move
Down", etc.) would take multiple steps. This was caused by the Action of
these channels being visited multiple times, and each visit taking a
step.

Pull Request: https://projects.blender.org/blender/blender/pulls/138257
2025-05-01 14:14:37 +02:00
Lukas Tönne
ed93044f70 Fix #138206: Pasting nodes is ignoring offset for frame children
The copy/paste function for nodes is offsetting the node centroid to the
mouse cursor. This was skipping direct children of selected frames, because
the node position was originally relative to the frame parent. This behavior
changed in 4bf34d95, which causes child nodes to remain stuck at their
original location.

All nodes should simply be offset now, since their positions are no longer
relative.

Pull Request: https://projects.blender.org/blender/blender/pulls/138252
2025-05-01 13:41:47 +02:00
Hans Goudey
2894fd79d4 Vulkan: Inline small data conversion function
In a profile of sculpting with the Vulkan GPU backend enabled,
This function made up 0.7% of samples. Since it's just a single
comparison, inlining it should be helpful for the compiler.

Pull Request: https://projects.blender.org/blender/blender/pulls/138210
2025-05-01 13:37:36 +02:00
Campbell Barton
e1e0c041cf Fix: incorrect peak sharpen calculation with the ocean modifier
The initial port [0] incorrectly use `sqrt` where `sqr` was used in the
original code. This mistake was made in two places but the second
causes a significant change in behavior, so this has been left as is
noting the difference in a comment.

Resolve the following issues:

- Use square instead of sqrt when calculating the peak value,
  besides following the original implementation it avoids the result
  being NAN when "Fetch" is below 30.

- Pass in `sqrt(m_omega)` matching the `omega` argument to
  `alpha_beta_spectrum` as well as following the upstream code.

In most cases the user visible changes are subtle.

Ref !137607

Co-authored-by: Nicolas Paris <nicolas.paris490@gmail.com>

[0]: 6ce709dceb
2025-05-01 11:04:45 +00:00
Sybren A. Stüvel
2e0a8ea027 Fix: memory leak when rearranging animation channels
Fix a memory leak when moving animation channels up/down.

Pull Request: https://projects.blender.org/blender/blender/pulls/138256
2025-05-01 12:38:39 +02:00
Philipp Oeser
4c7c26440a Fix #138162: Crash rearranging ungrouped channels the Dope Sheet
This happend to ungrouped channels and in the case other Actions are
also visible in the Dopesheet (e.g. by having multiple objects
selected).

We are going over the `bAnimListElem` nested / twice:
- once in `animchannels_rearrange_exec`
- then again in `rearrange_layered_action_fcurves`

The inner workings are tied to specific actions from the first loop, but
we are going over FCurves possibly contained in **other** actions in the
second loop. Doing this with the "wrong" action goes wrong (e.g. in
`get_group_or_make_fake` where we try to get a channelbag for an FCurve
slot handle in the "wrong" action).

So to resolve, skip `bAnimListElem` if its action does not match the
action passed into `rearrange_layered_action_fcurves`

Pull Request: https://projects.blender.org/blender/blender/pulls/138193
2025-05-01 12:29:35 +02:00
Nathan Vegdahl
30698cf885 Fix #137932: compute correct armature bounds
There were actually two issues here:

1. The dimension reported for armatures were often wildly incorrect,
   including negative values and zero!
2. The dimensions reported for objects are supposed to be invariant with
   rotation, representing the dimensions along the object's local axes.
   However, armature objects' reported dimensions changed with rotation.

The respective causes were:

1. `BKE_armature_min_max()` was using an incorrect formula (acknowledged
   in a comment) for transforming the bounding box between spaces. This
   worked fine for some of the places that `BKE_armature_min_max()` was
   called, since they just reverse the transform using the same(!)
   erroneous formula, but it didn't work for others.
2. `BKE_armature_min_max()` first computed the bounds in world space,
   and then transformed them into object space, rather than computing
   them in object space directly like the respective functions for other
   object types. Even when done correctly, this causes the reported
   dimension to vary with rotation.

This PR fixes these issues by simply computing the armature bounding box
in object space directly instead.

There is one place in the code base that was directly using the
world-space bounds: `view3d_calc_minmax_selected()`. However, for every
object type other than armatures, it takes the object-space bounds and
transforms them (with an incorrect formula!) to world space.  So this PR
also changes `view3d_calc_minmax_selected()`'s armature code to do the
same, except with a correct formula.

Note that the reason for using the correct transform formula (departing
from other object types) is that the world-space bounds for armatures
were already correct prior to this PR due to being computed in that
space. Therefore using the incorrect formula has the potential to
introduce regressions in this case.

Pull Request: https://projects.blender.org/blender/blender/pulls/137961
2025-05-01 12:25:52 +02:00
Sybren A. Stüvel
a3b8ea843c Anim: Add 'unshare' node to driver evaluation dependency graph
Add a new node to the dependency graph, to act as a single entry point
before drivers are evaluated in parallel.

The node will take all the driven RNA properties, and write their
current value to the property again. This ensures that any implicitly
shared data is copied to ensure writability. Subsequent concurrent
writes by the driver evaluation will then be safe, as the
thread-unsafe part has already been performed.

Fixes: #132423

Pull Request: https://projects.blender.org/blender/blender/pulls/135802
2025-05-01 11:49:21 +02:00
Habib Gahbiche
987fc14ada Cleanup: simplify logic in node tree iterator
Return separately for each node tree type.

This patch originally started as a refactor to change the logic of
iterating through compositing node trees but we ended up choosing
a different solution so only the small cleanup part is submitted here.

Pull Request: https://projects.blender.org/blender/blender/pulls/138205
2025-05-01 11:08:13 +02:00
Habib Gahbiche
5c801a7600 Cleanup: Initialize memory of default materials
Pull Request: https://projects.blender.org/blender/blender/pulls/138219
2025-05-01 10:58:24 +02:00
Omar Emara
510130de07 Compositor: Turn Bilateral Blur options to inputs
This patch turns the options of the Bilateral Blur node into inputs.

In the process, the Sigma Space and Iterations were joined into a single
Size input, previously they were just added together then ceiled to get
the blur size. Furthermore, Sigma Color was renamed to threshold and now
represents the average color difference, not the sum, so it was
previously multiplied by 3.

Versioning and RNA compatibility is not perfect due to joining the two
size options.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138249
2025-05-01 09:57:57 +02:00
Jordan Henshaw
10113a119e UI: Add missing periods to Overwrite file dialogue message
The paragraph message in the Overwrite File dialogue is missing periods.
Now added in this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/127953
2025-05-01 08:46:02 +02:00
Sergey Sharybin
d568b78717 GPU: Add immediate drawing of textured rectangle
New function called immRectf_with_texco(), which resides next to the other
immRectf utilities.

Currently used in a single place in the sequencer, but it will be used in
a few other places in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/138222
2025-05-01 08:40:18 +02:00
Jesse Yurkovich
4a0391c4a1 Cleanup: USD: Shrink the USDPrimReader base class
Shrinks the USDPrimReader base class by 24 bytes
- Uses `StringRefNull` in place of a full `string` (prevents additional
  runtime allocations)
- The `prim_path` field is only used sparingly, mostly for tracing, and
  a few non-perf-critical paths. No use keeping it around when it's
  easily, and quickly, accessible through other means.

Pull Request: https://projects.blender.org/blender/blender/pulls/138232
2025-05-01 06:30:55 +02:00
Campbell Barton
2f2d26fc54 Cleanup: use float2 for wmTabletData::tilt & PaintStroke::tilt 2025-05-01 12:51:55 +10:00
Campbell Barton
c3692c7008 Cleanup: use int2 for pointer location & 3D snapping functions
Use the term `mval` as these values are region relative,
which wasn't so clear.
2025-05-01 12:39:46 +10:00
Campbell Barton
bf7d4dca79 Correct error in 229ca9b8f0 2025-05-01 12:18:40 +10:00