Add support for x2 archetypes i a single system. #2

Closed
opened 2026-05-06 21:21:43 +00:00 by larssonmartin1998 · 1 comment

Since the systems dont get the entire range of entities as a parameter, it's difficult to do any comparisons to other entities within that archetype. For instance, a collision detection system which would need to compare all transforms against all other transforms.

In order to keep our nice API which also enables chunking from Taskflow without off loading that to the game creation space, we need to add the ability for a system to request more than one tuple of components, i.e:

hephaestus.create_system([](const IEngine& engine, std::tuple<const Transform&> archetype1, std::tuple<const Transform&> archetype2){
    // Some comparison code
});

This would ideally be called like this from the system (not accounting for chunking of parallel workflow just visualising):

for (auto& [component] : components) {
    for (auto& [other] : components) {
        if (component == other) continue;
        system_callback(engine, component, other);
    }
}

This will allow for the same nice API and scheduling while still enabling more complex systems. This should ALSO support different archetypes, meaning we could request tuples that have different components in it.

Since the systems dont get the entire range of entities as a parameter, it's difficult to do any comparisons to other entities within that archetype. For instance, a collision detection system which would need to compare all transforms against all other transforms. In order to keep our nice API which also enables chunking from Taskflow without off loading that to the game creation space, we need to add the ability for a system to request more than one tuple of components, i.e: ```cpp hephaestus.create_system([](const IEngine& engine, std::tuple<const Transform&> archetype1, std::tuple<const Transform&> archetype2){ // Some comparison code }); ``` This would ideally be called like this from the system (not accounting for chunking of parallel workflow just visualising): ```cpp for (auto& [component] : components) { for (auto& [other] : components) { if (component == other) continue; system_callback(engine, component, other); } } ``` This will allow for the same nice API and scheduling while still enabling more complex systems. This should ALSO support different archetypes, meaning we could request tuples that have different components in it.
Author
Owner

This is not a good idea.

Instead, add support for complex systems. A complex systems would take query/queries as parameter instead of component tuples. It would not batch entities and run the inner logic of the system in parallel. This system will still integrate with the system dependency graph and be executed in parallel against along side other safe systems.

Within these systems the user would be responsible for getting all data from the queries and iterating them themselves. Something like so:

// This lambda would still be executed in parallel, but the inner logic would not.
// This implementation leaves free control to the user to handle complex systems themselves instead of having to support multiple variations of systems with different component sets.
hephaestus.create_system([](const IEngine& engine, Query<const Transform&> q1, Query<const Health&, Velocity&>){
    for (auto& [transform] : q1) {
        for (auto& [health, velocity] : q2) {
            // Do something
        }
    }
});
This is not a good idea. Instead, add support for complex systems. A complex systems would take query/queries as parameter instead of component tuples. It would not batch entities and run the inner logic of the system in parallel. This system will still integrate with the system dependency graph and be executed in parallel against along side other safe systems. Within these systems the user would be responsible for getting all data from the queries and iterating them themselves. Something like so: ```cpp // This lambda would still be executed in parallel, but the inner logic would not. // This implementation leaves free control to the user to handle complex systems themselves instead of having to support multiple variations of systems with different component sets. hephaestus.create_system([](const IEngine& engine, Query<const Transform&> q1, Query<const Health&, Velocity&>){ for (auto& [transform] : q1) { for (auto& [health, velocity] : q2) { // Do something } } }); ```
larssonmartin1998 added reference feature/complex-systems 2026-05-10 15:15:29 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
larssonmartin1998/atlas#2
No description provided.