HomeBlog

Godot Turbo


Tags: C++, Godot, Flecs, Engine, Solo Project


Project Link

I made this module to have access to a fast, reliable ECS that could be integrated on a close level with Godot. I chose FLECS because of its rich feature set and performance. Godot had other options and alternatives for implementing a ECS. These solutions however did not satify my requirements of having a low-level, well-optimized ECS being statically linked to Godot. Static linking provides the opportunity to simplify porting to Consoles as dynamic linking is not permitted on those platforms.

Initially I created an implentation relying on extending the Godot Resource class as it provided a convenient way to write a reflection layer. This did not end up working due to the memory size and heap allocated nature of the underlying RefCounted and Object class. When creating or destroying a lot of instances at once memory would not be cleared quickly enough for it to add up. This caused the memory usage to spike above 40gbs.

I then scrapped most of the work done on the class structure and revised it to be a Godot Server, relying on resource ID's to allow GDScript users to access Flecs via the FlecsServer class.

I also experimented with making a system to individually cull Multimesh instances, but this proved to be too challenging. I could not find update the buffer on the GPU with computed frustum and occlusion culling results without having significant framerate issues.

To test if it would work, I made a system rendering Bad Apple as spaced grid of cubes managed through a multimesh instance.