Page MenuHome

Speed up for motion path calculation
ClosedPublic

Authored by Sergey Sharybin (sergey) on Sep 23 2019, 12:31 PM.
Tags
None
Subscribers
None
Tokens
"Love" token, awarded by Schamph."Love" token, awarded by Astiero."Yellow Medal" token, awarded by Zino.

Details

Summary

There are number of changes here (as separate commits) which are
making motion paths way faster for animators working on animation
training here in the studio.

One implemented direction of speedup here is building a dependency
graph from a given subset of IDs. This is more clean implementation
of filtering API which existed during Spring project but which later
on got reverted due to design conflicts with other areas.

This new approach has way smaller footprint and faster graph
construction as well, which opens a door for updating motion path in
several threads (multi-threading is not yet implemented, still need
to be careful about it due to increasing memory footprint).

Another direction which is implemented in this patchset is to only
update frame range of motion path which is changed due to user
transform as an opposite of old behavior when the entire motion path
would have been updated after translating a single bone.

This is happening based on a keyframes for motion path target.
Calculation of such range is a bit tricky and is not yet optimal
and is done as following:

  • For every motion path target we iterate over f-curves and calculate frame range between 2nd keyframes counted from the current frame (if acceleration smoothing is enabled it is 4th keyframes).
  • We choose widest range from the ranges of individual f-curves.

Ideally, we would only consider f-curves which are affected by the
auto-keying feature. This can be implemented later on based on the
changes in this patchset.

With the current animation file for training moving bone in pose
mode with motion path enabled brings update from 11 sec to 0.7 sec.

Extra speedup is possible if the acceleration smoothing on f-curves
is disabled (it's not something our animators want anyway) and in
that case the update time goes down to 0.4 sec.

Diff Detail

Repository
rB Blender

Event Timeline

Brecht Van Lommel (brecht) added inline comments.
source/blender/depsgraph/intern/builder/deg_builder_nodes.h
96 ↗(On Diff #18413)

Personally I would make as few methods as possible virtual.

Then when reading the code it's easier to understand where the behavior might be different than the base class.

This revision is now accepted and ready to land.Sep 24 2019, 5:19 PM
source/blender/depsgraph/intern/builder/deg_builder_nodes.h
96 ↗(On Diff #18413)

This is what override is for.

Having only some of the building functions virtual and others not causes other issue: you are able to override some aspects of behavior but not other. Is not so big of a problem with Clang/GCC with strict flags, but in MSVC that could be quite painful to realize.

Additionally, that also makes patches more noisy when behavior needs to be overwriten.