[Bf-animsys] Animation logic

Bassam Kurdali bassam at urchn.org
Tue Apr 19 21:44:50 CEST 2016


This reply is getting archived here for future reference, thanks for
the detailed explanation Joshua
On Tue, 2016-04-19 at 19:47 +1200, Joshua Leung wrote:
> Hi Erick,
> 
> For a useful (though overly broad/general) introduction to the key
> concepts of how updates in Blender happen in general, see this:
> https://wiki.blender.org/index.php/Dev:2.5/Source/Architecture/Window
> _Manager
> 
> 
> Here you go  (this was originally go to be "in short", but then it
> turned out to be a lot longer reply ;):
> * The code in your "operator" modifies the keyframes/etc. data (i.e.
> stuff stored in the SDNA structs that form that Main database)
> * When your operator is done, it sends a "notifier"  -
> WM_event_add_notifier(C, ....notifier flags..., NULL); 
>   For keyframe editing, this is usually something like NC_ANIMATION |
> ND_KEYFRAME | NA_EDITED (i.e. notifier for "animation context",
> "keyframe data", "editing performed/action").
> * Notifiers are added to a global queue to be processed the next time
> we go through flushing updates (more about this below), instead of
> being handled immediately (i.e. the "callback" style of updates that
> other toolkits - notably Qt, GTK, and all of the Java ones - Swing,
> etc. use. However, the "callback style" has some serious
> disadvantages - i.e. some updates happening multiple times, bad
> performance if you inadvertently chain up a bunch of these by relying
> on delegating to other callbacks, and "callback hell" if that
> chaining accidentally forms a loop.)
> * As in any GUI program, Blender has what's known as an "event
> loop".  Basically, it's like you've got a piece of code in your main
> function that does: 
>   while (true) {
>         get_event();
>         handle_event();    // run operators, and/or exit the program
>         flush_updates();   // handle notifiers
>         refresh_and_redraw(); 
>    }
> 
>   In Blender, notifiers are handled in the "flush_updates()" step,
> after the operator runs (i.e. handle_event() == an operator gets run,
> or some event gets sent to the UI handler, or something like that).
> What that means is that it goes through each window -> editor ->
> region, and for each of the queued up notifiers, it asks those if it
> would like to do anything about that notifier. (You could say it's
> sort of Observer Pattern stuff I guess, except it's deferred updates,
> and we're still really only asking if they'd like to do any updates).
> So, each of the animation editors will listen for NC_ANIMATION |
> ND_KEYFRAME events, and when they hear them, will tag themselves to
> be redrawn.
>   
>   Finally, when it's time to redraw the UI, only the editors/regions
> that are tagged to get redrawn will be redrawn (since redrawing
> everything all the time, even if nothing has changed is slow, and
> would make everything laggy). So, at this point, all the visible
> animation editors would get redrawn, because they tagged themselves
> to get redrawn, in response to the notifier that got sent out.
> 
> 
> 
> Now, all of the above is only just updating the UI (which is what
> your question was about). If you were to talk about how you get those
> animation changes flushed to the actual models and rigs, then you'll
> need to be talking about the dependency graph stuff then. But, there
> it's really a similar idea again :)
> 
> 
> (Also, if you're just concerned with the transform code, have a look
> in transform_generics.c -> recalcData() for how things get tagged for
> updates there :)
> 
> 
> 
> Regards,
> Joshua
> 
> 
> On Tue, Apr 19, 2016 at 7:19 PM, Erick Blender 
> m> wrote:
> > Hi there!
> > 
> > Wanted to ask about Blender animation logic, how graph editor,
> > timeline, dopesheet and NLA work together?
> > Reading code files in blender/editor/animation i find many useful
> > code and i found as well  that in
> > blender/editor/transform/transform_conversion.c there is basic
> > keyframes move, ... 
> > 
> > My question is how graph editor, timeline, dopesheet and NLA talk
> > to each other for example when moving a keyframe in graph it get
> > updated in the dopesheet or vise versa. Is there some where in the
> > code that Blender update dopesheet when action happening in the
> > graph editor?
> > 
> > Thanks in advance :)
> > 
> > 	Virus-free. www.avast.com
> > 
> > _______________________________________________
> > Bf-animsys mailing list
> > Bf-animsys at blender.org
> > https://lists.blender.org/mailman/listinfo/bf-animsys
> > 
> _______________________________________________
> Bf-animsys mailing list
> Bf-animsys at blender.org
> https://lists.blender.org/mailman/listinfo/bf-animsys
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-animsys/attachments/20160419/23db0ae1/attachment.html>


More information about the Bf-animsys mailing list