ImageEngine/gaffer — pull request #467 by johnhaddon (2013-08-09 01:29:36+00:00)
Title: Variable length coshader arrays

This pull request adds support for variable length coshader arrays in the RenderManShader node. New plugs are created "on demand" so that there is always a free plug available on the end of the array. The arrays are represented as a new ArrayPlug class, which I hope will be useful elsewhere. It should be possible to redeclare old fixed length shader arrays as variable length and just reload scripts to get the new variable length behaviour.

Internally the ArrayPlug uses an InputGenerator to do the hard work of creating and removing plugs where necessary. I recently did a bunch of work to improve the robustness of the InputGenerator to fix all the reported Group bugs, but there is still a chance that there are as-yet-unknown issues there, so it would be wise to keep an eye open for any problems that may or may not crop up.

In the longer term, I hope that we might ditch the InputGenerator and use ArrayPlugs everywhere we want dynamically generated inputs. The open question about this is the Group node, which uses an InputGenerator to create new plugs alongside the existing "in" plug on the Node. To convert this over we'd probably need the SceneNode base class to use an ArrayPlug for its "in" plug, and accept minSize/maxSize arguments to a protected constructor. This would break backwards compatibility for existing scripts (although with some hard work we might be able to fix that), but might still be something we want to consider before we start locking things down more.

Oh, and one question. Currently index 0 of the ArrayPlug has a name of "in1". I did this to match the existing behaviour for fixed length arrays. Would everyone prefer the index and the numeric part of the name to match? I think I would, but wanted to canvas opinions first. There are also backwards compatibility issues if we change, but again I think it might be worth it.