I think @ideasman42 's initiative about patch templates can be the good place to provide a feedback from a newbie to Blender development (as I am), even if all below is not only related to patch templates.
Few words about me (you probably don’t care, but that can explain some of the “why” about the points I will mention further). So, I’m 52, from France, and I love my wife and my cats.
Concerning Blender: as hobbyist from 2006 or around, from 2010 also using it for my work (illustrations for presale actions). Mainly modeling and shading, coding few little addons or operators. Sometimes active participant in BSE.
That said, I’ve decided recently (around 2 weeks ago) to go further trying to participate to Blender development. Here is my feedback about it (please consider nothing here is for criticizing, I’m just wondering about many points):
- My primary aim: coding a “Python modifier”, a modifier that accepts Python addons.
- To learn to do that, I’ve decided to first make few simple modifiers (or I thought it was simple)
- The first one (done): a “randomize modifier” (randoms mesh vertices from some parameters: axis, other object axis, vertex group)
- The second one (failed so far): a “remove doubles modifier”. I’ll explain why I failed below.
- The third one (planed): a “fan modifier” which is some kind of mix between screw and array and will be a port of a Python operator I’ve coded before.
The “remove doubles modifier”: I thought it was simple as the function already exists somewhere from an operator. But diving into the code, I’ve understood (may be wrong):
- It is operators data dependent for some parts
- It relies on kdtrees
- It seems that the function cannot be directly reused in a modifier context
So my thought was the following:
- The remove doubles algorithm should be isolated in another library
- By the way, this lib could be C++ based (except from extern parts), as I’ve seen some parts of Blender are coded using C++
- C++ can provide the very versatile data structures of std libs as I believe this kind of structures is a key element to code algorithms (the same way lists, arrays, dictionaries and sets are key points for Python) and Blender contains plenty of algorithms
- But… how to add a new library to Blender? I’ve spent a day on it and still don’t know how to add one (where is the how to for that?). I think a “patch template” can be usefull for that (or simply a documentation, but I was not able to find one).
More general aspects:
- Coding a feature is sparsed in several levels
- In my opinion, this is the why cookbooks are required (or patch templates) if you want to do anything. And that means that anyone who want to do anything needs to modify code parts that is not related to what he/she wants to do (example: rna_modifier.c contains definitions for all modifiers)
- I know we need to make the bridge between a feature (say a modifier) and Python GUI through DNA and RNA, but (again in my newbie opinion) this is not good to sparse that at different levels of the architecture
- I think, ideally, each complete feature (eg a modifier) should correspond to one set (a library) isolated from the other features (eg the other modifiers), having in its own scope all the needed parts (eg the modifier itself and its DNA and RNA parts)
- These independent features/modules should themselves be internally architectured in respect of the said levels/aspects through one or several “interfaces” (in the design pattern meaning).
- First thought, that probably could be done extending ModifierTypeInfo and/or ModifierData
- Pros: more simple to patch, maintain, explain, less impact on any other Blender’s architecture parts, allows to choose between C and C++ for coding, could open the way for C/C++ libraries plugins/addons
- Cons: maybe there is, please tell
Is there a way to do that progressively (for instance, if we want to do that on modifiers, is it possible to do it without ‘migrating’ all the modifiers in one step)? I think yes (but again I’m a newbie), and of course if I wanted to try a proof of concept about it, well… knowing how to add a new lib (as said above) is a key…
At this step, I’m wondering if I’m wrong or right writing all that as I know few and have done nothing so far. In some aspects, this is comparable to be a Blender user: this is not simple at the beginning but once the principles are acquired, you feel it great and it is a pleasure to use it… I hope I’ll feel the same coding for it, with time…
… ok, its time to click on the “reply” button.
Thanks for reading