Clean up scene loading

This commit is contained in:
Emil Axelsson
2017-03-07 16:33:56 +01:00
parent d92d001364
commit 92df9caf5a
9 changed files with 63 additions and 44 deletions

View File

@@ -178,22 +178,22 @@ private:
// Components
std::unique_ptr<ConfigurationManager> _configurationManager;
std::unique_ptr<interaction::InteractionHandler> _interactionHandler;
std::unique_ptr<RenderEngine> _renderEngine;
std::unique_ptr<SceneManager> _sceneManager;
std::unique_ptr<scripting::ScriptEngine> _scriptEngine;
std::unique_ptr<scripting::ScriptScheduler> _scriptScheduler;
std::unique_ptr<NetworkEngine> _networkEngine;
std::unique_ptr<SyncEngine> _syncEngine;
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
std::unique_ptr<DownloadManager> _downloadManager;
std::unique_ptr<LuaConsole> _console;
std::unique_ptr<ModuleEngine> _moduleEngine;
std::unique_ptr<NetworkEngine> _networkEngine;
std::unique_ptr<ParallelConnection> _parallelConnection;
std::unique_ptr<RenderEngine> _renderEngine;
std::unique_ptr<SettingsEngine> _settingsEngine;
std::unique_ptr<SyncEngine> _syncEngine;
std::unique_ptr<TimeManager> _timeManager;
std::unique_ptr<WindowWrapper> _windowWrapper;
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
std::unique_ptr<ghoul::fontrendering::FontManager> _fontManager;
std::unique_ptr<interaction::InteractionHandler> _interactionHandler;
std::unique_ptr<scripting::ScriptEngine> _scriptEngine;
std::unique_ptr<scripting::ScriptScheduler> _scriptScheduler;
// Others
std::unique_ptr<properties::PropertyOwner> _globalPropertyNamespace;

View File

@@ -68,18 +68,17 @@ public:
*/
void initialize();
/*
/**
* Load the scenegraph from the provided folder
*/
//void scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath);
void clear();
/*
/**
* Set the root node of the scene
*/
void setRoot(std::unique_ptr<SceneGraphNode> root);
/*
/**
* Set the root node of the scene
*/
void setCamera(std::unique_ptr<Camera> camera);
@@ -88,45 +87,61 @@ public:
* Return the camera
*/
Camera* camera() const;
/*
/**
* Updates all SceneGraphNodes relative positions
*/
void update(const UpdateData& data);
/*
* Evaluates if the SceneGraphNodes are visible to the provided camera
/**
* Evaluate if the SceneGraphNodes are visible to the provided camera.
*/
void evaluate(Camera* camera);
/*
* Render visible SceneGraphNodes using the provided camera
/**
* Render visible SceneGraphNodes using the provided camera.
*/
void render(const RenderData& data, RendererTasks& tasks);
/*
* Returns the root SceneGraphNode
/**
* Return the root SceneGraphNode.
*/
SceneGraphNode* root() const;
/**
* Return the scenegraph node with the specified name or <code>nullptr</code> if that
* name does not exist
* name does not exist.
*/
SceneGraphNode* sceneGraphNode(const std::string& name) const;
/**
* Add a node and all its children to the scene.
*/
void addNode(SceneGraphNode* node, UpdateDependencies updateDeps = UpdateDependencies::Yes);
/**
* Remove a node and all its children from the scene.
*/
void removeNode(SceneGraphNode* node, UpdateDependencies updateDeps = UpdateDependencies::Yes);
/**
* Update dependencies.
*/
void updateDependencies();
void sortTopologically();
/**
* Return a vector of all scene graph nodes in the scene.
*/
const std::vector<SceneGraphNode*>& allSceneGraphNodes() const;
/**
* Return a a map from name to scene graph node.
*/
const std::map<std::string, SceneGraphNode*>& nodesByName() const;
/**
* Output property documentation to a file.
*/
void writePropertyDocumentation(const std::string& filename, const std::string& type, const std::string& sceneFilename);
/**
@@ -142,6 +157,8 @@ public:
static documentation::Documentation Documentation();
private:
void sortTopologically();
std::unique_ptr<SceneGraphNode> _root;
std::unique_ptr<Camera> _camera;
std::vector<SceneGraphNode*> _topologicallySortedNodes;

View File

@@ -81,7 +81,6 @@ public:
std::unique_ptr<SceneGraphNode> detachChild(SceneGraphNode& child, UpdateScene updateScene = UpdateScene::Yes);
void setParent(SceneGraphNode& parent, UpdateScene updateScene = UpdateScene::Yes);
void addDependency(SceneGraphNode& dependency, UpdateScene updateScene = UpdateScene::Yes);
void removeDependency(SceneGraphNode& dependency, UpdateScene updateScene = UpdateScene::Yes);
void clearDependencies(UpdateScene updateScene = UpdateScene::Yes);

View File

@@ -38,6 +38,7 @@ public:
~SceneManager() = default;
Scene* loadScene(const std::string& path);
void unloadScene(Scene& scene);
void unloadAll();
private:
std::vector<std::unique_ptr<Scene>> _scenes;
};