Stuntman And Lover Of Cheese

by Dan Bostonweeks

Orders of Sorts

Back in those before times when I worked in animation and visual effects I did a lot of work around render queues and handling frames. Frames to be rendered, composited, passed to other departments, etc. At every studio there was a shorthand for specifying frames, frame.1-100.ext for example.

In dealing with them and generating new frames you didn’t always want to go through the list sequentially. For example if you’re generating an effects shot and you want to see it along the way you could render on tens (10, 20, 30, 40 and so on) but that wouldn’t always get you what you wanted fast enough, especially if your sequence of frames is 1000 frames or more. This allows the user to get a feel for the generated sequence before it is completed and make the call if changes are needed or it can continue.

To combat this and help users get to see their renders faster I came up with a few ways of reordering arrays (generally frame ranges, but they could be tasks too) that proved useful. Stochastic sampling would work, but could be heavy on one end of the sequence unintentionally. There’s also the issue of repeatability, since being able to repeat the same execution multiple times makes it easier to compare two runs of tasks.

Recently I wanted to run some discrete tasks that each took a non-significant amount of time. Rather than just randomizing my list of tasks I wanted to see progress across the whole sequence, just like when I was working on a shot in animation. To that end I ported my array ordering functions to an NSArray category: NSArray+FESOrderOps1.

So there it is, enjoy.

  1. There is also an implementation of a Fisher-Yates shuffle in there that could be handy because a shuffle is an order and this way I feel it’s complete for my needs.  ↩