Anim: Only sort FCurves that need it #119735

Merged
Christoph Lendenfeld merged 2 commits from ChrisLend/blender:remake_transdata_selective into main 2024-03-21 15:11:29 +01:00

Before this PR the sorting function would receive all FCurves from the anim_data ListBase
and sort them + recalculate the handles.

Considering we are already checking IF an FCurve needs sorting we might as well use
that and limit the sorting to FCurves that actually need it.
Doing that gives the following performance uplift.

- Before After
Moving 1 key only 109ms 0.72ms
Moving 1 key of each FCurve ~2000ms ~2000ms

As can be seen in the performance data, this greatly benefits the case of moving a single key, while not making it worse when moving keys on all FCurves.

Measurements of remake_graph_transdata using the following test file.
https://drive.google.com/file/d/11wQhuYmhCtQgjT4uJWORTwKlWit1irp2/view?usp=sharing
Imported and extended from: https://sites.google.com/a/cgspeed.com/cgspeed/motion-capture/the-motionbuilder-friendly-bvh-conversion-release-of-cmus-motion-capture-database

Before this PR the sorting function would receive all FCurves from the `anim_data` ListBase and sort them + recalculate the handles. Considering we are already checking IF an `FCurve` needs sorting we might as well use that and limit the sorting to FCurves that actually need it. Doing that gives the following performance uplift. | - | Before | After | | - | - | - | | Moving 1 key only | 109ms | 0.72ms | | Moving 1 key of each FCurve | ~2000ms | ~2000ms | As can be seen in the performance data, this greatly benefits the case of moving a single key, while not making it worse when moving keys on all FCurves. Measurements of `remake_graph_transdata` using the following test file. https://drive.google.com/file/d/11wQhuYmhCtQgjT4uJWORTwKlWit1irp2/view?usp=sharing Imported and extended from: https://sites.google.com/a/cgspeed.com/cgspeed/motion-capture/the-motionbuilder-friendly-bvh-conversion-release-of-cmus-motion-capture-database
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2024-03-21 12:22:47 +01:00
Christoph Lendenfeld added 1 commit 2024-03-21 12:22:52 +01:00
Hans Goudey reviewed 2024-03-21 13:25:56 +01:00
Hans Goudey left a comment
Member

Nice simple change here!

Nice simple change here!
@ -981,3 +975,2 @@
/* Do resort and other updates? */
if (dosort) {
remake_graph_transdata(t, &anim_data);
if (unsorted_fcurves.size() != 0) {
Member

unsorted_fcurves.size() != 0 -> !unsorted_fcurves.is_empty()

`unsorted_fcurves.size() != 0` -> `!unsorted_fcurves.is_empty()`
Author
Member

thanks Hans! fixed :)

thanks Hans! fixed :)
Sybren A. Stüvel reviewed 2024-03-21 14:04:52 +01:00
Sybren A. Stüvel left a comment
Member

Considering we are already checking IF an FCurve needs sorting we might as well use
that and limit the sorting to FCurves that actually need it.

😿 and here we have another one of those "Blender does WHAT?" moments. Yeah, skipping the sorting when you know you can skip the sorting, that sounds quite good.

Oh damn... and then we have test_time_fcurve(fcu) being called for every curve, even though it would sort them all anyway if even one needed sorting. Nice.

> Considering we are already checking IF an FCurve needs sorting we might as well use > that and limit the sorting to FCurves that actually need it. 😿 and here we have another one of those "Blender does WHAT?" moments. Yeah, skipping the sorting when you know you can skip the sorting, that sounds quite good. Oh damn... and then we have `test_time_fcurve(fcu)` being called for every curve, even though it would sort them all anyway if even one needed sorting. Nice.
Sybren A. Stüvel approved these changes 2024-03-21 14:05:28 +01:00
Sybren A. Stüvel left a comment
Member

Also the changes LGTM :)

Also the changes LGTM :)
Christoph Lendenfeld added 1 commit 2024-03-21 14:38:14 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
75d23f7cfc
use is_empty
Author
Member

@blender-bot build

@blender-bot build
Christoph Lendenfeld merged commit 6a55a126e9 into main 2024-03-21 15:11:29 +01:00
Christoph Lendenfeld deleted branch remake_transdata_selective 2024-03-21 15:11:31 +01:00
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
3 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#119735
No description provided.