Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 5, 2026·3 min de lecture

EnTT — Fast Entity Component System for Modern C++

A header-only C++17 library providing a cache-friendly entity-component-system, event dispatcher, and service locator for game engines and simulations.

Introduction

EnTT is a header-only C++17 library that implements the entity-component-system (ECS) pattern with a focus on cache efficiency and compile-time performance. It is used in commercial game engines and AAA titles where data-oriented design and minimal overhead are critical.

What EnTT Does

  • Manages entities as lightweight integer IDs with O(1) creation and destruction
  • Stores components in tightly packed arrays for cache-friendly iteration
  • Provides views and groups that iterate over component sets without allocation
  • Includes a signal/event dispatcher for decoupled communication
  • Offers type-erased containers, resource handles, and a service locator

Architecture Overview

EnTT uses sparse sets as its core data structure. Each component type is stored in a dedicated sparse set, which maps entity IDs to densely packed component arrays. Views combine multiple sparse sets at query time with minimal overhead. The library avoids virtual dispatch and dynamic allocation on the hot path, relying on templates and compile-time polymorphism.

Self-Hosting & Configuration

  • Header-only: copy the single_include/entt directory into your project
  • Also available via CMake FetchContent, Conan, vcpkg, or Homebrew
  • Requires a C++17-compliant compiler (GCC 7+, Clang 7+, MSVC 2017+)
  • Configure entity ID size and other options via preprocessor defines
  • No external dependencies; the library is fully self-contained

Key Features

  • Cache-friendly sparse-set storage for high iteration throughput
  • Compile-time type safety with zero-cost abstractions
  • Groups provide sorted, precomputed component layouts for frequent queries
  • Signals and event dispatcher built in for observer patterns
  • Used in production by Mojang (Minecraft Bedrock Edition) and other studios

Comparison with Similar Tools

  • flecs — C/C++ ECS with a runtime query language; EnTT is header-only and compile-time typed
  • Bevy ECS — Rust-native ECS; EnTT targets the C++ ecosystem
  • Unity DOTS — Proprietary ECS within Unity; EnTT is standalone and engine-agnostic
  • entityx — Older C++ ECS; EnTT offers better performance and more features
  • Entitas — C# ECS for Unity; EnTT is C++ and not tied to any editor

FAQ

Q: Is EnTT only for games? A: No. While designed with games in mind, it works well for simulations, UI frameworks, and any application that benefits from data-oriented design.

Q: Does EnTT support multithreading? A: The registry is not thread-safe by default, but views and groups can be iterated in parallel if components are not modified concurrently. Users typically partition work across threads.

Q: How does EnTT compare in performance to ECS alternatives? A: Benchmarks consistently show EnTT among the fastest C++ ECS implementations, particularly for iteration-heavy workloads due to its sparse-set storage.

Q: Can I use EnTT with an existing engine? A: Yes. It is engine-agnostic and integrates easily as a header-only dependency. Several engines including Godot forks and custom engines use EnTT internally.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires