Archived
1
Fork 0

Engine::create_empty_scene now returns the Scene it just created

This commit is contained in:
Joshua Goins 2022-08-15 10:10:50 -04:00
parent 2f0d1aace9
commit c6da6e05ce
3 changed files with 9 additions and 6 deletions

View file

@ -122,12 +122,14 @@ namespace prism {
*/
Physics* get_physics();
/// Creates an empty scene with no path. This will change the current scene.
void create_empty_scene();
/** Creates an empty scene with no path. This will change the current scene.
* @return Returns a instance of the scene if successful, and nullptr on failure.
*/
Scene* create_empty_scene();
/** Load a scene from disk. This will change the current scene if successful.
@param path The scene file path.
@return Returns a instance of the scene is successful, and nullptr on failure.
@return Returns a instance of the scene if successful, and nullptr on failure.
*/
Scene* load_scene(const prism::path& path);

View file

@ -139,13 +139,15 @@ Physics* engine::get_physics() {
return physics.get();
}
void engine::create_empty_scene() {
Scene* engine::create_empty_scene() {
auto scene = std::make_unique<Scene>();
setup_scene(*scene);
scenes.push_back(std::move(scene));
current_scene = scenes.back().get();
return current_scene;
}
Scene* engine::load_scene(const prism::path& path) {

View file

@ -12,8 +12,7 @@ void app_main(prism::engine*) {
}
void ExampleApp::initialize_render() {
engine->create_empty_scene();
auto scene = engine->get_scene();
auto scene = engine->create_empty_scene();
camera_obj = scene->add_object();
auto& camera = scene->add<Camera>(camera_obj);