Get/use depsgraph for a given (not the current) frame in draw handler, without affecting scene

Looking at the built-in motion path operator (anim_motion_paths.c), Blender allocates a new temporary depsgraph for building motion paths, but it does so without making the new depsgraph active, because doing so causes unkeyed animation changes to be lost, so I think the issue you face with stuff moving is inherent to the design - they know about this. Grepping the code for “unkeyed” yields several comments about this.
Just modifying the timeline will also cause this behavior.

Blender has an AnimOverride member on the AnimData instances that, according to the header files, was supposed to hold unkeyed changes, but introspection shows the listbase is always empty on objects that clearly do have unkeyed stuff, so I don’t think it’s even used.

You can indirectly create a depsgraph either by creating a view layer or a new scene. Each scene gets its own linked copy of the existing view layers, which is likely copy-on-write. What I don’t know, is how you can evaluate a depsgraph without setting the frame for the active scene.

There was a different motion paths addon just a year or two back, I forget the name. It would be interesting to see how they tackled this.

Have you thought about just saving the unkeyed changes and restoring them afterwards?

1 Like