Anim: Bake Channel operator #111263
No reviewers
Labels
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
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111263
Loading…
Reference in New Issue
No description provided.
Delete Branch "ChrisLend/blender:bake_channel_operator"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a replacement for the workflow that uses "Bake Curve" and "Unbake Curve" to quickly generate dense key data.
Compared to the existing workflow it has the advantage of allowing the user more control over the key types, and distance between keys, as well as the frame range affected.
Operator options
-- Keep existing keys
-- Remove keys within the range
-- Remove keys outside of the range
-- Remove all keys
The operator can be found in the Graph Editor under
Channel->Bake Channels
Part of this task
#111050: Better Baking in the Graph Editor
Animation: Bake Channel operatorto WIP: Animation: Bake Channel operator@blender-bot package
Package build started. Download here when ready.
WIP: Animation: Bake Channel operatorto Animation: Bake Channel operator@blender-bot package
Package build started. Download here when ready.
@blender-bot package
Package build started. Download here when ready.
@blender-bot package
Package build started. Download here when ready.
Animation: Bake Channel operatorto Anim: Bake Channel operatorFound a couple of bugs while testing:
And I have a couple of questions about functionality:
thanks for having a look at it
fixed that by clamping the range
The hardmin is 0.01 so it will get quite slow on high frame count. But I am not sure what the minimum number should be. I thought about setting it to 0.1 (so 10 subframes) but it feels like an arbitrary number so I kept it at 0.01 because I don't see anyone wanting more than 100 subframes. Users that venture into that realm better be careful. Let me know what you think
yes good point. Will make it inclusive
Made the default to remove in range.
Still kept the option to not remove any keys. While I don't have an immediate use case, it feels more complete to have it, and it doesn't add much complexity.
Generally looking good! But there are some changes I'd like.
@ -4326,0 +4327,4 @@
static const EnumPropertyItem channel_bake_key_options[] = {
{CHANNEL_BAKE_KEEP, "KEEP", 0, "Keep", "Keep the current key types"},
{BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", "New keys will be beziers"},
I'd prefer new constants for this enum, rather than awkwardly having just one that's new and defined arbitrarily high to avoid conflicting with the others. It's not as convenient in other code, because then you have to map between the two sets of constants later. But it feels cleaner to me that way.
not sure I agree with this. It would add a level of indirection to the enum which I think isn't needed. Atm it is quite clear what key types the options correspond to since they use the same constants.
I agree it does feel a bit weird, but I feel like it is the better option
That's fair. Let's leave it as-is, then. Thanks!
@ -4326,0 +4449,4 @@
/* Identifiers */
ot->name = "Bake Channels";
ot->idname = "ANIM_OT_channels_bake";
ot->description = "Create keyframes on the F-Curves of selected channels";
This description feels non-specific to me. There are a lot of operators that create key frames.
On the other hand, I'm struggling to think of a succinct alternative that doesn't suffer similar problems.
I think I made it better
Create keyframes following the current shape of F-Curves of selected channels
The distinction to other keyframe adding operators is that this one looks at the shape of the current curve, so I think it makes sense to mention that
Yeah, that's great. Thanks!
@ -4326,0 +4480,4 @@
RNA_def_enum(ot->srna,
"remove_existing",
channel_bake_remove_options,
int(BakeCurveRemove::REMOVE_NONE),
If we do keep these options as-are, I think
REMOVE_IN_RANGE
is a better default. I don't think people usually want to leave behind the old keys in the range being baked.@ -4326,0 +4482,4 @@
channel_bake_remove_options,
int(BakeCurveRemove::REMOVE_NONE),
"Remove Existing Keys",
"If enabled removes the keys that currently make up the curve");
This description reads like it's a boolean option.
indeed it used to be a boolean. changed it to be more representative of the enum
While that's true, this is also accidentally quadratic, because on every removal (
BKE_fcurve_delete_key
) it has to shift all the keys after the removed key back. If you iterate forward and keep track of the gap as it's created, you can shift keys over the gap as you go for linear runtime.Oops, I think a change got pushed while I was reviewing, so these last two comments got detached. I'll resubmit them.
This is also accidentally quadratic (actually slightly worse, because it additionally does a binary search to find where to insert each key), and does an allocation and full copy of the f-curve's entire bezt data on every insert.
However, this one is a bit dicier (but certainly not impossible) to make linear. So maybe it's better to leave this one as an optimization for later.
(Re-attached comments.)
@ -1219,0 +1222,4 @@
const BakeCurveRemove removal_mode)
{
/* Iterating backwards to not cause issues because the bezt array is modified during the
* loop. */
While that's true, this is also accidentally quadratic, because on every removal (BKE_fcurve_delete_key) it has to shift all the keys after the removed key back. If you iterate forward and keep track of the gap as it's created, you can shift keys over the gap as you go for linear runtime.
solved by adding a new function
BKE_fcurve_delete_keys
that removes a range of keys in one swoop@ -1219,0 +1265,4 @@
}
for (int i = 0; i < sample_count; i++) {
insert_vert_fcurve(
This is also accidentally quadratic (actually slightly worse, because it additionally does a binary search to find where to insert each key), and does an allocation and full copy of the f-curve's entire bezt data on every insert.
However, this one is a bit dicier (but certainly not impossible) to make linear. So maybe it's better to leave this one as an optimization for later.
I ran it through a profiler. 90% of the time was spent on
BKE_fcurve_recalc_handles
I changed the flag to
INSERTKEY_FAST
so it doesn't recalculate on every key insertNow 83% is spent on
__memcpy_avx_unaligned_erms
which I have no Idea where that comes fromOoooh, got it. Yeah, since you have to manually type it in for < 1.0, that's probably fine.
With some testing, I also suspect this is running into the quadratic performance I mentioned in the code review. Just counting seconds off, the time it takes to bake seems to increase super-linearly with the number of baked keys as the step size gets smaller.
My concern isn't the complexity, but rather that it makes the drop-down initially confusing (or at least it was to me). But maybe it could be made clearer by just changing the naming a bit? Like, "In Range" -> "Old In Range". And/or maybe it would be easier to grok if it was two boolean options ("Remove Keys In Range" and "Remove Keys Outside Range") rather than a single four-way option.
@nathanvegdahl I addressed the review comments but I am not quite ready for another review. The operator just runs too poorly on heavy scenes. The profiler tells me its the key insertion that eats the time and it makes sense since for every insert it reallocates the bezt array and copies data over.
I will look into a better way
That makes sense.
I was thinking a good approach might be to make a new function that takes two fcurves and merges them into a new one. That way all the complexity can be contained there (and it seems like the kind of utility function that would be generally useful). Then in the baking code you could start by creating two fcurves: the fcurve with the desired keys removed, and the fcurve with the new baked keys. And then you finish by simply merging them.
@nathanvegdahl I implemented a function
BKE_bezier_array_merge
. Now the thing runs on my heavy test scene.It's not realtime, but profiling it, most of the time is taken up by recalculating the handles. The merge function is insanely fast. I was quite surprised by that. The first block on the left above bake_fcurve is the merge
It might be possible to use that in other places as well.
@blender-bot package
@BClark can you review this once more. Should be super fast now, even on heavy scenes
Package build started. Download here when ready.
Wow it works great!!!! That is so nice to have the control over the modifier bake and to be able to replace keys!!!!
Checkout
From your project repository, check out a new branch and test the changes.