Builtin Library
README.md
generator.play
A Generator's play of its graph (call): loading, clocking, presenting, standing and advancing it; binding a graph to the generator (regenerate); following what the bound graph was built from (followBuild); and standing a baked snapshot in place of cooking.
What the bound graph was built from is recorded as it binds (gen.builtFrom): the
folder of its source with the source revision that folder last went stale at, the
version of its entry script and the count of render devices rebuilt
(proc.deviceEpoch()), each read before the build begins (gen.stampBuild), every
node it reaches, at any depth, with how many times it had been loaded
(proc.nodesReached, from proc.registry.loadCount), and for a graph of the node form the content of the graph
proc.played handed out (proc.depHash). Each frame followBuild compares three
numbers, the registry's definition revision and revision and proc.sourceRevision();
only when one moved does it walk the record, and the generator builds its graph again
when something it reaches moved. A node loading for the first time moves nothing it
records. A generator whose build or cook failed tries again whenever a registration or
a source moves. A graph of the call form whose source
does not build leaves what stands standing, its play included, and says why in
playback().error and as a failed cook targeting source.
A reload of the graph's folder or a change of params finds the graph standing built from the source as it stands
(gen.call.current): the entry's content version is the one recorded, nothing in gen.builtFrom or the play's record
moved, the last build did not fail, and the signature of the graph standing (its guid, the hash of its document, kept
in gen.call.content for that graph, and the outputs it shows) is the play's. Then regenerate builds nothing and
runs stand on the graph standing, which keeps the play and hands it the inputs params state. Otherwise the graph
is built again.
A play the generator lets go of because the graph is played afresh (its source, a node
or module it was built from, its output or the scene state it reads moved) keeps
standing in gen.call.superseded until a present of the play replacing it succeeds, and
goes in the frame that present's shows stand; a play let go of while its present runs
joins it once that present returns. Unbinding the graph or destroying the generator lets
go of every play at once. A present that cooks counts in cost.cooks, and the CPU its
thread runs, the frames it waits out apart, in cost.cookMs; a present on the device
counts in devicePresents and deviceMs. Its presents are recorded how = "cook" or
"device". An output the graph only returns is shown by the play itself
(opts.show of proc.eval.play), through io.output's show.
One part of the Generator component. ~.generator installs it on a
Generator instance's context table, gen, which the component makes
once per instance: the part keeps its shared state and the operations
other parts call as fields of gen, and what only it reads as locals of
its install function, so every instance holds its own.