WIP: Brush assets project #106303

Draft
Julian Eisel wants to merge 240 commits from brush-assets-project into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Tasks: #116337

This includes changes from multiple branches that are worked on as part of the brush assets project, see #101895.

At this point the main component is:

  • Core changes to support brush assets as by design: #116338
Tasks: #116337 This includes changes from multiple branches that are worked on as part of the brush assets project, see #101895. At this point the main component is: - Core changes to support brush assets as by design: #116338
Julian Eisel added 125 commits 2023-03-30 12:54:12 +02:00
33bcc4f430 Initial "All" asset library loading support
An "All" asset library can be selected in the Asset Browser and asset
view templates now, and that will load all assets from all asset
libraries. Preview loading, drag & drop and asset catalogs don't work
yet.
d51212c4f0 Integrate "All" library better with the asset system
Now it actually loads data from all asset libraries when this is
selected. The asset representations still need to be loaded by the file
browser backend, this won't change for now.

This adds the concept of nested asset libraries, which I'd prefer to
keep as implementation detail and not expose in the API. But for now
it's needed (for the asset representation loading by the file browser
backend).
126136baab Fix missing asset previews and broken drag & drop in "All" library
Together with the changes made in master, all this does is making sure
the assets are loaded and removed using the correct asset library nested
within the "All" library. Now full paths for the assets can be built
correctly from the asset identifier, which fixes preview loading and
drag & drop.
fb2303fb73 Avoid ugly nested library storage
We actually don't have to do this, since we can just iterate over all
loaded libraries after calling the loading for the "All" asset library.
af5d225653 Load catalogs for "All" asset library
Merges the catalog definitions from all asset libraries in to the
storage of the "All" one, builds the catalog tree and refreshes data as
needed. This doesn't allow writing changes back to the catalog
definition files, so the UI probably shouldn't allow edits.
ecc25bc62e Use "All" library for node add menu building
Code was manually building the add menu from all asset libraries, this
should be simpler now.
11abc1be39 Use "All" library for node search menu building
Code was manually building the search menu items from all asset
libraries, this is simpler now.
747a9ea263 Make catalogs from "All" library read-only
Loading the asset library will create a read-only catalog service. The
read-only nature is not dealt with much in the asset catalog code, the
using code (e.g. the UI) is responsible for respecting it.
3cd93ace24 Simple progress reporting for all library
Progress bar display the file reading (and other operations) is actually
broken in master for a while, so this won't actually be reported. Still
calculate it for once it's fixed.
8ddf492e7c Basic asset shelf prototype
Adds the necessary bits to be able to show an asset shelf template via
the pose library add-on.
b3ee7ad2cc Extend asset shelf region with a region for the catalogs & options
The new region is empty, except of a dummy button.
4fa69fbda8 Popup to select which catalogs are displayed in the asset shelf footer
The selected catalogs are currently listed as simple labels in the
footer, just for testing.
b4edc40fb8 UI: Make uiBut safe for non-trivial construction
Essentially, I wanted to use a non-trivially-constructible C++ type
(`std::function`) inside `uiBut`. But this would mean we can't use
`MEM_cnew()` like allocation anymore.

Rather than writing worse code, allow non-trivial construction for
`uiBut`. Member-initializing all members is annoying since there are so
many, but rather safe than sorry. As we use more C++ types (e.g. convert
callbacks to use `std::function`), this should become less since they
initialize properly on default construction.

Also use proper C++ inheritance for `uiBut` subtypes, the old way to
allocate based on size isn't working anymore.

Differential Revision: https://developer.blender.org/D17164
d5c60f912f Tabs to activate a catalog
The tabs should be fully working themselves, however we don't filter
the asset shelf contents based on the active catalog (well, catalog
path) yet.

Includes the changes from D17164.
buildbot/vexp-code-patch-coordinator Build done. Details
8b9db43ca0
Merge branch 'main' into asset-shelf
dcb1147eef Basic support for registering asset shelf as a type in BPY
For example, the pose library add-on can now register an asset shelf
like this:

```
class VIEW3D_AST_pose_library(bpy.types.AssetShelf):
    bl_space_type = "VIEW_3D"

    @classmethod
    def poll(cls, context: Context) -> bool:
        return PoseLibraryPanel.poll(context)
```

Filtering by ID type is not supported yet.

This replaces the hack of registering a header type and the asset shelf
template to draw into that.
ac17d02993 Nodes: Allow adding multiple search items per type in add menu
Add a per node type callback for creating node add search operations,
similar to the way link drag search is implemented (11be151d58).

Currently the searchable strings have to be separate items in the list.
In a separate step, we can look into adding invisible searchable text
to search items if that's still necessary.

Resolves #102118

Pull Request #104794
8ff42046ab Fix #82936: Make Geometry Nodes modifier icon blue in outliner
In the outliner, the icons for modifiers are tinted blue. This didn't
work for the geometry nodes modifier icon.

Defining the icon with the macro `DEF_ICON_MODIFIER` also
defines the appropriate theme color so it's now tinted blue
when drawn in the outliner like the other modifier icons.

Pull Request #104957
5de924a656 Fix test
Pull Request #104934
b3a5c8df62 BMesh: fix invalid existence check in BM_mesh_bm_to_me
Remember that the null customdata layer index is -1,
not 0.
8f2a9bc116 Sculpt: Implement mesh filter cancel
Added new function sculpt_mesh_filter_cancel in sculpt_filter_mesh.cc
for cancelling mesh filters. It currently is unused pending a
revamped modal map for mesh filter (see pull req 104718).
615958c449 Tests: Add tests for image format saving and loading
This adds saving and loading tests for our supported image formats.

**Saving - bf_imbuf_save.py**
There are 2 template images which are loaded anew for each file save
attempt.  One is an 8-bit RGBA image and the other 32-bit. This is
required as many formats use a variety of factors to determine which of
`ibuf->rect` or `ibuf->rectfloat` to use for processing.  The templates
are constructed to have alpha transparency as well as values > 1 (or
clamped to 1 for the case of the 8-bit template).

Test flow:
 - Load in an appropriate template image
 - Save it to the desired format with the desired set of options
 - Compare against the reference image

Notes:
 - 98 references are used totaling ~3.6MB
 - 10-12 second test runtime
 - Templates can be reconstructed with the create-templates.blend file

**Loading - bf_imbuf_load.py**
Test flow:
 - Load in each of the reference images
 - Save them back out as .exr
 - Save additional metadata to a secondary file (alpha mode, colorspace etc)
 - Compare the saved out .exr with another set of reference .exrs
 - Compare the saved out file metadata with set of reference metadata

Notes:
 - 98 exr references are used totaling ~10MB
 - 10-12 second test runtime as well

A HTML report is not implemented. The diff output organization is very
similar to the other tests so it should be somewhat easy to do in the
future if we want.

The standard set of environment variables are implemented for both:
BLENDER_TEST_UPDATE, BLENDER_VERBOSE, and BLENDER_TEST_COLOR

Pull Request #104442
57705d9f98 Tests: Address imbuf_save failures on ARM64 builds
This does 2 things to address the ARM64 failures:
- Increases the threshold to be inline with what Cycles uses
- Disables the 2 problematic WebP variations (#105006 will track)
ffebf8685f Fix: Channel clamping when markers are used
Previously when markers were used, the newly introduced clamping code (#104516) would stop the last channel from being shown.

This patch fixes that by modifying the `v2d->tot.ymin` calculation.

This is a bit counterintuitive since the `v2d->tot` height is calculated in `action_draw.c`. But the advantage of doing it there is that it also works for the channels region.

Pull Request #104892
37a2e81747 Fix #104979: GPencil Dot-hash only affects first frame with Time mod
The active frame must be recovered using `BKE_gpencil_frame_retime_get`
7fe04f68a0 Cleanup: Mark overriden virtual call as such
Fixes the `-Winconsistent-missing-override` warning.

In theory the `virtual` is redundant in such case, but this is how
it is done in may other areas of USD code.

Pull Request #104977
2d8b1455bc Curves: Fix proportional editing not working
This adds proper support for proportional editing for the Curves object.

Co-authored-by: Hans Goudey <h.goudey@me.com>
Pull Request #104620
b6a2d0cebd Curves: Add cursor snapping support
This adds support for cursor snapping for the new curves object.

It implements a function `transverts_from_curves_positions_create` (to separate the logic from the `Curves` object type). That function is then C wrapped by `ED_curves_transverts_create` and finally used in `ED_transverts_create_from_obedit`.

Pull Request #104967
de27f63ac4 Brush: Add writing and reading ID preview for Brushes.
Mandatory change for the Brush Assets project, from quick test does not
seem to break anything (more) in existing 'old' brushes...

Re. #101908.

Pull Request #105016
2cbf647d9c Temporary design to support filtering assets by type
Python defined asset shelfs can now define an `asset_poll__()` function
to determine if an asset should be visible or not, based on type
information. This isn't great and can probably be a performance issue in
bigger libraries. A proper solution would be to provide a set of asset
traits to filter by, but this is a bit tricky to implement. This is a
temporary solution so the brush assets project isn't held up by this.
62af85aed4 Split asset shelf file into multiple files
Makes code more focused, improving local readability.
54b6b8660a Fix error in asset weak reference move constructor
I thought the tests passed, what did I doo??..
buildbot/vexp-code-patch-coordinator Build done. Details
819933cc2e
Cleanup: struct member order
buildbot/vexp-code-patch-coordinator Build done. Details
3e844fb2dc
Attempt to fix linker error on GCC
693be95b2d Some refactoring for function to resolve to an exploded path
- Use (arguably) more readable return type instead of return arguments.
- Update function API comment.
- Use more clear (because more direct) return values
buildbot/vexp-code-patch-coordinator Build done. Details
974ebe4864
Merge branch 'main' into temp-asset-weak-reference
buildbot/vexp-code-patch-coordinator Build done. Details
ce2ef6b9cc
Merge branch 'main' into temp-asset-weak-reference
buildbot/vexp-code-patch-coordinator Build done. Details
4710dc0337
Fix test failure on macOS because of short string optimization of moved result
Since we pass around a struct with a string, and multiple string-references
into this string, we have to make sure the memory address of the string buffer
never changes. It would seem that move semantics give this behavior, but it
wouldn't work for short strings. When moving a string, short string
optimization would still require the string to be copied, not moved, causing a
change in the memory address. GCC and Clang use different definitions of "short
string", causing differences in behavior.

Wrap the string in a unique pointer, so the string itself is never moved or
copied.
buildbot/vexp-code-patch-coordinator Build done. Details
e27067d7ac
Attempt to fix normilizing ID name part of paths.
buildbot/vexp-code-patch-coordinator Build done. Details
ba73275532
Further fixes to path handling.
debug prints are intended for now.
buildbot/vexp-code-patch-coordinator Build done. Details
3dc872af0e
More fixes.
buildbot/vexp-code-patch-coordinator Build done. Details
e8bd93685b
Cleanup.
Bastien Montagne added 2 commits 2023-03-30 18:42:53 +02:00
Bastien Montagne added 1 commit 2023-04-01 20:21:48 +02:00
Bastien Montagne added 1 commit 2023-04-03 16:05:30 +02:00
Julian Eisel added 3 commits 2023-04-06 12:11:42 +02:00
Bastien Montagne added 5 commits 2023-04-07 14:35:59 +02:00
Bastien Montagne added 1 commit 2023-04-07 16:06:14 +02:00
Bastien Montagne added 3 commits 2023-04-12 15:18:55 +02:00
Bastien Montagne added 1 commit 2023-04-12 16:26:45 +02:00
Julian Eisel added 3 commits 2023-04-13 15:58:28 +02:00
Julian Eisel added 1 commit 2023-04-14 12:02:47 +02:00
Julian Eisel added 1 commit 2023-04-14 12:51:32 +02:00
Bastien Montagne added 1 commit 2023-04-18 11:19:43 +02:00
Bastien Montagne added 1 commit 2023-04-20 11:40:45 +02:00
Bastien Montagne added 1 commit 2023-04-21 11:04:19 +02:00
Julian Eisel added 12 commits 2023-05-17 11:39:17 +02:00
Julian Eisel added 65 commits 2023-05-17 23:32:44 +02:00
50292f1018 Use grid-view for the asset shelf
This is the main change needed to properly implement the asset shelf
main region. Loading, displaying, catalog based and type based filtering
work, custom drag & activation operators don't yet. There is no
paginated scrolling or so yet, but scrolling is vertical now (to be
evaulated).
b35dd323c3 Remove unnecessary & problematic header layout changes
Was only needed for the old asset shelf main region implementation, and
caused some issues (e.g. too small buttons in status bar).
0a742fd749 Reduce size of asset shelf footer/header a bit
A bit more space efficient this way, and looks better IMO.
040ecfa45f Use fixed width for grid-view items, don't stretch to full width
This just makes the UI feel more "stable" since things don't move around
as much anymore.
486ff75da7 Improve how default size is set
Set the default size later as part of regular area/region setup, when
DPI is available. Also use `uiStyle` paddings.
c3b36345c7 Basic paginated vertical scrolling
This means the view always scrolls by a full row, so that asset previews
are never partially in view.

The paginated scrolling is implemented as a standard View2D feature.
This doesn't work well with zooming yet, and it's tricky to get that to
work right.
e635ee1188 Disable region zooming
We want to support different preview sizes, but the regular region
zooming makes things overly complicated (because of the pagination
and region size snapping mostly). Plus region zooming would usually zoom
text as well. So the preview size is better managed separately.
9ef337ba95 Fix offset in region scaling hotspot
An offset was applied for transparent regions, so the hotspot is closer
to where the user expects (closer to the visual content). But this only
makes sense if the background is actually transparent or close to at
least.
a0a13c78c1 Disable transparency for asset shelf regions
Feedback is that this looks a bit odd, so rather keep it disabled.
157cc9b171 Turn catalog selector popup into popover, for consistency
Enables the triangle showing this popup was spawned from a button, uses
more padding (consistent with other popovers) and simplifies code.
ed2f8731f3 Enable item mouse hover highlight for the catalog selector popover
View items now always display mouse hover highlight, regardless of the
embossing (might want to give more precise control for this though).

- Made the active state of items visible, so had to add a way to disable
  that.
- Had to make the view item mouse hover highlight work in popups.
34b33dee07 Fix: Applying pose through redo last operation not working
AFAIK this doesn't work in master either. Issue is that the operator
relies on context that is only available in the asset shelf region (or
with the mouse over the asset-view template). So the correct region has
to be restored for redo to make this work.
buildbot/vexp-code-patch-coordinator Build done. Details
1fd5097d03
Fix possible crash on file read
Bastien Montagne added 7 commits 2023-05-19 17:56:22 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
67db4448de
Make overriding asset drag for pose blending work
Adds a `bl_option` to asset shelf type definitions to disable the
default asset dragging (`NO_ASSET_DRAG`), so the drag event can be
overridden by custom keymap items.
3e70549e70 Add context menu to asset shelf
In the Python asset shelf type definition, a `draw_context_menu()`
function can be defined now.
buildbot/vexp-code-patch-coordinator Build done. Details
4d1752fa81
Update version bump after changes in main
buildbot/vexp-code-patch-coordinator Build done. Details
61482f9c6d
Add toggle for asset shelf to View menu
Julian Eisel added 4 commits 2023-05-22 17:04:39 +02:00
85575edb11 Make shelf settings instance based
It's now possible to have multiple asset shelf types registered for
different contexts (e.g. sculpt mode vs. texture paint mode vs. pose
mode) and the settings are kept separate. For this a proper concept of
an active asset shelf is introduced. Basically only one asset shelf can
be active at a time, but we keep multiple shelves in storage, so we can
switch between them while all settings are preserved.
c2e0623ad1 Add an asset shelf for brushes in sculpt mode (experimental)
Only shows up when both the "Asset Shelf" and the "Extended Asset
Browser" experimental features are enabled.
buildbot/vexp-code-patch-coordinator Build done. Details
c12ac8bef6
Merge branch 'main' into asset-shelf
Julian Eisel added 3 commits 2023-05-31 17:07:21 +02:00
Julian Eisel added 1 commit 2023-06-05 15:40:20 +02:00
Bastien Montagne added 12 commits 2023-06-08 16:15:51 +02:00
Julian Eisel added 2 commits 2023-06-08 17:42:34 +02:00
Julian Eisel added 21 commits 2023-06-15 16:21:52 +02:00
a8450121d1 UI: Correct default width of toolbars
Correct default initial widths of toolbars

Pull Request: #108292
cbcc807289 Asset system: Add public functions for asset identifier query
No user visible changes expected.

This is needed in #104831 but makes sense to expose publicly in the
asset system APIs either way. So committing this to the main branch
already.
e8a89e6eca Only enable filtering on Ctrl+F to hovered view
Previously this allowed looking up a view to filter in in any region of
the current area, so Ctrl+F from the asset shelf footer would be
possible. However in own experiments this didn't really add much, so
rather keeping it simple now.
327bed9477 Remove changes from #108892
This is handled in a separate PR now.
Julian Eisel added 15 commits 2023-06-20 12:23:48 +02:00
86b2cf4574 UI: Add type-safe C++ button apply function object
No user visible changes expected.

Rather than relying on a C-style function pointer with void pointer
arguments, allow storing a `std::function` object, which can hold
arbitrary data in a type safe way. This can be conveniently used with
lambdas, e.g. from #104831:
```
UI_but_func_set(but, [&shelf_settings](bContext &C) {
  shelf::settings_set_all_catalog_active(shelf_settings);
  shelf::send_redraw_notifier(C);
});
```

This is not used yet, but will be with #104831 merged. Replacing the
existing C-style callback with this can be done separately.
0e3a77fdc0 Avoid paranoid explicit 0 initialization
Rather assert that these are initialized as expected.
165f73103d Refactor: draw fcurve bezt function
No functional changes

In preparation to tackle the following 2 Todos
*  TODO: view scale should factor into this someday too...
* TODO: optimize this to not have to calc stuff out of view too?

I did the following cleanup
* extracted drawing code for `BEZT_IPO_BEZ` into a separate function
* extracted code that calculates the resolution between 2 points into a separate function
* cleaned up comments
* renamed variables to have a more telling name
* moved variables closer to where they are used
* added `const` where possible

Pull Request: #108748
1a2b54eb58 Update rna additions to compile in C++
These RNA files are now compiled in C++, some adjustments were
necessary.
Julian Eisel added 3 commits 2023-06-26 18:00:53 +02:00
Julian Eisel added 5 commits 2023-07-05 17:03:39 +02:00
Julian Eisel added 22 commits 2023-07-13 15:05:11 +02:00
c81fd2cb6c Make asset shelf use full area width, cut into sidbar/toobar
Going a bit back and forth here, but in latest tests we've decided to
try this again.
buildbot/vexp-code-patch-coordinator Build done. Details
1a809193d5
Uncollapse root level catalogs in the catalog selector
01e3f76b9f UI: Make grid view visible items calculations more stable
No user visible changes expected.

Previously the calculations to skip building the layout for invisible
items used the scrolling offsets quite a bit. These require floating
point math and are managed in other code. So better to minimize use of
this to make code locally more clear & reliable.
Julian Eisel added 1 commit 2023-07-17 11:37:24 +02:00
Bastien Montagne force-pushed brush-assets-project from f6cff26977 to ab0cf3e4a3 2023-09-08 14:37:45 +02:00 Compare
Bastien Montagne force-pushed brush-assets-project from ab0cf3e4a3 to 0c95e0e627 2023-09-08 14:41:03 +02:00 Compare
Bastien Montagne added 3 commits 2023-11-09 12:20:07 +01:00
477bb662d7 Brush Assets: Add initial support for the new 'brush asset' usage.
This commit mainly adds the low-level logic to link and create a runtime
override for brushes.

The biggest changes are in `setup_app_data` (post-loading of .blend
file), to add support to move over some data from old bmain to newly
loaded bmain. The logic is complex, and different depending on whether
it is an undo (aka memfile read) step, or an actual .blend file reading:
* On undo, we only port over brushes themselves, their dependencies are
  not handled. However, since memfile reading code already ported over
  linked IDs, these do not need to be swapped.
* On real .blend file loading, brushes from the old bmain are being
  reused, as long as they do not conflict (name/lib) with brushes from
  the new bmain. Their dependencies are also re-used if needed.
  Only exception: local assets from old bmain are never re-used.

There is also a new step added to the 'open file' process, which checks
if the to-be-opened file is a library of the currently opened one, and
if so, if there are local tweaked overrides of assets from the new file.
The option to save these tweaks in draft is currently an empty mockup,
but the rest is functional.

Brush now has a new `AssetWeakReference` pointer to keep track of the
last active brush asset, and restore it on fileread in case there is
currently no active brush asset for the given paint/sculpt mode.

Some parts of this commits are mockups/place-holders that are not
expected to be committed as-is, if at all:
* Some initial support for an asset-shelf (using code from
  `brush-asset-project` branch), very much WIP still.
* Definition of test brush library with semi-hard-coded path.
* There is also a drawing bug because the poll function of Brush
  panels return false initially (tool has no data-block ref).
  Very unclear what's hapening here.

Ref. #101908.
e3ef163816 Fixes from rebase on main.
Note that current code is crashing on initial show of brush asset
browser in curve sculpt mode. Need Julian to help on this.
1e576c827f Merge branch 'tmp-brush-assets' into brush-assets-project
Conflicts:
	scripts/startup/bl_ui/space_view3d.py
	source/blender/blenloader/intern/versioning_defaults.cc
	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
Bastien Montagne added 4 commits 2023-11-24 11:20:18 +01:00
fe9e7eab13 Brush Assets: Add initial support for the new 'brush asset' usage.
This commit mainly adds the low-level logic to link and create a runtime
override for brushes.

The biggest changes are in `setup_app_data` (post-loading of .blend
file), to add support to move over some data from old bmain to newly
loaded bmain. The logic is complex, and different depending on whether
it is an undo (aka memfile read) step, or an actual .blend file reading:
* On undo, we only port over brushes themselves, their dependencies are
  not handled. However, since memfile reading code already ported over
  linked IDs, these do not need to be swapped.
* On real .blend file loading, brushes from the old bmain are being
  reused, as long as they do not conflict (name/lib) with brushes from
  the new bmain. Their dependencies are also re-used if needed.
  Only exception: local assets from old bmain are never re-used.

There is also a new step added to the 'open file' process, which checks
if the to-be-opened file is a library of the currently opened one, and
if so, if there are local tweaked overrides of assets from the new file.
The option to save these tweaks in draft is currently an empty mockup,
but the rest is functional.

Brush now has a new `AssetWeakReference` pointer to keep track of the
last active brush asset, and restore it on fileread in case there is
currently no active brush asset for the given paint/sculpt mode.

Some parts of this commits are mockups/place-holders that are not
expected to be committed as-is, if at all:
* Some initial support for an asset-shelf (using code from
  `brush-asset-project` branch), very much WIP still.
* Definition of test brush library with semi-hard-coded path.
* There is also a drawing bug because the poll function of Brush
  panels return false initially (tool has no data-block ref).
  Very unclear what's hapening here.

Ref. #101908.
b3964b1b0d Brush Assets: Add initial support for the new 'brush asset' usage.
This commit mainly adds the low-level logic to link and create a runtime
override for brushes.

The biggest changes are in `setup_app_data` (post-loading of .blend
file), to add support to move over some data from old bmain to newly
loaded bmain. The logic is complex, and different depending on whether
it is an undo (aka memfile read) step, or an actual .blend file reading:
* On undo, we only port over brushes themselves, their dependencies are
  not handled. However, since memfile reading code already ported over
  linked IDs, these do not need to be swapped.
* On real .blend file loading, brushes from the old bmain are being
  reused, as long as they do not conflict (name/lib) with brushes from
  the new bmain. Their dependencies are also re-used if needed.
  Only exception: local assets from old bmain are never re-used.

There is also a new step added to the 'open file' process, which checks
if the to-be-opened file is a library of the currently opened one, and
if so, if there are local tweaked overrides of assets from the new file.
The option to save these tweaks in draft is currently an empty mockup,
but the rest is functional.

Brush now has a new `AssetWeakReference` pointer to keep track of the
last active brush asset, and restore it on fileread in case there is
currently no active brush asset for the given paint/sculpt mode.

Some parts of this commits are mockups/place-holders that are not
expected to be committed as-is, if at all:
* Some initial support for an asset-shelf (using code from
  `brush-asset-project` branch), very much WIP still.
* Definition of test brush library with semi-hard-coded path.
* There is also a drawing bug because the poll function of Brush
  panels return false initially (tool has no data-block ref).
  Very unclear what's hapening here.

Ref. #101908.
Bastien Montagne added 2 commits 2023-11-24 15:32:29 +01:00
eb505ad1c7 Brush Assets: Add initial support for the new 'brush asset' usage.
This commit mainly adds the low-level logic to link and create a runtime
override for brushes.

The biggest changes are in `setup_app_data` (post-loading of .blend
file), to add support to move over some data from old bmain to newly
loaded bmain. The logic is complex, and different depending on whether
it is an undo (aka memfile read) step, or an actual .blend file reading:
* On undo, we only port over brushes themselves, their dependencies are
  not handled. However, since memfile reading code already ported over
  linked IDs, these do not need to be swapped.
* On real .blend file loading, brushes from the old bmain are being
  reused, as long as they do not conflict (name/lib) with brushes from
  the new bmain. Their dependencies are also re-used if needed.
  Only exception: local assets from old bmain are never re-used.

There is also a new step added to the 'open file' process, which checks
if the to-be-opened file is a library of the currently opened one, and
if so, if there are local tweaked overrides of assets from the new file.
The option to save these tweaks in draft is currently an empty mockup,
but the rest is functional.

Brush now has a new `AssetWeakReference` pointer to keep track of the
last active brush asset, and restore it on fileread in case there is
currently no active brush asset for the given paint/sculpt mode.

Some parts of this commits are mockups/place-holders that are not
expected to be committed as-is, if at all:
* Some initial support for an asset-shelf (using code from
  `brush-asset-project` branch), very much WIP still.
* Definition of test brush library with semi-hard-coded path.
* There is also a drawing bug because the poll function of Brush
  panels return false initially (tool has no data-block ref).
  Very unclear what's hapening here.

Ref. #101908.
Bastien Montagne added 1 commit 2024-01-09 17:26:25 +01:00
Julian Eisel added 1 commit 2024-01-16 11:39:22 +01:00
Hans Goudey added 55 commits 2024-01-17 16:39:30 +01:00
1f94c11d53 EEVEE: Fix Lights On High-res Monitors
When using EEVEE on high resolution monitors the light buffers might not
get initialized as there are range checks that pass in the first try.

- number of tiles needed is larger than the max_tile_count_threshold
- total_word_count is smaller than max_word_count_threshold as it is
  never set (still initialized to zero.

Solution is to not exit on the first try. In a later stage we might want
to use something that doesn't require any looping.

Fixes: #117128
Pull Request: #117164
5b952c0085 ImBuf: no need to use double precision inside IMB_transform
Double precision pixel coordinate interpolation was added in 3a65d2f591 to
fix an issue of "wobbly" resulting image at very high scale factors. But
the root cause of that was the fact that the scanline loop was repeatedly
adding the floating point step for each pixel, instead of doing multiplication
by pixel index (repeated floating point additions can "drift" due to
imprecision, whereas multiplications are much more accurate).

Change all that math back to use single precision floats. I checked the
original issue the commit was fixing, it is still fine. Also added a gtest
to cover this situation: `imbuf_transform, nearest_very_large_scale`

This makes `IMB_transform` a tiny bit faster, on Windows/VS2022/Ryzen5950X
scaling an image at 4K resolution:
- Bilinear: 5.92 -> 5.83 ms
- Subsampled3x3: 53.6 -> 52.7 ms

Pull Request: #117160
1c0d7ccc65 Fix #115727: Draw panel buttons in the node editor side bar
In 13fac109 the node panels got support for individual option button
callbacks, but these were not included in the node editor side bar.
Only the older top-level buttons are drawn there.

The panel structure is currently not accessible in python since it is
part of the `NodeDeclaration` system. To draw node input sockets and
buttons in the correct panel order as they appear on the node, a new
template function `uiTemplateNodeInputs` has been added. This iterates
over declared panels and their contents in the appropriate order and
draws the buttons before sockets in the same panel.

Pull Request: #116936
da6aae413e Build: bump sse2neon version to latest hash
This includes an additional fix for precision of some operations that affect
Blender tests.
c23d4869f5 Fix: broken make update on new macOS build
Properly check for the existence of the Python binary in precompiled libs.
af93b2877a Report when `register_class` overrides classes with the same bl_idname
The unregistering of already registered classes is expected behavior,
however this was done silently and can be unsafe as two Addons may have
the same names for operators and in case of name collision the addon
registered first will break silently / start behave unexpectedly.
So reporting the unregister step seems reasonable.

During Addon development, this might seem noisy when classes are
frequently updated, however catching the problematic cases instead of
being silent might be beneficial.

Part of #116370

Pull Request: #116374
f0e840375e Fix #117158: Multires sculpting crash
The change to use `float3` in `frontface` didn't account for the
fact that the values we sometimes null.
645b0e75c2 Fix #116477: Node group sockets with subtypes have broken idnames
Loading pre-4.0.20 node groups with sockets using subtypes causes
broken socket identifiers. This is because the node tree interface now
expects sockets to use the base identifiers ("NodeSocketFloat" instead
of "NodeSocketFloatFactor" etc.).

To correct this the conversion code now replaces socket idnames that
include a subtype suffix with their base names. This fix is also applied
to files between versions 4.0.20 and 4.1.10, where the socket types
may have been converted incorrectly.

Pull Request: #117133
35d4c509e7 Fix: error when custom socket has no 'draw' function
This `draw` method is optional. The same check is also done elsewhere.

Pull Request: #117061
35c362db89 Fix: incorrect Exists output in Named Attribute node for grease pencil
Grease pencil needs some special handling because it stores layer attributes
independently of point/curve attributes.
619d83d5ea Fix: crash trying to store an attribute on unsupported grease pencil domain
This crash happened when trying to store an attribute on the edge domain
on a grease pencil geometry.
dd67d941e5 Linux: Use huge pages in jemalloc to speed up allocations
Enable huge pages for jemalloc. This requests the Linux kernel to use
huge (2 MB) pages for large allocations. This has the effect of speeding
up first accesses to those allocations, and possibly also speeds up future
accesses by reducing TLB faults.

By default, 4 KB pages are used unless the user enables huge pages through
a kernel parameter or an obscure sysfs setting.

For Cycles benchmarks, this gives about a 5% CPU rendering performance
improvement. It likely also improves performance in other areas of Blender.

Pull Request: #116663
6c4a058e8b GPv3: Opacity modifier
Opacity modifier implementation based on GP2.
Functionality is largely unchanged.

_Color Mode_ is either `Stroke` or `Fill` for modifying color opacity or
`Hardness`.
_Uniform Opacity_ does two things at once (!):
- Sets the same opacity value for every point in a stroke.
- Sets opacity as an absolute value rather than a factor.

_Weight as Factor_ (button to the right of Opacity Factor): Use the
vertex group as opacity __factor__ rather than an overall __influence__.
This is confusing and hard to convey, but copies behavior from GP2.

The _Influence_ panel contains the same filter settings as the GP2
modifier, with some small changes:
- _Layer_ selects only strokes in the respective layer (with an _Invert_
  option)
- _Material_ selects only points with the respective material (with an
  _Invert_ option)
- _Layer Pass_ and _Material Pass_ select only strokes/points which are
  rendered in the respective pass.
  _Note 1: Layers don't have UI for setting a pass yet, this will be a
  generic layer attribute. This can be set through the API for testing._
  _Note 2: In GP2 a pass value of zero was used to disable pass filters.
  Since zero is a valid pass ID an explicit flag has been added for the
  purpose of turning pass filters on and off._
- _Vertex Group_: This can be used as an additional influence filter on
  points. If _Weight as Factor_ is enable the vertex group instead
  replaces the opacity factor. In _Fill_ mode the vertex group weight of
  the stroke's first point is used as influence for the entire stroke.
- _Custom Curve_ is another possible influence factor per point. The
  curve input value is the relative position of a point along its
  stroke.

The Influence settings have been moved into a separate DNA struct, which
should help with reusability in various modifiers. Various utility
functions can be found int `MOD_grease_pencil_util.hh` for handling
influence settings and generating `IndexMasks` for modernized C++ code.

Pull Request: #116946
f49b856bb0 Fix: GPv3: Opacity modifier compilation error
The parameters for `threading::parallel_for_each` were not correct.
a622a8573f Fix #117168: crash when using layout panel in popover
Using layout panels in this context is not yet supported. Therefor, the fix
is to raise an exception instead of crashing.

The problem here is that layout panels need an a parent panel which
has a persistent state. The popover currently does not only has a very
short-lived panel currently that is freed directly after drawing.
Also see `ui_paneltype_draw_impl`.

It's likely that support for this can be added in the future but it's currently
unclear how many changes this would require.
b341e6ea7d Cleanup: Use Map instead of GHash for memfile writing
The goal is to simplify future work on #106903.

Pull Request: #117141
22087e908a Cleanup: simplify code in IMB_transform
There were some abstractions inside `IMB_transform` implementation
that were kinda getting in the way. I want to speed up Subsampled3x3
filtering by reformulating the math being done, but that needs to
sample byte images while storing intermediate result as a float -- but
the whole `Pixel`, `PixelPointer` et al. machinery was not quite prepared
to deal with that. Feels like those helper classes do not achieve much,
just make the code longer.

So remove them (`Pixel`, `PixelPointer`, `ChannelConverter` etc.) and
use simple functions. Now the code is more straightforward (IMHO) and
270 lines shorter (40% of the whole file!), and allows me to do the
follow-up optimization easier.

No functional changes.

Pull Request: #117182
96041c9516 Cleanup: Use std::string to store UI button string
This simplifies memory management and button string manipulation in
general. Just change one of the few strings stored in `uiBut` for now.

Pull Request: #117183
59f3f88e46 Fix: Curves extrude with all points selected
CurvesGeometry has no ".selection" attribute when all control points
are selected. The earlier code assumed that the attribute always exists.
Also Python tests are added for the "extrude" operator.

Pull Request: #117095
9ff2dec171 Cleanup: remove outdated comment
String suggestion now allow the operator list to be searched.
03155f1316 Outliner: Double-click on item icon to select contents/hierarchy
Allow double-clicking on Outliner items to select all child items.

Pull Request: #110151
df57dc1882 UI: Cleanup Dialog to Manage Orphaned Data
Creates a new "Cleanup" dialog that allows purging unused data blocks,
as well as a window used for managing unused data blocks.

Pull Request: #106653
09871cec4e Fix: Tooltip contains bogus text after recent button string cleanup
The code still needs to differentiate a null string from an empty
string in one cast I missed earlier.
79804353ad Fix #117188: Context.temp_override() failed with full-screen areas
Using screen changing functions with screens used for full screen areas
isn't supported & caused corrupt screen data.

Add checks that the current and overriding screen support switching,
raising an error when they don't. Also add a check when restoring the
context not to change any full screen areas.
b1dcb37f76 Fix incorrect number of planes for ImBuf used for render passes
Set the number of planes based on the number of pass channels.

If the pass contains 2 passes or more than 4 passes set the number
of planes to the previously used value of 32.

This is needed because quite some areas check for the number of
planes for various optimizations. For example, this is one of the
factors which make IMB_create_gpu_texture() to choose the texture
format. If the number of planes for the depth pass is set to the
previously used this function will never consider using single
channel GPU texture.

Unfortunately, this change is not enough to make the GPU texture
to use single channel format as the color space of the image
buffer is also checked, and that is nullptr which means scene linear.
2592fa1dc7 Render: Set non-color colorspace for ImBuf of data passes
This allows code outside of the render pipeline to make proper
decisions about how the imbuf of render passes are to be handled.

For example, IMB_create_gpu_texture() will now properly select
single channel grayscale texture format for depth pass coming from
multilayer EXR, additionally solving assert in the GPU compositor
code which verifies expected and actual imbuf texture format.

Pull Request: #117184
50ec05a245 VSE: Speedup Subsampled 3x3 image filter
Make Subsampling 3x3 filter twice faster (on 4K UHD resolution,
Windows/VS2022/Ryzen5950X: 52.7ms -> 28.3ms), by reformulating how it works:

Conceptually Subsampling filter is a box filter: it sums up N source image
pixels, computes their average and outputs the result. Critical thing is,
that should be done in premultiplied space so that colors from fully or
mostly transparent regions do not "override" opaque  colors.

Previously, when operating on byte images, the code achieved this by always
working on byte values, doing "progressively smaller" lerp into byte color
result, taking care of premultiplication and again storing the "straight"
alpha for each sample being processed. This meant that for each sample, there
are 3 divisions involved! This also led to some precision loss, since for all
9 samples all the intermediate results would only be stored at byte precision.

Reformulate that by simply accumulating the premultiplied color as a float.
This gets rid of all divisions, except the last step when said float needs to
be written back into a byte color.

The unit test results have a tiny difference, since now it is arguably better
(as per above, previously it was having some precision loss).

Pull Request: #117125
c98323fc14 Geometry Nodes: expose bake id in Python API
This is necessary to be able to invoke baking of individual bake nodes
or simulation zones with Python.
a2915e83e5 Geometry Nodes: expose NodesModifierBake.node property in Python API
This allows scripts to filter the set of bakes by e.g. the node name.
More filtering options will be necessary, but this is a good start.
a18b0405f0 Curves: Debug crash after switching to sculpt mode
`bounds_min_max` returns an optional and it can be `nullopt` when
curve points are 0.

Pull Request: #117163
f5685e1570 Fix #117191: Crash using the Extrude tool and Snap Base
`GIZMO_GT_button_2d` has no modal/custom_modal callback function
defined hence the crash due to calling `modal_fn()`

Pull Request: #117194
741c13d1e9 Cleanup: Curves: Remove redundant resizing in extrude operator
Curve resizing is already handled in `copy_only_curve_domain` (i.e.
copy curve nums/attributes, point_num = 0, fresh offset array)

Pull Request: #117166
d8fe96d6ce Fix: crash when adding repeat zone from search
The issue was that some code expected the "extend" sockets
to always exist. This was already always true from the user
point of view, but not internally.

There are different possible fixes, but this patch makes sure
that the extend socket will be available as expected. This is
achieved by making them part of the static node declaration.
We want to extend the static declaration of such dynamic
nodes anyway, to improve reflection capabilities without
having to instantiate nodes.
6454d989fd Compositor: Port redesigned Defocus node to CPU
This patch ports the redesigned GPU Defocus node to the CPU.

Pull Request: #117174
e296f9fcaa Geometry Nodes: support synchronous baking
Previously, calling the bake operator was always creating a job that will
be run in parallel to Blender. This is good when baking from the UI, but may
be undesired when baking with a script.

Now, when the `exec` method of the bake operator is called, the baking
happens synchronously. That means that the operator call will return only
after the baking is done. The `invoke` method has the same behavior as
before. This approach is similar to e.g. `FLUID_OT_bake_all`.

I did notice that calling the invoke method from a script can still result
in a crash sometimes, probably due to conflicting depsgraph evaluations.
That has to be investigated more.
16875c82bb Geometry Nodes: reorganize panels in modifier
The goal is to simplify the interface of the geometry nodes modifier while also
making it more scalable. This allows creating better looking modifiers which
feel more built-in. No functionality is removed by this patch.

The following changes are done:
* The `Output Attributes` panel is hidden when there are no output attributes.
* The `Internal Dependencies` panel is replaced by a new `Manage` panel that
  contains all the stuff that is common to all geometry nodes modifiers. It
  contains new `Bake` and `Named Attributes` panels for now.

Potential next steps:
* Merge `Output Attributes` panel with the rest of the input list.
* Support hiding the `Manage` panel under some circumstances.

Pull Request: #117170
058ec36130 Cleanup: Remove unused weak asset reference in Library
A library probably shouldn't reference a single specific asset anyway.
23f0914744 Cleanup: Remove unused asset handle function
These days the function on AssetRepresentation can probably be used instead
Brecht Van Lommel added 1 commit 2024-01-17 17:12:30 +01:00
Julian Eisel added 1 commit 2024-01-17 19:38:11 +01:00
Julian Eisel added 4 commits 2024-01-17 19:52:29 +01:00
c65b0ad144 Bundle WIP brush assets as essentials
Change for development/prototyping only: Include the brush assets from
the `working/` part of the SVN libraries repository, not just the ones
under `publish/`. This is managed by CMake during the installation build
step.
d9f2fce614 Write compatible modes to brush asset metadata
Had to add support for JSon (de)serializing of boolean properties.
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
5e813f1563
Only show curve sculpt brushes in curve sculpt mode
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR106303) when ready.
Hans Goudey added 1 commit 2024-01-17 20:08:01 +01:00
Hans Goudey added 1 commit 2024-01-18 14:13:25 +01:00
33cc4af2a2 Cleanup: Use slightly simpler constexpr array
The need to repeat std::pair isn't great, but at least this won't
result in a heap allocation.
Bastien Montagne added 1 commit 2024-01-19 12:32:34 +01:00
Bastien Montagne added 1 commit 2024-01-23 15:46:14 +01:00
Bastien Montagne added 1 commit 2024-01-23 15:53:39 +01:00
Bastien Montagne added 1 commit 2024-01-24 11:27:24 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
94b18b9e67
Merge branch 'main' into brush-assets-project
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR106303) when ready.
Julian Eisel added 1 commit 2024-01-24 18:20:46 +01:00
Hans Goudey added 1 commit 2024-01-24 19:09:35 +01:00
Hans Goudey added 2 commits 2024-01-24 20:02:44 +01:00
6f84c5da8f Cleanup: Remove redundant comment
This fact is mentioned in the docs of #BKE_paint_brush_asset_set,
no need to duplicate the information.
Hans Goudey added 1 commit 2024-01-24 20:15:38 +01:00
Bastien Montagne added 1 commit 2024-01-25 10:35:07 +01:00
Hans Goudey added 1 commit 2024-01-25 16:13:37 +01:00
Bastien Montagne added 1 commit 2024-01-25 17:08:46 +01:00
Bastien Montagne added 1 commit 2024-01-25 17:10:47 +01:00
dcc1894b89 Report/confirm overwrite of 'asset library' blendfiles.
This commit extends the reporting and overwrite confirmation system
created for blendfiles saved by later Blender version, to also detect
and handle 'asset library' blendfiles.

Asset library blendfiles are defined by:
* Not having a defined current Screen or Scene in their global data.
* Having a filename ending by `.asset.blend`.

This is required to avoid/warn users about editing a file that would have
been generated in the 'default' asset library, e.g. when saving a new Brush
asset (see also Part of #116337 and #117239).

Pull Request: #117346
Hans Goudey added 1 commit 2024-01-25 21:45:50 +01:00
Hans Goudey added 1 commit 2024-01-26 19:20:12 +01:00
Hans Goudey added 1 commit 2024-01-26 19:48:31 +01:00
Hans Goudey added 1 commit 2024-01-26 20:40:03 +01:00
Hans Goudey added 1 commit 2024-01-26 21:08:33 +01:00
65fce64213 Brush Assets: Switch to a single "Brush" active tool
Instead of showing an active tool for every brush type,
just show a single active tool and rely on the asset shelf
to select different brushes.

A single generic "Brush" icon is used instead of the tool
icons. That avoids raising many questions in the future as
we get more brushes.

Pull Request: #117491
Brecht Van Lommel added 1 commit 2024-01-26 21:21:18 +01:00
Hans Goudey added 2 commits 2024-01-27 01:00:54 +01:00
Hans Goudey added 1 commit 2024-01-27 01:07:14 +01:00
Hans Goudey added 1 commit 2024-01-27 01:18:45 +01:00
Brecht Van Lommel added 1 commit 2024-01-27 23:32:13 +01:00
Brecht Van Lommel added 1 commit 2024-01-28 00:01:26 +01:00
buildbot/vexp-code-experimental-lint Build done. Details
buildbot/vexp-code-experimental-darwin-arm64 Build done. Details
buildbot/vexp-code-experimental-darwin-x86_64 Build done. Details
buildbot/vexp-code-experimental-linux-x86_64 Build done. Details
buildbot/vexp-code-experimental-windows-amd64 Build done. Details
buildbot/vexp-code-experimental-coordinator Build done. Details
8e6dbddc5a
Brush Assets: Save As, Delete, Revert and Update operators
This is quickly hacked code to get basic features and user interface
testable. A lot more work will be required to make this good.

* Add Save As Asset and Delete Asset operators. These create and delete
  brushes assets in asset blend files in a user asset library.
* Update Asset save the current settings to the brush to the asset blend.
* Revert to Asset reverts settings to the ones from the asset blend.
* Regular datablock management buttons are replaced by this mechanism and
  hidden from the UI.
* Custom icon, modes and tool have been put into a subpanel. These will need
  to find a better place, but should be out of the way for now.

There are many TODO comments in the code, but some main things:
* Delete Asset should become undoable, perhaps with a Trash mechanism.
* Asset shelf refresh performance is poor and looks flickery.
* The brush selector menu lists local, linked and override brushes which is
  confusing. It should be made to match the asset shelf.
* Brush dependencies like textures are not handled yet.
* The partial write mechanism and various other parts of this code will
  need refactoring to be less hacky.

![brush_asset.png](/attachments/100f59cb-4ddf-429c-83d3-39b071c0cb08)

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: #117513
Brecht Van Lommel added 1 commit 2024-01-29 12:33:58 +01:00
Brecht Van Lommel added 1 commit 2024-01-29 12:44:20 +01:00
Brecht Van Lommel added 1 commit 2024-01-29 13:34:26 +01:00
buildbot/vexp-code-experimental-lint Build done. Details
buildbot/vexp-code-experimental-darwin-arm64 Build done. Details
buildbot/vexp-code-experimental-darwin-x86_64 Build done. Details
buildbot/vexp-code-experimental-linux-x86_64 Build done. Details
buildbot/vexp-code-experimental-windows-amd64 Build done. Details
buildbot/vexp-code-experimental-coordinator Build done. Details
e26ebf6324
Fix: missing catalogs, replace bundled assets entirely with testing/
Not ideal to not have the hair node group assets, but we can have only
one catalog file so better to have brushes working at least.
Hans Goudey added 2 commits 2024-01-29 23:47:15 +01:00
Hans Goudey added 3 commits 2024-01-31 21:13:52 +01:00
Brecht Van Lommel added 3 commits 2024-01-31 21:24:19 +01:00
Brecht Van Lommel added 1 commit 2024-01-31 21:36:38 +01:00
Hans Goudey added 4 commits 2024-02-01 02:33:25 +01:00
458716b675 Cleanup: Perform cleanup on sculpt_automasking.cc
* Add documentation / comments
* Apply const where possible to cache_init function codepath
* Minor cleanup of conditionals and initialization

Contains changes that were deferred from #117316

Pull Request: #117651
b3cea96228 Cleanup: Use StringRef arguments for some UI button functions
The benefits are O(1) access to the string size, clearer ownership,
and easily accessible utility functions. For now, only change functions
where the string is clearly non-null. It's not clear in what cases some
other functions recieve null strings.
Hans Goudey added 2 commits 2024-02-01 03:56:05 +01:00
Julian Eisel added 1 commit 2024-02-01 15:13:18 +01:00
Hans Goudey added 1 commit 2024-02-01 17:02:28 +01:00
Hans Goudey added 1 commit 2024-02-01 19:57:11 +01:00
Hans Goudey added 1 commit 2024-02-02 17:01:06 +01:00
Hans Goudey added 1 commit 2024-02-02 20:33:05 +01:00
Julian Eisel added 1 commit 2024-02-05 10:45:53 +01:00
Julian Eisel added 1 commit 2024-02-05 16:07:50 +01:00
128d9e142e Bind active brush two asset shelf active item
Adds a new `bpy.types.AssetShelf.get_active_asset()` method to return
an active asset reference.
Hans Goudey added 1 commit 2024-02-05 17:21:38 +01:00
Hans Goudey added 1 commit 2024-02-05 17:43:44 +01:00
Julian Eisel added 1 commit 2024-02-05 18:26:46 +01:00
Julian Eisel added 1 commit 2024-02-07 10:58:05 +01:00
Julian Eisel added 1 commit 2024-02-07 16:33:18 +01:00
Hans Goudey added 1 commit 2024-02-07 18:36:01 +01:00
Hans Goudey added 1 commit 2024-02-07 18:48:47 +01:00
Hans Goudey added 1 commit 2024-02-07 19:02:56 +01:00
44b80df241 Brush Assets: Support adding shortcut to asset shelf items
Don't use a keymap for the asset shelf to activate brushes; there's no
need to recreate basic UI interaction at this level. Instead use an
operator button so the ability to add a shortcut is automaticaly added
by other UI code.

Also change the operator to use an explicit asset reference instead of
the "context asset". This was already done for other operators that add
data-blocks from assets.

Pull Request: #117861
Hans Goudey added 1 commit 2024-02-07 19:18:29 +01:00
f6898f9bcb Fix brush tool dissapears with no brush active
I'm not sure what the "data_block" part of the tool dictionary
actually does anymore but I won't get rid of it for now
Julian Eisel added 1 commit 2024-02-07 20:40:07 +01:00
Hans Goudey added 1 commit 2024-02-08 18:28:38 +01:00
Hans Goudey added 1 commit 2024-02-08 18:39:09 +01:00
9817b56c9b Cleanup: Move new code to proper namespace
Also use StringRef and pass the string refs by value
Hans Goudey added 1 commit 2024-02-08 18:47:28 +01:00
Hans Goudey added 1 commit 2024-02-08 21:22:30 +01:00
Hans Goudey added 1 commit 2024-02-08 23:48:01 +01:00
Hans Goudey added 1 commit 2024-02-09 00:02:45 +01:00
4812d45c21 Brush Assets: Add "Default" option for asset library for new brushes
A new option controls where duplicated brushes are stored.
Maybe eventually the duplicate operator will allow choosing the
library, but it also seems reasonable to store a default so users
don't have to make that choice every time.

Pull Request: #117963
Hans Goudey added 1 commit 2024-02-09 00:07:04 +01:00
Hans Goudey added 1 commit 2024-02-09 00:11:50 +01:00
2dec98b69f Cleanup: Rename more variables that aren't brush specific
The idea is to make this code more general in the future
so it doesn't just deal with brush assets
Hans Goudey added 2 commits 2024-02-09 00:21:26 +01:00
9c1b837578 Fix: Refresh proper library after deleting asset
Pass the asset library to some functions that always just retrieved the
default before. That makes them more flexible and fixes some potential
issues where the wrong asset library was updated or used in a poll
function, etc.
24d4ee1ab6 Cleanup: Reorder static function
Just to make a diff in a future PR cleaner
Hans Goudey added 1 commit 2024-02-09 00:23:18 +01:00
Hans Goudey added 2 commits 2024-02-09 00:26:22 +01:00
Hans Goudey added 1 commit 2024-02-09 00:29:54 +01:00
Hans Goudey added 1 commit 2024-02-09 20:05:56 +01:00
Hans Goudey added 1 commit 2024-02-12 20:57:40 +01:00
buildbot/vexp-code-experimental-darwin-x86_64 Build done. Details
buildbot/vexp-code-experimental-windows-amd64 Build done. Details
buildbot/vexp-code-experimental-darwin-arm64 Build done. Details
buildbot/vexp-code-experimental-lint Build done. Details
buildbot/vexp-code-experimental-linux-x86_64 Build done. Details
buildbot/vexp-code-experimental-coordinator Build done. Details
da344d30cd
Merge branch 'main' into brush-assets-project
Hans Goudey added 1 commit 2024-02-14 17:00:21 +01:00
Hans Goudey added 1 commit 2024-02-14 17:34:14 +01:00
Hans Goudey added 1 commit 2024-02-14 17:37:07 +01:00
a2768e3066 Brush Assets: Add library choice to "Save As" operator
Previously the new brush would always be saved to the default library.
Now the user is presented with a choice that defaults to the library marked
as "Default" in the preferences.

Because the library is now chosen by an operator property, we can't check
its editable status in the poll function. Instead we just check it when the
operator executes.

Pull Request: #118021
Hans Goudey added 2 commits 2024-02-14 19:35:04 +01:00
71f2c80a77 Cleanup: Rename variable
Soon there will be another asset library variable with a different type,
this is to distinguish the two
Hans Goudey added 1 commit 2024-02-14 20:25:42 +01:00
126636854b Brush Assets: Versioning to activate new brush tool and asset
Activate the new brush tool when opening old files, and activate the
default brush asset for the mode. I'm guessing we may end up storing
the default brush asset for each mode somewhere else in the long term,
but doing it in versioning is simple now, and has the benefit of decoupling
the one time change from the defaults in the future.

Also replace the workspace's tool reference that could still point to the
old separate tools for each brush. This makes everything work by default
when opening a new factory startup file.

Pull Request: #118289
Hans Goudey added 1 commit 2024-02-14 23:24:13 +01:00
Hans Goudey added 1 commit 2024-02-15 17:37:58 +01:00
Julian Eisel added 1 commit 2024-02-15 18:01:08 +01:00
b5d44d8f5d Make asset shelf visible by default in sculpt/paint modes
Adds a new `DEFAULT_VISIBLE` option for the `bl_options` of an asset
shelf. When this asset shelf will be created for the first time, the
asset shelf will be made visible, otherwise it will be hidden.

We don't mess with the visibility further, meaning, when re-opening a
previously active asset shelf, we keep the current asset shelf
visibility. So only the first load is affected. Alternatively asset
shelves could remember their last visibility state, and restore that as
context (e.g. the mode) changes. To be evaluated.

Had to add some trickery to make this overriding of visibility possible.
Julian Eisel added 1 commit 2024-02-15 18:05:29 +01:00
Brecht Van Lommel added 3 commits 2024-02-15 21:14:45 +01:00
Hans Goudey added 1 commit 2024-02-15 22:24:34 +01:00
Julian Eisel added 1 commit 2024-02-16 16:57:16 +01:00
Hans Goudey added 1 commit 2024-02-16 17:05:32 +01:00
Julian Eisel added 1 commit 2024-02-16 18:40:15 +01:00
2c4f83d901 Enable sculpt brush catalogs by default
After feedback from Julien, the "Cloth", "General" and "Painting"
catalogs are the ones we want to enable by default in mesh sculpt mode.
Other modes are fine with "All" only.
Hans Goudey added 2 commits 2024-02-20 21:07:46 +01:00
Hans Goudey added 1 commit 2024-02-20 21:35:21 +01:00
Julian Eisel added 1 commit 2024-02-21 12:23:25 +01:00
Julian Eisel added 1 commit 2024-02-21 13:04:11 +01:00
Hans Goudey added 1 commit 2024-02-21 14:03:49 +01:00
633e0a6b3a Brush Assets: Add catalog option to asset pushing operator
Adds the ability to choose which of the libraries catalogs to add the
new asset to, or to create a new catalog. The catalogs are presented
in a dropdown list, and every hierarchy level is available. Eventually
we might want some form of tree view here. But for now this approach is
very simple.

Pull Request: #118382
Hans Goudey added 1 commit 2024-02-21 15:52:16 +01:00
Hans Goudey added 2 commits 2024-02-21 16:25:55 +01:00
Hans Goudey added 1 commit 2024-02-21 16:27:04 +01:00
Hans Goudey added 1 commit 2024-02-21 16:59:56 +01:00
Hans Goudey added 1 commit 2024-02-21 17:08:17 +01:00
Hans Goudey added 1 commit 2024-02-21 23:09:58 +01:00
Julian Eisel added 1 commit 2024-02-22 17:48:18 +01:00
Hans Goudey added 1 commit 2024-02-22 19:03:45 +01:00
Hans Goudey added 1 commit 2024-02-22 21:54:57 +01:00
Brecht Van Lommel added 5 commits 2024-02-27 14:52:29 +01:00
b030911aa9 Brush Assets: Store assets outside Main
This is an experiment, but we hope this can become stable
and in an acceptable state in the brush-assets-project branch.

* One main database per asset blend file, so that there are no
  conflicts between the regular main and different asset blend files.
* Various code for avoiding conflicts and untangling databases can
  be removed because of this.
* Assets are appended to this, no linking and overrides. Highlighting
  property changes is gone because of this. This change does not
  necessarily need to be made along with the rest, but it does simplify
  making renaming and editing textures work.
* Some basic checks to avoid linking between regular main and
  asset main, but much more would be needed.
* Tool settings brush pointers were changed to do no user counting,
  but really should not be part of ID management at all and handled
  purely through some runtime lookup outside of it.
* Basic texture editing works and gets saved and loaded. But will need
  more work for all operators, RNA, editors to deal with different mains.

Includes other changes for brush/tool selection.
* Remove "brush select" operator
* Remove creating a new brush on Paint init when none is found
* Remove unnecessary tool -> brush connection
* Remove BRUSH_OT_add operator

Pull Request: #117730
a4e5d54a76 Remove BRUSH_OT_add operator
This doesn't seem to be visible anywhere in the UI. New brushes
are more easily created by duplicating existing brushes anyway.
88602a74da Remove unnecessary tool -> brush connection
These were adding brushes and finding brushes in the active (non-asset)
main. This sort of thing should be handled differently now anyway
951eedb2ae Remove creating a new brush on Paint init when none is found
Now instead of creating a brush from scratch, the default asset
should be used instead. I'm pretty sure that is done elsewhere,
and if it isn't it should be fixed.
5cc18152c0 Remove "brush select" operator
Selecting a brush based on the tool type isn't done anymore,
and this operator doesn't really make sense in the context of
prioritizing brush selection instead of tool selection / the asset
shelf. It would otherwise have to be fixed for storing brush
data-blocks in other mains.
Hans Goudey added 1 commit 2024-02-28 15:49:09 +01:00
Brecht Van Lommel added 5 commits 2024-02-28 17:12:38 +01:00
f29e118487 Refactor: Add BKE_main_from_id for main lookups
Instead of specifically naming this function after asset weak
references.
2ac6f8d455 RNA: Better validation of matching main database
Including no main database cases that were not checked previously.
Replaces BKE_id_is_in_global_main assets by moving them in
BKE_main_from_id which needs to be called anyway.
Hans Goudey added 1 commit 2024-02-28 17:23:59 +01:00
Hans Goudey added 1 commit 2024-02-28 18:59:44 +01:00
c5b25d954b Fix: Brushes not activated properly in curves sculpt mode
This code that set a different tool as active depending on the brush
isn't relevant anymore. It's possible that the deletion could go further
into Python code, but the separation isn't so clear there.
Julian Eisel added 1 commit 2024-02-28 19:54:30 +01:00
7677c036c0 Fix factory settings not using default catalogs
Apparently userdef versioning doesn't run for factory settings.
Hans Goudey added 2 commits 2024-02-28 20:20:20 +01:00
0c75cdf626 Fix: Use after free on exit
I found two cases where `BKE_blender_free` frees pointers that
are owned by the asset main, resulting in use-after-frees:
- Image pool for sculpt brush evaluation
- Freeing the "moviecache" system which isn't stored per-Main

To fix these, free the asset main data-bases after the global main.
038b29caa5 Fix: Support separate asset main in image open operator
Put the new image data-block in the asset main if the owner
of the pointer property is also in that Main.
Brecht Van Lommel added 1 commit 2024-02-28 20:23:00 +01:00
buildbot/vexp-code-experimental-lint Build done. Details
buildbot/vexp-code-experimental-darwin-x86_64 Build done. Details
buildbot/vexp-code-experimental-linux-x86_64 Build done. Details
buildbot/vexp-code-experimental-windows-amd64 Build done. Details
buildbot/vexp-code-experimental-coordinator Build done. Details
buildbot/vexp-code-experimental-darwin-arm64 Build done. Details
e7c03c1644
Fix: Restore bundling of testing/ assets that got lost in merge
Hans Goudey added 2 commits 2024-02-28 22:15:09 +01:00
Julian Eisel added 1 commit 2024-02-29 12:27:30 +01:00
Julian Eisel added 1 commit 2024-02-29 12:47:22 +01:00
buildbot/vexp-code-experimental-lint Build done. Details
buildbot/vexp-code-experimental-darwin-arm64 Build done. Details
buildbot/vexp-code-experimental-darwin-x86_64 Build done. Details
buildbot/vexp-code-experimental-linux-x86_64 Build done. Details
buildbot/vexp-code-experimental-windows-amd64 Build done. Details
buildbot/vexp-code-experimental-coordinator Build done. Details
554dcdd429
Take brush assets out of experimental
This makes brush assets be fully supported (non-experimental) asset types.
Julian Eisel added 1 commit 2024-02-29 14:40:11 +01:00
Hans Goudey added 1 commit 2024-02-29 16:36:45 +01:00
Hans Goudey added 2 commits 2024-02-29 17:43:56 +01:00
Hans Goudey added 1 commit 2024-02-29 17:54:28 +01:00
Julian Eisel added 1 commit 2024-02-29 17:55:37 +01:00
Hans Goudey added 1 commit 2024-02-29 19:57:13 +01:00
5204c7dd43 Fix: Refresh asset libraries after updating asset
Otherwise a name change doesn't update the asset shelf.
Though there are still other issues with renaming- duplicate brushes
will be created when renaming a local copy, switching brushes, then
switching back. Other local changes will also be lost in that case.
Hans Goudey added 2 commits 2024-02-29 20:43:35 +01:00
Hans Goudey added 1 commit 2024-02-29 21:11:01 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
buildbot/vexp-code-experimental-lint Build done. Details
buildbot/vexp-code-experimental-darwin-arm64 Build done. Details
buildbot/vexp-code-experimental-darwin-x86_64 Build done. Details
buildbot/vexp-code-experimental-linux-x86_64 Build done. Details
buildbot/vexp-code-experimental-windows-amd64 Build done. Details
buildbot/vexp-code-experimental-coordinator Build done. Details
151e5f4fe2
UI: Use "label tooltip" as a fallback for quick favorites menu text
Useful when the button has no display text but has been set up
to have a quickly accessible tooltip in its place.
Brecht Van Lommel added 1 commit 2024-03-06 18:13:46 +01:00
Hans Goudey added 1 commit 2024-03-06 19:56:58 +01:00
Julian Eisel added 1 commit 2024-03-07 17:18:57 +01:00
Julian Eisel added 1 commit 2024-03-07 17:19:39 +01:00
Julian Eisel added 2 commits 2024-03-13 16:30:04 +01:00
Julian Eisel added 1 commit 2024-03-13 17:43:17 +01:00
Julian Eisel added 1 commit 2024-03-13 17:49:43 +01:00
Julian Eisel added 2 commits 2024-03-20 18:38:01 +01:00
Brecht Van Lommel added 5 commits 2024-03-22 20:09:08 +01:00
Brecht Van Lommel added 1 commit 2024-03-22 20:21:13 +01:00
Brecht Van Lommel added 1 commit 2024-03-22 20:40:29 +01:00
Brecht Van Lommel added 1 commit 2024-03-25 14:35:04 +01:00
99b9650f87 Brush Assets: Make revert and delete operators affect dependencies
This is done by reloading or freeing the entire main of the asset, and
remapping pointers for all datablocks contained in it. This remapping is
primarily needed for the user interface to point to the same datablocks.

Pull Request: #119806
Hans Goudey added 1 commit 2024-03-27 14:02:11 +01:00
Hans Goudey added 1 commit 2024-03-27 14:38:40 +01:00
Hans Goudey added 2 commits 2024-03-27 14:46:02 +01:00
Hans Goudey added 1 commit 2024-03-27 17:20:09 +01:00
Hans Goudey added 1 commit 2024-03-27 21:29:15 +01:00
This pull request has changes conflicting with the target branch.
  • source/blender/editors/interface/interface_region_tooltip.cc
  • source/blender/editors/interface/interface_templates.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin brush-assets-project:brush-assets-project
git checkout brush-assets-project
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#106303
No description provided.