All Projects → SanderMertens → Flecs

SanderMertens / Flecs

Licence: mit
A fast entity component system (ECS) for C & C++

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to Flecs

Entt
Gaming meets modern C++ - a fast and reliable entity component system (ECS) and much more
Stars: ✭ 6,017 (+173.38%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system, data-oriented-design, ecs-framework
Defaultecs
Entity Component System framework aiming for syntax and usage simplicity with maximum performance for game development.
Stars: ✭ 286 (-87.01%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system
Shipyard
Entity Component System focused on usability and speed.
Stars: ✭ 247 (-88.78%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system
Entitas Csharp
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
Stars: ✭ 5,393 (+145.02%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system
Entitas Sync Framework
Networking framework for Entitas ECS. Targeted at turnbased games or other slow-paced genres.
Stars: ✭ 98 (-95.55%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system
Godex
Godex is a Godot Engine ECS library.
Stars: ✭ 307 (-86.05%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system
Uecs
Ubpa Entity-Component-System (U ECS) in Unity3D-style
Stars: ✭ 174 (-92.09%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system
Entitas Cpp
Entitas++ is a fast Entity Component System (ECS) C++11 port of Entitas C#
Stars: ✭ 229 (-89.6%)
Mutual labels:  ecs, game-development, gamedev, entity-component-system
apecs
A petite entity component system
Stars: ✭ 17 (-99.23%)
Mutual labels:  data-oriented-design, ecs, entity-component-system, ecs-framework
polymorph
A fast and frugal entity-component-system library with a focus on code generation and compile time optimisation.
Stars: ✭ 74 (-96.64%)
Mutual labels:  gamedev, data-oriented-design, ecs, entity-component-system
Gdk For Unity
SpatialOS GDK for Unity
Stars: ✭ 296 (-86.55%)
Mutual labels:  ecs, game-development, entity-component-system
Etengine
Realtime 3D Game-Engine with a focus on space sim. Written in C++ 14
Stars: ✭ 408 (-81.46%)
Mutual labels:  ecs, game-development, entity-component-system
Kengine
Entity-Component-System (ECS) with a focus on ease-of-use, runtime extensibility and compile-time type safety and clarity.
Stars: ✭ 417 (-81.05%)
Mutual labels:  ecs, game-development, entity-component-system
Anything about game
A wonderful list of Game Development resources.
Stars: ✭ 541 (-75.42%)
Mutual labels:  ecs, game-development, gamedev
Edyn
Edyn is a real-time physics engine organized as an ECS.
Stars: ✭ 113 (-94.87%)
Mutual labels:  ecs, game-development, entity-component-system
UnityDOTS-Thesis
Bachelor's degree thesis on Unity DOTS architecture
Stars: ✭ 14 (-99.36%)
Mutual labels:  data-oriented-design, ecs, entity-component-system
js13k-ecs
A 1kb entity component system, designed for Js13kGames
Stars: ✭ 76 (-96.55%)
Mutual labels:  gamedev, ecs, entity-component-system
Svelto.ecs
Svelto ECS C# Lightweight Data Oriented Entity Component System Framework
Stars: ✭ 605 (-72.51%)
Mutual labels:  ecs, game-development, entity-component-system
Ecs
LeoECS is a fast Entity Component System (ECS) Framework powered by C# with optional integration to Unity
Stars: ✭ 578 (-73.74%)
Mutual labels:  ecs, game-development, entity-component-system
Ecs
A simple and easy to use entity-component-system C++ library
Stars: ✭ 20 (-99.09%)
Mutual labels:  ecs, game-development, entity-component-system

flecs

CI build codecov Discord Chat Try online Documentation

Flecs is a fast and lightweight Entity Component System that lets you build games and simulations with millions of entities (join the Discord!). Here are some of the framework's highlights:

  • Fast native C99 API that can be used with most game engines and scripting languages
  • Modern type-safe C++11 API that doesn't rely on STL types
  • Entire framework builds in less than 5 seconds.
  • Cache friendly archetype/SoA storage that can process millions of entities every frame
  • Automatic component registration that works out of the box across shared libraries/DLLs
  • Run games on multiple CPU cores with a fast lockless scheduler and command queue
  • First open source ECS with full support for entity relationships!
  • Compiles warning-free on 8 compilers on all major platforms, with CI running more than 3000 tests
  • No need to reinvent the wheel with fast native hierarchy, prefab and reflection implementations
  • A web-based dashboard (click to try!) for exploring entities, running queries & learning Flecs:

Screen Shot 2021-11-07 at 10 20 51 PM

You're looking at Flecs v3! While v3 stability is good, API changes can still happen.

Last stable v2 release: Flecs v2.4.8.

What is an Entity Component System?

ECS is a new way of organizing code and gameplay data that lets you build game worlds that are larger, more complex and are easier to extend. ECS is different in how it dynamically binds simulation logic ('systems') with game data ('components').

Something is typically called an ECS when it:

  • Has entities, that uniquely identify objects in a game
  • Has components, which are datatypes that can be added to entities
  • Has systems which are functions that run for all entities matching a component query

A simple example of this would be a game with two components, Position and Velocity, and a Move system that finds all entities with both components, and adds Velocity to Position.

For more info on ECS, check the ECS FAQ!

Getting Started

Here is some awesome content provided by the community ❤️ :

Show me the code!

C99 example:

typedef struct {
  float x, y;
} Position, Velocity;

void Move(ecs_iter_t *it) {
  Position *p = ecs_term(it, Position, 1);
  Velocity *v = ecs_term(it, Velocity, 2);
  
  for (int i = 0; i < it->count; i ++) {
    p[i].x += v[i].x;
    p[i].y += v[i].y;
  }
}

int main(int argc, char *argv[]) {
  ecs_world_t *ecs = ecs_init();

  ECS_COMPONENT(ecs, Position);
  ECS_COMPONENT(ecs, Velocity);

  ECS_SYSTEM(ecs, Move, EcsOnUpdate, Position, Velocity);

  ecs_entity_t e = ecs_new_id(ecs);
  ecs_set(ecs, e, Position, {10, 20});
  ecs_set(ecs, e, Velocity, {1, 2});

  while (ecs_progress(ecs, 0)) { }
}

Same example in C++11:

struct Position {
  float x, y;
};

struct Velocity {
  float x, y;
};

int main(int argc, char *argv[]) {
  flecs::world ecs;

  ecs.system<Position, const Velocity>()
    .each([](Position& p, const Velocity& v) {
      p.x += v.x;
      p.y += v.y;
    });

  auto e = ecs.entity()
    .set([](Position& p, Velocity& v) {
      p = {10, 20};
      v = {1, 2};
    });
    
  while (ecs.progress()) { }
}

Addons

Flecs has a modular architecture that makes it easy to only build the features you really need. By default all addons are built. To customize a build, first define FLECS_CUSTOM_BUILD, then add defines for the addons you need. For example:

#define FLECS_CUSTOM_BUILD  // Don't build all addons
#define FLECS_SYSTEM        // Build FLECS_SYSTEM

Here's an overview of all supported addons:

Addon Description Define
Cpp C++11 API FLECS_CPP
Module Organize game logic into reusable modules FLECS_MODULE
System Create & run systems FLECS_SYSTEM
Pipeline Automatically schedule & multithread systems FLECS_PIPELINE
Timer Run systems at time intervals or at a rate FLECS_TIMER
Meta Flecs reflection system FLECS_META
Meta_C (C) Utilities for auto-inserting reflection data FLECS_META_C
Expr String format optimized for ECS data FLECS_EXPR
JSON JSON format FLECS_JSON
Doc Add documentation to components, systems & more FLECS_DOC
Coredoc Documentation for builtin components & modules FLECS_COREDOC
Http Tiny HTTP server for processing simple requests FLECS_HTTP
Rest REST API for showing entities in the browser FLECS_REST
Parser Create entities & queries from strings FLECS_PARSER
Plecs Small utility language for asset/scene loading FLECS_PLECS
Rules Powerful prolog-like query language FLECS_RULES
Snapshot Take snapshots of the world & restore them FLECS_SNAPSHOT
Stats See what's happening in a world with statistics FLECS_STATS
Log Extended tracing and error logging FLECS_LOG
App Flecs application framework FLECS_APP
OS API Impl Default OS API implementation for Posix/Win32 FLECS_OS_API_IMPL

Flecs Hub

Flecs Hub is a handy collection of repositories built with Flecs that showcase basic ways of how to build engine features like input handling, transformations and rendering:

Module Description
flecs.components.cglm Component registration for cglm (math) types
flecs.components.input Components that describe keyboard and mouse input
flecs.components.transform Components that describe position, rotation and scale
flecs.components.physics Components that describe physics and movement
flecs.components.geometry Components that describe geometry
flecs.components.graphics Components used for computer graphics
flecs.components.gui Components used to describe GUI components
flecs.systems.transform Hierarchical transforms for scene graphs
flecs.systems.physics Systems for moving objects and collision detection
flecs.systems.sdl2 SDL window creation & input management
flecs.systems.sokol Sokol-based renderer

Language bindings

The following language bindings have been developed with Flecs! Note that these are projects built and maintained by helpful community members, and may not always be up to date with the latest commit from master!

Links

Supporting Flecs ♥️

Supporting Flecs goes a long way towards keeping the project going and the community alive! If you like the project, consider:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].