Serial loops allow the repeated evaluation of nodes. This is necessary for many effects but became significantly more important with simulations recently. That’s because many kinds of simulations do repeated solver steps to reduce e.g. collisions. Currently, people just copy the same nodes many times, but that’s annoying and easily doesn’t allow an arbitrary number of iterations.
Example from the simulation demo file:
Note, the goal is not to provide a solution to e.g. iterating over every point one by one. While it’s technically possible, serial loops are a very inefficient way to do this. That’s what lists and parallel loops will be for in the future.
There are a few features we expect from a serial loop:
- Should be possible to mimic a
for
,while
anddo while
loop from programming. - Should support an arbitrary number of values that are looped.
Serial Loop Zones
Similar to simulation zones, we can add a new zone type for serial loops. This works well, because the same restrictions with respect to adding links apply to simulations and serial loops (and parallel loops as well for that matter). I.e. it’s possible to link from the outside into a zone but not the other way around.
The Max Iterations
input is a hard limit to how many iterations the loop will do. This makes the loop behave like a simple for
loop by default with a fixed number of iterations. Using the Break
output one can stop the loop before the maximum number of iterations is reached. Based on the Output Previous
socket, the loop will either behave like a while
or do while
loop. Suggestions for better naming are welcome.
The Max Iterations
is still a hard limit even when the Break
socket is used. This makes it impossible to accidentally create an infinite loop which is very easy to do otherwise.
The mockups don’t show it, but the Serial Loop Input and Output nodes should have empty in and outputs that allow adding more sockets, just like the simulation nodes.