Flecs 3.1 is out!
What is Flecs?
Flecs is an Entity Component System (FAQ) for C and C++ that helps with building games, simulations and more. The core features of Flecs are:
- Store data for millions of entities in data structures optimized for CPU cache efficiency and composition-first design
- Find entities for game systems with a high performance query engine that can run in time critical game loops
- Run code using a multithreaded scheduler that seamlessly combines game systems from reusable modules
- Builtin support for hierarchies, prefabs and more with entity relationships which speed up game code and reduce boiler plate
- An ecosystem of tools to profile, visualize, document and debug projects
Flecs is fully open source and licensed under the MIT license. Check out the Github repository here:
Link to the v3.1 release:
Who is using Flecs?
Flecs is used in a wide range of projects, from small web-based games to RPGs to sprawling universe simulators. Projects are built with existing engines like Unreal, Godot and Unity, as well as brand new engines that use Vulkan, OpenGL, bgfx, sokol and SDL. Some projects aren’t games at all, and use Flecs as a fast in-memory database.
A lot of cool projects are currently in development, like the Equilibrium engine that has just been made open source:
Equilibrium is a 3D data-oriented and multi-threaded C11 game engine built with Flecs and bgfx. It has features like hot reloading of libraries and shader code, forward and deferred shading, PBR and HDR tone mapping and much more!
Another neat thing to check out is this Flecs project, now ported to Unreal 5, where 12.000 spaceships are duking it out in a massive battle:
Release Highlights
Here is a summary of the biggest changes since the v3.0 release:
- Query Groups. Query groups (example) are a feature that let you group entities/tables, for example based on where they are in the world. Groups are cheap to use, so apps can make fast decisions for lots of entities, like whether a group should be rendered. This enables massive worlds where a game is only doing work where needed, like in this scene with more than 1 million entities (renderer source):
- Command batching. The new command batching feature significantly reduces how often components are moved around in memory. Without command batching, each time you add or remove a component all components for an entity are moved to another table. With command batching, multiple add/remove operations are combined into a single table move operation, which can speed up apps by a lot!
- Faster change detection. The change detection feature is now faster to use than ever, with a new query function (
ecs_query_next_table
) that just iterates tables in the query cache. This significantly reduces overhead of skipping tables for which nothing has changed, and can make a big difference in apps with lots of tables (example usage). - Improved Entity DSL. The entity DSL is a text-based format that lets you describe things like assets, scenes and configuration for your games. In Flecs v3.1 the DSL got a bunch of new features, like support for multiline strings, variables and simple arithmetic expressions:
- Vscode extension. The entity DSL code now looks a lot better with the new vscode extension! To install it, search for “flecs” in the vscode extension browser, or go through the Visual Studio Marketplace.
- Custom allocators. Most of Flecs internals now use custom thread-specific allocators, which reduces the number of heap allocations by a lot. This measurably improves performance, as custom allocations can be as much as 60x faster than OS allocations.
- Improved statistics. Flecs now tracks a lot more statistics that tell you exactly what is happening under the hood. The explorer also got a new statistics page which makes better usage of screen space, and shows a description for each statistic:
- World cell partitioning. A new feature has been added to the flecs-game module in Flecs hub that can automatically partition a world. This code can be plugged in directly into projects, or used as example code.
- Group based rendering. The geometry part of the flecs-systems-sokol module in Flecs hub has been rewritten to take advantage of query groups. The module now uses groups for broad-phase visibility tests and change detection.
That’s all folks! If you’d like to try out Flecs, check out the GitHub repository and consider giving it a ⭐️!
If you have any questions, suggestions or projects you’d like to share with others, join the Flecs Discord: