Skip to content

does registry.any_of<...> cause any mayor overhead? #1156

Answered by skypjack
rudiHammad asked this question in Q&A
Discussion options

You must be logged in to vote

Why not three loops then? It's much faster then iterating all entities with a cascade of ifs. I mean something like this:

void update(float delta, entt::registry& registry) {
    for(auto [entt, elem]: registry.view<LinearComponent>().each()) {
        // process linear movement
    }

    for(auto [entt, elem]: registry.view<ParabolicComponent>().each()) {
        // process parabolic movement
    }

    for(auto [entt, elem]: registry.view<CurveComponent>().each()) {
        // process curve (or what ever) movement
    }
}

Or even three different systems. I don't get why you should iterate all entities and check if they have the right component. Views already do it for you in a sense.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@rudiHammad
Comment options

@skypjack
Comment options

@rudiHammad
Comment options

@skypjack
Comment options

Answer selected by rudiHammad
@rudiHammad
Comment options

@skypjack
Comment options

@rudiHammad
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question open question
2 participants