diff --git a/engine/core/include/app.hpp b/engine/core/include/app.hpp index 4a718b8..b01ba5a 100755 --- a/engine/core/include/app.hpp +++ b/engine/core/include/app.hpp @@ -3,7 +3,7 @@ class GFXCommandBuffer; namespace prism { - class Engine; + class engine; /// The base class for any Prism application. class app { @@ -34,4 +34,4 @@ namespace prism { } /// This is an app's equivalent of main(). You can check command line arguments through Engine::command_line_arguments. -void app_main(prism::Engine* engine); +void app_main(prism::engine* engine); diff --git a/engine/core/include/engine.hpp b/engine/core/include/engine.hpp index ef9d66c..d69a3bb 100755 --- a/engine/core/include/engine.hpp +++ b/engine/core/include/engine.hpp @@ -36,7 +36,7 @@ namespace prism { }; /// The glue between app and systems such as the Renderer. - class Engine { + class engine { public: /** Constructs an Engine with command line arguments. Can be accessed later from command_line_arguments. @@ -44,12 +44,12 @@ namespace prism { @param argc Numer of arguments. Can be null. @param argv Array of strings containing arguments. Can be null. */ - Engine(int argc, char* argv[]); + engine(int argc, char* argv[]); - Engine(const Engine& other) = delete; - Engine(Engine&& other) = delete; + engine(const engine& other) = delete; + engine(engine&& other) = delete; - ~Engine(); + ~engine(); /// Command line arguments, can be empty. std::vector command_line_arguments; @@ -391,4 +391,4 @@ namespace prism { } } -inline prism::Engine* engine = nullptr; +inline prism::engine* engine = nullptr; diff --git a/engine/core/src/engine.cpp b/engine/core/src/engine.cpp index c019b5d..43f6f09 100755 --- a/engine/core/src/engine.cpp +++ b/engine/core/src/engine.cpp @@ -23,9 +23,9 @@ #include "shadowpass.hpp" #include "scenecapture.hpp" -using prism::Engine; +using prism::engine; -Engine::Engine(const int argc, char* argv[]) { +engine::engine(const int argc, char* argv[]) { console::info(System::Core, "Prism Engine loading..."); console::register_command("test_cmd", console::ArgumentFormat(0), [](const console::Arguments) { @@ -47,19 +47,19 @@ Engine::Engine(const int argc, char* argv[]) { assetm = std::make_unique(); } -Engine::~Engine() {} +engine::~engine() {} -void Engine::set_app(app* app) { +void engine::set_app(app* app) { Expects(app != nullptr); _app = app; } -prism::app* Engine::get_app() const { +prism::app* engine::get_app() const { return _app; } -void Engine::load_localization(const std::string_view path) { +void engine::load_localization(const std::string_view path) { Expects(!path.empty()); auto file = file::open(file::app_domain / path); @@ -71,53 +71,53 @@ void Engine::load_localization(const std::string_view path) { } } -void Engine::pause() { +void engine::pause() { _paused = true; push_event("engine_pause"); } -void Engine::unpause() { +void engine::unpause() { _paused = false; push_event("engine_unpause"); } -bool Engine::is_paused() const { +bool engine::is_paused() const { return _paused; } -void Engine::quit() { +void engine::quit() { _windows[0]->quitRequested = true; } -bool Engine::is_quitting() const { +bool engine::is_quitting() const { return _windows[0]->quitRequested; } -void Engine::prepare_quit() { +void engine::prepare_quit() { _app->prepare_quit(); } -void Engine::set_gfx(GFX* gfx) { +void engine::set_gfx(GFX* gfx) { _gfx = gfx; } -GFX* Engine::get_gfx() { +GFX* engine::get_gfx() { return _gfx; } -Input* Engine::get_input() { +Input* engine::get_input() { return _input.get(); } -Renderer* Engine::get_renderer() { +Renderer* engine::get_renderer() { return _renderer.get(); } -Physics* Engine::get_physics() { +Physics* engine::get_physics() { return _physics.get(); } -void Engine::create_empty_scene() { +void engine::create_empty_scene() { auto scene = std::make_unique(); setup_scene(*scene); @@ -126,7 +126,7 @@ void Engine::create_empty_scene() { _current_scene = _scenes.back().get(); } -Scene* Engine::load_scene(const file::Path path) { +Scene* engine::load_scene(const file::Path path) { Expects(!path.empty()); auto file = file::open(path); @@ -172,7 +172,7 @@ Scene* Engine::load_scene(const file::Path path) { return _scenes.back().get(); } -void Engine::save_scene(const std::string_view path) { +void engine::save_scene(const std::string_view path) { Expects(!path.empty()); nlohmann::json j; @@ -186,13 +186,13 @@ void Engine::save_scene(const std::string_view path) { out << j; } -ui::Screen* Engine::load_screen(const file::Path path) { +ui::Screen* engine::load_screen(const file::Path path) { Expects(!path.empty()); return new ui::Screen(path); } -void Engine::set_screen(ui::Screen* screen) { +void engine::set_screen(ui::Screen* screen) { _current_screen = screen; screen->extent = _windows[0]->extent; @@ -201,11 +201,11 @@ void Engine::set_screen(ui::Screen* screen) { get_renderer()->set_screen(screen); } -ui::Screen* Engine::get_screen() const { +ui::Screen* engine::get_screen() const { return _current_screen; } -AnimationChannel Engine::load_animation(nlohmann::json a) { +AnimationChannel engine::load_animation(nlohmann::json a) { AnimationChannel animation; for(auto& kf : a["frames"]) { @@ -219,7 +219,7 @@ AnimationChannel Engine::load_animation(nlohmann::json a) { return animation; } -Animation Engine::load_animation(const file::Path path) { +Animation engine::load_animation(const file::Path path) { Expects(!path.empty()); auto file = file::open(path, true); @@ -277,7 +277,7 @@ Animation Engine::load_animation(const file::Path path) { return anim; } -void Engine::load_cutscene(const file::Path path) { +void engine::load_cutscene(const file::Path path) { Expects(!path.empty()); cutscene = std::make_unique(); @@ -313,11 +313,11 @@ void Engine::load_cutscene(const file::Path path) { } else { load_scene(file::root_path(path) / s["scene"].get()); - if(engine->get_scene() == nullptr) - engine->create_empty_scene(); + if(get_scene() == nullptr) + create_empty_scene(); - auto cameraObj = engine->get_scene()->add_object(); - engine->get_scene()->add(cameraObj); + auto cameraObj = get_scene()->add_object(); + get_scene()->add(cameraObj); for(auto& anim : shot.channels) { if(anim.target == NullObject) @@ -332,12 +332,12 @@ void Engine::load_cutscene(const file::Path path) { } } -void Engine::save_cutscene(const std::string_view path) { +void engine::save_cutscene(const std::string_view path) { Expects(!path.empty()); nlohmann::json j; - for(auto& shot : engine->cutscene->shots) { + for(auto& shot : cutscene->shots) { nlohmann::json s; s["begin"] = shot.begin; s["end"] = shot.length; @@ -354,7 +354,7 @@ void Engine::save_cutscene(const std::string_view path) { out << j; } -Object Engine::add_prefab(Scene& scene, const file::Path path, const std::string_view override_name) { +Object engine::add_prefab(Scene& scene, const file::Path path, const std::string_view override_name) { Expects(!path.empty()); auto file = file::open(path); @@ -389,7 +389,7 @@ Object Engine::add_prefab(Scene& scene, const file::Path path, const std::string return root_node; } -void Engine::save_prefab(const Object root, const std::string_view path) { +void engine::save_prefab(const Object root, const std::string_view path) { Expects(root != NullObject); Expects(!path.empty()); @@ -404,7 +404,7 @@ void Engine::save_prefab(const Object root, const std::string_view path) { out << j; } -void Engine::add_window(void* native_handle, const int identifier, const prism::Extent extent) { +void engine::add_window(void* native_handle, const int identifier, const prism::Extent extent) { Expects(native_handle != nullptr); Expects(identifier >= 0); @@ -426,7 +426,7 @@ void Engine::add_window(void* native_handle, const int identifier, const prism:: render_ready = true; } -void Engine::remove_window(const int identifier) { +void engine::remove_window(const int identifier) { Expects(identifier >= 0); utility::erase_if(_windows, [identifier](Window*& w) { @@ -434,7 +434,7 @@ void Engine::remove_window(const int identifier) { }); } -void Engine::resize(const int identifier, const prism::Extent extent) { +void engine::resize(const int identifier, const prism::Extent extent) { Expects(identifier >= 0); auto window = get_window(identifier); @@ -456,7 +456,7 @@ void Engine::resize(const int identifier, const prism::Extent extent) { } } -void Engine::process_key_down(const unsigned int keyCode) { +void engine::process_key_down(const unsigned int keyCode) { Expects(keyCode >= 0); _imgui->process_key_down(keyCode); @@ -465,37 +465,37 @@ void Engine::process_key_down(const unsigned int keyCode) { debug_enabled = !debug_enabled; } -void Engine::process_key_up(const unsigned int keyCode) { +void engine::process_key_up(const unsigned int keyCode) { Expects(keyCode >= 0); _imgui->process_key_up(keyCode); } -void Engine::process_mouse_down(const int button, const prism::Offset offset) { +void engine::process_mouse_down(const int button, const prism::Offset offset) { if(_current_screen != nullptr && button == 0) _current_screen->process_mouse(offset.x, offset.y); } -void Engine::push_event(const std::string_view name, const std::string_view data) { +void engine::push_event(const std::string_view name, const std::string_view data) { Expects(!name.empty()); if(_current_screen != nullptr) _current_screen->process_event(name.data(), data.data()); } -bool Engine::has_localization(const std::string_view id) const { +bool engine::has_localization(const std::string_view id) const { Expects(!id.empty()); return _strings.count(id.data()); } -std::string Engine::localize(const std::string id) { +std::string engine::localize(const std::string id) { Expects(!id.empty()); return _strings[id]; } -void Engine::calculate_bone(Mesh& mesh, const Mesh::Part& part, Bone& bone, const Bone* parent_bone) { +void engine::calculate_bone(Mesh& mesh, const Mesh::Part& part, Bone& bone, const Bone* parent_bone) { if(part.offset_matrices.empty()) return; @@ -517,7 +517,7 @@ void Engine::calculate_bone(Mesh& mesh, const Mesh::Part& part, Bone& bone, cons } } -void Engine::calculate_object(Scene& scene, Object object, const Object parent_object) { +void engine::calculate_object(Scene& scene, Object object, const Object parent_object) { Matrix4x4 parent_matrix; if(parent_object != NullObject) parent_matrix = scene.get(parent_object).model; @@ -552,7 +552,7 @@ void Engine::calculate_object(Scene& scene, Object object, const Object parent_o mesh.temp_bone_data[i] = mesh.mesh->bones[i].final_transform; } - engine->get_gfx()->copy_buffer(part.bone_batrix_buffer, mesh.temp_bone_data.data(), 0, mesh.temp_bone_data.size() * sizeof(Matrix4x4)); + _gfx->copy_buffer(part.bone_batrix_buffer, mesh.temp_bone_data.data(), 0, mesh.temp_bone_data.size() * sizeof(Matrix4x4)); } } } @@ -561,8 +561,8 @@ void Engine::calculate_object(Scene& scene, Object object, const Object parent_o calculate_object(scene, child, object); } -Shot* Engine::get_shot(const float time) { - for(auto& shot : engine->cutscene->shots) { +Shot* engine::get_shot(const float time) { + for(auto& shot : cutscene->shots) { if(time >= shot.begin && time <= (shot.begin + shot.length)) return &shot; } @@ -570,7 +570,7 @@ Shot* Engine::get_shot(const float time) { return nullptr; } -void Engine::update_animation_channel(Scene& scene, const AnimationChannel& channel, const float time) { +void engine::update_animation_channel(Scene& scene, const AnimationChannel& channel, const float time) { { int keyframeIndex = -1; int i = 0; @@ -635,7 +635,7 @@ void Engine::update_animation_channel(Scene& scene, const AnimationChannel& chan } } -void Engine::update_cutscene(const float time) { +void engine::update_cutscene(const float time) { Shot* currentShot = get_shot(time); if(currentShot != nullptr) { _current_scene = currentShot->scene; @@ -647,12 +647,12 @@ void Engine::update_cutscene(const float time) { } } -void Engine::update_animation(const Animation& anim, const float time) { +void engine::update_animation(const Animation& anim, const float time) { for(const auto& channel : anim.channels) update_animation_channel(*_current_scene, channel, time); } -void Engine::begin_frame(const float delta_time) { +void engine::begin_frame(const float delta_time) { _imgui->begin_frame(delta_time); if(debug_enabled) @@ -662,14 +662,14 @@ void Engine::begin_frame(const float delta_time) { _app->begin_frame(); } -void Engine::end_frame() { +void engine::end_frame() { ImGui::UpdatePlatformWindows(); } int frame_delay = 0; const int frame_delay_between_resolution_change = 60; -void Engine::update(const float delta_time) { +void engine::update(const float delta_time) { const float ideal_delta_time = 0.01667f; if(render_options.dynamic_resolution) { @@ -743,14 +743,14 @@ void Engine::update(const float delta_time) { assetm->perform_cleanup(); } -void Engine::update_scene(Scene& scene) { +void engine::update_scene(Scene& scene) { for(auto& obj : scene.get_objects()) { if(scene.get(obj).parent == NullObject) calculate_object(scene, obj); } } -void Engine::render(const int index) { +void engine::render(const int index) { Expects(index >= 0); auto window = get_window(index); @@ -776,25 +776,25 @@ void Engine::render(const int index) { _gfx->submit(commandbuffer, index); } -void Engine::add_timer(Timer& timer) { +void engine::add_timer(Timer& timer) { _timers.push_back(&timer); } -Scene* Engine::get_scene() { +Scene* engine::get_scene() { return _current_scene; } -Scene* Engine::get_scene(const std::string_view name) { +Scene* engine::get_scene(const std::string_view name) { Expects(!name.empty()); return _path_to_scene[name.data()]; } -void Engine::set_current_scene(Scene* scene) { +void engine::set_current_scene(Scene* scene) { _current_scene = scene; } -std::string_view Engine::get_scene_path() const { +std::string_view engine::get_scene_path() const { for(auto& [path, scene] : _path_to_scene) { if(scene == this->_current_scene) return path; @@ -803,13 +803,13 @@ std::string_view Engine::get_scene_path() const { return ""; } -void Engine::on_remove(Object object) { +void engine::on_remove(Object object) { Expects(object != NullObject); _physics->remove_object(object); } -void Engine::play_animation(Animation animation, Object object, bool looping) { +void engine::play_animation(Animation animation, Object object, bool looping) { Expects(object != NullObject); if(!_current_scene->has(object)) @@ -830,21 +830,21 @@ void Engine::play_animation(Animation animation, Object object, bool looping) { _animation_targets.push_back(target); } -void Engine::set_animation_speed_modifier(Object target, float modifier) { +void engine::set_animation_speed_modifier(Object target, float modifier) { for(auto& animation : _animation_targets) { if(animation.target == target) animation.animation_speed_modifier = modifier; } } -void Engine::stop_animation(Object target) { +void engine::stop_animation(Object target) { for(auto& animation : _animation_targets) { if(animation.target == target) utility::erase(_animation_targets, animation); } } -void Engine::setup_scene(Scene& scene) { +void engine::setup_scene(Scene& scene) { _physics->reset(); scene.on_remove = [this](Object obj) { diff --git a/tools/editor/src/prismeditor.cpp b/tools/editor/src/prismeditor.cpp index d2793d5..d825785 100755 --- a/tools/editor/src/prismeditor.cpp +++ b/tools/editor/src/prismeditor.cpp @@ -24,7 +24,7 @@ std::string get_filename(const std::string path) { std::vector editors; -void app_main(prism::Engine* engine) { +void app_main(prism::engine* engine) { CommonEditor* editor = (CommonEditor*)engine->get_app(); platform::open_window("Prism Editor",