Commit Graph

101162 Commits

Author SHA1 Message Date
Jacques Lucke
3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Jacques Lucke
19d4cafb12 Cleanup: move more editors code to c++
This moves the remaining `.c` files in the following `editors` folders to C++:
`physics`, `screen`, `sound`, `space_buttons`, `space_file`, `space_graph` and `space_image`.

One exception is `fsmenu.c` which has platform specific issues on macos and
windows. E.g. the `Carbon/Carbon.h` include also declares a `Collection` type that collides
with ours.

Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/109918
2023-07-12 13:43:00 +02:00
Jacques Lucke
38cecf9f89 Fix: simulation nodes baking does not work
This was accidentally broken in 7ec335f995.
There is a difference between resetting the `std::shared_ptr` and resetting
the cache.
2023-07-12 13:08:28 +02:00
Falk David
84c8c331b4 Fix: Complier error
The commit 64887c80a2 declared
rna_enum_grease_pencil_selectmode_items as static, when it should
have not been static.
2023-07-12 12:01:13 +02:00
Richard Antalik
5f17e0c796 VSE: Optimize cache linking
Pass key that is being removed to `seq_cache_relink_keys()`. This allows
to remove checks before calling the function. Also makes it possible to
assert, that links are actually pointing where they should be.
2023-07-12 10:50:45 +02:00
Falk David
09f8f4d049 GPv3: Add initial dopesheet support
This PR adds basic support for viewing layers and keyframes in the grease pencil dopsheet for the new grease pencil data-type.
Resolves #108508.

Co-authored-by: Amelie Fondevilla <amelie.fondevilla@les-fees-speciales.coop>
Pull Request: https://projects.blender.org/blender/blender/pulls/108807
2023-07-12 10:32:09 +02:00
Sietse Brouwer
64887c80a2 GPv3: Convert selection domain on curves when selection mode changes
When the selection mode in the Grease Pencil tool settings changes,
the selection domain of all curves in the active Grease Pencil object
has to change.
This PR handles that conversion. Point selections are converted to
curve selection and vice versa.

Note: this PR only takes care of selection modes 'Point' and 'Stroke'.
'Segment' mode is handled in a separate PR (#109221).

Pull Request: https://projects.blender.org/blender/blender/pulls/109964
2023-07-12 10:22:46 +02:00
Philipp Oeser
ac3f4e959f Fix #109822: Average Brush in Vertex Paint Mode is broken
Caused by 7a943428de

Looking at history, e.g. 575ade22d4 or prior, it seems the
"fallthrough" [related compiler warning was removed in 7a943428de] was
actually intended in the case of `VPAINT_TOOL_AVERAGE`.

So first, the average color is calculated and after that regular drawing
should happen with that color.

Now make this more clear by calling both `calculate_average_color` as
well as `vpaint_do_draw` before breaking.

Pull Request: https://projects.blender.org/blender/blender/pulls/109971
2023-07-12 09:45:21 +02:00
Harley Acheson
c6adafd8ef UI: add progress indicator variations & RNA API
Add pie and ring styles of progress indicators. Exposes progress bar to
the Python API and adds a "type" property to allow style variation.

This can be used for scripts & add-ons to show progress in the UI.

Ref !109882.

Co-authored-by: Campbell Barton <campbell@blender.org>
2023-07-12 14:00:39 +10:00
Campbell Barton
e63a77eeb8 Cleanup: rename uiButProgressbar to uiButProgress
Prepare for other types of progress to be added.
2023-07-12 13:31:46 +10:00
Campbell Barton
46815ac188 Cleanup: quiet warning for a NONULL argument being NULL
Only call BKE_pose_blend_write when the object has a pose.
2023-07-12 13:30:54 +10:00
Campbell Barton
f9316e4079 Cleanup: spelling in comments 2023-07-12 12:45:35 +10:00
Campbell Barton
d5c2c98314 Cleanup: remove redundant call to seq_cache_relink_keys
When all keys are removed there is no need to update links.
2023-07-12 12:41:33 +10:00
Campbell Barton
7af0c79722 Cleanup: add function attributes to BKE_action.h 2023-07-12 12:31:05 +10:00
Guillermo Venegas
6c3a2a033a Fix: wrong parameter order in BKE_action_frame_range_calc
Error in 2f2facef74.

Ref !109979.
2023-07-12 12:31:05 +10:00
Richard Antalik
02c87b1740 Fix possible use after free in VSE cache
Use `BLI_ghash_insert` instead of `BLI_ghash_reinsert` to store images.

VSE links stored cache keys for each frame in style of linked list.
These links must be maintained when any image/key is removed from the
cache. Reinserting can free key without proper relinking, which would
lead to accessing this freed key when cache limiting frees images in
a frame.

This should not happen since reinserting is prevented in
`seq_cache_put()`, but it's safer to assert, that key is not stored in
hash instead.
2023-07-12 03:36:14 +02:00
Hans Goudey
c728fa0663 Cleanup: Simplify retrieving color attribute, improve const correctness
Make it harder to retrieve a mutable attribute from const a const mesh,
and use the attribute search function to check multiple domains and
colors at once.
2023-07-11 16:50:34 -04:00
Jacques Lucke
3d73b71a97 Geometry Nodes: new Repeat Zone
This adds support for running a set of nodes repeatedly. The number
of iterations can be controlled dynamically as an input of the repeat
zone. The repeat zone can be added in via the search or from the
Add > Utilities menu.

The main use case is to replace long repetitive node chains with a more
flexible alternative. Technically, repeat zones can also be used for
many other use cases. However, due to their serial nature, performance
is very  sub-optimal when they are used to solve problems that could
be processed in parallel. Better solutions for such use cases will
be worked on separately.

Repeat zones are similar to simulation zones. The major difference is
that they have no concept of time and are always evaluated entirely in
the current frame, while in simulations only a single iteration is
evaluated per frame.

Stopping the repetition early using a dynamic condition is not yet
supported. "Break" functionality can be implemented manually using
Switch nodes in the  loop for now. It's likely that this functionality
will be built into the repeat zone in the future.
For now, things are kept more simple.

Remaining Todos after this first version:
* Improve socket inspection and viewer node support. Currently, only
  the first iteration is taken into account for socket inspection
  and the viewer.
* Make loop evaluation more lazy. Currently, the evaluation is eager,
  meaning that it evaluates some nodes even though their output may not
  be required.

Pull Request: https://projects.blender.org/blender/blender/pulls/109164
2023-07-11 22:36:10 +02:00
Ray Molenkamp
9547e7a317 Fix: shader_builder build issue
The blenkernel cleanup commit from this morning
forgot to update the shader builder.
2023-07-11 14:20:31 -06:00
Hans Goudey
282993e75f Cleanup: Simplify RNA access of attribute data type and domain 2023-07-11 15:43:48 -04:00
Hans Goudey
f0b53777c8 Cleanup: Use spans and float3 to store sculpt and PBVH vert positions
Also store the allocated deformed positions in a separate array in PBVH,
so there isn't one pointer that _sometimes_ has ownership of its data.

Pull Request: https://projects.blender.org/blender/blender/pulls/109981
2023-07-11 21:01:53 +02:00
Hans Goudey
90ba798885 Cleanup: Remove file added mistakenly in previous commit 2023-07-11 14:54:54 -04:00
Hans Goudey
be09e94f05 Cleanup: Remove unused animation channel type
Unused after f3f05daf11
2023-07-11 14:50:29 -04:00
Hans Goudey
f5ffdafea2 Fix: Node operators crash when using depsgraph
The scene time node and volume nodes crashed, since the despgraph
needs to be retrieved from the operator data instead of modifier data.
2023-07-11 13:38:25 -04:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Hans Goudey
c8e0c69c73 Geometry Nodes: Hide node operators behind experimental option for now
Until the traits (#109526) and the redo panel (#109975) are added,
this is non-functional and confusing enough that it's worth hiding.
2023-07-11 11:43:40 -04:00
Bastien Montagne
8e780e9415 Cleanup: Unused parameters warning in release builds. 2023-07-11 17:10:04 +02:00
Hans Goudey
f3f05daf11 Cleanup: Remove unused "Simulation" data-block
This data-block was originally added in eb4e3bbe68.
However, that original plan wasn't fully implemented, with simulations
now integrated with geometry nodes and modifiers instead of a separate
data-block. We kept the data-block around anyway since we have the
loose plan of using a similar data-block to make global simulations
connected between multiple objects. But it may be a while before we
implement that, and in the meantime having this just causes confusion.
2023-07-11 10:53:15 -04:00
Hans Goudey
4d54e3b6e1 Cleanup: Move simulation nodes cache reset function to proper place
The simulation data-block file isn't used currently, and is unrelated to
the current simulation caches. It would also be reasonable to declare
the function in MOD_nodes.hh, but I went for keeping it together
with the other more public simulation cache code.

Pull Request: https://projects.blender.org/blender/blender/pulls/109967
2023-07-11 16:43:42 +02:00
Nathan Vegdahl
c814d9323e Fix #109920: f-curve ghosts are drawn with incorrect extrapolation
This simply disables extrapolation for all sampled ghost curves,
since their extrapolation doesn't match the f-curves they're ghosting
anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/109926
2023-07-11 16:43:23 +02:00
Philipp Oeser
300cfecc46 Fix #109802: Outliner "Blender File" view cant delete scene
`outliner_do_scene_operation` wasnt recursive, so it only acted on the
top-level `TreeElement` (which was fine for Scenes view, but failed in
`Blender File` view).

Now use an iterator that handles open subhierarchies as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/109810
2023-07-11 16:31:01 +02:00
Hans Goudey
087612c042 Cleanup: Reduce use and scope of templates in vertex paint
Many high-level functions with unrelated code were templated based on
the color attribute domain and type. In the end, those were just a few
branches though, similar to other branches. So to reduce binary bloat
and clarify code, move tempates to the point where separate types are
actually needed. Also move constant code out of loops, and use generic
arrays and spans to store some caches. The binary ended up 53 KB
smaller for me, which isn't much but it's in the right direction.

Performance wise nothing really changes. The vast majority of time in
vertex paint is spent on unrelated things like calculating normals or
uploading GPU buffers anyway.

The one ugly part I didn't account for when I started is the casting
between the "ColorGeometry" and "ColorPaint" types. I'm not sure that
this is correct, but it's just a more explicit version of what was
there already.

Pull Request: https://projects.blender.org/blender/blender/pulls/109941
2023-07-11 15:52:28 +02:00
Julian Eisel
efbca8d660 Cleanup: Remove unnecessary tree view function override, add comment
`AbstractTreeViewItem::supports_collapsing()` returns true in the
default implementation, so no need to override that to do the same.
Notes the default behavior in a comment now.
2023-07-11 15:33:26 +02:00
Bastien Montagne
d2c87c3281 LibOverride: Add debug util to print out liboverride data.
No functional changes here.
2023-07-11 15:30:30 +02:00
Bastien Montagne
e11da03e7a LibOverride: Generate 'more unique' names for liboverrides.
Name collisions can become a big issue in liboverrides when production
files gets messy (weird overrides duplicates, bad resync with heavily
changing assets, etc.).

This commit tries to alleviate a bit the problem by generating 'more
unique' names for liboverrides, when an exact match with the reference
is not possible.

So by default, in most common case, the liboverride ID will still have
the exact same name as its linked reference.

If this is not possible, then the new liboverride ID will get a name
which is unique to within the whole current Main (for its ID type). In
particular, this ensure that new override IDs are either named exactly
as their references, or have a name which is not used by any other
reference (linked) IDs.

Note that this is not a perfect solution, since changes in library data
can lead to name collisions later on. However, it should greatly reduce
the frequency of such problems.
2023-07-11 15:30:30 +02:00
Bastien Montagne
b9becc47de Core: ID naming: Add 'global' namemap.
This new namemap allows to generate new ID names which are unique in
current Main (for a given ID type), regardless of the library they
belong to.

This new feature will be used by library override to try to reduce name
collisions with its linked reference IDs when more than one override
exists. It is not intended to be used for general ID naming.
2023-07-11 15:30:30 +02:00
Bastien Montagne
457b26aba3 LibOverride: Work around reset of system liboverrides on save.
Now that liboverride process on save (the diffing + pruning unused
override operations + reset of non-overridable changes) works better. it
leads to a bad side-effect: all system overrides data indirectly
modified through animation or drivers get reset.

Since in current system e.g. most objects of a rigged asset are system
overrides, but their transform is modified by bones animation, this
leads to entire overrides of assets being reset to their linked state
until next depsgraph evaluation.

While this is the expected and correct behavior in absolute, this is
very bad from a user experience PoV.

This commit address the issue by simply re-running a 'frame change'
despgraph update, to ensure all drivers, animations etc. are properly
re-applied after liboverride diffing cleanup & reset.
2023-07-11 15:30:30 +02:00
Bastien Montagne
a05419f18b LibOverride: RNA Apply code: Work around potential duplicates in names of RNA collections of IDs.
While in theory RNA collections of IDs will have unique names in common
use cases, it can happen that there are naming collisions (due to a same
RNA collection having ID pointers to data from different libraries,
having the same name).

This situation is deadly for liboverride applying code, since it rely on
finding which item of the collection to modify by using its name.

To alleviate the problem, this commit changes the way items are searched
for, by adding an extra first check to find an item which matches both
the requested name and index.

While not perfect, this should reduce the breaking cases when production
files get dirty and start having complex mangling of override and linked
data naming.
2023-07-11 15:30:30 +02:00
Bastien Montagne
6dd51353dd LibOverride: Fix potential minor issues in RNA liboverride handling code. 2023-07-11 15:30:30 +02:00
Bastien Montagne
2dfbd653a0 LibOverride: Fix 'resync enforce' not working on RNA collections of IDs.
Code was only considering RNA pointer properties to IDs, but not the
case of RNA collections of ID pointers (like e.g. the Collections' `objects`
property).

This would result in 'resync enforce' fixing tool not working properly
e.g. on liboverride collections' objects.
2023-07-11 15:30:30 +02:00
Bastien Montagne
784d09a87c LibOverride: Fix diffing code not always cleaning unused operations.
In RNA collections cases, the cleaning code was buggy and could end up
never cleaning actually unused liboverride operations, resulting in
sometimes tens of garbage operations on e.g. Collection's objects list.

This was a fairly severe bug, since it could lead to very broken
overrides of collections in some cases when things start to get broken
in the production file, amplifying greatly initially small issues.
2023-07-11 15:30:30 +02:00
Bastien Montagne
df0d6d0022 LibOverride: Expose 'match reference' status flag in RNA API. 2023-07-11 15:30:30 +02:00
Bastien Montagne
5b85248c71 LibOverride: Cleanup: Split log into dedicated output for resync code.
Helps filtering out walls of texts when debuging massive production
files.
2023-07-11 15:30:30 +02:00
Bastien Montagne
9889d0ef6f Fix (unreported) potential crash in 'make override' Outliner tool. 2023-07-11 15:30:30 +02:00
Bastien Montagne
4842424220 LibOverride: Reset object-parenting related properties in resync process.
When the parent ID pointer of an object is a 'system override' (i.e.
matches hierarchy-wise the parent of the linked reference object, or
actually use the same linked object), also clear potential liboverrides
for the other related parenting properties.

This is especially critical for the parent inverse matrix, otherwise if
it ever gets out of sync, in case of re-parenting in the lib data, the
offset would remain and move the liboverride child object into random
places.

NOTE: This may break some very specific workflows where users would rely
on actually overridden parent invert matrix. Not much to be done here,
there is currently no way to support both cases. This is not expected to
be a common use case.
2023-07-11 15:30:30 +02:00
Bastien Montagne
9ed5177055 LibOverride: Fix RNA handling of object parent-related properties.
While setting the parent object itself already had its dedicated
liboverride apply function to avoid resetting other related properties
like the invert parent matrix, other related properties also had custom
setter callbacks with similar effect.

This commit fixes the propblem for the `parent_bone` and `parent_type`
properties by adding a custom liboverride apply callback for them too.
2023-07-11 15:30:30 +02:00
Amelie
f2d3d321bb GPv3: Add access functions for opacity and radius attributes
We need setters and getters for these two very commonly accessed attributes of grease pencil.
The code is based on the implementation of `CurvesGeometry::positions()` and `CurvesGeometry::positions_for_write()`.

Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/109733
2023-07-11 15:11:14 +02:00
Julian Eisel
d31a0e8393 GPv3: Drag & drop reordering & inserting in the layer tree UI
Note: Change applies to Grease Pencil 3.0 only (experimental feature).

Enables use of drag & drop to reorder grease pencil layers through the layer
tree UI, as well as inserting layers into groups. This is an intuitive and
often requested method of managing such data-structures. Visual feedback should
be improved still, and the gap between items be removed, to reduce flickering
while dragging. These are general improvements for tree views however which
should be done separately.

There is no support yet for dragging layer groups, this requires further
changes in the internal grease pencil APIs.

#109825 introduced the necessary drag & drop support for tree views, #109824
prepared the internal grease pencil API for it.

Pull Request: https://projects.blender.org/blender/blender/pulls/109826
2023-07-11 15:05:17 +02:00
Julian Eisel
3757ec7ee8 Silence unused variable warning in Outliner code
Also add type forward declarations to avoid breaking IDE features
(because type name is not known from the header only).
2023-07-11 14:44:50 +02:00
Julian Eisel
4525527852 UI: Basic tree-view drag & drop reordering and inserting support
No user visible changes expected, these are just the internal API preparations.

Modifies the Drop API for views so that tree-views can choose to insert items
before, after and into other items.

Note: While there is support for drag-tooltips that can explain how an item
will be inserted, there is no drawing yet like in the Outliner, that indicates
if an item is inserted before, after or into. There is some work on that but
that can be done separately.

Changes:
- Removes `AbstractViewDropTarget` that was shared between tree- and
  grid-views, and adds `AbstractTreeViewDropTarget` and
  `AbstractGridViewDropTarget`. The tree-view needs specialized handling now,
  and although they could share some code still, it's not worth having another
  level of inheritance.
- Modifies the drop-target API to use `DragInfo` which contains more info about
  the dragging operation than just the `wmDrag`.
- Adds `determine_drop_location()` to the `DropTargetInterface` which drop
  targets can use to determine when dropping means inserting before, after or
  into.
- Store the block and region in the view. This is needed unfortunately but
  shouldn't be an issue since the tree view is recreated on redraws, together
  with the block.
- Various smaller tweaks and additions to views as needed.

TODO (outside scope of this change): Increase row height so there is no gap
between tree view items, but keep things visually the same otherwise. This
reduces flickering while dragging.

Pull Request: https://projects.blender.org/blender/blender/pulls/109825
2023-07-11 14:30:26 +02:00