Commit Graph

5478 Commits

Author SHA1 Message Date
Julian Eisel
cc8cc48a0a Cleanup: UI: Move related tree view functions closer together
These functions are closely related, keep them together.
2025-02-13 12:11:50 +01:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Harley Acheson
5956752eb7 UI: Themeable RedAlert, Error, Warning, Info Colors
The "Red Alert" color is currently hard-coded, which causes problems in
themes.  It also has an Enum value of 0, which precludes using this
value as "unset". We also use Error, Warning, and Info colors that are
part of the Info Editor.  This PR moves these out of the Info Editor
and into the "State" part of the theme. And then makes TH_REDALERT use
the TH_ERROR color.

Pull Request: https://projects.blender.org/blender/blender/pulls/131127
2025-02-12 20:59:47 +01:00
Julian Eisel
e2b1f1f818 UI: Remember scroll offset for tree-views
f0db870822 added support for tree-views to remember state, but only to
remember their custom height for the start. This change makes the scroll
offset be remembered too.

Not remembering the scroll offset can be very annoying in some cases,
e.g. when working with bone collections and changing the active tab in
the properties editor often. In realistic, non-trivial bone collection
set ups this can lead to a lot of repeated scrolling.
2025-02-10 15:56:10 +01:00
Sebastian Parborg
cad4b39af3 Merge branch 'blender-v4.4-release' 2025-02-08 12:03:13 +01:00
Sebastian Parborg
ea380b1efe Revert "Sound: Sync up the screen refresh timer to the audio when seeking"
This reverts commit c952b12a6e.

This caused segfaults when playing back animations and seeking.
See #133542
2025-02-08 12:01:51 +01:00
Sebastian Parborg
7a0f2ce8b1 Merge branch 'blender-v4.4-release' 2025-02-07 19:01:22 +01:00
Falk David
971f3e0699 Fix #132826: Grease Pencil: Missing "Paste by Layer" option
The Grease Pencil `Clipboard` only stored a single `CurvesGeometry`. This meant
that the `Paste by Layer` operation (from 4.2 LTS) couldn't be implemented.

This PR adds an `Array` of `ClipboardLayer`s to the  `Clipboard`. Each layer stores
the name of the Grease Pencil layer that it was copied from and the `CurvesGeometry`.

The `grease_pencil.paste` operator has a new property `type` (`ACTIVE` or `LAYER`)
that decides how to paste the strokes.

Using the `ACTIVE` type, the strokes of all the `ClipboardLayer`s get merged and then
pasted to the active layer.
Using the `LAYER` type, we first try to find layers to paste the `ClipboardLayer`s into.
We just look for matching layer names. If no matching layer is found, the strokes are
pasted into the active layer instead.

This should be consistent with how Grease Pencil used to behave in 4.2. LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/134168
2025-02-07 16:17:16 +01:00
Hans Goudey
d216476458 Cleanup: Use StringRef for UI search menu code
Also use Vector to store menu search items instead of a linked
list. And extend the change into the autocomplete API slightly.
The main benefit is to avoid measuring the length of strings over
and over, but the code also gets simpler.
2025-02-05 18:27:44 -05:00
Philipp Oeser
eecf5787c1 Fix #119932: Weight paint loop selection fails when bones are rotated
Previous approach was using non-evaluated meshes to find the closest edge from a face index retrieved from the selection buffer.
This can fail though if the mesh is deformed or even altered to not have the same indices anymore (e.g. generating/masking modifiers).

In order to make this work, added `ED_mesh_pick_edge` which switches the selection context to edges directly
and picks from those. No need to map anything back and forth between original and evaluated, the selection buffer contains the original indices already.

Further logic (following the face loop) is untouched (and happens on the original geometry which is fine)

Should go into 4.2 LTS as well

Pull Request: https://projects.blender.org/blender/blender/pulls/132803
2025-02-05 15:13:48 +01:00
Julian Eisel
21e626ced3 Refactor: Assets: Improve asset system APIs for asset operators
Brush and pose asset operators were doing some avoidable roundtrips
through asset types, lookups and rather low level operations. This
indicates that the asset system APIs need some improvements. Moving
lower-level logic there can help avoiding errors, since implementation
details are kept inside the corresponding module.

- Avoid lookups for asset library reference in operator code, make asset
  library itself construct it.
- Avoid redundant lookups for asset library definition (was looking up
  the asset library definition in the Preferences from the library
  reference type, just to turn it into the reference type again).
- Add utility for refreshing loading asset libraries
- Add utility for saving asset catalogs for an asset
- Remove unused function
2025-02-04 17:28:23 +01:00
Sybren A. Stüvel
2b5946da4e Anim: make copy-paste of keyframes slot-aware
Copy-paste of keyframes is now slot-aware. See [1] for the design.

[1]: https://developer.blender.org/docs/features/animation/tools/action-editor-copy-paste/

In short:

- Copy-paste still works broadly as it used to. Only the visible
  F-Curves are pasted into.
- Slot identifiers matter when copying from multiple slots. When
  copying from one slot, they don't.
- Selection of channels (either F-Curves or Slots) determines where
  keys get pasted into.
- Pasting will either copy from the slot with the same identifier
  (when identifiers matter), or paste whatever was copied (when they
  do not).
- If both F-Curves and slots are selected, only the selected F-Curves
  get pasted into, and slots without any selected F-Curves are ignored
  (i.e. target is only defined by selected F-Curves, or only by
  selected slots, never by a mixture).

Fixes #129690

Pull Request: https://projects.blender.org/blender/blender/pulls/133979
2025-02-04 16:12:57 +01:00
Sebastian Parborg
c952b12a6e Sound: Sync up the screen refresh timer to the audio when seeking
This fixes the case when the screen update timer would not be reset
when seeking leading to screen updates happening mid frame.
For example when jumping to a keyframe during playback.

Note that this doesn't reset the timer when no audio is playing.
It would be nice to have it happen there as well. But it is probably not
too noticeable.

Pull Request: https://projects.blender.org/blender/blender/pulls/133542
2025-02-04 15:30:20 +01:00
Hans Goudey
73b25ba12e Cleanup: Use StringRef for some WM and UI APIs
Instead of const char * or StringRefNull.

Pull Request: https://projects.blender.org/blender/blender/pulls/134004
2025-02-04 13:53:30 +01:00
Christoph Lendenfeld
358a0479e8 Anim: create pose assets to different libraries
Similar to how brush assets are created and managed this
PR allows to export pose assets into a different library.
Because of this there is a limitation to this where each
asset is stored in a separate blend file.
This may be lifted in the future as there are planned changes in
the design phase: #122061

### Create Asset

Now available in the 3D viewport in the "Pose" menu: "Create Pose Asset".
The button in the Dope Sheet will now call this new operator as well.

Clicking either of those will open a popup in which you can:

* Choose the name of the asset, which library and catalog it goes into.
* Clicking "Create" will create a pose asset on disk in the given library.

It is possible to create files into an outside library or add it in the current file.
The latter option does a lot less since it basically just creates the
action and tags it as an asset.

If no Asset Shelf **AND** no Asset Browser is visible anywhere in Blender,
the Asset Shelf will be shown on the 3D viewport from which
the operator was called.

### Adjust Pose Asset

Right clicking a pose asset that has been created in the way described
before will have options to overwrite it.
Only the active object will be considered for updating a pose asset

Available Options (the latter 3 under the "Modify Pose Asset" submenu):
* Adjust Pose Asset: From the selected bones, update ONLY channels that
are also present in the asset. This is the default.
* Replace: Will completely replace the data in the Pose Asset from
the current selection
* Add: Adds the current selection to the Pose Asset. Any already existing
channels have their values updated
* Remove: Remove selected bones from the pose asset

Currently this refreshes the thumbnail. In the case of custom
thumbnails it might not be something want

### Deleting an existing Pose Asset

Right click on a Pose Asset and hit "Delete Pose Asset". Works in the shelf
and in the asset library. Doing so will pop up a confirmation dialog,
if confirming, the asset is gone forever. Deleting a local asset is basically the
same as clearing the asset. This is a bit confusing because you get
two options that basically do the same thing sometimes,
but "Delete" works in other cases as well.
I currently don't see a way around that.

Part of design #131840

Pull Request: https://projects.blender.org/blender/blender/pulls/132747
2025-02-04 11:29:05 +01:00
Campbell Barton
007d46ef6d Cleanup: rename "opengl" to "gpu" for 3D viewport utilities 2025-02-04 21:19:28 +11:00
Campbell Barton
972a8c7b76 Cleanup: unused window argument to view3d_region_operator_needs_opengl 2025-02-04 21:17:10 +11:00
Julian Eisel
7acd7e1246 UI: Rewrite asset shelf preview loading
- Fixes preview flickering on actions like undo/redo in the asset shelf (#93726), not yet for the
  file browser.
- Fixes #130861.

Makes the asset shelf use the asynchronous preview loading system of the UI instead of the file
browser one. The issues above where mostly caused by the file browser caching design.

The asset system and its UIs can now manage previews independently of the file browser back-end.
This is another step towards making the asset system independent of the file browser, see
https://developer.blender.org/docs/features/asset_system/fundamentals/from_file_browser_to_asset_system/.
Code to query asset previews through file browser types is removed.

Quite some work was done to prepare the UI preview system for this, to make it on par with the file
browser preview system. E.g.: 9d83061ed4, 315e7e04a8, 5055adc1c0, 16ab6111f7.

Note that the same change should be done to the asset/file browser, but this requires more work.

Pull Request: https://projects.blender.org/blender/blender/pulls/131871
2025-02-03 13:13:53 +01:00
YimingWu
44f2c4836f Fix #132743: Grease Pencil: Support drawing primitives on the back
The "On Back" option in the viewport draw mode allows new strokes to be
placed behind existing strokes, grease pencil will now recognize this
option when using primitives drawing tool.

Pull Request: https://projects.blender.org/blender/blender/pulls/132787
2025-01-31 17:46:27 +01:00
Brecht Van Lommel
3725fad82f Cleanup: Various clang-tidy warnings in editors
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Jonas Holzman
22582bf6f0 UI: Node Editor Color Drag & Drop Support
This patch adds support for drag and dropping colors (from color buttons) into
the Compositing, Shading and Geometry node trees.

Additional support was added for dragging and dropping colors with an Alpha
component (which was previously ignored), both in the context of the Node Editor
and for Color Buttons in general. This handles cases like drag and dropping a
color from an RGB to an RGBA button, which recreates the color with a default
Alpha value of 1.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/129026
2025-01-30 12:37:15 +01:00
Sybren A. Stüvel
6d832ee5b3 Anim: refactor keyframe copy/paste code
Refactor the keyframe copy-paste code to prepare for supporting action slots.

This is a non-functional change, as the slots are stored but otherwise completely ignored. This way the refactor to the new data structure can be reviewed & tested before actually changing the behaviour.

Related: #129690
Pull Request: https://projects.blender.org/blender/blender/pulls/133497
2025-01-30 10:28:45 +01:00
Hans Goudey
ca64f2f7e7 Cleanup: Use StringRef instead of StringRefNull 2025-01-29 12:49:41 -05:00
Julian Eisel
f5b1a4625d UI: Allow drawing icons as drag previews, use for dragging assets
Instead of requiring an image buffer to draw a bigger preview image
while dragging, allow passing an icon ID and draw that as preview. This
is also how we draw previews elsewhere. Use this for attaching the asset
previews to draggable buttons.

A small user visible change is that previews from the asset browser will
always draw at the default size (multiplied by the interface scale)
while dragging. Previously it used the same size as the asset browser
preview size, which I don't think was useful really. With small sizes
the preview while dragging got unnecessarily small too, with big sizes
it got in the way.

Needed for #131871.
2025-01-24 22:32:27 +01:00
Julian Eisel
315e7e04a8 UI: Avoid double scaling of preview images, improve filtering
When loading preview images from disk, we'd first scale them to the
standard preview image size (in `icon_copy_rect()`) and then scale them
again to the drawing size when eventually drawing to screen. The first
scaling would happen on the CPU, which is slow, and without filtering.

Now the image is stored in its original size and only scaled when
drawing, which uses scaling on the GPU with mipmaps and bi-linear
filtering. While a bit more blurry, the resulting image has less
artifacts and represents the original image better. Keeping the images
unscaled means memory footprint is bigger, we could cap the size if
necessary.

Noticed while working on #131871. Asset shelf previews would have more
artifacts than before.

See pull request for comparisons.

Pull Request: https://projects.blender.org/blender/blender/pulls/133559
2025-01-24 19:46:33 +01:00
Christoph Lendenfeld
e4f34453e3 Refactor: pass Vector instead of ListBase to motion path functions
This changes the `ListBase` argument for certain motion path functions
to `Vector<MPathTarget *>`. (and `Span`)

To better describe what the function is doing,
`animviz_get_object_motionpaths` has been renamed
to `animviz_build_motionpath_targets`.

Since `BLI_freelistN` can no longer be used, I added
`animviz_free_motionpath_targets`.

Note that the Vector is of `MPathTarget *` which
are allocated the C way. Because the `MPathTarget` struct is defined
in the .cc file, that's the only way for it to work atm.
Other refactors may mitigate that in the future, but I wanted to keep
the scope small.

Pull Request: https://projects.blender.org/blender/blender/pulls/133212
2025-01-24 12:43:20 +01:00
Julian Eisel
efadb938f0 Fix #132422: Crash when opening UV editor from shader editor
Fixes: #132422, #133288.

`ED_area_init()` is called when the editor in an area changes, this also changes
the available regions. That means, region polling needs to be executed. The
crash was happening because that wasn't the case, and the asset shelf region was
initialized before the polling was executed, which allocates region data in the
`on_poll_success()` callback.

Also had to pass context to `ED_area_init()`, which is an annoyance, but should
be fine. Similar functions like `ED_area_exit()` take it too.

Pull Request: https://projects.blender.org/blender/blender/pulls/133388
2025-01-22 19:24:38 +01:00
Harley Acheson
efe75841d3 UI: Status Bar Display for POSELIB_OT_blend_pose_asset
Simplify and improve the status bar display by adding icons and
state highlighting while running "Blend Pose Asset".

Pull Request: https://projects.blender.org/blender/blender/pulls/133397
2025-01-22 03:30:40 +01:00
Lukas Tönne
cde64dbdd5 Fix #129145: Grease Pencil: Stroke depth detection and interpolation for drawing and primitives
GPv2 used the depth buffer at the end of a stroke drawing operation to project points and interpolated between detected values. This does not work in GPv3 because the strokes are added directly to drawings. Depth projection has to happen continuously, updating points between the last depth value and the next when a new hit is recorded.

Resolves #125258.

Pull Request: https://projects.blender.org/blender/blender/pulls/131842
2025-01-21 13:04:48 +01:00
Christoph Lendenfeld
3f76352149 Refactor: extract utility functions from brush asset code
No functional changes intended.

Some functionality from the brush asset system will be reused by the pose library.
To avoid duplicating code, the relevant functions are extracted to a common place.

All functions are moved as is, except for `visit_library_catalogs_catalog_for_search`.
For that I changed the `bUserAssetLibrary` argument to a `AssetLibraryReference`.
That is because in the follow up PR I am using this function with non user libraries as well.

This is a refactor PR extracted from #132747.
To get a full picture of the use case see that PR.

Part of #131840

Pull Request: https://projects.blender.org/blender/blender/pulls/132857
2025-01-17 17:11:03 +01:00
Campbell Barton
4e683c4bd6 Cleanup: doxygen formatting for param 2025-01-16 13:04:17 +11:00
T0MIS0N
ac64ada636 Texture: Add an option for scaling all UDIM tiles when resizing images
This addresses the 'Resize UDIM sequences' feature from issue #109820

If the user needs to resize all UDIMs in an image, they currently need
to go through a tedious process of switching through all the UDIMs and
resizing them individually.

Now, when the user resizes an image, they can choose to apply the
operation to all UDIM tiles in the image.

Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/132524
2025-01-15 03:30:29 +01:00
Harley Acheson
de95daaadf Fix #130171: Stop Panel Animation When Removing Regions
When removing areas ensure that none of its panels are currently
running open/close animations. If so turn them off.

Pull Request: https://projects.blender.org/blender/blender/pulls/131998
2025-01-14 19:43:42 +01:00
YimingWu
1bacb0de62 Fix #132987: Grease Pencil: Ensure selection domain when switching modes
Grease Pencil tool settings could have different selection modes for
different object modes (like edit mode and sculpt mode). This fix
ensures when switching object modes, the selection domain is updated to
match the selection mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/133030
2025-01-14 16:46:23 +01:00
Jacques Lucke
684fd4643a Nodes: use BKE_main_ensure_invariants directly instead of ED_node_tree_propagate_change
`BKE_main_ensure_invariants` was added in 1fae5fd8f6. The older
`ED_node_tree_propagate_change` was already implemented as a thin wrapper around
`BKE_main_ensure_invariants`. This patch removes the wrapper and calls the more
general function directly.

A new overload of `BKE_main_ensure_invariants` is added for the common case when
only a single data-block has been modified.

Pull Request: https://projects.blender.org/blender/blender/pulls/133048
2025-01-14 16:26:54 +01:00
Pratik Borhade
eb57878bec Grease Pencil: Support Boolean property in modifier panel header
A separate function is declared/defined `uiLayoutPanelPropWithBoolHeader`,
it will add a boolean property to the panel.header.
Clear decorate and separator flag, otherwise they will offset the panel
header horizontally and also adds animate decorator on the right side.

Resolves #131623.

Pull Request: https://projects.blender.org/blender/blender/pulls/132726
2025-01-10 14:51:19 +01:00
Lukas Tönne
d27e0fcbaf Fix #130855: RegionView3D matrices need to be reset before transforming points
- In "Surface" mode the depth buffer needs to be cached after constructing the base DrawingPlacement, otherwise there is no depth data for projection and the origin is used as a fallback.
- The DrawingPlacement relies on the RegionView3D matrices to project from the rendered image back into 3D space. Because the boundary projection is called while the rv3d matrices are still set up for the image render it will look up the wrong pixels from the depth buffer. The solution is to make sure the viewport reset happens before projecting the boundary, i.e. by making sure the reset function is called before `process_image`.
- The aspect ratio needs to be taken into account for the boundary-to-strokes transform, otherwise the placement is wrong depending on how much the region aspect deviates from square.

The code for computing the zoom factor and offset has also been cleaned up and documented somewhat better, and now uses the `Bounds<float2>` struct instead of old `rctf`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131321
2025-01-10 12:17:38 +01:00
Hans Goudey
7c775c6f57 Cleanup: Move some node editors functions to C++ namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/132873
2025-01-09 19:19:06 +01:00
Jacques Lucke
038159e96b Refactor: Nodes: improve node tree update API
Main goals of this refactor:
* Make it more obvious which update function should be used.
* Make it more obvious which parameters are required by using references instead
  of pointers.
* Support passing in multiple modified trees instead of just a single one.

No functional changes are expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/132862
2025-01-09 17:00:05 +01:00
Jacques Lucke
db7ff834c9 Refactor: Nodes: remove context argument from propagation function
The part that used the context does not seem to be necessary anymore. If the
given tree has any update tag set, the same notifiers will be sent anyway by the
`tree_changed_fn` callback.

If it turns out that we are now missing some notifier, then we have to change
the caller. It either has to call the proper `BKE_ntree_update_tag_*` function,
or create the notifier directly.

This change helps to generalize the concept of propagating changes in original
data, because the context is rarely available.

Pull Request: https://projects.blender.org/blender/blender/pulls/132810
2025-01-08 19:45:50 +01:00
Campbell Barton
7e8dcf77db Cleanup: pass UnitSettings as a const reference 2025-01-08 21:22:45 +11:00
Falk David
a9c87a15fc Cleanup: VSE: Rename SequenceColorTag to StripColorTag and flags
Also rename the flags from `SEQUENCE_COLOR_*` to `STRIP_COLOR_*`.
2025-01-07 17:19:24 +01:00
Falk David
8541296e9d Cleanup: VSE: Rename Strip *seq variables to strip
This only renames variables named `seq` and not other variants,
like `seq_*` or `seq1`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132736
2025-01-07 14:09:45 +01:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Campbell Barton
5003253aca Cleanup: spelling & repeated terms 2025-01-07 13:20:19 +11:00
Julian Eisel
11b006e01a UI: Don't spawn asset shelf popup by hovering button
Papercut reported in #132293.

Allow explicitly disabling this behavior for a button, and do so for the
big preview asset shelf popup button. It gets more in the way than it's
useful in this case.
2025-01-06 17:42:29 +01:00
Falk David
655a17a6ab Refactor: VSE: Rename Sequence to Strip
This renames the struct `Sequence` to `Strip`.

While the motivation for this partially comes from
the "Sequence Design" #131329, it seems like this
is a good refactor whether the design gets implemented
or not.

The `Sequence` represents what users see as strips in the
VSE. Many places in the code already refere to a `Sequence`
as "strip". It's the C-style "base class" of all strip types.

This also renames the python RNA type `bpy.types.Sequence`
to `bpy.types.Strip` which means that this technically breaks
the python API.

Pull Request: https://projects.blender.org/blender/blender/pulls/132179
2025-01-06 14:19:24 +01:00
Campbell Barton
d2d754be3f Cleanup: spelling in comments (make check_spelling*)
- Back-tick quote math expressions so differentiate them
  from English.
- Use doxygen code blocks for TEX expressions.
2025-01-04 16:26:39 +11:00
Christoph Lendenfeld
7636e6fca4 Fix #132182: Graph Editor slider increment having no visible effect
The issue was that the range for the time offset operator
was so large, that the 0.1 increment seemingly had no effect.
The solution is to add functionality to the slider to specify the increment step.
Since the time offset operator deals in frames it made sense to snap to whole numbers.

Also fixes #132187
For that the increment step has been chosen to allow for 10 steps in the slider range.

Pull Request: https://projects.blender.org/blender/blender/pulls/132554
2025-01-03 17:23:12 +01:00
Hans Goudey
70a86b14c0 Cleanup: Repace BLI_range.h with Bounds<float>
Pull Request: https://projects.blender.org/blender/blender/pulls/132181
2024-12-20 21:05:40 +01:00