5
$\begingroup$

I would have imagined that frame_change_pre is the event that happens, well, before the frame changes. Silly me!

The documentation states (emphasis mine):

Called after frame change for playback and rendering, before any data is evaluated for the new frame. This makes it possible to change data and relations (for example swap an object to another mesh) for the new frame. Note that this handler is not to be used as ‘before the frame changes’ event. The dependency graph is not available in this handler, as data and relations may have been altered and the dependency graph has not yet been updated for that.

I'm joking a little bit here but it's a serious question. How am I supposed to think about the event? It says that I can change relations and (rather vaguely) data, and that I can't depend on the dependency graph, but what sorts of things is that trying to tell me that I can't do? I would think that most things I'd want to do before a frame change would be to change data but the warning's got me spooked.

How should I think of it if not that event that happens pre-frame change?

$\endgroup$
4
  • 2
    $\begingroup$ Perhaps think of it as a “after the frame has started to be changed (so the old frame is invalid) but before it’s all settled into the new frame (so the new frame is unfinished)” event…? $\endgroup$ Commented Jul 7, 2021 at 14:08
  • 1
    $\begingroup$ .. will notice too it mentions depsgraph is only available (not none) for post events. The first script here makes a set of dummy handlers to print to console when they are fired. blender.stackexchange.com/a/62870/15543 (remove startswith clause to get a full set. Be wary depsgraph update will fire a lot) The depsgraph is used (among other things) to obtain the modified data blender.stackexchange.com/questions/146559/… $\endgroup$
    – batFINGER
    Commented Jul 7, 2021 at 15:21
  • 1
    $\begingroup$ If script run to echo to console name for all handlers (without testing) would imagine that there will be a call (or two...) to depsgraph_update between frame_change_pre and post Making pre after frame change, pre depsgraph update. $\endgroup$
    – batFINGER
    Commented Jul 7, 2021 at 15:22
  • 1
    $\begingroup$ ... lol scrub that thought. Depsgraph handlers not fired between frame change. Updated code in blender.stackexchange.com/a/62870/15543 , is an interesting exercise. In prior versions scene_update handler was fired a lot, the depsgraph update a lot less. $\endgroup$
    – batFINGER
    Commented Jul 7, 2021 at 16:15

0

You must log in to answer this question.

Browse other questions tagged .