Commit Graph

26393 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
Hans Goudey
88b4498b32 Cleanup: Miscellaneous cleanups to workspace status items
- Remove meaningless const for by-value arguments in declarations
- Use std::move for strings (otherwise StringRef should be used)
- Move struct to C++ namespace
- Avoid unnecessary namespace specification
- Use static constexpr instead of macros
- Add const for other arguments in function definitions
- Avoid copying struct in for loop
- Remove redundnat "private" in class
2024-05-06 18:20:43 -04: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
Iliya Katueshenock
968b98be56 Geometry Nodes: new Input Rotation node
This adds a new node input node for a constant rotation.
Similar nodes exist for vector, integer, boolean, etc. already.

Pull Request: https://projects.blender.org/blender/blender/pulls/120345
2024-05-06 19:04:30 +02:00
Richard Antalik
69472c88ee IMB: Cleanup timecode options
Remove options that are duplicate and change description of options, so
they describe bit better, how timecodes are actually used.

Timecodes in Blender have pretty much nothing in common with more widely
known term "timecode". This confused users (and developers).
There were 5 options of which 3 were exactly same. This commit leaves
user with 3 options:
 - Use timecodes for normal seeking/playback - Record Run
 - Ensure, that no frame is duplicated or skipped - "Record Run No Gaps"
 - Do not use timecodes - "None"

More verbose description was added to the definition in code.

Naming of these timecode types was kept, even if it is incorrect to not
break scripts and habits.

Pull Request: https://projects.blender.org/blender/blender/pulls/121001
2024-05-06 17:56:56 +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
ff4fc03023 UI: Make asset shelf type registration space-type independent
Rather than storing asset shelf types only for the space type defined
with `bl_space_type`, store them statically/globally so that asset shelf
popups can later be displayed in any space. In earlier designs the asset
shelf was more space dependent than it is now.

For example the brush selector asset shelf popup being implemented for
the brush assets project should be available in the tool settings UI,
which is also displayed in the Properties. If the asset shelf type is
space dependent, this popup won't work in the Properties.

To be clear, `bl_space_type` will still be what defines where the asset
shelf region will be available. But the popup version can be displayed
anywhere.

Pull Request: https://projects.blender.org/blender/blender/pulls/121411
2024-05-03 23:16:29 +02:00
Julian Eisel
a700c90ec3 Asset Shelf: Add callback to get active asset
Add a function for asset shelves, `get_active_asset` in RNA, that
can be used to sync the active item of an asset shelf with an asset
reference elsewhere in Blender. In the brush asset system this is
used to retrieve the asset reference from the active `Paint` struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/121405
2024-05-03 15:27:35 -04:00
Hans Goudey
798219225d Asset Shelf: Add optional operator to activate assets
The operator stored when registering the asset shelf will be called
with properties that reference the asset (a weak reference, split into
three properties already used in other asset-related operators). The
operator is called whenever a grid view item is activated, and is
meant to do things like import and activate a brush asset.

Previously Reviewed: https://projects.blender.org/blender/blender/pulls/117861

Pull Request: https://projects.blender.org/blender/blender/pulls/121402
2024-05-03 19:24:00 +02: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
Julian Eisel
05b125f399 Asset Shelf: Add default preview size option
Allow changing the size of previews in a new asset shelf
when registering a new asset shelf type.

Pull Request: https://projects.blender.org/blender/blender/pulls/121358
2024-05-02 12:56:53 -04:00
Hans Goudey
6f5f70994e Cleanup: Unnecessary const in declaration, format 2024-05-02 12:43:07 -04: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
Sebastian Parborg
221951657b VSE: Make cache overlay visible to non "Developer extras" users
This also moves the option to be a per editor space setting so you can
have different cache visualization options in different editor spaces
at the same time.

A quick toggle for the cache visualization is now available in the
overlays popover.

Pull Request: https://projects.blender.org/blender/blender/pulls/119428
2024-05-02 16:36:11 +02:00
Julian Eisel
d4fc167db1 Asset Shelf: Add region poll mechanism for initialization
Allows running some action when the context changes to make the
asset shelf region visible. Also add an option for when whether the
shelf should be visible by default when the poll succeeds.

Pull Request: https://projects.blender.org/blender/blender/pulls/121315
2024-05-02 10:27:55 -04: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
Iliya Katueshenock
831e91c357 Geometry Nodes: support working with raw matrix values
These nodes allow working with the raw values that make up a matrix.
This can be used to construct a 4x4 matrix directly, without using the
`Combine Transform` node. This allows building transforms with arbitrary
skew, or projection matrices.

Pull Request: https://projects.blender.org/blender/blender/pulls/121283
2024-05-01 21:31:08 +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
Clément Foucault
ff15d31bc1 EEVEE-Next: Forgot version bump
Sorry.
2024-05-01 14:47:18 +02:00
Omar Emara
f595345f52 Compositor: Match size of Fast Gaussian with Gaussian
This patch matches the size of the Fast Gaussian mode of blur with the
standard Gaussian mode. The sigma value was computed as half the radius,
while it should be third of the radius, since Blender's Gaussian
function is truncated at 3 of the standard deviation of the unit
Gaussian. The patch include versioning to adjust the size of existing
files.

Pull Request: https://projects.blender.org/blender/blender/pulls/121211
2024-05-01 09:01:53 +02:00
Hans Goudey
809ed077ac Cleanup: Use const in some modifier related functions 2024-04-30 16:02:08 -04:00
Clément Foucault
303f91a09c EEVEE-Next: Add slab thickness and thickness from shadow options
Implement the design discussed in #120384.

This adds two parameters. One for changing the approximation
method, and another to use the thickness from shadow map.

We pack the former in the gbuffer by dividing the 16bits
used for thickness by two and use one bit to store the
method.

The thickness from shadow map is now decoupled from the
light evaluation shader. This makes it more performant and
compatible with ray-tracing. This commit also uses the
same biases as shadow mapping to avoid aliasing artifacts
(fix #119339).

This refactors the light evaluation quite a bit to
remove unused bits bits and make the whole transmission
light evaluation without too much complexity.

Pull Request: https://projects.blender.org/blender/blender/pulls/121171
2024-04-30 20:32:46 +02:00
Hans Goudey
462e7aeedd Geometry Nodes: Add Align Rotation to Vector node
A version of "Align Euler to Vector" with the rotation socket
instead of the vector Euler socket. Other than that, and a few
cleanups to use newer math functions, the node is the same.

The old node is just "Deprecated" for now. We could remove
it with versioning, but we can also wait to do that.

In a simple test this node is about 1.7 times faster than the old one.

Pull Request: https://projects.blender.org/blender/blender/pulls/118565
2024-04-30 15:52:11 +02: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