Synodic-Software / Soul-Engine

Physically based renderer and simulation engine for real-time applications.
GNU General Public License v3.0
42 stars 24 forks source link

Rework SparseSet #247

Closed Behemyth closed 5 years ago

Behemyth commented 6 years ago

SparseSet is a data structure only used with the Entity Component system. Quick synopsis: the ECS acts as a central store for all the objects for the engine. Entities are just integers that act as weak references. The SparseSet is the structure for holding all that data contiguously. It is totally implemented like garbage and I am ashamed of it. Instead of acting like a nice, cohesive data structure, it is implemented across four different classes (Core/Structures/... and Composition/Entity/SparseEntitySet/...). The ECS system makes use of special indexing that makes it hard to have a single data structure and then use that special indexing. I decided to do the worst possible thing at the time and inherit from the structure, requiring the Abstract variants of the class to maximally reuse code. The final resting place should be in Core/Structures/..., you should be proud of it, and it shouldn't be anything like the eyesore I made.