Layer should extend from Entity #126

Open
opened 2016-04-06 22:39:02 +00:00 by adderly · 0 comments
adderly commented 2016-04-06 22:39:02 +00:00 (Migrated from github.com)

I see in a lot of places in the sources, sequential casting for Entity and Layer along with calling exact same methods in either case.
If Layer extends from Entity the overhead in the game loop will be reduced by almost half in evaluation time in each game/scene initialization or/and update.
A little code from scene.cpp:

    QQuickItem *item;
    foreach (item, parent->childItems()) {
        if (Entity *entity = qobject_cast<Entity *>(item))
            entity->update(delta);
        else if (Layer *layer = qobject_cast<Layer *>(item))
            layer->update(delta);
    }
I see in a lot of places in the sources, sequential casting for Entity and Layer along with calling exact same methods in either case. If Layer extends from Entity the overhead in the game loop will be reduced by almost half in evaluation time in each game/scene initialization or/and update. A little code from scene.cpp: ``` qml QQuickItem *item; foreach (item, parent->childItems()) { if (Entity *entity = qobject_cast<Entity *>(item)) entity->update(delta); else if (Layer *layer = qobject_cast<Layer *>(item)) layer->update(delta); } ```
Commenting is not possible because the repository is archived.
No labels
No milestone
No project
No assignees
1 participant
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
mdkcore/Bacon2D#126
No description provided.