Closed Eragonfr closed 4 years ago
Hello. rg3d is not ECS-based engine, it is "classic" game engine with objects and methods. However it uses some optimizations for efficient memory layout such as pools as it would be in ECS-engine. Engine uses composition to build complex data structures. For example lets take a look at scene graph and its nodes. rg3d has Base node which contains all info needed for simplest node - local and global transform, visibility properties, name, etc. "Derived" nodes (Mesh, Light, etc) contains Base
node as field inside of self, so they have all functionality of Base
node. To be able to store nodes of different types rg3d uses Node enumeration which contains all possible scene graph nodes. All nodes also implements Deref trait to access Base part of each node, this is a bit "hackish" but simple way to obtain reference to inner Base part.
Such design is easy to understand, but it can be slower than ECS approach when you need millions of objects. I'm saying can be slower - because you never know until you use profiler. Also such design is borrow checker-friendly, you can access things only from top-to-bottom in hierarchy. If you need to do something from bottom-to-top you can use messages, you probably saw them in rusty-shooter (one, two). The idea can be easily explained on a simple example - a weapon fires a rocket. All you need to do is to post a message CreateProjectile(params) and "systems" in various places of your game can handle this message, for example level can create a rocket and start handing its movement\collision\etc. In this approach you don't need direct access to level to create rocket, you just telling level "I need you to create a rocket with these params".
I'm using simple technique to understand what I need from the engine and what should be in the engine - I'm writing a game using it. So you can start writing your own game (using some of exisiting examples, or from scratch), once you found that some part is missing\bugged you can make an issue here and ask some questions, I'll help you to understand parts of engine so you can start adding new feature or fixing something. Of course there a lots of missing features:
I prefer not to implement feature until I need it, I can spend my time on something that I need for my game, making abstract game engine is always a bad idea.
Thanks for the explanations, as i understand, it's better for now to not use an ECS.
I totally understand the design choice, it's simpler to understand a non-ecs system than an ecs system.
I'm going to implement my own game based on that, but the most missing part for now is the ability to change the level of detail, because my computer is old(the cpu is an intel i5 from the second gen…) and don't have a graphic card(it use the integrated chipset from my cpu), so it's the part that i want to implement first, maybe, before starting to implement my own game.
You should try to reduce quality settings first, there are some heavy graphical effects:
LODs are not hard to implement in general, what you need to do is to make an array of sets with surfaces out of this. Also current LOD index should be stored nearby. In renderer then you can switch surface for rendering based on distance to camera. To fill LODs into your mesh you can use standard instantiate method. However there are some stuff that should be take into account - animation and serialization. Skeletal animation binds bones to mesh so bones can affect shape of mesh, I suspect in case of LODed mesh you should only take geometry, but leave bones from existing model, so there won't be duplicated bones per LOD. Serialization should be easy, just save array of surface sets and current LOD index. But again, there can be some issues while implementing this. I'd say it is not easy task.
I'm going to try that. I'm not promise any results but i want to try.
I'm sorry i don't know where i can ask my questions about how the engine work and other related things…
I'v look at rusty-shooter code and, I don't find any ECS related stuff, do you think It is possible to use and ECS like legion or specs(or anything else) and this game engine ?
I have another question, I want to use this game engine, I know it is not enough mature to be used in a real production, and that's exactly why i want to use it. I want to participate to this engine. Where should i start to help ?