Entity Component System

The entity component system has been created specifically for the engine, aiming for a fast and cache-friendly approach.

The entities are the objects in the scene, internally stored as unique IDs. These IDs are used to find a mapping between entities and components. A component is a simple structure which is usually defined as a struct with various data fields. The entities and the components are managed by a coordinator, which keeps track of all the component arrays (storage for the component data) and the bidirectional mapping between entities and their components.

Within the coordinator, there is a system manager which controls multiple systems. A system is a construct that has access to entities that have a specific set of components, through a binary signature. The signature of an entity represents which components it contains. This signature is used to retrieve the entities that have at least the components required by the system. The cache optimization consists of storing the components in contiguous memory such that when iterating over entities from a system, components from consecutive entities will be close in memory, with a high chance of being retrieved in the same cache line.

The entity component system is the core organizational component of the engine, and thus, the engine's performance is enhanced by its optimizations.