How to code MacroPatches

cwright's picture

Macro Patches are quite handy for OpenGL rendering, where you want the same modifications applied to several patches, such as the 3D transformation patch, the GLSL Patch, lighting, and fog.

Programming them is also exceptionally simple.

First, write a patch as normal. For + (BOOL)allowsSubpatches; be sure to return YES instead of NO.

then, to execute your subpatches, you just need to add one line of code to your patch's execute method:

[self executeSubpatches:time arguments:arguments];

This also means timewarping patches should be possible without much work at all :)

The QCPatch superclass automatically handles saving and restoring, connecting subpatch published outputs, and other metadata associated with its subpatches (apparently, object reordering can happen if you want, but I don't know why you'd want this...)

That's all there is to it!