
Custom Entity-Component System
Rendering System using SDL3's rendering API
Particle System
Parent-Child Transformations
WHAT I WORKED ON
Language:
C++
Framework:
SDL3
Build System:
CMake
Entity-Component System - WIP
I was really interested in Data-Oriented Programming and Entity-Component Systems, so I wanted to give creating one a shot.
I used many references online such as EnTT and flecs to understand how the "API" surrounding an ECS should work.
For building sparse sets and the ECS itself from scratch, I mostly referred to skypjack's ECS back and forth series:
OVERVIEW
My Sparse Set class has a sparse entity array, dense entity array, and dense component array.
If N was the max number of entities my scene was going to allow for, my sparse entity array would start out with a size of N, and I would reserve N space for my dense arrays.
I have functions for adding and removing components, as well as getters for each of my arrays.
My ECS Manager contains querying functions for groups of components, examples of which will be shown in the systems section.
The Sparse Sets can definitely be improved, as they function as a simple naive lookup in the sparse arrays. I have researched techniques such as pagination that could be used to improve sparse lookups, and I plan to implement that in the future.
SPARSE SETS
(C++) Sparse Set
My Transform Components contain local and world positions, rotations and scales, as well as Up and Right vectors. They also hold a parent entity ID which shows whether it is parented to another transform or not.
Currently, it also has an "Owner" GameObject pointer, which I use only for debugging purposes.
For the system code, I use a lambda function which is passed to a ForEach function in my ECS Manager, which fetches the corresponding components needed by the system.
RENDERING SYSTEM
(C++) Rendering System
Since I am making Asteroids, I thought that while I am making an ECS, why not make a particle system as well since we are controlling a rocket with thrusters.
So I put together a simple and functional particle system with adjustable particle amount, lifetime, speed and randomness.
PARTICLE SYSTEM
(C++) Particle System