Fix: Cycle aware keying inserting first key #116356

Closed
Christoph Lendenfeld wants to merge 1 commits from ChrisLend/blender:fix_insert_cycle_aware_key into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

Issue

When inserting the first key to a channel with cycle aware keying enabled the bookend keys would end up in the wrong position.
E.g. in this screenshot, the action range is 1 to 11
image

To reproduce:

  • Download the attached file
  • Hit I in the viewport and insert Location
  • Notice the keys are outside the actions range (1, 11)

Solution

If I understand the intention correctly, the code is meant to add the bookend keys to the animation cycle, so it cycles correctly for new F-Curves.
To do that I replaced the existing logic with a simple check if the inserted key is at the start or the end of the cycle.
This ensures the loop is properly bookended.

image

# Issue When inserting the first key to a channel with cycle aware keying enabled the bookend keys would end up in the wrong position. E.g. in this screenshot, the action range is 1 to 11 ![image](/attachments/022b87fd-20d8-42ce-8d0f-8dea74c650d7) To reproduce: * Download the attached file * Hit `I` in the viewport and insert `Location` * Notice the keys are outside the actions range (1, 11) # Solution If I understand the intention correctly, the code is meant to add the bookend keys to the animation cycle, so it cycles correctly for new F-Curves. To do that I replaced the existing logic with a simple check if the inserted key is at the start or the end of the cycle. This ensures the loop is properly bookended. ![image](/attachments/4937a173-51ef-4c03-a597-74260f4df3b4)
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-12-19 17:00:41 +01:00
Christoph Lendenfeld added 1 commit 2023-12-19 17:00:52 +01:00
Christoph Lendenfeld requested review from Alexander Gavrilov 2023-12-19 17:01:30 +01:00

There is no such thing as 'bookend keys'. It would be completely detrimental to mandate keys to be placed at any specific point on all channels. The only thing that matters is the distance between the first and last keyframes of each curve.

There is no such thing as 'bookend keys'. It would be completely detrimental to mandate keys to be placed at any specific point on all channels. The only thing that matters is the distance between the first and last keyframes of each curve.
Author
Member

So it is a feature to create keys outside the defined action range?
Sorry that wasn't clear to me. If you can confirm I will just leave a comment in that place that clarifies that

So it is a feature to create keys outside the defined action range? Sorry that wasn't clear to me. If you can confirm I will just leave a comment in that place that clarifies that

The real solution for cycling would be to avoid any repetition by implementing cycling implicitly based on the action frame range. Thus there would be no need to repeat any keys in the first place, and there would be no special 'first' and 'last' keys. However this would mean refactoring cyclic behavior implementation to be an integral part of action and F-Curve behavior, rather than some bolted-on modifier or NLA thing.

The real solution for cycling would be to avoid any repetition by implementing cycling implicitly based on the action frame range. Thus there would be no need to repeat any keys in the first place, and there would be no special 'first' and 'last' keys. However this would mean refactoring cyclic behavior implementation to be an integral part of action and F-Curve behavior, rather than some bolted-on modifier or NLA thing.

The basic idea of cyclic aware is that cyclic curves repeat infinitely, so inserting a key at any point in the timeline should automatically update the interval where the keys are "really" defined, so that "real" location should not matter to the user.

The action frame range defines the "window" where the action is intended to be played, and also the cycle length. This allows additionally taking the interval and length into account in cycle aware to ensure new curves are also cyclic with the right period, and to preferentially use the window for placing the "real" keys. However it absolutely does not mean there cannot be keys outside the window, and staggering keys between channels should be allowed.

The current implementation is based on the simple idea that you inserted one key, so it should remain a single key: even though it has to be duplicated to ensure the cycle, this duplication is a technical hack necessary for the cycle to work, and logically this is one key. Unfortunately, this of course can result in "weird" placement of the "real" key interval. Your version on the other hand actually inserts two separate logical keys.

The basic idea of cyclic aware is that cyclic curves repeat infinitely, so inserting a key at any point in the timeline should automatically update the interval where the keys are "really" defined, so that "real" location should not matter to the user. The action frame range defines the "window" where the action is intended to be played, and also the cycle length. This allows additionally taking the interval and length into account in cycle aware to ensure new curves are also cyclic with the right period, and to preferentially use the window for placing the "real" keys. However it absolutely does not mean there cannot be keys outside the window, and staggering keys between channels should be allowed. The current implementation is based on the simple idea that you inserted one key, so it should remain a single key: even though it has to be duplicated to ensure the cycle, this duplication is a technical hack necessary for the cycle to work, and logically this is one key. Unfortunately, this of course can result in "weird" placement of the "real" key interval. Your version on the other hand actually inserts two separate logical keys.

I actually envisioned an operator to move the "real" interval by rotating the keys left or right along the cycle (thus changing which key is the duplicated end point), but never got around to implementing it either in C or python. It would have allowed easily fixing weird key placement later.

I actually envisioned an operator to move the "real" interval by rotating the keys left or right along the cycle (thus changing which key is the duplicated end point), but never got around to implementing it either in C or python. It would have allowed easily fixing weird key placement later.
Author
Member

ok I see what you mean, I will close the PR in that case.

About the offset of keys from the cycle range. The use case I see for that is offsetting animations to do e.g. overlaps which is usually a pain with bookend keys.
We could explore other ways to do that in the future. E.g. update the keyframes while translating them to respect the loop. Kind of what the "Time Offset" operator in the graph editor does

ok I see what you mean, I will close the PR in that case. About the offset of keys from the cycle range. The use case I see for that is offsetting animations to do e.g. overlaps which is usually a pain with bookend keys. We could explore other ways to do that in the future. E.g. update the keyframes while translating them to respect the loop. Kind of what the "Time Offset" operator in the graph editor does

Potentially that rotate keys operator (naming inspired by the 'bit rotate' bit shift operation) could be implemented in such a way that key insertion could automatically run it in the cycle aware mode after the actual key insertion to fit the key placement to the action frame range as much as possible given the existing key locations.

Potentially that rotate keys operator (naming inspired by the 'bit rotate' bit shift operation) could be implemented in such a way that key insertion could automatically run it in the cycle aware mode after the actual key insertion to fit the key placement to the action frame range as much as possible given the existing key locations.

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#116356
No description provided.