4 Commits

Author SHA1 Message Date
Sean Kim
ab3c129dd9 Refactor: Paint: Rename brush _tool properties to _brush_type
This commit renames the python Brush properties that end with `_tool` to
`_brush_type` (e.g. `sculpt_tool` -> `sculpt_brush_type`) to better
distinguish the property from the concept of tools in a workspace
context.

Resolves #124201

Pull Request: https://projects.blender.org/blender/blender/pulls/139909
2025-06-06 23:40:13 +02:00
Sean Kim
4ecde8dc53 Paint: Allow duplicating essential brushes into current file
With the release of the brush assets project in 4.3, most brush
management moved out of the current .blend file into either the
essentials library or user-created libraries.

With this change, a number of workflows became more difficult:
* Handling a large library of texture and texture properties for brushes
  due to ID linkage constraints.
* Having local tweaks to a brush without bloating the the asset library
  and reducing discoverability.

This commit introduces an intermediate step to assist with both of the
preceding pain points. The `brush.asset_save_as` operator is extended
to allow saving into the current blend file via the `Duplicate Asset`
context menu entry.

Additionally, these features help ease authoring brush assets in general
from the UI instead of requiring manual datablock management.

This allows brushes to be stored alongside other data inside a specific
blend file.

Related to #129655 and [1].

[1] https://blender.community/c/rightclickselect/XYMA/

Pull Request: https://projects.blender.org/blender/blender/pulls/138105
2025-05-20 22:02:42 +02:00
Sean Kim
9e1e9b0859 Paint: Add toggle support for brush.asset_activate
This commit adds a toggle functionality to the `brush.asset_activate`
operator that makes it behave similarly to the `paint.brush_select`
parameter of the same name.

When the operator has this option enabled, using the operator or
pressing the relevant key will either:
* Activate the specified brush and store it if the current brush does
  not match the specified brush
* Activate the previously stored brush if it exists.

This option is exposed in the keymaps and enabled by default for the
Sculpt Mask brush.

This allows, for example, users to press 'M' to switch to the mask brush
and then press 'M' again to switch back to their previously active
brush.

Partially addresses this RCS submission: [1]
[1] https://blender.community/c/rightclickselect/1VwZ/

---

### Notes
This commit does not currently clear the `AssetWeakReference` when switching paint modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/138845
2025-05-16 23:25:45 +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