Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engine/includes/components/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ENGINE_EXPORT World : public Object {
void graphUpdated();

private:
void addScene(Scene *scene);
void addChild(Object *child, int32_t position = -1) override;

private:
Expand Down
18 changes: 12 additions & 6 deletions engine/src/components/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void World::setActive(bool flag) {
*/
Scene *World::createScene(const TString &name) {
Scene *result = Engine::objectCreate<Scene>(name, this);
m_scenes.push_back(result);
addScene(result);
return result;
}
/*!
Expand All @@ -65,7 +65,7 @@ Scene *World::loadScene(const TString &path, bool additive) {
}
scene->setParent(this);
}
m_scenes.push_back(scene);
addScene(scene);
sceneLoaded();
return scene;
}
Expand Down Expand Up @@ -193,15 +193,21 @@ void World::graphUpdated() {
/*!
\internal
*/
void World::addScene(Scene *scene) {
auto it = std::find(m_scenes.begin(), m_scenes.end(), scene);
if(it == m_scenes.end()) {
m_scenes.push_back(scene);
}
}
/*!
\internal
*/
void World::addChild(Object *child, int32_t position) {
Object::addChild(child, position);

Scene *scene = dynamic_cast<Scene *>(child);
if(scene) {
auto it = std::find(m_scenes.begin(), m_scenes.end(), scene);
if(it == m_scenes.end()) {
m_scenes.push_back(scene);
}
addScene(scene);
}
if(m_activeScene == nullptr && scene) {
setActiveScene(scene);
Expand Down
Loading