Commit Graph

120055 Commits

Author SHA1 Message Date
Campbell Barton
6d6c695619 Fix: integer overflows calculating the number of pixels in imbuf
Use IMB_get_pixel_count to prevent integer overflow.
2025-04-11 18:52:38 +10:00
Habib Gahbiche
b148593c5d Compositor: implement gizmo for ellipse mask node
Implement ellipse gizmo for the ellipse mask node. Behavior and implementation are similar to the box node with the exception that corners are always visible.

Pull Request: https://projects.blender.org/blender/blender/pulls/137115
2025-04-11 10:32:43 +02:00
Habib Gahbiche
51c2cf2b9d Fix #137268: CTRL+Shift clicking creates additional Material Outputs
Only geometry nodes is allowed to have no active output (the group output node acts as an explicit node tree output). The previous fix only considered geometry nodes and compositor cases, which was not enough.

Pull Request: https://projects.blender.org/blender/blender/pulls/137288
2025-04-11 10:04:56 +02:00
Campbell Barton
d256b7f688 Fix: crash loading & saving large Iris images
Integer overflow in IMB_convert_rgba_to_abgr assigned a negative value
to size_t resulting in a large value which wrote past the buffer bounds.
2025-04-11 17:40:11 +10:00
Campbell Barton
37148d6711 Fix: crash saving large WebP images
WebP images can be at most 16383x16383,
however saving sizes which overflowed an integer would crash.

- Early exit with an error when the image is too large.
- Replace integer offsets with size_t.
2025-04-11 07:33:48 +00:00
Campbell Barton
2cbb07d7ad Fix: error reading RLE compressed Iris images
Regression in [0] which used a 4x large size bounds check
to prevent a buffer read overflow reading the RLE table.

[0]: 829916f4e5
2025-04-11 15:22:17 +10:00
Campbell Barton
d0157b0b70 UI: various minor fixes/changes to file BUTTONS_OT_file_browse
The internal logic for this operator has become broken over time.

- Relative paths could expand using, then be made relative
  using the blend file - but only for directories (not files).
- A trailing slash was added for directories (noted as important),
  but then ignored when the relative option was disabled.

Simplify the logic here:

- Use the same relative path logic for all paths.
- Add the trailing slash for the directory based on the RNA type
  instead of checking if the underlying path is a directory.
- Remove the logic that stripped the file-name off non-directories
  since the file selector doesn't allow a filename to be set
  when selecting a directory.
2025-04-11 14:11:57 +10:00
Campbell Barton
aff2738dc5 PyAPI: match the more verbose identifier for blend-relative paths
Use the more descriptive identifier
when setting the option via `bpy.props`.

Missed this when updating the name elsewhere.
2025-04-11 13:06:51 +10:00
Campbell Barton
024ab180ca UI: hide "Relative Path" in the file selector when it's not supported
Hide the the relative option when browsing paths that don't support
relative paths.
2025-04-11 02:48:24 +00:00
Campbell Barton
e1ac1a71ff RNA: use the file-path subtype & blend relative flag where supported 2025-04-11 12:22:39 +10:00
Campbell Barton
d6825c863f Cleanup: remove redundant PropertyFlag casts which can hide errors 2025-04-11 12:02:07 +10:00
Campbell Barton
b2ee52775a Cleanup: remove invalid ParameterFlag cast to PropertyFlag
Correct invalid mixing of different flag types,
this happened not to cause any problems but it's error prone.

There is no need to set the "required" flag for return values.
2025-04-11 02:01:10 +00:00
Campbell Barton
b4d09517c1 RNA: enable flag the font-directory as relative
Based on it's usage it wasn't clear if this supported a relative prefix.

Enable the flag & add comments clarifying the file-selector
will expand the relative prefix.
2025-04-11 01:08:54 +00:00
Campbell Barton
968f156fae Fix: assert adding relative entries from preferences
Don't add directories with the relative prefix to the FSMenu.
While mostly harmless, causes unnecessary checks on startup
and asserts with debug builds.
2025-04-11 10:43:44 +10:00
Sean Kim
f711010c12 Fix: Brushes incorrectly show gravity as an option when unsupported
Prior to this commit, the set of brushes that ignore the gravity brush
effect and the set of brushes that dim the display of the related
options were mismatched.

Pull Request: https://projects.blender.org/blender/blender/pulls/137309
2025-04-11 02:25:01 +02:00
Campbell Barton
a5d8e5766d RNA: remove sequencer cache directory update function
The update function expanded a relative paths and ensured a slash.

Making "safe" could even change the blend file path,
causing the expanded path not to match the blend file path.

There is no need to treat this path as a special case
which is handled differently from other preferences.
2025-04-11 09:40:48 +10:00
Campbell Barton
ab20edf469 RNA: support flagging properties as support blend file relative prefix
Some paths in Blender support the `//` prefix for blend-file relative
paths however this is not communicated anywhere.

Support declaring this with a new flag which can be applied to filepath
& dirpath typed properties.

This is used to:

- Show red-alert when "//" are used in paths which don't support a relative prefix.
- Show a warning in the tooltip that the relative suffix is used when unsupported.
- Python warns if this prefix is ever used in an assignment or
  function argument.

Resolves #133456.

Ref !137060
2025-04-10 23:27:21 +00:00
Sean Kim
9519f4d028 Cleanup: Clarify & reformat comments in StrokeCache
Pull Request: https://projects.blender.org/blender/blender/pulls/137307
2025-04-11 00:07:37 +02:00
Sean Kim
898e6f3687 Paint: Ensure brushes are loaded when requested while in background mode
Depending on internal details of how Blender is run, attempting to load
elements from the asset library may either execute as synchronous &
blocking or asynchronously.

When executing a script in background mode, prior to this commit,
operators that are dependent on the asset system will not execute
correctly due to the loading not being complete.

Busy-waiting for this by repeatedly calling the operator over and over
again in python does not resolve. To match behavior of other operators
when called from python scripts such as the quadriflow remesh, this
commit changes the `brush.asset_activate` operator and dependent code to
force a blocking call instead of optionally using the wmJob background
abstraction system.

Related to #117399

Pull Request: https://projects.blender.org/blender/blender/pulls/134203
2025-04-10 22:09:06 +02:00
Sean Kim
001b8912ff Cleanup: Consolidate sculpt brush capability checks into BKE_brush.hh
Prior to this commit, whether or not a brush was capable of using
certain options in Sculpt mode and whether or not these properties would
be shown to the user was spread across a number of files and
inconsistently applied.

This commit moves most of these checks to the bke::brush namespace so
that we have a single source of truth for these checks.

In total this commit:
* Changes all BrushCapabilitiesSculpt methods to use the equivalent
  bke::brush function
* Removes brush type macros
* Renames BKE_brush_supports_secondary_color to fit the new pattern
* Refactors inverted logic for the `direction` property

Pull Request: https://projects.blender.org/blender/blender/pulls/137249
2025-04-10 22:05:23 +02:00
Mattias Fredriksson
6f0e814ff9 Curves: Simplified Curve Tangent Evaluation
Simplifies implementation of curve tangent calculation for polylines
and evaluated curves. Loop now re-uses results from previous
iteration and adjusts for 0-length segments in the same loop,
removing need for a conditional extra loop.

Performance gain comes from removing a normalization and difference per
iteration. Curves with 0-length segments can benefit further.
For a single  curve containing 860K points containing 0-length segments
measured improvement was 1.43x (from 33ms to 23ms).

Test does not utilize threading since it's threaded for curves, adding
threading to single/large curves might be better but would require
the current dependency to previous iterations to be removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/137182
2025-04-10 21:21:23 +02:00
Julian Eisel
071a6d4221 UI: Include button type in button comparisons to preserve UI state
Only consider buttons with matching types as matching, when comparing
them between redraws to preserve active button state.

We could have avoided a bunch of issues in the past with this. They are
becoming quite common since we use more spacers and invisible elements
to enable certain behavior. Especially with nodes this caused some issues
recently.

Further code in `ui_but_update_old_active_from_new()` assumed matching
button types resulting in undefined behavior.

Fixes heap-buffer-overflow ASAN crash since 8ec9c62d3e.

Steps to reproduce were:
- Open [emitter-closures.blend](/attachments/e7689016-064c-4390-9f02-c2665b2a6a6b)
- Ctrl+Shift+Click on the header of the "Evaluate Closure" node

Pull Request: https://projects.blender.org/blender/blender/pulls/136943
2025-04-10 20:42:10 +02:00
Jacques Lucke
b92fdff697 Refactor: BLI: use FunctionRef in BLI_uniquename api
This simplifies the API usage, removes the need for intermediate structs
and reduces the overall amount of code.

Pull Request: https://projects.blender.org/blender/blender/pulls/137300
2025-04-10 20:30:45 +02:00
Hans Goudey
9f46f09075 Cleanup: Correct order of forward compatibility mesh versioning
And clarify the comment.
2025-04-10 13:58:43 -04:00
Harley Acheson
a043a0e74d UI: Increase Gizmo 3D Part Hit Size For Pens
Gizmos that contain 3D parts, like the rounded lines of the "Rotate"
gizmo, have a fairly small hit size that make it hard to grab with a
tablet pen. This PR just increases the radius around the pointer
position while using a pen.

Pull Request: https://projects.blender.org/blender/blender/pulls/136847
2025-04-10 18:38:23 +02:00
Hans Goudey
4c38327ea2 Cleanup: Explicitly define default constructor for StrokeCache
This is helpful for #133123 where we want to use std::unique_ptr for
a struct with a definition that's ideally unavailable in sculpt_intern.hh.
Just adding the constructor changes the initialization of the struct,
so I added explicit defaults for the struct's fields.

Pull Request: https://projects.blender.org/blender/blender/pulls/137233
2025-04-10 18:24:04 +02:00
Harley Acheson
14407595ce Fix #137218: Make All Tabs Visible for New Properties Area
With commit bf18e8f814 the Properties editor can filter categories.
There is versioning code to ensure that any existing areas show all by
default. But newly-created Properties areas start without any. For
example, start with Factory Settings and then change the 3D Viewport to
a Properties editor and it will be blank. I'm assuming this is not
intended behavior so this PR makes new editors start with all tabs
shown.

Pull Request: https://projects.blender.org/blender/blender/pulls/137237
2025-04-10 17:56:45 +02:00
Jeroen Bakker
3da222cb9a Vulkan/OpenXR: Direct3D Bridge
Some OpenXR platforms do not support OpenGL or Vulkan. To support these
platforms we use a bridge. Blender still renders in OpenGL/Vulkan, but
will copy the render result into a D3D11 swapchain.

OpenGL doesn this by importing the D3D11 swapchain into the OpenGL
context and perfor OpenGL calls to update the swapchain. However for
vulkan that could lead to construct 3 context for OpenXR

- Blender GPU Context
- OpenXR D3D Context
- New context that imports the Blender render result and the OpenXR
  Swapchain image and copies them.

Due to Direct3D limitations importing into a vulkan context has known
issues (driver + extensions). Secondly we are not sure if we are running
on the same device as the OpenXR swapchain. The solution provided with
this PR is to only support CPU data transfers.

**SteamVR using d3d bridge**

SteamVR normally would use the Vulkan binding. But by changing the binding
priority in code you can make it select the D3D bridge.

<img width="1518" alt="Screenshot 2025-04-10 114534.png" src="attachments/f856bb2b-9ad5-4bb2-9cfd-a1412da9edd1">

It has been tested and validated to work using Mixed reality portal as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/137264
2025-04-10 16:15:27 +02:00
Falk David
d0cf7df902 Fix: Geometry Nodes: Avoid recomputation of evaluated gizmo node ids
The `GeoTreeLog::ensure_evaluated_gizmo_nodes()` reran the iteration
over the tree loggers to add the node ids for the evaluated gizmo.

This wasn't an issue because `GeoTreeLog::evaluated_gizmo_nodes` is
a set, so nothing changed when trying to re-add the same ids.

This sets `reduced_evaluated_gizmo_nodes_` to `true` (probably an
oversight when this got added) so that the function returns early when
called again.
2025-04-10 14:52:19 +02:00
Brady Johnston
32b26e62ce Geometry Nodes: Hide "Group ID" value in Accumulate Field node
The `Group ID` input on every node is a hidden value except for the
Accumulate Field node. This patch just hides that value to bring it
inline with the other nodes, as different single values are meaningless.

Pull Request: https://projects.blender.org/blender/blender/pulls/137160
2025-04-10 14:30:44 +02:00
quackarooni
93f7c40fd0 Cleanup: Use std::move and std::nullopt in Accumulate Field Node
The nodes from #134640 were initially built off the Accumulate Field node.
During review for those nodes, certain changes to the code were suggested.

This patch applies the same changes to Accumulate Field node.
These changes namely being:
- Use `std::move` for field inputs
- Use `std::nullopt` as default for `node_type_from_other_socket`

Pull Request: https://projects.blender.org/blender/blender/pulls/137209
2025-04-10 14:29:19 +02:00
Jeroen Bakker
b65b6febb9 Fix: Vulkan/OpenXR: Use correct data format for CPU transfers
Incorrect data format was selected when using CPU data transfers in
OpenXR. It always used `GPU_DATA_HALF_FLOAT`, also when the swapchains
where `GPU_RGBA8`. This resulted in black screens in release mode, and
asserts in debud mode.

Fixed by selecting the correct data transfer data type based on the
swapchain format.

Co-authored-by: jeroen@blender.org <Jeroen Bakker>
Pull Request: https://projects.blender.org/blender/blender/pulls/137269
2025-04-10 14:22:55 +02:00
Falk David
afc3ae623c Fix: Geometry Nodes: Attribute search not working for Grease Pencil drawings
The attribute search for e.g the attribute name input in
the `Store Named Attribute` node did not list attributes
inside Grease Pencil drawings (curve and point domain).

The fix ensures that for the `GeometryComponent::Type::GreasePencil`
we also iterate over the attributes of each evaluated drawing.

Pull Request: https://projects.blender.org/blender/blender/pulls/137267
2025-04-10 14:16:22 +02:00
Brecht Van Lommel
1e49a7e135 Fix #137197: Grease pencil duplicating materials on custom brushes
Always compare absolute file paths.

Pull Request: https://projects.blender.org/blender/blender/pulls/137229
2025-04-10 13:06:27 +02:00
Brecht Van Lommel
7aaa43b557 Revert "Fix: Build failures when using path with spaces on macOS"
This reverts commit be63ebd961.

This doesn't work well with MSBuild, semicolons get escaped even in
verbatim mode.
2025-04-10 13:04:34 +02:00
Falk David
62062c7915 Fix #137227: Grease Pencil: Crash when getting multi frame falloff
One of the calls to get the frame falloff was missing a
check for `use_multi_frame_falloff`.

This puts the conditions for when the multi frame falloff
needs to be calculated in the `get_frame_falloff` function.
That fixes the crash and makes a code a bit easier to read
(without ternary operator).

Pull Request: https://projects.blender.org/blender/blender/pulls/137259
2025-04-10 12:21:52 +02:00
Julian Eisel
4f965e4d38 Fix #136254: Assets not available in search after saving file
We'd rather aggressively clear asset lists on file save since 9a9e2e19a9 (and
some related commits), seems like we can be a bit more precise here. Only
reload assets from the current file when saving the file, which is quite fast
to do and doesn't happen asynchronously (so UIs showing assets will only show
up once the assets are ready).

Actually we might not have to clear on file save at all, but needs more
testing.

Also fixes disappearing of asset previews on file save.

Pull Request: https://projects.blender.org/blender/blender/pulls/137117
2025-04-10 11:31:46 +02:00
YimingWu
79c6f2eacf Grease Pencil: Use smooth brush setting when smoothing temporarily
When sculpting a grease pencil object, user can hold `Shift` key to
temporarily switch to smooth brush. Previously it will keep using
whatever brush settings from the original brush for smoothing, which is
not ideal, now it will switch to the actual smooth brush but only keep
the radius the same.

The implementation is largely the same as `smooth_brush_toggle_on` from
`sculpt.cc`, brush is changed and restored in `on_stroke_begin/end`.

Part of #136300

Pull Request: https://projects.blender.org/blender/blender/pulls/136827
2025-04-10 11:28:34 +02:00
Jacques Lucke
dcc8d28859 Refactor: Geometry Nodes: store tree identifier in tree logger
The main goal here is to add `GeoTreeLogger.tree_orig_session_uid`. Previously,
it was always possible to derive this information in `ensure_node_warnings`.
However, with closures that's not possible in general anymore, because the
Evaluate Closure node does not know statically which node tree the closure zone
is from that it evaluates. Therefore, this information has to be logged as well.

This patch initializes `tree_orig_session_uid` the same way it initializes
`parent_node_id`, by scanning the compute context when creating the tree logger.
To make this work properly, some extra contextual data had to be stored in some
compute contexts.

This is just a refactor with no expected functional changes. Node warnings for
closures are still not properly logged, because that requires storing
source-location data in closures, which will be implemented separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/137208
2025-04-10 08:56:02 +02:00
Jeroen Bakker
a564a27c1f Cleanup: OpenXR: Introduce a Direct3D base class.
For the Vulkan/OpenXR code will be shared with the OpenGL-Direct3D
bridge. This cleanup separates the OpenGL specifics in its own class.

Pull Request: https://projects.blender.org/blender/blender/pulls/137252
2025-04-10 08:50:52 +02:00
Campbell Barton
39db404ba4 Fix: resetting/clearing the filename skipped validation
The logic to add a file extension to the filename - which runs when
editing the text was not running when resetting/clearing the value.

Resolve by calling `uiBut::func`.

Along with [0], this fixes #134101.

[0]: f2a1c8d77c
2025-04-10 04:20:53 +00:00
Sean Kim
98fa6927d8 Cleanup: Various non-functional changes to paint cursor drawing methods
* Uses C++ math functions and types where possible
* Uses const where possible
* Reduces scope of variables where possible

Pull Request: https://projects.blender.org/blender/blender/pulls/137239
2025-04-10 05:39:34 +02:00
Sean Kim
7a4052e561 Cleanup: Reorganize rna_brush.cc capability section
* Groups related capabilities together
* Also adds a missing undef

Pull Request: https://projects.blender.org/blender/blender/pulls/137241
2025-04-10 05:39:06 +02:00
Campbell Barton
b2dbfa7d77 Cleanup: spelling in comments, use doxygen comments 2025-04-10 13:02:29 +10:00
Harley Acheson
2f6a10c75e Fix #137186: Allow Event Handling When Cursor Outside Wide Menus
When a wide menu is open and you move your mouse outside of it we have
new code that prevents the immediate opening of neighboring menus. But
while in this condition of mouse outside the menu, the rest of the
event processing is not run, so pressing "escape" will not close it.
This PR just moves the conditions around so event handling always
continues unless another menu is opened.

Pull Request: https://projects.blender.org/blender/blender/pulls/137243
2025-04-10 04:06:21 +02:00
Campbell Barton
94aabc0dbe Versioning: ensure render slot names are valid UTF8
Also include pixel density which missed a version bump.
2025-04-10 01:47:11 +00:00
Campbell Barton
c70b48aae2 Fix: new render slots could contain truncated UTF8 byte sequences
Creating render slots from Python could truncate multi-byte sequences
which would then raise an exception when accessed.
2025-04-10 11:41:49 +10:00
Campbell Barton
4bd7706099 Fix: error report writing image that displayed "Success"
Failure to write an image that didn't set `errno` reported:

"Could not write image: Success"

Check errno is non-zero before using it's message,
ideally error prints would be shown here.
2025-04-10 01:01:35 +00:00
Campbell Barton
24f8819c78 Fix: correct check for Iris image dimensions
Mistake in [0], missed width check.

[0]: 7a23d7aba4
2025-04-10 10:50:10 +10:00
Sean Kim
4a97a807e5 Cleanup: Various non-functional changes to PaintCursorContext struct
* Use C++ math container types instead of arrays
* Use enum class instead of enum
* Use references instead of pointer for PainCursorContext
* Add a few comments

Pull Request: https://projects.blender.org/blender/blender/pulls/137235
2025-04-10 00:47:35 +02:00