When keyframing with the `Only Insert Needed` flag enabled,
the code was able to delete keyframes in certain cases.
This behavior is removed and replaced with the following rules.
* If there is a key on the current frame, and it has the same value, skip it.
* If there is no key, but the FCurve evaluates to the same value, skip it.
* Add a key in all other cases.
Remove that functionality for consistency and simplify the code around it.
Pull Request: https://projects.blender.org/blender/blender/pulls/115360
New FCurves for bones were not automatically set to `FCURVE_COLOR_AUTO_RGB`
because the RNA path couldn't be resolved.
That was because the `PointerRNA` passed into the function points to the bone,
but the rna path is relative to the ID.
Fixed by resolving the path from the bones owner ID
Pull Request: https://projects.blender.org/blender/blender/pulls/115517
When pressing `I` in the viewport, the colors of the FCurve channels were no longer set correctly.
Caused by #113504
Fix by removing the flag that determined that in the first place,
and read straight from the user preferences. Then move the code
that sets the mode on the FCurve into the function that actually creates it.
For 99% of cases the code went to the user preference flag `AUTOKEY_FLAG_XYZ2RGB`
and if that was set, the `INSERTKEY_XYZ2RGB` would be set. The only case where this
was not from the user preferences was from custom keying sets.
There was an override flag for FCurve colors on custom keying sets.
I removed that with this patch since the use case is not apparent
and custom keying sets are hardly used.
Pull Request: https://projects.blender.org/blender/blender/pulls/115297
No functional changes.
Rename the `eAutokey_Flag` to `eKeyInsert_Flag`
to indicate that it is not only used for auto keying.
Also rename the enum items to better reflect what they are used for.
Pull Request: https://projects.blender.org/blender/blender/pulls/115295
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
No functional changes.
Move the function `autokeyframe_pose` from
`transform_convert_armature.cc` to `keyframing_auto.cc`
The function has a lot of overlap with `autokeyframe_object` so it
can potentially be simplified later on.
Pull Request: https://projects.blender.org/blender/blender/pulls/115051
No functional changes.
The function `insert_vert_fcurve` also initialized a `BezTriple` from the flags it got.
Extract that logic into a separate function so it can be reused elsewhere
Pull Request: https://projects.blender.org/blender/blender/pulls/115039
No functional changes.
Extract code from the function `insert_keyframe_value`
to make it easier to use in other places.
I created a new function `remap_driver_frame` that
removes 3 parameters from the function.
And I removed the requirement for a `ReportList`
by just returning false and letting the caller
create a message.
Pull Request: https://projects.blender.org/blender/blender/pulls/114700
No functional changes.
Renaming the following functions
`ANIM_remove_empty_action_from_animdata` and
`ANIM_fcurve_delete_from_animdata`
to
`animdata_remove_empty_action` and
`animdata_fcurve_delete`
The `ANIM` prefix was no longer needed since the code is now in
a namespace. In order to make the function name consistent with
the functions in `fcurve.cc` the thing it modifies is now at the
start of the function name
Pull Request: https://projects.blender.org/blender/blender/pulls/114584
No functional changes.
Move the following functions
`ANIM_fcurve_delete_from_animdata` and
`ANIM_remove_empty_action_from_animdata`
to
`ANIM_animdata.hh` / `animdata.cc`
in animrig
This removes some includes to `ED_anim_api.hh`
from animrig
Pull Request: https://projects.blender.org/blender/blender/pulls/114581
No functional changes.
Move the functions
`insert_vert_fcurve` and
`insert_bezt_fcurve`
from `ED_keyframing.hh` / `keyframing.cc`
to `ANIM_fcurve.hh` / `fcurve.cc`
in animrig
Pull Request: https://projects.blender.org/blender/blender/pulls/114570
No functional changes.
Moving the following functions
`action_fcurve_ensure` and
`action_fcurve_find`
from
`ANIM_fcurve.hh`/`fcurve.cc`
to
`ANIM_action.hh`/`action.cc`
This is an effort to ensure that the fcurve files don't need to know
about the container they are stored in so we can swap out
the container more easily.
Pull Request: https://projects.blender.org/blender/blender/pulls/114575
No functional changes.
Improve the readability of the code by
* returning early where possible
* moving variables closer to where they are used
* renaming variables
Pull Request: https://projects.blender.org/blender/blender/pulls/114568
No functional changes.
Since the following functions are now in a C++ namespace, their prefix can be removed:
* ANIM_setting_get_rna_values -> get_rna_values
* ED_action_fcurve_find -> action_fcurve_find
* ED_action_fcurve_ensure -> action_fcurve_ensure
Pull Request: https://projects.blender.org/blender/blender/pulls/114450
No functional changes.
For all the recently moved keyframing code I did the following:
* Remove comments that just repeat what the code is doing.
* Move comments for public functions to their location in the header file.
* Make sure comments are formatted properly with a capital letter at the start and a dot at the end.
Pull Request: https://projects.blender.org/blender/blender/pulls/114448
No functional changes.
Changing old C code to C++ by returning a `Vector` from `ANIM_setting_get_rna_values`.
This reduces the argument count for that function and simplifies the code.
Pull Request: https://projects.blender.org/blender/blender/pulls/113931
No functional changes
`ANIM_builtin_keyingset_get_named` had a `KeyingSet *` argument
that was always passed as `nullptr`
This patch removes it to simplify the code.
Pull Request: https://projects.blender.org/blender/blender/pulls/113677
No functional changes
The keying set code was passing around a list
of `tRKS_DSource` through a lot of functions.
It turns it this was just a ListBase wrapper around `PointerRNA`.
So to make it clearer what is passed around, I replaced the
`ListBase` with a `Vector<PointerRNA>`
To make the use of `ANIM_relative_keyingset_add_source` clearer
I made two functions out of it with different parameters.
Those can take the vector as a reference and
EITHER only an `ID *`
OR an `ID *`, `StructRNA *` and a `void *`
Pull Request: https://projects.blender.org/blender/blender/pulls/113675
No functional changes
Since the functions now live in a namespace,
they no longer need the prefix
as a result there are now 2 functions named
`autokeyframe_object`
which is fine because they take different parameters
If both are needed is for a future patch to investigate
Pull Request: https://projects.blender.org/blender/blender/pulls/113612
No functional changes
The following functions have been moved
`autokeyframe_cfra_can_key`
`autokeyframe_object`
`ED_autokeyframe_object`
`ED_autokeyframe_pchan`
`ED_autokeyframe_property`
they are all in a new file
keyframing_auto.cc
while the declarations are in
ANIM_keyframing.cc
The autokeyframe makros also have been moved
Pull Request: https://projects.blender.org/blender/blender/pulls/113607
No functional changes
Following changes have been made to make the code more readable
* added const where possible
* move variables closer to use
* rename abbreviated variables
* invert `if` and return early
Pull Request: https://projects.blender.org/blender/blender/pulls/113595
No functional changes.
Move the following keyframing functions to the animrig folder
* `insert_keyframe_direct`
* `insert_keyframe`
* `delete_keyframe`
* `clear_keyframe`
In order to disentangle the code I had to move the following as well
* `delete_keyframe_fcurve`
* `visualkey_can_use`
* `visualkey_get_values`
In order to sort the functions I made 3 files (and their header counterparts)
* fcurve.cc
* keyframing.cc
* visualkey.cc
The following functions I made public so they won't get duplicated
* `update_autoflags_fcurve_direct`
* `ANIM_setting_get_rna_values`
There are public keyframing functions that
I left in the editors/animation/keyframing.cc file
I'd like to limit the scope of this refactor, and then
clean up the moved functions before moving even more over
Part of #113278
Pull Request: https://projects.blender.org/blender/blender/pulls/113503
Newly created bones and bone collections get a default name. Like
other types of data, these names should be translated if the user
enabled the translation of new data in the preferences.
This commit adds the appropriate `DATA_()` macro:
- when creating a new armature;
- when creating a new bone;
- when creating a new bone collection through `ANIM_bonecoll_new()`;
- when ensuring that a new bone collection has a unique name;
- when renaming a bone collection;
- in the bone collection tests, to check that new bones have the
expected translated name.
It also sets the default value of the bone name in the
`ARMATURE_OT_bone_primitive_add()` operator to a null string instead
of "Bone", so that the default name may be chosen while checking for
unique names, since an empty string will default to the translation.
Pull Request: https://projects.blender.org/blender/blender/pulls/113171
The color returned by `ANIM_bonecolor_posebone_get()` is not supposed
to be edited, so just return it as `const` and take a `const bPoseChannel`
as argument.
This makes the function usable in a wider range of situations, for example
the drawing code (which shouldn't alter any of these colors).
Replace the import/export of armature layers with bone collections.
The Old Way:
- Export: Each bone would store which armature layer it was on.
- Import: All armature layers that contain at least a bone are shown.
The New Way:
- Export: Each armature contains a list of its bone collections,
including which one is active and which ones are visible.
- Export: Each bone stores which bone collection it is on.
- Import: the above data is simply used as-is.
Due to limitations of the current Collada importer code, each "extra"
tag can only occur once per Collada node. This means that it was
impossible to write a `<collection name="Bones">` tag for each bone
collection, as only one of those would actually be stored by the
importer for further processing. To work around this limitation, all
bone collection related tags store their values as newline-separated
strings. Example:
```
<node id="Armature">
<extra>
<technique profile="blender">
<collections sid="collections" type="string">Layer 1
Layer 3b
Group
That One Bone</collections>
<visible_collections sid="visible_collections" type="string">Layer 1
Layer 3b
That One Bone</visible_collections>
<active_collection sid="active_collection" type="string">That One Bone</active_collection>
</technique>
</extra>
</node>
```