In the `blender::animrig` namespace, add two new functions
`generic_assign_action()` and `generic_assign_action_slot()`. These are
now used as basis for (un)assigning Actions and Action slots, both
directly on the ID and for NLA strips.
The method `Action::assign_id()` has been removed, in favour of free
functions for (un)assigning Actions and slots.
This is almost a non-functional change. The only thing that's different
is when both an Action and a slot should get assigned in one go.
Old behaviour: the slot would be inspected, and if not suitable for the
animated ID, the entire operation would be aborted. In other words, any
previously-assigned Action would still be assigned, making this an
atomic operation.
New behaviour: assigning an Action + a slot is no longer atomic. First
the new Action is assigned (which uses the automatic slot selection
based on the name). If after this the given slot cannot be assigned, the
new Action + the auto-selected slot are still kept.
This makes the Action & slot assignment more uniform in behaviour, where
"assign this Action + this slot" as one operation behaves the same as
two sequential operations "assign this Action" + "assign this slot". If
it turns out to be confusing, we can always improve things.
The return code for slot assignment is now more explicit (enum instead
of boolean), so that the caller can decide what to do in case of which
error (like unassigning the slot if the automatic behaviour is
unwanted).
Pull Request: https://projects.blender.org/blender/blender/pulls/127712
It was possible for a Grease Pencil object to have a material
with no Grease Pencil settings. This can lead to crashes in many
places because it's often assumed that the material has
these settings.
The fix makes sure that `BKE_object_material_get` returns
a Grease Pencil material when called on a Grease Pencil
object. If the Grease Pencil settings don't exist,
it returns `nullptr`.
In the future, it should be possible to have these materials
and code that reads from the settings should fall back to
the default material.
Pull Request: https://projects.blender.org/blender/blender/pulls/127570
Saving files could take ~3-4 seconds on debug builds because of new
imbuf scaling logic.
Even though debug performance usually isn't much of a consideration,
it gets in the way of development.
Since thumbnails don't require the same accuracy as the sequencer or
compositor, use a faster scaling method that uses a box-filter clamped
to integer bounds & integer math.
In practice the difference between the resulting thumbnails isn't
noticeable in my tests.
For debug build with ASAN this gives a ~25x speedup,
for release builds it gives a ~1.4x speedup which is to be
expected with a more approximate scaling method.
Avoid a division by zero when the Action constraint has the same value
for its 'min' and 'max' parameters.
When `min` and `max` are equal, the code will now choose either `min`
(when `target value` ≤ `min`) or max (`target value` > `max`).
Pull Request: https://projects.blender.org/blender/blender/pulls/127583
To avoid unnecessary looping over listbase items the function
`BLI_listbase_count_at_most` was used however it resulting in an awkward
expression: `BLI_listbase_count_at_most(list, count + 1) == count`
replace this with `BLI_listbase_count_is_equal_to(list, count)`.
BKE_id_copy_in_lib took an argument `r_newid` which was was to
initialize `new_id` in the functions body.
While this may not have caused any user visible bugs, it's error prone,
one caller even passed in an uninitialized pointer.
- Rename `r_newid` to `new_id_p` since it's not a return argument.
- Initialize the value from all callers.
The tricky thing here is that this graph is only generated while geometry nodes
is evaluated and is generally only stored temporarily. To make it accessible via
Python, the accessor method will cause a reevaluation specifically to log the
generated graph.
Updating attributes is now done specifically for each attribute,
and topology and visibility updates tag the draw cache data
explicitly too. That makes checking for updates with these
tags unnecessary.
Similar to the previous commits, previously all GPU buffers
were recreated when only masks changed. Now only
that masks are re-uploaded, using the same mechanism.
Part of #118145.
Similar to 7b69c82494.
We didn't make any good use of the time in between changing
mask values and recalculating whether nodes were fully masked
or not masked at all. There was no point in the lazy calculation.
Eager calculation should be faster too, for the same reason as
the above commit.
Part of #118145.
Similar to the previous commit, previously all GPU buffers
were recreated when only a color attribute changed. Now only
that attribute is re-uploaded, using the same mechanism.
Part of #118145.
Similar to the previous commit, previously all GPU buffers
were recreated when only face sets changed. Now only face
sets are re-uploaded, using the same mechanism.
Part of #118145.
Previously tagging node positions dirty set the `PBVH_UpdateDrawBuffers`
flag which was then used by `node_draw_update_mask` and
`tag_all_attributes_dirty`, which, as hinted by the name, causes a refresh
of all the PBVH GPU vertex buffers, not just positions and normals.
Instead of using that flag, add a function to the draw cache to tag only
position-related data dirty. This should give a performance improvement
when there are also face sets, masks, and/or generic attributes being
extracted for drawing.
Part of $118145.
Also remove noisy print when a thumbnail can't be generated from an
animation. Similar prints have been commented and mainly seem useful
for debugging.
Replace the `PBVH_UpdateBB` flag with a separate vector of booleans.
The simplest impact of this is that we can tell when there are no changed
nodes in constant time. Besides that, it also works better with the recent
IndexMask usage for selections of nodes, and allows better const
correctness too, since nodes themselves don't have to be changed
when positions are changed. This also leads into plans to change PBVH
draw data tagging to avoid having to reupload all attributes when only
one changes.
Part of #118145.
Pull Request: https://projects.blender.org/blender/blender/pulls/127587
When syncing the NLA strip length with the Action it uses, use the
length of the assigned action slot. Previously the entire Action was
considered when determining the length.
Pull Request: https://projects.blender.org/blender/blender/pulls/127573
Move the following BKE functions to the `animrig::Action` class. Some of
those will be extended to support slots in a future commit; for now they
still operate on all F-Curves in the Action.
| Old | New |
|---------------------------------|-------------------------------------|
| `BKE_action_frame_range_calc()` | `Action::get_frame_range_of_keys()` |
| `BKE_action_frame_range_get()` | `Action::get_frame_range()` |
| `BKE_action_has_motion()` | `Action::has_keyframes()` |
| `BKE_action_has_single_frame()` | `Action::has_single_frame()` |
| `BKE_action_is_cyclic()` | `Action::is_cyclic()` |
Implementations have been copied from the BKE functions. The frame range
functions now return `float2` instead of requiring two `float *r_…`
return parameters.
The `has_motion` function is now renamed to `has_keyframes`, as that is
what the implementation was actually testing for.
The functions now no longer are null-safe. The BKE functions handled a
null action pointer, but IMO that doesn't make sense, and in none of the
call sites I could find where this would actually be valid.
No functional changes.
Ref: #127489
Pull Request: https://projects.blender.org/blender/blender/pulls/127512
Duplicating an Action stashes the original one on the NLA. The NLA
evaluation code didn't properly handle the special case of an all-muted
NLA (all stashed actions are muted there) when a layered Action was
assigned directly to the animated ID.
The code is now refactored to remove this special handling from the
`animsys_calculate_nla()` function. Instead it now just returns whether it
did anything. The caller can then decide to evaluate the main Action
instead. This ensures that there is only one "evaluate the main Action"
branch in the `BKE_animsys_evaluate_animdata()` function.
Pull Request: https://projects.blender.org/blender/blender/pulls/127569
Add support for slotted Actions to the NLA evaluation code.
This also affects the pose library code and the Action Constraint. These
both share some Action evaluation logic with the NLA. They now
explicitly looks at only the first Action slot. The Action Constraint will
have to be updated to have an explicit slot selector, but that's for another
commit.
Pull Request: https://projects.blender.org/blender/blender/pulls/127425
Refactor to prepare for slotted action support to the evaluation of
quaternion F-Curves.
Since slotted Actions store F-Curves in an array, you cannot iterate over
them any more via the `ListBase` pointer `fcurve.next`. Quaternion
evaluation code has been refactored to work on a span of F-Curves instead
of just getting the first one.
For now, slotted Actions just evaluate their first slot only. A future
commit will add a slot handle parameter to evaluate the correct slot.
Implements the legacy `weight_data_add` button for GPv3.
Note: This PR properly accounts for the bone's transformation when applying so that the stroke does not appear to teleport after drawing, unlike the legacy system.
Pull Request: https://projects.blender.org/blender/blender/pulls/119302
Updating the node bounds just after deforming the vertices in the
node is faster because the position data is still fresh in CPU caches.
Updating it later on means all the other nodes have been processed
in the meantime which will evict that position data from the caches.
This results in a 1.11x improvement in the brush benchmark timing,
from 0.495s to 0.438s on a Ryzen 7950x (best of 5 runs).
As part of the change, the update tagging has completely moved
to each brush implementation. This continues the process of
making each brush more independent.
Part of #118145.
Pull Request: https://projects.blender.org/blender/blender/pulls/127536