[Bf-committers] Code refactoring suggestions

Prashant Sohani prashant.sohani at gmail.com
Wed Jan 30 11:48:59 CET 2013


Hi,
While the following is only mildly related to the ongoing 'Code cleanup
woes' thread in the short run, I feel that any serious
rewriting/refactoring attempt in the future could benefit from these
observations:

For the last month or more, I've been poking at the Blender source to
familiarize myself with it. I am trying to add a couple of new features
here or there; for instance
a) A Time input node in Material/Shader compositor would enable OSL etc to
leverage the same for awesome time-varying materials.
b) A circular 'ring' modifier similar to the linear array modifier, that
would create N copies of the object, equally spaced in a circular
arrangement of variable radius, orientation etc
c) A 'teleport' or 'global bus' aspect to the reroute nodes, so that they
can serve as proxy portals to be quickly instantiated anywhere in the node
view, without having to explicitly add an ugly visible on-screen link
between the source socket and every reference to it.

In each case, one of the major issues I have with the source is that it
simply isn't modular enough. For instance, I'd expect everything that is
specific to individual modifiers to lie in the blender/modifiers directory.
In particular, the names of the modifiers shouldn't even be mentioned
anywhere outside that directory.

At the moment, to add the ring modifier I have to currently 'follow' the
existing Array modifier all around the blender source, locate several
occurrences in unexpected places; blindly duplicate the Array code often [
while also trying to figure out for every occurrence of the word 'array' if
it was expected to be unique in any way, and so needs to be changed to
'ring' or not ]. And they're all tiny additions, too; and still not so tiny
that they could all be one-shot scripted into place every time I need to
add such a feature.

So, I guess what I'm driving at is, for example. a kind of a one-place
'index' in blender/modifiers that catalogues all the implemented modifiers
such as 'Array', and all external references to individual modifiers (i.e.
outside of the modifiers folder) should be like factories that would read
the catalogue and do the needful per-entry.

PS: While on the subject, any comments on those features?

Regards,
Prashant


More information about the Bf-committers mailing list