Commit Graph

101468 Commits

Author SHA1 Message Date
Amelie Fondevilla
0c07fb50c8 GPv3: Keyframe on-click selection
Implementation of the click-selection operator of keyframes in the dopesheet, along with its alternatives : deselect all when no frames is hit, extend selection with shift, column selection with alt, select all keyframes on current channel with ctrl+alt.

Includes the new following API functions :
 * `select_frame_at` : selects a frame in a layer at a specific time (if such frame exists),
 * `select_all_frames` : selects all frames of a layer,
 * `select_layer_channel` : selects a layer, and sets it as active (if layer is not null, otherwise the active layer is set null),
 * `layer_has_frame_selected` : checks if any of the frames in the layer is selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/110492
2023-07-26 17:59:09 +02:00
Falk David
d6aa9906fd Modifiers: Add idname field to ModifierTypeInfo
Previously the panel type name of a modifier (e.g. "MOD_PT_Smooth") was
created by copying from the ModifierTypeInfos name.
This meant that modifiers with the same default name would use
the same identifier for the panels.

Since different object types (e.g. OB_GREASE_PENCIL and OB_MESH)
might want to use the same default modifier name, this PR introduces
an idname field in the ModifierTypeInfo struct. This is then used to
generate the panel type name.

For compatibility reasons, the idname is the same as the name for now.

Note: Because the name was used previously, this means that some
modifiers have spaces in their panel type name.
E.g. "MOD_PT_Volume to Mesh".

Pull Request: https://projects.blender.org/blender/blender/pulls/110468
2023-07-26 17:08:14 +02:00
Hans Goudey
580833165c Fix #109583: Avoid non-threadsafe writing to custom normals data
Currently, while calculating face corner normals, Blender retrieves
custom normal data with write access. When the the custom normals in a
single smooth corner fan don't match, they are reset to the average
value.

This behavior is very old, but it comes from when Blender didn't have a
strong idea of const correctness. Indeed, modifying custom normal data
while calculating normals isn't threadsafe, which is important because
normals are calculated for viewport drawing, for example. And in the
future, properly caching face corner normals (see #93551) will require
the ability to calculate normals on a properly const mesh.

The fix is to still use the average of custom normals in a fan, but
not write that back to the custom data array. In my testing the results
are the same. Setting custom normals still fills the same value for all
corners in a fan.

Pull Request: https://projects.blender.org/blender/blender/pulls/110478
2023-07-26 17:04:13 +02:00
Julian Eisel
741c684bf6 Refactor: Pass context to UI view item activate function
The `on_activate()` function is expected to do undo pushes, call
operators, send notifiers and things like that as needed. Context is
necessary for such things, so seems reasonable to provide it as
argument.

Also needed for #110378.
2023-07-26 16:50:17 +02:00
Julian Eisel
2e9bc6373c Refactor: Deduplicate view item active state logic
Much of this was duplicated between grid view and tree view items which
keeping them in sync was becoming a hassle already. Now the logic is
shared via the base class. I find this makes the interfaces easier to
scan through visually as well.

Had to add a virtual iterator function that can be called on an
`AbstractView`.
2023-07-26 16:45:14 +02:00
Jacques Lucke
29aa89e4ec Fix: build error in windows debug builds 2023-07-26 16:39:48 +02:00
Jacques Lucke
932332ad6e BMesh: move bmesh module to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110489
2023-07-26 16:12:55 +02:00
Jacques Lucke
325acb51df Grease Pencil: move legacy grease pencil editors code to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110495
2023-07-26 16:12:48 +02:00
Julian Eisel
5f437908a2 Cleanup: Correct grid view comments 2023-07-26 15:39:47 +02:00
Julian Eisel
dedd55df33 Fix API design issue with activating UI view items
The `on_activate()` function of an item should only be called when the
item was activated through the view, not through an external data change
(e.g. changing an active item through Python). That is important because
`on_activate()` is expected to do things like sending an undo push. This
is now respected in tree and grid views.
2023-07-26 15:39:47 +02:00
Julian Eisel
add3ec71d2 Cleanup: Address clang-tidy warnings in UI views
Unused header warning and `modernize-use-override` warnings.

I would like to selectively disable warnings about redundant `virtual` and
`override` keywords, since both together are useful (`override` enables
important compiler warnings that can avoid bugs, `virtual` helps quickly
identifying API functions available for overriding). But this doesn't
seem to be possible, only all of `modernize-use-override` can be
disabled, so simply keep the `virtual` but comment it out.
2023-07-26 15:39:47 +02:00
Falk David
5846b9164a GeometrySet: Add new GreasePencilComponent
This is mostly boilerplate code to add a new `GeometryComponent` as well as making sure
the new `GeometryComponent::Type` is handled in all the `switch` statements.

Pull Request: https://projects.blender.org/blender/blender/pulls/110457
2023-07-26 13:59:37 +02:00
Campbell Barton
cda7e5af19 PyAPI: expose missing show_region_* properties
Add show_region_channels access for animation editors &
show_region_tools for the spreadsheet.

These could be hidden by resizing the region, there was just not way to
do this from Python.

Exposing these means they can be toggled from WM_MT_region_toggle_pie.
2023-07-26 21:55:26 +10:00
Jacques Lucke
00e6adb49c Grease Pencil: move legacy grease pencil modifiers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110493
2023-07-26 13:45:04 +02:00
Clément Foucault
38542ceeda DRW: Make tests pass
These were just changes that changed the test
output but not the behavior.
2023-07-26 12:42:36 +02:00
Clément Foucault
ad2771878d DRW: Add missing defines for tests
Prior to that, the Draw tests would be missing.
2023-07-26 11:45:36 +02:00
Clément Foucault
2a286ff0f1 GPU: Make shader tests pass on OpenGL
There was some inconsistencies between GLSL and MSL
regarding vector comparison.
2023-07-26 11:27:48 +02:00
Amelie
4c12988d5a GPv3: Add filtering for channels in the grease pencil dopesheet
Take into account the filtering flags while filtering grease pencil channels in the grease pencil dopesheet.
This PR also adds two API functions for layers :
* `is_empty` checks if a layer contains no frame, and
* `is_selected` checks if a layer is selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/110484
2023-07-26 11:06:36 +02:00
Amelie
8fc2b6ad06 GPv3: Prevent crashes from the dopesheet functions
Some animation operators are not yet implemented for Grease Pencil 3, and trigger asserts. This patch prevents the asserts to be triggered in case of grease pencil channels, so that  Grease Pencil 3 can be tested until the operators are properly implemented.

Pull Request: https://projects.blender.org/blender/blender/pulls/110486
2023-07-26 10:29:40 +02:00
Campbell Barton
9c7ef4a3b4 Fix build error in fcacebbfb1
The header was not included, define ulong locally.
2023-07-26 15:52:54 +10:00
Campbell Barton
566118f7f1 UI: change the name of RGN_TYPE_UI in the enum to "Sidebar"
This is the term used in the interface, using this term means enum items
can be used in UI code without having to use a separate name mapping.
2023-07-26 15:23:30 +10:00
Campbell Barton
44b9fba9d2 Cleanup: restore parenthesis in ME_FACE_TRI_TOT macro
This was removed in a recent refactor, also use a more meaningful
argument name.
2023-07-26 15:23:28 +10:00
Campbell Barton
e6dafbed66 Cleanup: spelling in comments 2023-07-26 15:23:26 +10:00
Campbell Barton
cf49cbde45 Cleanup: use doxygen formatting in UI_interface.h, DNA_screen_types.h
Also use doxygen type references & correct some typos.
2023-07-26 15:23:24 +10:00
Campbell Barton
fcacebbfb1 Cleanup: brief unsigned types, bool literals, correct struct comments 2023-07-26 15:23:23 +10:00
Hans Goudey
673fc326db Cleanup: Remove unnecessary manual mesh edit data destruction
Also slightly improve comments about original indices.
2023-07-26 00:08:31 -04:00
Hans Goudey
f9a4fcd8cf Cleanup: Access more mesh data with C++ methods
Recent C++ conversions have enabled more changes like
af53207b43 and 7826aed105.
2023-07-25 21:59:54 -04:00
Germano Cavalcante
fce95f330d Fix #110475: 'Use Mouse Position' option for navigation not working
Caused by 384c2e1f36

The 'Use Mouse Position' option was always being false which caused
navigation operators to behave as if the cursor was in the middle of
the region.
2023-07-25 21:55:44 -03:00
Hans Goudey
aebc743bf1 Cleanup: Make format
Sorry for the noise, I thought I ran this in the previous commit.
2023-07-25 15:23:56 -04:00
Hans Goudey
95edff7495 Cleanup: Rename mesh custom data fields
Implements the rest of #101689, after 5e9ea9243b.

- `vdata` -> `vert_data`
- `edata` -> `edge_data`
- `pdata` -> `face_data`
- `ldata` -> `loop_data`

A deeper rename of `loop` to `corner` will be proposed as a next
step, and renaming `totvert` and `totedge` can be done separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/110432
2023-07-25 21:15:52 +02:00
Brecht Van Lommel
aef3d1c95b Fix grease pencil crash with render engines that don't deliver Z pass
Found during Hydra render engine development, could also happen with
render engine add-ons.
2023-07-25 19:19:51 +02:00
Brecht Van Lommel
97007e56e5 Fix Freestyle build error when not using unity build 2023-07-25 19:19:51 +02:00
Hans Goudey
af19de3986 Cleanup: Pass edge to corner map by value in normal calculation 2023-07-25 11:56:01 -04:00
Hans Goudey
bd4be36894 Cleanup: Avoid passing redundant face index in normal calculation
The current face index can always be retrieved from the "loop_to_face"
map, so passing it around and updating it manually just adds more
state to track.
2023-07-25 11:56:01 -04:00
Hans Goudey
0e87e25b37 Cleanup: Simplify iteration over mesh faces, use utility functions
Utility functions make accessing the next and previous corner of a face
more obvious, and range based for loops make iterating over corners
or vertices in a face simpler too.
2023-07-25 11:56:01 -04:00
Nathan Vegdahl
6b872079fe Fix #88752: overlapping IK constraints with zero-influence misbehave
Bones with overlapping IK constraints would jump about unpredictably
when at least one of those constraints was either zero-influence or
disabled.

The underlying issue appears to be that depsgraph construction assumes
all IK constraints are enabled (which is necessary for e.g. animating
influence), but the IK solver code excludes disabled and zero-influence
constraints from the solve.  This in turn leads to
`BKE_pose_where_is_bone` not getting called when needed in some cases.

This commit addresses the issue by always including all IK targets in
the solve even when disabled or zero-influence, and simply excluding
them from being applied.

See the discussion in #88752 for more details.

This patch was primarily authored by Brecht, but with a minor fix
by me after testing.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/110417
2023-07-25 16:45:31 +02:00
Ray molenkamp
4ea2baf4ae CMake: revert last weeks modernizations
The cleanup of blenkernel last weeks , caused the house of cards to
collapse on  top of bf_gpu's shader_builder, which is off by default
but used on a daily basis by the rendering team.

Given the fixes forward in #110394 ran into a ODR violation in OSL that
was hiding there for years, I don't see another way forward without
impeding the rendering teams productivity for "quite a while" as there
is no guarantee the OSL issue would be the end of it.

the only way forward appears to be back.

this reverts :

19422044ed
a670b53abe
0f541db97c
be516e8c81
3e88a2f44c
4e64b772f5
9547e7a317
07fe6c5a57

The problematic commit was 07fe6c5a57
as blenkernel links most of blender, it's a bit of a link order issue
magnet. Given all these commits stack, it's near impossible to revert
just that one without spending a significant amount of time resolving
merge conflicts. 99% of that work was automated, so easier to just
revert all of them, and re-do the work, than it is to deal with the
merge conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110438
2023-07-25 16:43:21 +02:00
Julian Eisel
9d0907560a UI: Refactor quick label tooltip implementation for buttons
No user visible changes expected. Used in the asset shelf branch,
see #104831.

These tooltips only show a label string and appear after a shorter timeout
than the regular tooltips. After the regular tooltip timeout they expand to
the full tooltip. The toolbar and properties editor navigation tabs make use
of this already.

The changes here enable more control over quick label tooltips, making them
usable in more cases, and less ad-hoc. Main changes:
- Refactors internal logic so a single `UI_BUT_HAS_TOOLTIP_LABEL` button flag
  can be used to enable quick label tooltips. This decentralizes logic in a
  way that's more consistent and extensible.
- Custom callback to return a quick label. This is useful when a label tooltip
  should be displayed even when there is no button string set. E.g. in the
  asset shelf with "Show Names" disabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/110200
2023-07-25 16:22:31 +02:00
Alexander Gavrilov
b248295530 Depsgraph: handle camera switching via markers in context drivers.
Blender allows animating the active camera selection (i.e. scene.camera)
by binding cameras to markers in the timeline. The dependency graph was
completely ignoring this by not building nodes for these cameras (it is
possible to reference a camera not directly included in the scene), and
not taking this into account in driver relations.

This change ensures that all cameras are included in the dependency
graph, and any drivers referencing scene.camera get dependencies on
all cameras of the timeline, and also time itself to ensure switches
are processed.

Pull Request #110139
2023-07-25 14:03:17 +03:00
Alexander Gavrilov
406f601c4b Depsgraph: change the fix for #107081 to handle any Scene references.
The cause of that bug is any dependency on Scene COW, because that is
triggered by selection. Context properties merely are the most reasonable
way for that to happen. Therefore, the special rule should really apply
to any Scene references.

The real motivation is this removes dependency on dvar for when this
code is extracted as a new method in the next commit.

Pull Request #110139
2023-07-25 14:03:17 +03:00
Alexander Gavrilov
347a466e15 Depsgraph: tag relations update when marker camera refs are changed.
Since markers are used to animate scene.camera, changing their camera
links carries the same consequences as changing scene.camera directly.
This means relations need rebuilding in case a new camera was added.

Pull Request #110139
2023-07-25 14:03:17 +03:00
Alexander Gavrilov
cc7dcfcfd5 Depsgraph: tag relations update from Set Active Object As Camera.
Dependency building assumes scene.camera is fixed due to #107081.
Thus it is necessary to do a relations update when it does change.

Pull Request #110139
2023-07-25 14:03:17 +03:00
Campbell Barton
9581007322 Cleanup: correct declaration 2023-07-25 20:51:32 +10:00
Julian Eisel
db0b804a0a UI: Attempt to restore region for redo from Adjust Last Operation panel
The Adjust Last Operation panel would attempt to use the main region,
even when the operator was initially executed in a different region.
This becomes an issue when the operator relies on context of the region.
For example the pose library gets the active asset from context, which
is only available in the region (e.g. asset shelf) displaying the
assets. In general it seems like redo should restore the region of
invocation.

This uses the region type from the initial operator call context to
lookup a region to restore on redo. While not completely bullet proof
(multiple regions of the same type may be present), this should mitigate
the issue quite a bit.

Required for #104831.

Pull Request: https://projects.blender.org/blender/blender/pulls/108892
2023-07-25 12:42:42 +02:00
Julian Eisel
63c07c80f5 Cleanup: Use const for screen lookup helpers 2023-07-25 12:38:47 +02:00
Julian Eisel
4137f9a87f Fix missing redraws of affected regions with dynamically sized regions
Regions that change their size in the layout phase (something that is
supported for a while now) might affect the size of following regions.
For example the asset shelf design forsees that it takes space away from
the tool- and sidebar. When its size changes, tool- and sidebar need to
redraw.

Without this there is a crash in the `asset-shelf` branch:
- Open sidebar
- In the asset shelf Display Settings popover, toggle "Names" twice.

At first the sidebar will be empty, when toggling the second time a
null-dereference will cause a crash. This is because the layout phase of
the sidebar does not run, but after that the region size is updated,
it's tagged for redraw and the draw phase runs (without any layout).

Pull Request: https://projects.blender.org/blender/blender/pulls/110212
2023-07-25 12:07:53 +02:00
Hans Goudey
1f302a0635 Cleanup: Small changes to GP smooth operator
- Avoid calling `.finish()` twice, only pass span
- Fix "opcities" typo
- Remove unnecessary "is_empty()" check
- Group creation of "src_data" in one block
- Remove periods after doxygen titles
- Remove unnecessary "curves" argument
- Order mutable argument last

Pull Request: https://projects.blender.org/blender/blender/pulls/110428
2023-07-25 11:00:45 +02:00
Jacques Lucke
f397ba7571 BLI: update blender::Set vs std::unordered_set benchmark results
Also give more details about the used CPU and compiler.
2023-07-25 10:49:14 +02:00
Campbell Barton
c6725b935c Fix #109720: load_post can't be used to initialize the driver namespace
Regression in [0] changed the order of execution for the load_post
handler which previously (in 3.5x) ran before driver evaluation.

Calling either load_post/load_post_fail handlers after loading was
changed intentionally to simplify the code-path for calling handlers
however it meant the handler couldn't be used to setup drivers,
so restore the original logic.

[0]: 46be42f6b1
2023-07-25 15:42:36 +10:00
Campbell Barton
530ee6e7fa Cleanup: make class doc-strings directly above classes
In some cases it wasn't clear if a comment before a class was meant
to be it's doc-string. Remove blank lines between the class & it's
doc-string.
2023-07-25 14:11:42 +10:00