ecs: third major redesign/rethink of implementation #185
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the past:
Our second revision of the ECS, however, still had archetypes exposed as a public-facing user concern. When a new component was added to an entity, say a weapon, the table storing entities of that archetype changed to effectively have a new column
?Weaponwith a null value for all existing entities of that archetype. We can say that our ECS had archetypes as a user-facing concern AND this made performance worse: when iterating all entities with a weapon, we needed to check if the component value wasnullor not because every column was?Weaponinstead of a guaranteed non-null value likeWeapon. This was a key learning that I got from discussing ECS tradeoffs with the Bevy team.This third revision of our ECS has some big benefits:
nullor not.Some examples of how the API looks today:
mach/ecs/src/main.zig
Lines 49 to 87 in 9792401
mach/ecs/src/entities.zig
Lines 625 to 656 in 9792401
Much more work to do, I will do a blog post detailing this step-by-step first though.
Signed-off-by: Stephen Gutekanst [email protected]