Commit Graph

18 Commits

Author SHA1 Message Date
83311ef96d Fix #122777: The keyframe_insert method throws python exceptions
Just for the `pyrna_struct_keyframe_insert()` function, reduce the
reporting level of keyframe insertion failures from `RPT_ERROR` to
`RPT_WARNING`. This prevents the conversion of these reports to a Python
exception.

`CombinedKeyingResult::generate_reports()` now accepts an option
argument `report_level`, so that the caller is in control over the type
of reports it generates.

Previously only errors were converted to exceptions; warnings were
implicitly cleared and never displayed. To avoid these 'keyframe
insertion failure' reports from becoming invisible, the
`pyrna_struct_keyframe_insert()` function now sends any warnings to
stdout (unless there were errors, in which case the old
error-to-exception behaviour is still there).

Pull Request: https://projects.blender.org/blender/blender/pulls/122827
2024-06-11 11:11:16 +02:00
Christoph Lendenfeld
8a8921e7a8 Anim: Add unit tests for keying custom properties
This PR adds unit tests for the "Custom Properties" option in the User Preferences.
It checks that the correct properties are keyed but not others.

Pull Request: https://projects.blender.org/blender/blender/pulls/120422
2024-04-23 09:36:38 +02:00
Brecht Van Lommel
056becae8a Merge branch 'blender-v4.1-release' into main 2024-02-22 14:36:13 +01:00
Brecht Van Lommel
8dfb87d1af Fix: Update tests data path to new directory 2024-02-22 14:25:54 +01:00
Brecht Van Lommel
0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564ad2.
2024-02-19 15:59:59 +01:00
Hans Goudey
ef7d2a2dd9 Cleanup: Make format 2024-02-13 08:49:08 -05:00
Campbell Barton
2119d271e0 Cleanup: remove "-noaudio" argument in background mode
This is no longer needed as background mode implies -noaudio.
2024-02-14 00:13:38 +11:00
Christoph Lendenfeld
7fddad529e Fix: keyframe values with additive NLA stack
The new keyframing functions introduced in #113504
didn't call the functions to decompose the NLA stack.

In practice this meant that when inserting keys into strip
that is under an additive strip, it would take the result of the additive Strip and
bake it back into the base. This would double the transform.

The fix is to call `BKE_animsys_nla_remap_keyframe_values`.
Unfortunately to do so, I had to pass through a few more
arguments to the keyframing functions.

Also adds unit tests to cover the caused bug.

Pull Request: https://projects.blender.org/blender/blender/pulls/118053
2024-02-13 11:10:18 +01:00
Christoph Lendenfeld
afa4391eeb Fix: Issue with Cycle aware keying when inserting second key
Caused by #113504

While basic cycle aware keying works, there is a special case
when inserting the first key. In that case, after the key has been inserted,
it is duplicated and moved around so the FCurve range from
first to last key is exactly the range of the action.
It also auto-creates the Cycle modifier on the FCurve .

Fix the issue by calling the function that does the key duplication
and cover with unit tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/116943
2024-02-09 10:13:28 +01:00
Christoph Lendenfeld
5e28601d69 Anim: Separate keying flags
Splits the flag `..._FLAG_INSERTNEEDED` between autokey and
manual keying. The fact that this flag was shared between the two
systems has been the cause of issues in the past. It wouldn't
let you insert a keyframe even though you explicitly used an operator
to do so.

In order to be clearer what options are used where, the user preferences
have been reordered.

By default "Only Insert Needed" will be enabled for auto-keying, but not for manual keying.
The versioning code will enable both if it was enabled previously.

# Code side changes

The keying system has flags that define the behavior
when keys are inserted. Some of those flags were shared
between keying and auto-keying. Some were only used for
auto-keying.
To clarify that, prefix flags that used exclusively in one or the other
system with `AUTOKEY`/`MANUALKEY`

Also the flag name on the user preferences and the tool settings was renamed.
Previously it was called `autokey_flag`. To indicated that it is not only used
for autokeying, rename it `keying_flag`.

Fixes: #73773

Pull Request: https://projects.blender.org/blender/blender/pulls/115525
2024-01-19 16:26:10 +01:00
Christoph Lendenfeld
73f968dbe5 Refactor: keyframing unit tests
This PR changes two things

Move setup/cleanup code into `setUp`/`tearDown`

Change the `_fcurve_paths_match` to raise an error instead of returning a bool.
That makes it easier to see what the actual error is.

Pull Request: https://projects.blender.org/blender/blender/pulls/116816
2024-01-05 13:38:45 +01:00
Christoph Lendenfeld
03a66af318 Anim: Unit tests for "Insert Needed"
Add unit tests for the user preference option "Insert Needed"

Basic tests for objects and bones that check if autokeying in
combination with "Insert Needed" only
* keys all location channels on the first key
* keys only the modified channel on the second key

It is supposed to add only keyframes that have been affected
by the used transform operation.
E.g. translating an object will only add keys on translation keys.

The behavior of keying all property array channels first, and then
only add keys on values that have actually changed may change
in the future. Ideally it would only key actual changes to begin
with. But there is no way to do this right now.

Pull Request: https://projects.blender.org/blender/blender/pulls/116419
2024-01-05 09:52:22 +01:00
Jeroen Bakker
d37f9e6587 Cleanup: Make format 2023-12-21 10:47:42 +01:00
Christoph Lendenfeld
de61ec3e6f Anim: Unit Tests for "Insert Available"
In preparation to the upcoming refactor of the keying set code,
extend the unit tests with more sophisticated
tests for "Insert Available".

This PR tests
* key available using the preference setting with autokeying on an object and a bone
* key available using the keyingset "Available"

Pull Request: https://projects.blender.org/blender/blender/pulls/116327
2023-12-21 10:22:21 +01:00
Christoph Lendenfeld
09e93ecc23 Anim: Add basic autokey tests
Add basic unit tests for the auto keying system.

Part of #113278

Pull Request: https://projects.blender.org/blender/blender/pulls/115064
2023-11-21 16:08:16 +01:00
Christoph Lendenfeld
a99e419b6e Anim: Insert keyframes without keying sets
When animators want to key something in the viewport,
the code needs to know *which properties* should be keyed of that selected thing.
So far that was done with keying sets, and a pop-up that let's
you choose the keying set to use. You can get rid of the popup by
choosing a keying set ahead of time. But that is also not always desirable.

That pop-up is quite confusing and gives way too many options.
To simplify this process this PR adds a User Preference option to choose one or more of:
* Location
* Rotation
* Scale
* Rotation Mode
* Custom Properties

Now whenever the `I` key is pressed in the viewport,
and no keying set is enabled, it reads the preferences for which channels to insert.

# User Facing changes
* The popup will not be shown when pressing the hotkey,
 but you can still explicitly use keying sets by going to the menu
* Which channels are keyed is defined by a User Preference setting under animation
* when a keying set is used explicitly, the User Preference settings are ignored

Part of #113278

Pull Request: https://projects.blender.org/blender/blender/pulls/113504
2023-11-21 15:38:01 +01:00
Campbell Barton
6bba008325 Cleanup: format 2023-11-09 09:34:49 +11:00
Christoph Lendenfeld
40dccc1975 Anim: Unit tests for inserting keyframes
Cover the current behavior of keyframe insertion with unit tests,
so the changes planned in #113278 are less likely to break things.

Unit tests added:

InsertKeyTest
very basic test to ensure keying things by
name or with a keying set adds the right keys

VisualKeyingTest
check if visual keying produces the
correct keyframe values

CycleAwareKeyingTest
check if cycle aware keying remaps
the keyframes correctly and adds fcurve modifiers

Pull Request: https://projects.blender.org/blender/blender/pulls/114465
2023-11-07 16:17:32 +01:00