Is Blender design like an Entity Component System?

Greetings. In my quest to see if/how I can add an new object type to blender, a few months ago after looking at the code I decided that it was over my head and in the time to figure out how Blender is designed and what needs to go where, it would take just as long as to take my prototype project to the next level and create an app with some basic features and handle multiple objects and GPU uitilisation. Well last week I had complete that and was very pleased as I had accomplished all I set out do.

But when I considered the possibility of adding extra object types, and eventually large number of objects, I saw the OOP approach I had used would be slow and difficult to achieve to perform complicated tasks. How does Blender and game engines overcome this ?
Almost immediately I came across what is called an Entity Component System (ECS) design approach to overcome performance issues and other problems. It quickly dawned on me that this ECS is basically a relational data base problem, something I understand and have implemented quite a few times. Thus I have created and tested the scaffolding for my own ECS, and am just about to finish it off with coding for all the initial mangers that will be needed to get it up and running properly.

Then it dawned on me. Blender has in its code sections called RNA, DNA and BKE that from memory corresponded to this kind of design. In an instant I could understand Blender and its structure and If Blender is a kind of ECS, from the begininng I would not have been overwhelmed by the code. I did a quick search in the developer forums and found only one topic that matched the search for entity component system.

I skimmed through this as it was long, but there was a mention that Blender is designed using a data oriented design (DOD) and one poster call astrand suggested using and ECS approach rather than a DOD.I thought these are the same.

Does Blender use a DOD and if so, If what is the difference to an ECS design for Blender?

If Blender utilises a DOD or ECS, then knowledge of that design and its layout or relationship of the various directories and files would help and even make life so much easier for wannabe developers get to know, navigate the code and how to contribute to Blender much more easily and not be overwhelmed by it. Reading code or a list of directory structures, or the diagram showing code layout of modules give little insight to the overall workings of Blender. So if there is a diagram of Blenders design it would be grateful if anyone could help me as I have never, despite many attempts to found one, and would suggest that such a diagram be included in the documentation.

Sorry for the long post, it went much longer than I had planned it to be.

Regards

Blender really isn’t really like an ECS at all. It’s mostly just C-style object oriented. DNA is basically almost all of blender’s internal structures implemented in a subset of C89 which is parsed at compile time to generate info for writing/reading blend files. RNA binds Python and the animation system to DNA. The blender kernel (BKE) is where a lot of core functionality is implemented often working on DNA structures (constructors, utilities, etc). An ECS is basically a system in which entities are just handles to key into a data structure of components. Blender’s object system doesn’t really do this that. Objects are structures, not keys, structures will own pointers to other structures or point to a data block which is managed by garbage collection. Hopefully this clears up any confusion.

4 Likes

Thanks astrand. That certainly clears things up a lot. This description of what RNA, DNA are and how the blender kernal is connected to DNA helps a lot to understanding what these are and how they fit in with the design of Blender. Thank you.

I have decided that Blender is too much for me to handle and that with this information, the desire of adding the procedural object I have created probably cannot be done anyway. But as Blender has already some procedural functionality and reading on some future features, I may be replicating some of the things that are or have been done anyway.

Regards

You said you want to add a procedural object? If you can’t create it with the existing tools and you need more speed than a python script you can always make a custom build with a modifier for your specific purpose. It should be a relatively small modification.