Commit Graph

24274 Commits

Author SHA1 Message Date
Philipp Oeser
b57916463c Fix #121121: NLA push down places local tracks before library overrides
The history here goes from c0bd240ad0 through 89ae4a7a2a (which were
still good), but then with 81b56f8bbc we have gotten to a point were
tracks were placed **before** overrides in case no local tracks were
found.

Now corrected.

Pull Request: https://projects.blender.org/blender/blender/pulls/121395
2024-05-07 15:16:47 +02:00
Nathan Vegdahl
8dbd167e80 Anim: add failure propagation to more lower-level keying functions
This changes the following keyframing functions to return
`SingleKeyingResult`, which is in turn used for better failure
reporting in the higher-level functions that call them:

- `KeyframeStrip::keyframe_insert()`
- `insert_vert_fcurve()`

As a side effect, this also means that
`rna_KeyframeAnimationStrip_key_insert()` can no longer return an
`FCurve *`, and now instead returns a bool indicating success.

This is part of an ongoing progressive refactor to improve error
messages and failure handling in the keyingframing code.

Pull Request: https://projects.blender.org/blender/blender/pulls/121517
2024-05-07 15:06:57 +02:00
Sybren A. Stüvel
18cccafeaf Refactor: Lattice deform: prevent incrementing nullptr
The lattice deform code would always call `co += 3` in a loop, even when
co is `nullptr`. This is invoking undefined behaviour, and causes UBSAN
warnings.

Pull Request: https://projects.blender.org/blender/blender/pulls/121396
2024-05-07 14:23:27 +02:00
Aras Pranckevicius
6efa5c16ab Mesh: speedup BKE_mesh_validate
BKE_mesh_validate is called by mesh.validate() Python API, as well as optionally
when doing file imports. This PR speeds it up a bit:
- Faster face data sorting by using parallel sort instead of qsort,
- One allocation for all face vertex indices, instead of a separate allocation
  for each face,
- (more like a fix) Validation no longer adds a MDeformVert layer when there was
  none in the input mesh.
- Small cleanups (more const inputs, etc.)

On my Windows/VS2022/Ryzen5950X machine, import time in seconds (validation on
before this PR -> validation on with this PR, validation off):
- USD (Intel Moore Lane): 9.1 -> 6.7, 4.8.
- OBJ (Blender 3.0 splash): 22.7 -> 18.6, 16.5.

Pull Request: https://projects.blender.org/blender/blender/pulls/121413
2024-05-07 12:29:32 +02:00
Pratik Borhade
8d8d358196 GPv3: Replace active_layer with active_node
This was discussed in #121390 for further selection support of
layer groups.

Pull Request: https://projects.blender.org/blender/blender/pulls/121475
2024-05-07 11:26:33 +02:00
Christoph Lendenfeld
afe13175da Anim: run bezier handle calculation in parallel
Bezier handles are recalculated in many places in the
animation code. Threading that code can give a performance
boost  all over Blender.
This patch only threads a part of the handle calculation code.
`BKE_nurb_handle_smooth_fcurve` can still be run in parallel,
but that's more complicated, so not done in this PR.

Overall this patch mostly benefits code paths that are not already threaded.

------

Performance delta

| Action | Before | After |
| - | - | - |
| `recalcData_graphedit` moving a single key | 1.06 ms | 1.0 ms |
| `recalcData_graphedit` moving 300 keys of a single FCurve | 1.6 ms | 1.4 ms |
| `recalcData_graphedit` moving 300 keys of multiple FCurves | 60 ms | 55 ms |
| `ANIM_animdata_update` when using the Breakdown operator in the GE | 90 ms | 73 ms |

Test file used
https://download.blender.org/ftp/sybren/animation-rigging/heavy_mocap_test.blend

Pull Request: https://projects.blender.org/blender/blender/pulls/119388
2024-05-07 10:42:53 +02:00
Iliya Katueshenock
4e3af58885 Cleanup: Avoid unnecessary copies of VArray
Cleanup to avoid unnecessary copies of VArray. This
requires ref-qualifier overloads of dereference operator
of attribute reader and some move operators and constructor
overloads in the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/118437
2024-05-07 04:02:17 +02:00
Sean Kim
d584cdbb8a Fix #121341: Add pbvh null check when destroying attribute
This PR fixes #121341 by adding a null check for the PBVH.

Pull Request: https://projects.blender.org/blender/blender/pulls/121418
2024-05-07 00:51:48 +02:00
Harley Acheson
c4e5a70e07 UI: Optional Complex Layout for Workspace Status
Optionally allow complex layout instead of just plain text when using
ED_workspace_status_text.

Pull Request: https://projects.blender.org/blender/blender/pulls/120595
2024-05-06 23:52:37 +02:00
Sean Kim
80092fe1e0 Fix: Crash when showing all multires grid elements
This PR fixes the ternary operation to avoid indexing into a cleared
`BitGroupVector`when trying to create an `IndexMask` for a mesh
with no hidden elements.

Pull Request: https://projects.blender.org/blender/blender/pulls/121461
2024-05-06 23:04:35 +02:00
Raul Fernandez
27c1618c5d Fix #94631: Multires: Duplicating objects sets the viewport level to sculpt level
Fixes duplicating objects sets the viewport level to sculpt level.

Self explanatory fix.

Pull Request: https://projects.blender.org/blender/blender/pulls/121429
2024-05-06 17:34:52 +02:00
Sietse Brouwer
c4405f61d5 Fix: GPv3: Crash when duplicating frames
In larger scenes Blender could crash when duplicating frames in GPv3.
This was caused by a dangling reference in `insert_duplicate_frame`.
The source frame could become invalid when the frames map was
reallocated due to `layer.add_frame(dst_frame_number, ...)` a few lines
later in the code.
The fix replaces the reference and assigns by value.

Pull Request: https://projects.blender.org/blender/blender/pulls/121414
2024-05-06 14:21:04 +02:00
Jacques Lucke
18600e430c Geometry Nodes: show correct type in menu socket tooltips
Previously, menu sockets were sometimes shown as integers or strings
in socket tooltips. Now, they are always shown as "Menu" type. This also
changes how these values are logged. Previously, they were logged as
strings. Now, only the integer identifier is logged and the name is looked
up when drawing the tooltip.

Pull Request: https://projects.blender.org/blender/blender/pulls/121236
2024-05-05 09:30:02 +02:00
Campbell Barton
4f5f0040c0 Cleanup: back-tick quote file extensions in code-comments 2024-05-04 15:06:46 +10:00
Julian Eisel
a6ebfb05ad UI: Option to store enabled asset shelf catalogs in preferences
Adds a new asset shelf option (`STORE_ENABLED_CATALOGS_IN_PREFERENCES`
option in RNA) to use the Preferences for storing the enabled catalogs.
This way asset shelf types can decide if for their use-case, they want
to synchronize the enabled catalogs over Blender sessions and files, or
keep the stored locally in the file.

This is important because for example on one hand, it would be annoying
if for brush assets you'd have to enable the visible catalog tabs for
every 3D View and every file, while on the other hand you need that
level of control for the pose library where the catalogs the rigger/
animator cares about varies from project to project, character to
character and shot to shot.

Conceptually this also makes some sense: The new brush assets workflow
synchronizes brush assets and their catalogs across Blender sessions
and files, basically making them globally accessible independent of
the current file/project, so treating the enabled catalogs the same
is consistent.

Previously reviewed in #120264

Pull Request: https://projects.blender.org/blender/blender/pulls/121363
2024-05-03 10:20:01 -04:00
Hans Goudey
8203184192 Cleanup: Modernize variable naming in mesh_validate.cc
Change "poly" to "face" and "loop" to "corner"
2024-05-03 08:50:07 -04:00
Hans Goudey
43b46503f1 Cleanup: Use const for mesh selection retrieval functions 2024-05-02 22:08:25 -04:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
Campbell Barton
5529a94f14 Cleanup: spelling in comments 2024-05-03 11:33:18 +10:00
Bastien Montagne
ec350a6115 BKE ID copy: Pass new owner ID when possible.
Advanced ID copying code can now take a `new_owner_id` ID pointer parameter,
and use it to set the relevant 'loopback' pointer to its owner ID by the
copy code itself.

Besides avoiding the need for all code copying embedded IDs to set the
loopback pointer themselves, this also means that `lib_id` copying code
itself does not need to use `IDWALK_IGNORE_MISSING_OWNER_ID` anymore.

This change is not expected to have any effect in current codebase.
2024-05-02 17:17:04 +02:00
Bastien Montagne
36c3504994 BKE lib_query: Improve handling of owner ID info for embedded ID.
In previous code, the owner ID info would not be available when
processing an embedded ID in two cases, and was incorrectly set to the
processed (embedded) ID instead:
1. When directly calling `BKE_library_foreach_ID_link` on an embedded ID.
2. When using recursive processing (`IDWALK_RECURSE`).

This commit mostly fixes both cases, by using `BKE_id_owner_get` to find
the owner ID when it is unknown.

There are some caveats here though: in a few specific cases (mainly ID
copying, and depsgraph ID copying), `BKE_library_foreach_ID_link` can be
called on embedded IDs which owner ID is not yet valid. In such case, a
new flag can be used to keep using the previous behavior
(`IDWALK_IGNORE_MISSING_OWNER_ID`).

Fixing the issue with copy code being unaware of the owner ID when
copying an embedded one should also be fixed, but this will be addressed
separately.

Note that as 'side efect', this commit also fixes a matching issue in
the `lib_remap` code, where the `IDRemap.id-owner` pointer would also
wrongly be set to the remapped embedded ID instead of its actual owner.

This change is not expected to have any effect in current codebase.
2024-05-02 17:17:03 +02:00
Bastien Montagne
eb9bec54ad IDType owner ID accessor: Add option to skip relationship sanity checks.
While currently, all cases where `BKE_id_owner_get` is called are
'safe', there are some points in code where the pointers ensureing the
relationship between an embedded ID and its owner are not (fully) valid.

This new option (`false` by default) allows to skip the debug asserts
ensuring the sanity of these 'owner <-> embedded' ID pointers in the
relevant `owner_pointer_get` callbacks.

This change is not expected to have any effect in current codebase.
2024-05-02 17:17:03 +02:00
Bastien Montagne
8ba6c16242 BKE: ID copy: do not expand linked data usages when copying an embedded ID.
There is no reason to do this for embedded IDs - this process is
expected to happen as part of the copying of their owner ID anyway.

Further more, embedded IDs are not in a fully valid state during the
copying of their owner, better avoid as much processing on them as
possible.

This change is not expected to have any effect in current codebase.
2024-05-02 17:17:03 +02:00
Bastien Montagne
27f404c1b4 Cleanup/fix BKE scene copy code remapping its nodetree pointers before setting its owner ID.
While not an issue in current code, this was logically not ideal.
The owner ID is an important information that should be valid as soon as
possible after the copy, before any other process happens.

Ideally this could even become part of the ID copying code itself.

This change is not expected to have any effect in current codebase.
2024-05-02 17:17:03 +02:00
Sergey Sharybin
1b0012d51c Refactor: Require C++ for users of BLI_simd.h
This is because sse2neon.h might be used to emulate SSE intrinsics
on ARM64 architecture, and it uses some preprocessor which is not
available for C language when using MSVC.

The old-style math file math_matrix.c uses this header, so needed
to become C++. Simple rename did not work since there is a new math
utility math_matrix.cc exists. Following some existing convention
the math_matrix.c is renamed to math_matrix_c.cc. Eventually all the
code should switch to use C++ style math, and the C style removed,
so it seems reasonable to not mix old and new style of API in the
same file.

There should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/121335
2024-05-02 16:22:19 +02:00
Campbell Barton
f6b7464b4c Cleanup: spelling in comments 2024-05-02 16:44:10 +10:00
Jacques Lucke
5bc949b4a7 Fix: avoid tagging file as modified when clicking in node editor 2024-05-02 01:43:45 +02:00
Jacques Lucke
17cc5d694c Fix #121214: invalid owner_tree pointer when node tree is overridden 2024-05-01 21:29:04 +02:00
Hans Goudey
4dbdd925d4 Assets: Add equality operators to AssetWeakReference 2024-05-01 13:24:39 -04:00
Hans Goudey
c9625cbc7b Brush: Rename BKE_paint_toolslots_brush_validate function
Change from the brush assets branch. Arguably the funciton name
is just as clear this way anyway.
2024-05-01 11:49:48 -04:00
Hans Goudey
c549c1b29c Brush: Add Main argument to BKE_paint_ensure
This is used by the brush assets branch. Though it is unused currently, the
argument is added now to reduce the trivial boilerplate changes in the diff.
2024-05-01 11:49:48 -04:00
Iliya Katueshenock
5fa98aa0fd Cleanup: Camel case for node size enum items
Pull Request: https://projects.blender.org/blender/blender/pulls/121297
2024-05-01 15:27:34 +02:00
Hans Goudey
809ed077ac Cleanup: Use const in some modifier related functions 2024-04-30 16:02:08 -04:00
Nathan Vegdahl
f099977923 Fix: add missing nullptr check in BKE_fcurve_find_by_rna_context_ui
The guard clauses elsewhere in the function clearly indicate that
`r_driven` should be passable as a nullptr if the caller doesn't need
it, but there is one place where the guard clause was missing.

Discovered while working on #120936.

Pull Request: https://projects.blender.org/blender/blender/pulls/121253
2024-04-30 12:05:20 +02:00
Jacques Lucke
176c6ef329 Geometry Nodes: unify menu switch with other nodes with dynamic sockets
This changes the menu switch socket to use the socket-items system
(`NOD_socket_items.hh`) that is already used by the simulation zone, repeat
zone, bake node and index switch node. By using this system, the per-node
boilerplate can be removed significantly. This is especially important as we
plan to have dynamic socket amounts in more nodes in the future.

There are some user visible changes which make the node more consistent with
others:
* Move the menu items list into the properties panel as in 0c585a1b8a.
* Add an extend socket.
* Duplicating a menu item keeps the name of the old one.

There is also a (backward compatible) change in the Python API: It's now
possible to directly access `node.enum_items` and `node.active_index` instead of
having to use `node.enum_definition.enum_items`. This is consistent with the
other nodes. For backward compatibility, `node.enum_definition` still exists,
but simply returns the node itself.

Many API functions from `NodeEnumDefinition` like
`NodeEnumDefinition::remove_item` have been removed. Those are not used anymore
and are unnecessary boilerplate. If ever necessary, they can be implemented back
in terms of the socket-items system.

The socket-items system had to be extended a little bit to support the case for
the menu switch node where each socket item has a name but no type. Previously,
there was the case without name and type in the index switch node, and the case
with both in the bake node and zones. The system was trivial to extend to this
case.

Pull Request: https://projects.blender.org/blender/blender/pulls/121234
2024-04-30 10:19:32 +02:00
Campbell Barton
9ee0912d1c Cleanup: pass a const Lattice to BKE_lattice_* functions
Also match arguments between function & declaration.
2024-04-30 12:13:25 +10:00
Campbell Barton
734a312004 Cleanup: remove unused argument 2024-04-30 12:13:23 +10:00
Hans Goudey
2ac6321e88 Refactor: Remove corner triangle faces from PBVH storage
Part of an effort to reduce redundancy of storage for data used
by sculpt mode. See #118145.

Pull Request: https://projects.blender.org/blender/blender/pulls/121238
2024-04-30 04:02:59 +02:00
Hans Goudey
75e424563c Refactor: Remove vert to face map from PBVH storage
Part of an effort to reduce redundancy of storage for data used
by sculpt mode. See #118145.
2024-04-30 04:02:57 +02:00
Hans Goudey
76a151b9d6 Refactor: Store PBVH in unique_ptr
This requires adding a destructor and deleting move and copy assignment
for SculptSession, because (for now at least) we want to keep the PBVH
as an opaque type (though with one exception for including pbvh_intern.hh
in paint.cc for the SculptSession destructor).

Pull Request: https://projects.blender.org/blender/blender/pulls/121227
2024-04-29 22:21:24 +02:00
Hans Goudey
7c56e16e44 Cleanup: Use references for sculpt PBVH variables 2024-04-29 22:21:23 +02:00
Nathan Vegdahl
bd3518946e Anim: implement "Copy Driver to Selected" operator
This allows the user to copy the driver(s) of a property to other selected items (e.g. objects, nodes, etc.) via the right-click menu.  The implementation is based on the "Copy to Selected" operator, and generally behaves the same except for copying drivers instead of values.

Resolves #120518
2024-04-29 18:34:57 +02:00
Hans Goudey
a63e32fabf Fix #121187: Sculpt dynamic topology crash with empty mesh
Mistake in b3aca5b28f. Some sculpt PBVH code has null checks
so I must have assumed a null PBVH was an expected situation. It turns
out those null checks are very inconsistent. We would probably be better
off removing them and ensuring the PBVH always exists.
2024-04-29 10:57:00 -04:00
Campbell Barton
4ec93f73a5 Cleanup: spelling in comments 2024-04-29 09:09:44 +10:00
Bastien Montagne
f933dae207 BKE_lib_query: Add a partial ID usage iterator system.
The idea is to allow iterating over e.g. all ID usages of a node from a
whole nodetree, using the same generic handling as existing 'whole ID'
`foreach_id` code.

This is necessary in some cases wher a sub-data needs to processed
independently from any 'owner ID', e.g. in some copy/paste handling.

This is a pre-requirement for proper fix of nodes copy/paste (see
e.g. #120103).

Pull Request: https://projects.blender.org/blender/blender/pulls/121018
2024-04-28 17:35:02 +02:00
Hans Goudey
e3894f0a07 UV: Remove UV sculpt use of brushes
For the brush assets project (#116337) all editors with brushes are
getting an asset shelf, and the brush tools are combined, with
individual brushes accessed in the shelf. That design seems way
overkill for UV sculpting which is just three very simple tools.

In order to avoid one editor with inconsistent use of brushes, which
would significantly increase the complexity of the system after the
brush assets merge, port the three UV sculpt tools to be regular
modal operators that don't use the brush or paint system at all.

To be clear, this is a compromise that doesn't feel ideal, but no
one could think of a better solution. Theoretically this removes
some flexibility from UV edit "sculpting", in practice it probably
won't be a noticeable change.

Pull Request: https://projects.blender.org/blender/blender/pulls/120797
2024-04-26 17:10:04 +02:00
Falk David
62151ffaeb Fix: GPv3: Thickness modifier conversion of "uniform thickness"
The "uniform thickness" was still in the legacy "pixel" space. The fix
makes sure that value is always converted to the right radius space.
We also convert the potentially animated property for the thickness
and scale the fcurves to be in the right space.

Pull Request: https://projects.blender.org/blender/blender/pulls/121128
2024-04-26 15:16:43 +02:00
Falk David
c0fc1fc938 Cleanup: GPv3: Remove wrap/unwrap macros for lineart 2024-04-26 14:49:54 +02:00
Falk David
c2504eb779 Cleanup: Use legacy radius conversion factor constant
This moves the seemingly arbitrary value of  "1 / 2000"
into a constant variable
(`bke::greasepencil::LEGACY_RADIUS_CONVERSION_FACTOR`)
so that it can be used in all the places where
legacy "thickness" values need to be converted.
This also expands the explanation of the factor a bit, so it's
clearer why it is needed.
2024-04-26 12:48:26 +02:00
Hans Goudey
fc1a4647cf Cleanup: Use C++ types for pose brush segments
Use unique_ptr, Array, float3, and references for stored pose brush segments.
2024-04-25 15:20:25 -04:00