Expose existing mask operators as tools in the toolbar.
The primitive tools are commented out since interactively placement
isn't currently supported by the operators.
Ref !136086
Use `BLI_strncpy_utf8` & `BLI_snprintf_utf8` for fixed size buffers in
DNA and screen data structures such as panels, menus & operators.
This could be considered a fix as copying a UTF8 string into a smaller
buffer without proper truncation can create an invalid UTF8 sequence.
However identifying which of these users are likely to run into would
be time consuming and not especially useful.
* Remove bke, ed and wm prefixes
* Add prefixes like: geom, object, blend, lib.
* Shorten some category names
* A few log level changes to improve --log-level info output
Pull Request: https://projects.blender.org/blender/blender/pulls/140244
This commit takes the previously defined `Paint_Runtime` struct and
moves it into the BKE namespace, initializing it on demand instead of it
being a default-allocated member. This data does not need to be
persisted and is runtime only.
Pull Request: https://projects.blender.org/blender/blender/pulls/141413
Follow up to #140668 that fixes the same issue when using multiple
windows & scenes. This is needed as the active tool can apply to
multiple scenes.
Ref !141260
Toggle support for brushes was added back in 4.5 with
9e1e9b0859. The intent of this feature is
to allow for easy switching between a specified brush upon using a
hotkey.
Whils this behavior works well in the case of switching between brushes,
the initial implementation didn't account for using other non-brush
tools.
To fix this issue, when activating a tool, if it doesn't handle brushes,
clear the last active brush.
Pull Request: https://projects.blender.org/blender/blender/pulls/141161
e.g. stands for "exempli gratia" in Latin which means "for example".
The best way to make sure it makes sense when writing is to just expand
it to "for example". In these cases where the text was "for e.g.", that
leaves us with "for for example" which makes no sense. This commit fixes
all 110 cases, mostly just just replacing the words with "for example",
but also restructuring the text a bit more in a few cases, mostly by
moving "e.g." to the beginning of a list in parentheses.
Pull Request: https://projects.blender.org/blender/blender/pulls/139596
For IDProperties, this flag is mostly used only to controll whether
IDProperty code should also handle ID refcounting or not (through
`LIB_ID_CREATE_NO_USER_REFCOUNT`).
Without this fix, IDProp Group Merge could end up trying to modify ID
refcount of its data-block properties (via `IDP_FreeProperty`), which
can lead to data corruption or even crashes (e.g. when used in readfile
code, before lib-linking process).
Issue discovered while working on the system IDProperties split project
(!135807).
Pull Request: https://projects.blender.org/blender/blender/pulls/139230
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
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.
This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.
MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.
NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.
Pull Request: https://projects.blender.org/blender/blender/pulls/135626
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.
* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.
Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.
Following discussions in !134452.
NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.
Pull Request: https://projects.blender.org/blender/blender/pulls/134771
Set sample tool as default for `view` mode of image editor.
Also expanded the condition in `toolsystem_key_ensure_check` so default
tool can be obtained inn view ui_mode.
Pull Request: https://projects.blender.org/blender/blender/pulls/133471
Resolve an error where the brushes from the image/3D viewport
where shared but the tool was not. Causing the brush not to match
the appropriate tool when both an image & 3D viewport were displayed.
Resolve the issue by adding support for a "pending" tool,
a tool ID which is to be used.
This accounts for cases where it's not known if the requested tool
exists and uses the same code paths for initializing tools as is done
for initializing on file load for e.g.
Ref !133085
Better to make sure that these functions operate on the passed in data,
and do not access the current context in some way. Generally that's more
predictable, but also makes sure these functions can be called on
inactive spaces (e.g. to update the active tool in the image editor on
changes in the 3D View, see #131062).
We need to be careful about not just looking up active tool data from
context, because this code path may also be run from the Properties,
which use the tools of the 3D view. So make sure related code falls back
to the 3D view, like it's already done in some other places.
PR #128051 made some improvements to code by cleaning up properties and
simplifying logic.
However, the default tool in most spaces is box select. By switching to
box select default, there should be more front-facing consistency across
spaces while still retaining near-identical behavior.
This patch would fix the small bug listed in #128671 while keeping the
simplified code benefits from #128051.
Also:
- Move selection keymap items up in the Sequencer (Global) keymap so it
is more visible (similar to Node Editor ordering).
- Split `side_of_frame` property for ctrl press keymap item into a
separate keymap item on ctrl click for both LCS and RCS to avoid
clashing with ctrl+drag for box selects in RCS.
Pull Request: https://projects.blender.org/blender/blender/pulls/129028
Second part to fix#128420.
On startup, the Blender File Outliner mode would show empty libraries
linked, pointing to the brush essentials files. This was because some
grease pencil versioning code would call
`BKE_paint_ensure_from_paintmode()`, which would link in the default
brushes. Then a bit later, brush assets versioning code would remove
local brushes from the default starup file, so the library link became
empty.
Initializing paint data shouldn't necessarily include importing default
brushes. In an earlier version I made this optional with a boolean, but
it's easy enough to separate out entirely.
Now `BKE_paint_ensure()` just initializes paint data, and
`BKE_paint_brushes_ensure()` has to be called to ensure that active
brushes are available.
Pull Request: https://projects.blender.org/blender/blender/pulls/128801
As discussed in #128066, we want that activating a brush makes sure the
most appropriate tool is activated. For example activating an eraser
brush should activate an eraser tool, if available. This makes the
tool and brush binding two ways, which is more clear. Plus it means that
users don't have to care about tools at all if they don't want to, they
can just keep switching brushes and Blender takes care of the tool.
Implementation wise, this works by letting a Python operator lookup a
tool for a given brush type name, when activating a brush.
Design Task: https://projects.blender.org/blender/blender/issues/128066
We'd first set the brush, then change tools, which would again set the
brush to what it was before (switching tools tries to remember its last
used brush). Instead, switch the brush after switching the tool.
Also added a brush API check to test if the brush is valid for the
current mode, so that we don't end up switching tools in that case. This
matches previous behavior where this would be checked as part of setting
the brush already, causing the function to early exit before the tool is
changed.
Getting the active tool from context doesn't work exactly when executed
from the properties editor, which shows the active tool settings of the
3D view. Make the brush tool code fallback to the active tool from the
3D view, so it can be called from the properties.
Order of operations was wrong: First, the new tool has to be activated
(or at least identified) before we can tell which tool (or more precise,
which brush type) to update the brush binding for.
Design: https://projects.blender.org/blender/blender/issues/126032
The brush assets project merged all brush based tools into a single, "Brush"
tool. After feedback, we want to bring back some of the previous brush based
tools. For example in grease pencil draw mode, not having an eraser or fill tool
available, and having to go through all the brush assets instead made the
workflow more cumbersome, and features less discoverable (an eraser tool in the
toolbar is quite easy to find, a brush deep down in the asset library may not
be).
With this commit we can add back some tools for specific brush types in sculpt &
paint modes. The follow up commit will start with the eraser and fill tools for
grease pencil draw mode, but more tools in other modes are expected to follow.
For every brush type that has a tool in the toolbar, the last used brush is
remembered. This is the biggest part of the changes here.
Brush asset popups will only show the brushes supported by the active tool for
now. The permanent asset shelf region displays all brushes. Activating a brush
that isn't compatible with the current tool will also activate the general
"Brush" tool, but while the brush tool is active we never switch to another one
(e.g. activating an eraser brush will keep the "Brush" tool active). All this
might change after further feedback.
Pull Request: https://projects.blender.org/blender/blender/pulls/125449
Part of blender/blender!125449.
Since brush assets were merged, the brush asset selector and some other brush
UIs wouldn't show up for the primitive tools. This is addressed now. The
primitive tools use the same brush as the brush tool, although only the draw
brushes will work properly. !125449 addresses this so the primitive tools
remember their own draw brush, separate from the brush tool.
Turns out that these primitive tools were never tagged as using brushes by
setting the `data_block` member (or setting the `'USE_BRUSHES'` option since
b64bf66257). The UI was just hardcoded to display things like the brush selector
for primitive tools. So as far as the tool system knew, these tools did not use
brushes.
Tagging the tools properly exposed some issues that are addressed here (see PR
for details).
Pull Request: https://projects.blender.org/blender/blender/pulls/127204
The previous way of considering tools with the `data_block` member set
as using brushes was rather unclear/confusing, but also a bit outdated
with the brush assets changes. Since then most sculpt/paint modes use a
unified brush tool, there was no tool for every brush type (aka brush
tool) anymore. So now the `data_block` member was just set dynamically to
match the active brush type which is otherwise irrelevant to the tool
system now.
Further, this will become important to bring back some of the tools that
use brushes in grease pencil draw mode, see #116337. For that we want to
keep the unified brush tool, but still allow other tools that only use a
specific brush type. So marking a tool as using brushes should be done
separately from indicating a specific brush type.
Removing/replacing the `data_block` member should happen separately
still, pending further developments (e.g. see #125449).
Pull Request: https://projects.blender.org/blender/blender/pulls/125911
Pass the context using const where it makes sense. Had some own code
that called some of these functions, so I had to keep context non-const
there too for no good reason.
Current default tool is "sample" which is a bit odd, and coupled with
the fact that the toolbar is hidden by default, this can be confusing
to new users, leading them to believe tweak/select tools are not
supported for the VSE preview.
This change:
- Sets "box select" as the default tool for the Preview
- Makes both Preview and Timeline toolbars shown by default
Pull Request: https://projects.blender.org/blender/blender/pulls/126336
Previously, values for `ID.flag` and `ID.tag` used the prefixes `LIB_` and
`LIB_TAG` respectively. This was somewhat confusing because it's not really
related to libraries in general. This patch changes the prefix to `ID_FLAG_` and
`ID_TAG_`. This makes it more obvious what they correspond to, simplifying code.
Pull Request: https://projects.blender.org/blender/blender/pulls/125811
This is the main merge commit of the brush assets project. The previous
commits did some preparing changes, more tweaks are in the following commits.
Also, a lot of the more general work was already merged into the main branch
over the last two years.
With the new design, quite some things can be removed/replaced:
- There's a unified "Brush" tool now, brush based tools and all special
handling is removed.
- Old tool and brush icons are unsed now, and their initialization code
removed here. That means they draw as blank now, and the icon files can be
removed in a follow up.
- Creation of default brushes is unnecessary since brushes are now bundled in
the Essentials asset library. Icons/previews are handled as standard asset
previews.
- Grease pencil eraser options are replaced by a general default eraser brush
that can be set by the user.
More changes are planned still, see task list issue below.
Main Authors: Bastien Montagne, Brecht Van Lommel, Hans Goudey, Julian Eisel
Additionally involved on the design: Dalai Felinto, Julien Kaspar
Blog Post: https://code.blender.org/2024/07/brush-assets-is-out/
Tasks:
https://projects.blender.org/blender/blender/issues/116337
Reviewed incrementally as part of the brush assets project, see:
https://projects.blender.org/blender/blender/pulls/106303
This is used by the brush assets branch. Though it is unused currently, the
argument is added now to reduce the trivial boilerplate changes in the diff.
Adds an (empty) sculpt mode for Grease Pencil v3 objects.
The object `SCULPT_GPENCIL` mode is re-used for Grease Pencil object
types. A `SCULPT_GREASE_PENCIL` context mode has been added, which is
specific to grease pencil objects. This is necessary for polling tools
and keymaps.
Pull Request: https://projects.blender.org/blender/blender/pulls/119338
There are still a few places that are more complicated where the replacement
to `IDP_New` isn't obvious, but this commit replaces most uses of the ugly
`IDPropertyTemplate` usage.