Use new `_in_lib` BKE_image API to re-use or load an image from/in the
expected library, including using the library path as root path for
relative file paths handling.
Using the new `BKE_image..._in_lib` API also allows to get rid of the
`check_exists` 'hack' introduced in `image_open_exec` (when support to
edit some linked data was added, in 5f9f3116db) to avoid re-using local
Image IDs for editable linked data (brush assets), since
`BKE_image_load_exists_in_lib` will now ensure to only re-use an Image
ID if it matches the target library.
This commit also simplifies/makes `ED_image_filesel_detect_sequences`
signature more to the point. It replaces the `Main` parameter by a mere
`root_path` string. The given `bmain` was indeed only used to extract
(again) a base for relative paths.
NOTE: The general idea of this fix is the same as in PR !130058, thanks
to Sean Kim for the investigation and initial fix.
Pull Request: https://projects.blender.org/blender/blender/pulls/130197
This commit adds support for clang-tidy checks during compilation on
macOS, which can now be enabled using the optional `WITH_CLANG_TIDY`
CMake variable.
The clang-tidy executable doesn't need to be separately installed since
CMake will pick up the executable from the LLVM pre-compiled library.
This commit also expands the coverage of clang-tidy checks to
Objective-C/C++, for which checks were enabled in PR #128334.
Pull Request: https://projects.blender.org/blender/blender/pulls/129761
Previously, we had to fetch all asset previews at once. However the preview
caching system was limited at 8192 previews, so with large asset libraries, many
previews would get dropped. Instead, allow selectively requesting previews and
only request previews of items displayed on screen. This should fix the issue,
and reduce the time it takes to display brush assets in general, especially with
bigger libraries. This should also reduce memory usage quite a lot when
displaying the asset shelf, since not all asset previews are loaded anymore.
Pull Request: https://projects.blender.org/blender/blender/pulls/130105
This commit refactors `BKE_image_load` and `BKE_image_load_exists` APIs:
* Remove the `_ex` versions (the 'exist' boolean return pointer can have
default `nullptr` value instead).
* Add `_in_lib` versions, which match signature and behavior of the
generic ID creation code to allow to find or create a new image ID
directly in a library 'namespace' (as linked data).
This is required by upcommig fixes for Brush Assets, which are using
linked but editable data-blocks.
Fix#130194: When trying to add a new image from the UI (e.g. for a new
texture) for a local ID, if that same exact image was already loaded by
a linked ID, it would trigger an assert in `BKE_id_move_to_same_lib`,
because `BKE_image_load_exists` would return the matching linked Image ID
instead of creating a new local one. In release builds with no assert,
it would result in making a linked ID 'local', while still being used by
original other linked data.
Passing around the intended final destination of the new Image (local or
in a given library) allows `BKE_image_load_exists` to be more specific
when searching for an already loaded matching image ID, and ensures that
a new local Image ID is created in the case described above.
Pull Request: https://projects.blender.org/blender/blender/pulls/130195
Remove `node_under_mouse_tweak` and replace it with
`node_under_mouse_select`.
The special handling for tweaking reroutes wasn't working correctly:
1. It didn't check at the correct reroute node location.
2. The (de-)selection behavior negated possible benefits anyway.
In practice the user-facing behavior is not affected by this.
Pull Request: https://projects.blender.org/blender/blender/pulls/130222
Partial fix for #129267.
Avoid creating an entry in the file list cache for every asset when iterating
over the available assets. For this, allow passing a pre-filter function to the
asset iterator, to filter based on `AssetRepresentation` data. The asset shelf
can then pre-filter based on asset type and the active catalog.
Really, the cached file entry is only needed to access the preview image of the
asset, so it can be avoided most of the time.
While this should still be solved properly as outlined in #122439, this is
a general improvement and fix the mentioned report in a minimal way.
Was hoping this would be sufficient to fix#129267, but the whole of
!130105 will be needed.
Pull Request: https://projects.blender.org/blender/blender/pulls/130166
This implements the proposal from #124512. For that it contains the following
changes:
* Remove the global override of `new`/`delete` when `WITH_CXX_GUARDEDALLOC` was
enabled.
* Always use `MEM_CXX_CLASS_ALLOC_FUNCS` where it is currently used. This used
to be guarded by `WITH_CXX_GUARDEDALLOC` in some but not all cases. This means
that a few classes which didn't use our guarded allocator by default before,
are now using it.
Pull Request: https://projects.blender.org/blender/blender/pulls/130181
Caused by 71398478b2.
`parsubstr` is nullptr in Layer struct. This results in crash when an
object is parented to a new layer. This can be fixed by passing layer
member function `parent_bone_name()`. It handles the null pointer.
Pull Request: https://projects.blender.org/blender/blender/pulls/130205
* Early return in case the given `id` is already in the same library as
its target `owner_id` (in addition to both being local data).
* Assert with message AND return in case the given `id` is a linked ID
from a different library.
The second point somewhat mitigates the severity of #130194.
These were last used in some sculpt code that has been refactored
to do things more efficiently. For that same reason I don't think we're
likely to need them elsewhere.
OBJ, PLY, and STL used a mix of fprintf, std::cout, and std::cerr to
trace warnings, errors, and general messages to the console.
Now, we instead use CLOG which provides real facilities for warnings and
errors and generally removes the need to pull in and use the heavy
`<iostream>` machinery.
For traces that should always be printed, `fmt::print` is used since
CLOG currently doesn't provide that particular level of trace.
Tests were only minimally changed to drop usage of streams while keeping
their prior usage of older stdio APIs. We can change to using fmtlib
there too if desired.
Pull Request: https://projects.blender.org/blender/blender/pulls/130107
There is actually a valid (rare) case where a Library ID can have a `0`
versionfile value during blendfile loading: if that library only
contains 'indirect weak' linked data.
These IDs are only actually read in the library blendfile if they are
also used by some other data, otherwise they are purposedly dropped and
removed, and the library blendfile can end up never being read at all.
This would lead to a completely empty library on blendfile loading,
which can then be removed from the data-base.
NOTE: this _does not_ affect cases where the whole library is missing,
or some linked IDs from that library are not found anymore.
The data-block selector filters out local data-blocks when trying to
assign to linked data. A lot of data-block management relies on this.
Since these data-blocks are created for the use with brushes only,
create them under the same library that the brush is from, as indirect
data. The UI allows selecting these data-blocks then. We do the same for
textures attached to a brush, and some other data-block types.
Also add paint-curves to the editable data-block types, so they can be
edited despite being considered linked data.
Pull Request: https://projects.blender.org/blender/blender/pulls/130184
Brush assets from the current file should be supported like other brush
assets.
This assert would fail on startup for example, when opening the
essentials file containing the default brush of this mode.
The operator to move a channel to the top revered the layer order
by iterating from the top to the bottom and moving selected channels
to the top. Iterate from the bottom to the top instead to keep the right
layer ordering.
Pull Request: https://projects.blender.org/blender/blender/pulls/128793
The cache mechanism for line art is changed during migration to GPv3,
however the code path failed to handle following cases which could lead
to a few problems:
- Line art cache isn't deleted after last line art modifier because it
coule be hidden, causing memory leaks.
- A modifier inside a multiple line art modifier sequence that doesn't
use cache would prematurely delete line art cache, causing subsequent
line art modifier to give empty result.
- When the first line art modifier is hidden (in viewport/render), the
cache is not created correctly, leading to crashes.
Now the new code logic addresses these problems properly by:
- Making sure the last visible line art modifier deletes cache.
- Giving a fresh cache pointer for modifiers that doesn't use global
cache.
- Line art cache is correctly ensured when there are modifiers that
are hidden
Pull Request: https://projects.blender.org/blender/blender/pulls/129953
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.