r/EntityComponentSystem • u/ajmmertens • Sep 01 '20
r/EntityComponentSystem • u/mlange-42 • Mar 31 '23
Arche 0.6 released -- fastes Entity Component System (ECS) for Go?
What is Arche?
Arche is an archetype-based Entity Component System (ECS) for Go: https://github.com/mlange-42/arche
Features
No systems. Just queries. Use your own structure.
No dependencies. Except for unit tests (100% coverage).
Probably the fastest Go ECS out there. See the Benchmarks.
Release highlights
Batch creation and deletion of entities, with up to 4x and 10x speedup, respectively. Even more when combined with
World.Reset().Cached filters for handling many archetypes and complex queries without slowdown.
A lot of internal performance optimizations.
See the GitHub release for the full list of changes.
Feedback?
Your feedback is highly appreciated!
Further, I would be interested in finding more serious Go ECS implementations for performance comparison. check out the Benchmarks, and feel challenged!
I am also very interested in your opinion on how the benchmarks compare to ECS implementations in other languages, especially C++ and Rust.
r/EntityComponentSystem • u/thejaguar83 • Oct 11 '22
How do I go about diagramming for an ECS framework before implementing?
I'm just starting out in working with ECS (using flecs in C++). One issue I'm running into early is deciding and documenting what components do, how they are used and how they are related. I looked at using Draw.io UML, but I can't quite figure out how to properly represent everything diagrammatically.
The project is a card game. Here's a few of the components I've got that I want to document or am trying to design:
Every card has 1 or more colours. I have a component for each colour and each colour component inherits from the base of "Colour":
e.g.:world.use<Red>("colour_red").is_a<Colour>()Cards are assigned to "containers" (e.g. Deck, Hand) and can only be in one of those:
e.g.:world.component<ContainedIn>().add(flecs::OneOf, world.component<Container>())A card can have a cost.
A card can be played on top of another one for a cost, given certain requirements (actually loaded from data, but simplified here):
auto played_on = world.entity();played_on.set<Cost>({ 2 }); auto requirements = world.entity(); requirements.add<Red>(); requirements.set<Level>({ 3 }); played_on.add<Requirements>(requirements); card.add<CanBePlayedOn>(played_on);
Cards can be modified be effects. I plan to model this by having every card inherit from a base description of the card, then have modifier relationships that store the changes with the final value overriding the base card. (No code yet)
I need to model cards that are under other cards retaining the order. (No info yet)
As you can see, I have some things worked out, others in planning and the rest yet-to-be-determined. These last two categories are why I need to diagram it, so that I can work out and document how everything is designed so that when I go to write all of the systems, I already have an idea of how they should be interacting with the components.
Have others already done this kind of thing documentation/diagramming? If so, how did you do it? What tools work best for this kind of thing? Is there any formal way of diagramming or documenting this?
r/EntityComponentSystem • u/GasimGasimzada • Aug 06 '22
How to handle parent-child relations in a cache friendly ECS?
I keep coming back to this issue over and over again. I would like to know what’s the right way to handle parent-child relationship in a cache friendly ECS? I currently have two components: Parent and Children. Whenever a relationship needs to be created, both of these components are created. The reason for it is that, depending on usage, I need to use one or the other. This adds its own slew of complexities due to needing to synchronize these components for write operations.
However, for me personally, this method of providing both the parent and the children is a patch over the fundamental problem that I keep having with using hierarchial relationship in a cache friendly data structure (i.e dynamic arrays). From my experience in implementing Skeleton animation, I know that if the data is sorted from parent to children, it is sufficient for me to store Parent component, which will solve all the problems that I face with relations. This is easy to do in a skeletal animation because I know the joints of each skeleton beforehand and I can sort it once and use it in an optimized way. On the other hand, I cannot do the same for scene hierarchy where nodes can be deleted, added, or moved as a child of another node at any point.
What are some of the techniques that I can use to sort the data in-place while expecting a lot of updates? At the moment, the only thing that comes to mind is to create something similar to what database systems do and create a key/index that creates a specific data structure, whose entire purpose is to keep sorted list of entity indices. Are there other methods that I can utilize for handling relations in an efficient and also intuitive way.
r/EntityComponentSystem • u/timschwartz • Jun 15 '22
Any such thing as an entity component system cookbook?
self.gamedevr/EntityComponentSystem • u/jumpixel • Feb 01 '22
Dominion, an attempt to implement a fast ECS by design
A few months ago, I started looking for a fast ECS for Java and found ECS related benchmarks for C / C++ and Rust.
So I was amazed at how fast an ECS can be in a system language like C / C++ and started thinking about how fun and challenging it would be to start writing an ECS for Java with comparable performance. And here we are.
Dominion is still in its early stages but has already started running at a very high speed, fast by design. It's still far from a complete ECS solution, but I've already implemented the API to create/delete Entities with Components, find them and iterate. I've also posted some benchmarks related only to what I've achieved so far (so on the speed of creating, deleting, and iterating Entities), and I think it looks very promising.
Happy to receive suggestions and to know your first impressions.
r/EntityComponentSystem • u/skypjack • Jun 12 '21
ECS Back and Forth, part 11: the Big Matrix revised
r/EntityComponentSystem • u/skypjack • Feb 28 '21
ECS back and forth Part 10 - Hybrid storage
r/EntityComponentSystem • u/ajmmertens • Feb 21 '21
ECS: From Tool to Paradigm
r/EntityComponentSystem • u/sebasjammer • Jan 07 '21
OOP abstraction layer in an ECS-centric application
Hello,
I am not going just to post the link because I am new here and it's correct to introduce myself. I am the author of Svelto.ECS and glad that this reddit exists. This is my new article:
https://www.sebaslab.com/oop-abstraction-layer-in-a-ecs-centric-application/
r/EntityComponentSystem • u/skypjack • Aug 31 '20
EnTT v3.5.0 is out: Gaming meets Modern C++
self.gamedevr/EntityComponentSystem • u/ajmmertens • Aug 11 '20
Why Storing State Machines in ECS is a bad idea.
r/EntityComponentSystem • u/ajmmertens • Aug 03 '20
Flecs 2.0, an Entity Component System for C and C++ is out!
r/EntityComponentSystem • u/ajmmertens • May 07 '20
Web-based introspection of Entity Component System
r/EntityComponentSystem • u/ajmmertens • Aug 25 '19
Just released v1.0 of Flecs, an Entity Component System for C99!
Link to project: https://github.com/SanderMertens/flecs
Flecs is an Entity Component System designed from scratch in C99. It has (roughly) the same architecture as Unity DOTS, but with a few fun twists! Besides from being a super fast ECS implementation, Flecs has:
Entity hierarchies
Component sharing
Expressive system queries with lots of operators and features to subscribe for entities
Group systems with Flecs features
A web dashboard
Multithreading
... and much, much more
A few links to older reddit posts with Flecs examples:
https://www.reddit.com/r/gamedev/comments/afor8v/nbody_simulation_written_in_pure_ecs_entity/ https://www.reddit.com/r/gamedev/comments/aiymwl/pure_ecs_collision_detection_demo_in_under_70/ https://www.reddit.com/r/gamedev/comments/ce926i/a_quick_overview_of_how_i_implemented_inheritance/
r/EntityComponentSystem • u/Crystallo07 • Nov 23 '25
What would you think about hybrid ECS architectures?
There are pros and cons to both sparse-set and archetype architectures. I'd like to parallelize components while also being able to easily add and remove them. So my current idea is to use archetypes for components that rarely change, such as render, transform, etc. and store more dynamic or situational components in sparse sets. Also, this is not meant to be a general-purpose ECS library; only we are going to use it, so I’ve set some strict rules for its design.
Archetypes would be easy to parallelize because they share the same index across component arrays and also have some advantage on accessing multiple components.
Sparse-set is very good at adding and removing components and iterating single component.
However, I’m concerned that when iterating a single dense array, accessing a component from an archetype might become too complex or the other way around.
What do you think about this architecture? What pros and cons should I expect?
Do you know of any example implementations that use a similar hybrid approach?
r/EntityComponentSystem • u/zklegksy • Apr 23 '23
I've written an ECS library in Rust.
Hey there. Over the last few days I've written sweets my own ECS library. I'm currently using it to power the world of my software ray tracer treat which is very early in development, and I'm still learning all the basics of computer graphics. Nevertheless, I'd love to get some feedback for my ECS implementation :)
The Structure of sweets:An entity is a struct containing two u32 bit numbers. These two numbers combined make up the entity. The first number is the index of the entity and the second one the generation. Each time an entity gets deleted, its index will be saved inside a free_indices vec inside the entity manager. This allows me to reuse old entities. To still make them unique from other entities with the same index, i have the generation. Each time I delete the entity, I increase the generation. In order to check if the entity is alive, I can compare the generation of the entity and the stored generation at the entity index of the generation vec inside the entity manager. All this is managed inside the EntityManager struct.
A Component can be any struct implementing default. Each component will get a unique Index ranging from 10to the amount of components. My first idea was to use a static counter, that each component will take as its Index and increment by one, but it either didn't increment it or did each time and not only once. Thus, I adopted to using a has map indexed by the TypeId rust assigns each Component. The Index will be used, to index a Vec of ComponentPools to get the right Pool for the component. A ComponentPool saves the component data for each entity having a component of this type. When a Component is deleted if will be released into the Pool to be reused later. With the index, a ComponentId can also be created. Its just a one moved by the index to the left (1 << index). This way only one bit will be flipped in each ComponentId. Combining them by bitwise | I get a unique identifier for the needed components.
This identifier of all components an entity might have is stored by the ComponentManager.
Limitations:I can only have 64 different Components currently. If I'd use an u128 this number would double, but some may still consider it really limited.
I hope my explanation paired with the source code can guide you through the implementation, if not feel free to ask, I'm open to any feedback, ideas, or questions :)
r/EntityComponentSystem • u/ajmmertens • Dec 15 '22
I built a web-based component editor for an Entity Component System
r/EntityComponentSystem • u/sebasjammer • Sep 20 '22
10 years worth of articles on Inversion of Control and ECS
self.gamedevr/EntityComponentSystem • u/sephirothbahamut • Apr 25 '22
Transform as component, or split?
Hi,
I started getting interpolation and hierarchies in my 2d engine. I wanted to do something that only unreal does, in that children's transform may or may not consider the parent, it's a free choice. (you can have an attached object use relative position and world rotation for example).
Thus in an ecs, if a child uses an absolute "component" of the transform, that part of the transform doesn't even need to know this entity is a child of something in the hierarchy. So I thought about splitting the Transform into 3 parts (translation, rotation, scaling)
Then for each of them i'id have: (the x/x_end pair is used for interpolation)
// Components:
speed //any
relative //children
relative_end //children
absolute //everyone
absolute_end //everyone
// Systems each game step
view of relative, speed, relative_end
{ relative = relative_end; relative_end = relative + speed; }
view of absolute, speed, absolute_end; exclude any with relative
{ absolute = absolute_end; absolute_end = absolute + speed; }
view of relative, absolute, parent
{ absolute = relative + parent; }
view of relative_end, absolute_end, parent
{ absolute_end = relative_end + parent; }Does it make sense to do this kind of split, or it's too fine?
The alternative (and my current method) would be to simply have whole transform components, updating them as a whole, and for the previously mentioned opt-in unusual behaviour of ignoring the parent, i'd have just some flags based on which the parent value is added or not.
The former seems more efficient, the latter seems more intuitive.
Any thoughts? Anyone else split his transform and has opinions about that?
r/EntityComponentSystem • u/sephirothbahamut • Mar 23 '22
Adding ECS to Inheritance based engine trying to make an hybrid, ECS not much better, what am I doing wrong?
self.gameenginedevsr/EntityComponentSystem • u/ajmmertens • Dec 13 '20
Entity Component System FAQ
r/EntityComponentSystem • u/[deleted] • Nov 23 '20
Objects with multiple sprites / drawables
Language: C++, I also use SFMLHello everyone, I've been tackling with a problem for a while. I created an ECS and I want to draw entities with many sprites but I have no idea how to do it.
Such entity could be for example a "Game Paused Box" that appears when player pauses the game. It contains a few buttons with text or sprites.
Or a playable character entity, which has body parts. The player's arms could be carrying a gun or some other weapon while the legs would be running at the same time.
The problem is ...
> should I create one object that has a few components of the same type (sprite/text) (which currently isn't possible with my ECS),
> a multiple drawable component that stores sprites and texts + manges their drawing order
> or one main object containing pointers to few sub objects with own sprite components?
Well, I did see people making sprite components, but never saw anyone making a multiple drawable component so i wonder how do their projects manage objects with more than one drawable...
I hope, I explained that clear enough.Edit:Maybe the picture can help:https://i.imgur.com/3cZoGPn.png
r/EntityComponentSystem • u/ajmmertens • Jul 09 '20