Commit Graph

26258 Commits

Author SHA1 Message Date
Campbell Barton
c31b4b810c Cleanup: pass by const reference instead of value 2024-04-14 23:09:35 +10:00
Campbell Barton
a70d6d79dd Cleanup: various non-functional C++ changes 2024-04-14 12:24:17 +10:00
Campbell Barton
6e3eaae299 Cleanup: spelling in comments 2024-04-14 12:13:55 +10:00
Bastien Montagne
48baa80a05 Fix #120287: Annotations GPv2 data must not be converted.
This commit ensures that no legacy GP data is shared between GP objects
and annotations, before doing the conversion, by duplicating annotation
data when required.

Conversion code can then completely ignore annotation GPv2 IDs.

Pull Request: https://projects.blender.org/blender/blender/pulls/120581
2024-04-13 15:44:51 +02:00
Hans Goudey
c91449836a Cleanup: Move BKE_workspace.h to C++ 2024-04-12 17:03:18 -04:00
Hans Goudey
75077a8b0e Refactor: Move node tools OperatorComputeContext to blenkernel
For socket value logging this needs to be used in a couple other places.
Also remove the operator name argument. For the forseable future this
will only be used with the existing node tools operator anyway.
2024-04-12 16:16:55 -04:00
Hans Goudey
2361f90264 Cleanup: Resolve integer type conversion warnings 2024-04-12 11:29:20 -04:00
Christoph Lendenfeld
883af6dd63 Anim: Add custom pre and post frame color to motion path
This PR adds an option to specify custom colors for a
motion path. One for frames before the current frame
and one frame for after. With this it is easier to see
the relation of the motion path to the current frame.
That was already the case with the default colors, but
not with custom colors.

On a technical side note, the colors pre and post the current
frame were already different.
The shader multiplied the custom color by 0.25
for anything pre current frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/119375
2024-04-12 15:11:51 +02:00
Falk David
355079cbb2 GPv3: Add option to disable masks in viewlayer
In GPv2 there was an option to disable masks during rendering
of a viewlayer. This wasn't implemented for GPv3 yet.

This needs to change the way the draw calls are created,
because we need to skip over drawings at render time.
So to do this, we precompute the drawing offsets,
then check if we need to skip over it and otherwise
create the draw calls.

Pull Request: https://projects.blender.org/blender/blender/pulls/120561
2024-04-12 14:44:13 +02:00
Falk David
ff625b79f6 GPv3: Expose "Use Lights" option in the object data properties
Adds a `use_lights` option to the layer in RNA and
exposes the setting in the object data properties under
the layer opacity.
2024-04-12 13:19:05 +02:00
Campbell Barton
78413ff4e2 Fix error resetting the theme which would add a new theme
Regression caused by [0], also correct memcpy calls that overwrite
listbase link variables and the theme name, note that this is more a
code-correctness issue as it wouldn't cause user visible bugs.

[0]: adbec9eea9
2024-04-12 16:54:57 +10:00
Sean Kim
f7d5ec8661 Refactor: Remove trim variables from SculptSession
This PR moves the three sculpt trim gesture variables from
`SculptSession` into the `TrimOperation` `struct` to reduce
the size of the former and make it less likely that the data
is depended on in other operators.

Pull Request: https://projects.blender.org/blender/blender/pulls/120504
2024-04-11 20:55:11 +02:00
Falk David
0f72f67d56 Fix: GPv3: Crash after conversion because of strokes with no points
In GPv2 strokes could technically have zero points.
`CurvesGeometry` doesn't allow this, so we need to make
sure to explicitly skip over strokes with no points.

Pull Request: https://projects.blender.org/blender/blender/pulls/120536
2024-04-11 19:03:34 +02:00
Hans Goudey
3d1bf4eb74 Fix: Properly free/allocate non-trivial shrinkwrap cache struct
Mistake in 0b80d5e755

Pull Request: https://projects.blender.org/blender/blender/pulls/120527
2024-04-11 16:15:18 +02:00
Sybren A. Stüvel
ded8c5d6e6 Fix #120447: Anim/Drivers on Bone Collections created in 4.0 break in 4.1
Use versioning code to change Drivers & F-Curves targeting
`armature.collections[...` to target `armature.collections_all[...`
instead. The former contains the root collections only, whereas the
latter contains all of them in a flat list. Not only does this fix the
tree view (it binds to properties via the `.collections_all` RNA path),
but also this makes the drivers & animation of the properties work even
when the hierarchy changes.

Note that both `.collections` and `.collections_all` give access to all
bone collections. The former just requires iterating hierarchically,
that is, via `some_collection.children`.

Pull Request: https://projects.blender.org/blender/blender/pulls/120514
2024-04-11 15:26:47 +02:00
Philipp Oeser
2f67c45b65 Fix: renaming an ID does not properly update actions in the NLA
`BKE_animdata_fix_paths_rename` would tag the owner ID itself
(`ID_RECALC_SYNC_TO_EVAL`) upon renaming when a corresponding fcurve was
found/fixed, however the action itself wasnt tagged. "The action is an
own datablock, meaning, changes to f-curves need to copy those changes
to all evaluated versions of the action datablock" (wording from
4045730d58).

(this is also the reason the action would "fix" itself after entering
tweakmode on it in the NLA, since that ripples down to
`ANIM_list_elem_update` -- which does the tagging on the action then).

Part of #104055

Pull Request: https://projects.blender.org/blender/blender/pulls/120292
2024-04-11 14:32:14 +02:00
Campbell Barton
3a8cceee7d Cleanup: remove redundant checks & assignments 2024-04-11 20:47:07 +10:00
Campbell Barton
793b99ca7c Theme: ensure unique theme names, increase name size to 64
Ensure unique names when setting the name and with versioning.
2024-04-11 17:44:27 +10:00
Campbell Barton
09ee8d97e6 Cleanup: use C-style comments for descriptive text 2024-04-11 17:44:27 +10:00
Lukas Tönne
658a9ac3a9 GPv3: Initial sculpt mode
Adds an (empty) sculpt mode for Grease Pencil v3 objects.

The object `SCULPT_GPENCIL` mode is re-used for Grease Pencil object
types. A `SCULPT_GREASE_PENCIL` context mode has been added, which is
specific to grease pencil objects. This is necessary for polling tools
and keymaps.

Pull Request: https://projects.blender.org/blender/blender/pulls/119338
2024-04-11 09:39:48 +02:00
Iliya Katueshenock
6bafe65d28 Mesh: Calculate edges with VectorSet instead of Map
Due to legacy reasons (`MEdge`), edge calculation was being done with
idea that edges cannot be temporarily copied. But today, edges are just
`int2`, so using `edge *` instead of `edge` actually made things worse.
And since `OrderedEdge` itself is the same thing as `int2`, it does not
make sense to use `Map` for edges. So, now edges are in a hash set.
To be able to take index of edges, `VectorSet` is used.

The only functional change now is that original edges will be reordered
as well. This should be okay just like an unintentional but stable
indices change.

For 2'000 x 2'000 x 2'000 cube edges calculation, change is around
`3703.47` -> `2911.18` ms.

In order to reduce memory usage, a template parameter is added to
`VectorSet` slots, so they can use a 32 instead of 64 bit index type.
Without that, the performance change is not consistent and might not be
better on a computer with more memory bandwidth.

Co-authored-by: Hans Goudey <hans@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/120224
2024-04-11 04:33:25 +02:00
Harley Acheson
7642a5452a UI: Consistent Cursor Color
Change Console and text editor cursor color to match that of
widget_text_cursor. Console cursor is currently red which we normally
use for error conditions.

Pull Request: https://projects.blender.org/blender/blender/pulls/120491
2024-04-11 04:00:14 +02:00
Harley Acheson
4e8cc76c2d Cleanup: Make Format
Just changes resulting from running make format.
2024-04-10 18:34:52 -07:00
YimingWu
5fcbbb5b42 FCurve: Separate fcu->bezt check in deduplicate
This is to avoid uncessary assertion exception when `fcu->totvert < 2`.

Also fixes #120155

Pull Request: https://projects.blender.org/blender/blender/pulls/120158
2024-04-11 03:05:35 +02:00
Hans Goudey
19e94bf9d2 Fix: Crazyspace memory leak with curve modifier
This free was missing compared to BKE_sculpt_get_first_deform_matrices
2024-04-10 18:36:50 -04:00
Hans Goudey
563bb7e1da Cleanup: Grammar in mesh creation comments 2024-04-10 16:06:34 -04:00
Lukas Tönne
efd07d8207 Fix #118509: GPv3: fix broken drawing array compression function
The `remove_drawings_with_no_users` did not work properly when removing
more than one drawing at a time. It created incorrect drawing indices
that were larger than the drawings array, causing crashes down the line.

The new implementation should be both cleaner and more efficient,
avoiding a loop over all frames for every drawing removed.

This complements #119337 which fixes disappearing keyframes during
transform.

Pull Request: https://projects.blender.org/blender/blender/pulls/120433
2024-04-10 18:23:33 +02:00
Jacques Lucke
55cbb9f271 Fix #120402: memory leak in volume grid handling
The openvdb tree was not freed correctly because the destuctor
of the `shared_ptr` was not run.
2024-04-10 14:10:56 +02:00
Falk David
554b064214 Fix #120459: GPv3: Issue in conversion for layer parents
The layer parenting did not account for storing an
initial parent inverse matrix (to "keep transform").

This adds this matrix, stores it in DNA, and uses it
when we compute the parent matrices on demand.

Note: This PR does not set the parent inverse matrix
outside of conversion from GPv2. Support for
"keep transform" parenting will have to be added
in another PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/120462
2024-04-10 12:41:28 +02:00
Sean Kim
ea1cfdbf83 Fix #120400: Remove cyclic dependency of pbvh type when building bmesh pbvh
This PR fixes a crash when enabling Dyntopo.

When the PBVH generation code for BMesh was changed in b3aca5b28f, a
bug was introduced where dependent code to generate necessary layers
for BMesh could no longer access the PBVH type, as it was not generated
yet. As the type is known in the code at time of construction, I opted
to add parameters specifying the PBVHType to necessary methods when
accessing attributes.

Pull Request: https://projects.blender.org/blender/blender/pulls/120445
2024-04-10 02:57:34 +02:00
Iliya Katueshenock
ebd04b5660 Fix: Crash calculating edges of empty mesh
At some point (Fill Curve node in my case) it is possible to have
empty task of edges. Simplest fix - ignore such tasks. In future
this might be improved (see: #120224).

Pull Request: https://projects.blender.org/blender/blender/pulls/120330
2024-04-10 02:36:26 +02:00
Amelie Fondevilla
d0d4bf2068 Fix #118509: GPv3: frames disappear during transform in the timeline
While selecting and transforming multiple grease pencil frames in the
timeline, frames would sometimes disappear. This happened when the
transformation overlapped, meaning when a frame replaced another moving
one in the timeline. The frames transformation was happening in place
and in series, and thus leaded to the initial position of the frame to
be removed, even if it was occupied by a freshly transformed framed.

This commit fixes the issue by storing two separate maps in the
transform data structure instead of one, one map to store the static
data, meaning the frames that are not affected by the transform, and
another one for the moving data, meaning the frames that are affected by
the transform.

Some changes were made to account for the potential duplication of the
frames (move + duplicate):
* the map of the duplicated frames was renamed to a more explicit name,
* when a duplication occurs, the original frame is stored in the static
  frames map, and the duplicate is stored in the moving frames map,
* thus the check for the duplicate flag of the operator is now done at
  the init step of the transform, instead of the update step, so that
  the maps are initialized accordingly.

Co-authored-by: Lukas Tönne <lukas@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119337
2024-04-09 16:44:34 +02:00
Campbell Barton
e01525cf2c Cleanup: remove redundant variables & assignments
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
2024-04-09 13:52:41 +10:00
Jesse Yurkovich
509a7870c3 Collection Exporters: Enable file exporters to be specified on Collections
This implements the ability to have file exporters added and configured on Collections.

Exporting is reachable from several locations:
- Individually on each exporter configuration: The `Export` button in each panel header
- For all exporters on the collection: The `Export All` button in the main panel interface
- For all exporters on all collections in the scene: The `File`->`Export All Collections` button

Visibility of which collections currently have exporters configured is done by ways of an icon added to the Collection row in the Outliner.

Adding multiple exporters for the same file type is permitted. The user is free to setup several exports of the same format but with different file locations or settings etc.

Notes:
Only USD and Wavefront OBJ are enabled for the initial commit. Additional formats, including those implemented in Python will be added as separate commits after this.

Ref #115690
Pull Request: https://projects.blender.org/blender/blender/pulls/116646
2024-04-08 22:10:39 +02:00
Iliya Katueshenock
942ca6be6d Fix #120071: quadratic complexity for dangling reroute check
To know if link is connected to dangling reroute and can be skipped
as value-less, we need to know if reroute is dangling. This requires
graph traversal. Currently this is done by non-recursive iteration.
But this can lead quadratic complexity for some of the cases.
Other way is to make this linear while cache building.

Pull Request: https://projects.blender.org/blender/blender/pulls/120375
2024-04-08 16:19:40 +02:00
Jacques Lucke
936fb7488e Cleanup: move runtime data to Library.runtime
Having a better separation between runtime and non-runtime data makes
it easier to reason about the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/120271
2024-04-08 13:08:36 +02:00
Sybren A. Stüvel
694e5b50f4 Anim: show animated properties with the appropriate color in the GUI
Use the `Animation` data-block to find F-Curves, for drawing the
background color of properties in the GUI (green for 'animated', yellow
for 'keyed on this frame', etc.).

This assumes (correctly) that the `Animation` is limited to a single
layer with a single strip. As such, there is only one set of F-Curves
for every animated ID, which means that the correct F-Curve will be
found. This will need adjustment when the same property can have
multiple F-Curves (due to layers) or when an F-Curve may not be
applicable for each point in time (due to the use of finite strips).

Pull Request: https://projects.blender.org/blender/blender/pulls/118677
2024-04-08 12:53:32 +02:00
Sybren A. Stüvel
631f72265d Anim: add evaluation of Animation data-blocks
Include Animation data-block handling in Blender's animation evaluation
stack. If an `Animation` is assigned to an `ID`, it will take precedence
over the NLA and/or any `Action` that might be assigned as well.

For more info, see #113594.

Pull Request: https://projects.blender.org/blender/blender/pulls/118677
2024-04-08 12:53:32 +02:00
Sybren A. Stüvel
13f3a81842 Anim: allow assigning Animation data-blocks
Expand the `AnimData` struct with an `Animation *` + an
`binding_stable_index` field, and properly handle those relations.

This also adds functionality for actually pointing animated IDs to
`Animation` data-blocks, and automatically hooking up the relevant
`Binding`.

The Depsgraph code is extended to take these new relations into account,
but doesn't trigger any animation evaluation yet.

For more info, see #113594.

Pull Request: https://projects.blender.org/blender/blender/pulls/118677
2024-04-08 12:53:32 +02:00
Iliya Katueshenock
f8efd4fad0 Fix #120367: Attach to root panel if new parent is null
If pointer to new parent is null, use pointer to root panel of interface.

Pull Request: https://projects.blender.org/blender/blender/pulls/120369
2024-04-08 12:42:34 +02:00
Campbell Barton
6b14b67a29 Cleanup: spelling in comments 2024-04-08 16:23:25 +10:00
Campbell Barton
430d7961a2 Cleanup: remove redundant checks & struct declaration 2024-04-08 12:03:08 +10:00
Lukas Tönne
ee1714136e Fix #119554: Remove links to and from unsupported socket types
#114401 added forward compatibility code to remove unsupported socket
types and avoid crashing with unknown default_value data. However, this
did not update link pointers (which haven't been read at that point),
so the tree can end up with dangling pointers.

To fix this, removal of unsupported sockets is moved further back to a
point where links have been read and can be fixed accordingly.

Ported to main from #119630

Pull Request: https://projects.blender.org/blender/blender/pulls/119650
2024-04-06 11:23:53 +02:00
Hans Goudey
61b28227bb Fix #120309: Remove from Vertex Group operator broken
This check for whether there is vertex group data was mistakenly
reversed in b52a071e7a.
2024-04-05 13:41:59 -04:00
Falk David
1c0a278abd Fix: GPv3: Crash on conversion
This was introduced by d7230516c1.
The wrong API was used.
2024-04-05 15:34:26 +02:00
Falk David
d7230516c1 Cleanup: GPv3: Add drawing API for fill color
This adds two functions to the `Drawing` class: `fill_colors()`
and `fill_colors_for_write()`.
In places where the attribute API was used directly, these
functions are now used instead.

This is part of #119080. The point is that developers
shouldn't need to remember the name, type, default value,
and domain of built-in attributes (e.g. used by the renderer).

Pull Request: https://projects.blender.org/blender/blender/pulls/120296
2024-04-05 15:28:28 +02:00
Bastien Montagne
cb66cc3028 Fix #120058: Undoing a rename while in edit mode crashes Blender.
The root of the issue, as identified by Jake-Faulkner in his PR
(!120099), was that after changes in commit 195bb4f8f5,
`BKE_libblock_ensure_unique_name` would not always correctly set
`bmain->is_memfile_undo_written` to false when an ID name was actually
modified.

However, after analyzing a bit more the code in ID renaming, it appeared
that `BKE_libblock_ensure_unique_name` was not needed and only made
things more confusing. Some ID renaming code (from RNA, the Outliner,
and some do_version areas) would then do some manual ID renaming
operations and then call it, instead of simply using the existing 'all
in one' `BKE_libblock_rename` function.

This commit removes `BKE_libblock_ensure_unique_name` and all of its
usages, and simplify all code previously using it by calling
`BKE_libblock_rename` instead.

NOTE: The only non-trivial (not-so-nice) aspect of this commit is the
changes needed in the Outliner renaming code, since here the name of the
ID is directly edited, before calling the rename function, so this edit
needs to be undone to allow calling the generic ID rename API.

Pull Request: https://projects.blender.org/blender/blender/pulls/120196
2024-04-05 03:19:35 +02:00
Hans Goudey
4db6cbfbe0 Cleanup: Improve comment for Mesh::runtime::mesh_eval 2024-04-04 16:52:00 -04:00
Hans Goudey
b195014e05 Cleanup: Clarify modifier depends_on_normals handling
Because normals are calcualted lazily for all cases "depends_on_normals"
except for BMesh original normals, this is mostly unnecessary. It's actually
probably not necessary at all, because in practice there is always a separate
positions array stored in `EditMeshData` during mesh edit mode modifier
evaluation, bringing us back to the lazy calculation. But anyway, removing
the usage for topology-changing modifiers and modifiers  which don't
accept BMesh as input anyway simplifies things.

Pull Request: https://projects.blender.org/blender/blender/pulls/120274
2024-04-04 22:46:41 +02:00
Falk David
398c4471ec Cleanup: GPv3: Const parent functions for tree nodes
This resolves #120220.

The `parent_group()` and `parent_node()` functions would be
callable on `const` instances but return a non-`const` pointer/reference.

This introduces `const` and non-`const` variants of these
methods.

Pull Request: https://projects.blender.org/blender/blender/pulls/120261
2024-04-04 18:41:38 +02:00