From 2ffd1a421e43315e0baf085fd1d78b959f4737e9 Mon Sep 17 00:00:00 2001 From: redstrate <54911369+redstrate@users.noreply.github.com> Date: Mon, 21 Sep 2020 09:37:52 -0400 Subject: [PATCH] Remove even more includes --- engine/asset/src/asset.cpp | 4 +++ engine/audio/include/audio.hpp | 7 +--- engine/core/CMakeLists.txt | 5 +-- engine/core/include/cutscene.hpp | 3 ++ engine/core/include/engine.hpp | 44 +++++++++++------------- engine/core/include/file.hpp | 2 +- engine/core/include/physics.hpp | 8 ++++- engine/core/src/debug.cpp | 2 ++ engine/core/src/engine.cpp | 36 ++++++++++--------- engine/core/src/physics.cpp | 5 +++ engine/renderer/CMakeLists.txt | 4 +-- engine/renderer/include/renderer.hpp | 4 +-- engine/renderer/src/imguipass.cpp | 1 + engine/renderer/src/materialcompiler.cpp | 1 + engine/renderer/src/renderer.cpp | 2 ++ engine/renderer/src/shadowpass.cpp | 1 + engine/utility/CMakeLists.txt | 2 ++ engine/utility/include/path.hpp | 7 ++++ tools/common/include/commoneditor.hpp | 2 ++ tools/common/src/commoneditor.cpp | 2 ++ tools/common/src/debugpass.cpp | 1 + tools/editor/src/uieditor.cpp | 1 + 22 files changed, 90 insertions(+), 54 deletions(-) create mode 100755 engine/utility/include/path.hpp diff --git a/engine/asset/src/asset.cpp b/engine/asset/src/asset.cpp index 2128756..0f18486 100644 --- a/engine/asset/src/asset.cpp +++ b/engine/asset/src/asset.cpp @@ -10,6 +10,10 @@ #include "json_conversions.hpp" #include "gfx_commandbuffer.hpp" #include "assertions.hpp" +#include "renderer.hpp" +#include "input.hpp" +#include "physics.hpp" +#include "imguilayer.hpp" std::unique_ptr load_mesh(const file::Path path) { Expects(!path.empty()); diff --git a/engine/audio/include/audio.hpp b/engine/audio/include/audio.hpp index 989015e..11fae57 100755 --- a/engine/audio/include/audio.hpp +++ b/engine/audio/include/audio.hpp @@ -1,11 +1,6 @@ #pragma once -#include -#include -#include -#include - -#include "file.hpp" +#include "path.hpp" /* * Audio API diff --git a/engine/core/CMakeLists.txt b/engine/core/CMakeLists.txt index 12ab62c..9e2e8fc 100755 --- a/engine/core/CMakeLists.txt +++ b/engine/core/CMakeLists.txt @@ -48,9 +48,10 @@ target_link_libraries(Core PUBLIC Renderer nlohmann_json magic_enum - ${BULLET_LIBRARIES} imgui Log ${EXTRA_LIBRARIES} - Asset) + Asset + PRIVATE + ${BULLET_LIBRARIES}) set_engine_properties(Core) diff --git a/engine/core/include/cutscene.hpp b/engine/core/include/cutscene.hpp index 5ff3a89..0825004 100755 --- a/engine/core/include/cutscene.hpp +++ b/engine/core/include/cutscene.hpp @@ -5,6 +5,7 @@ #include "vector.hpp" #include "quaternion.hpp" #include "math.hpp" +#include "object.hpp" struct PositionKeyFrame { float time; @@ -49,6 +50,8 @@ struct Animation { std::vector channels; }; +class Scene; + struct Shot { int begin, length; diff --git a/engine/core/include/engine.hpp b/engine/core/include/engine.hpp index 8440c91..ca37224 100755 --- a/engine/core/include/engine.hpp +++ b/engine/core/include/engine.hpp @@ -1,27 +1,13 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include +#include -#include "scene.hpp" -#include "renderer.hpp" -#include "input.hpp" -#include "cutscene.hpp" -#include "physics.hpp" -#include "file.hpp" #include "object.hpp" -#include "imguilayer.hpp" -#include "shadowpass.hpp" -#include "scenecapture.hpp" -#include "smaapass.hpp" -#include "gaussianhelper.hpp" +#include "cutscene.hpp" #include "common.hpp" #include "asset_types.hpp" +#include "platform.hpp" +#include "path.hpp" class GFX; @@ -30,6 +16,11 @@ namespace ui { } class App; +class Scene; +class Input; +class Renderer; +class Physics; +class ImGuiLayer; struct Timer; struct AnimationTarget { @@ -51,6 +42,11 @@ public: @param argv Array of strings containing arguments. Can be null. */ Engine(const int argc, char* argv[]); + + Engine(const Engine& other) = delete; + Engine(Engine&& other) = delete; + + ~Engine(); /// Command line arguments, can be empty. std::vector command_line_arguments; @@ -338,13 +334,13 @@ private: Scene* _current_scene = nullptr; std::vector> _scenes; std::map _path_to_scene; - + struct Window { int identifier = -1; prism::Extent extent; bool quitRequested = false; - - std::unique_ptr renderer = nullptr; + + std::unique_ptr renderer; }; std::vector _windows; @@ -370,8 +366,8 @@ private: App* _app = nullptr; GFX* _gfx = nullptr; - std::unique_ptr _input = nullptr; - std::unique_ptr _physics = nullptr; + std::unique_ptr _input; + std::unique_ptr _physics; std::vector _timers, _timersToRemove; @@ -379,7 +375,7 @@ private: std::vector _animation_targets; - std::unique_ptr _imgui = nullptr; + std::unique_ptr _imgui; const InputButton debug_button = InputButton::Q; }; diff --git a/engine/core/include/file.hpp b/engine/core/include/file.hpp index 251486e..5a59aa7 100755 --- a/engine/core/include/file.hpp +++ b/engine/core/include/file.hpp @@ -9,6 +9,7 @@ #include "log.hpp" #include "file_utils.hpp" +#include "path.hpp" namespace file { enum class Domain { @@ -133,5 +134,4 @@ namespace file { inline Path internal_domain = "/internal", app_domain = "/app"; } - inline std::array domain_data; diff --git a/engine/core/include/physics.hpp b/engine/core/include/physics.hpp index 740683e..74f0052 100755 --- a/engine/core/include/physics.hpp +++ b/engine/core/include/physics.hpp @@ -1,14 +1,20 @@ #pragma once -#include #include #include "vector.hpp" #include "object.hpp" +class btBroadphaseInterface; +class btDefaultCollisionConfiguration; +class btCollisionDispatcher; +class btSequentialImpulseConstraintSolver; +class btDiscreteDynamicsWorld; + class Physics { public: Physics(); + ~Physics(); void update(float deltaTime); diff --git a/engine/core/src/debug.cpp b/engine/core/src/debug.cpp index ba940e6..a14fbc2 100644 --- a/engine/core/src/debug.cpp +++ b/engine/core/src/debug.cpp @@ -9,6 +9,8 @@ #include "gfx.hpp" #include "asset.hpp" #include "imgui_utility.hpp" +#include "scene.hpp" +#include "renderer.hpp" void draw_general() { ImGui::Text("Platform: %s", platform::get_name()); diff --git a/engine/core/src/engine.cpp b/engine/core/src/engine.cpp index a2023d3..cda4865 100755 --- a/engine/core/src/engine.cpp +++ b/engine/core/src/engine.cpp @@ -2,22 +2,25 @@ #include -#include "timer.hpp" -#include "gfx.hpp" -#include "renderer.hpp" -#include "screen.hpp" -#include "file.hpp" -#include "transform.hpp" -#include "math.hpp" -#include "cutscene.hpp" -#include "log.hpp" -#include "imguilayer.hpp" -#include "app.hpp" -#include "json_conversions.hpp" -#include "debug.hpp" -#include "assertions.hpp" +#include "scene.hpp" #include "console.hpp" +#include "log.hpp" #include "asset.hpp" +#include "json_conversions.hpp" +#include "app.hpp" +#include "assertions.hpp" +#include "screen.hpp" +#include "renderer.hpp" +#include "gfx.hpp" +#include "imguilayer.hpp" +#include "debug.hpp" +#include "timer.hpp" +#include "physics.hpp" +#include "input.hpp" + +// TODO: remove these in the future +#include "shadowpass.hpp" +#include "scenecapture.hpp" Engine::Engine(const int argc, char* argv[]) { console::info(System::Core, "Prism Engine loading..."); @@ -37,6 +40,8 @@ Engine::Engine(const int argc, char* argv[]) { assetm = std::make_unique(); } +Engine::~Engine() {} + void Engine::set_app(App* app) { Expects(app != nullptr); @@ -400,7 +405,7 @@ void Engine::add_window(void* native_handle, const int identifier, const prism:: _gfx->initialize_view(native_handle, identifier, drawable_extent.width, drawable_extent.height); - Window window; + Window& window = _windows.emplace_back(); window.identifier = identifier; window.extent = extent; window.renderer = std::make_unique(_gfx); @@ -408,7 +413,6 @@ void Engine::add_window(void* native_handle, const int identifier, const prism:: window.renderer->resize(drawable_extent); render_ready = true; - _windows.push_back(std::move(window)); } void Engine::remove_window(const int identifier) { diff --git a/engine/core/src/physics.cpp b/engine/core/src/physics.cpp index 00bc980..6c8581d 100755 --- a/engine/core/src/physics.cpp +++ b/engine/core/src/physics.cpp @@ -1,11 +1,16 @@ #include "physics.hpp" +#include + #include "engine.hpp" +#include "scene.hpp" Physics::Physics() { reset(); } +Physics::~Physics() {} + void Physics::update(float deltaTime) { if(engine->get_scene() == nullptr) return; diff --git a/engine/renderer/CMakeLists.txt b/engine/renderer/CMakeLists.txt index c978305..a1de7dc 100755 --- a/engine/renderer/CMakeLists.txt +++ b/engine/renderer/CMakeLists.txt @@ -31,10 +31,10 @@ target_link_libraries(Renderer stb Math Utility - Core imgui SMAA::SMAA - ShaderCompiler) + ShaderCompiler + Core) target_include_directories(Renderer PUBLIC include) set_engine_properties(Renderer) diff --git a/engine/renderer/include/renderer.hpp b/engine/renderer/include/renderer.hpp index 5a71f40..ce9ba75 100755 --- a/engine/renderer/include/renderer.hpp +++ b/engine/renderer/include/renderer.hpp @@ -4,13 +4,12 @@ #include #include -#include "file.hpp" #include "pass.hpp" #include "matrix.hpp" #include "object.hpp" -#include "dofpass.hpp" #include "common.hpp" #include "render_options.hpp" +#include "path.hpp" namespace ui { class Screen; @@ -45,6 +44,7 @@ class Material; class Renderer { public: Renderer(GFX* gfx, const bool enable_imgui = true); + ~Renderer(); void resize(const prism::Extent extent); void resize_viewport(const prism::Extent extent); diff --git a/engine/renderer/src/imguipass.cpp b/engine/renderer/src/imguipass.cpp index e77c6ba..90ab5fb 100755 --- a/engine/renderer/src/imguipass.cpp +++ b/engine/renderer/src/imguipass.cpp @@ -8,6 +8,7 @@ #include "gfx_commandbuffer.hpp" #include "log.hpp" #include "assertions.hpp" +#include "renderer.hpp" void ImGuiPass::initialize() { ImGuiIO& io = ImGui::GetIO(); diff --git a/engine/renderer/src/materialcompiler.cpp b/engine/renderer/src/materialcompiler.cpp index 82af5dc..7e8e0c5 100755 --- a/engine/renderer/src/materialcompiler.cpp +++ b/engine/renderer/src/materialcompiler.cpp @@ -6,6 +6,7 @@ #include "string_utils.hpp" #include "shadercompiler.hpp" #include "material_nodes.hpp" +#include "renderer.hpp" ShaderSource get_shader(std::string filename, bool skinned, bool cubemap) { auto shader_file = file::open(file::internal_domain / filename); diff --git a/engine/renderer/src/renderer.cpp b/engine/renderer/src/renderer.cpp index 231966d..f541839 100755 --- a/engine/renderer/src/renderer.cpp +++ b/engine/renderer/src/renderer.cpp @@ -98,6 +98,8 @@ Renderer::Renderer(GFX* gfx, const bool enable_imgui) : gfx(gfx) { createBRDF(); } +Renderer::~Renderer() {} + void Renderer::resize(const prism::Extent extent) { this->extent = extent; diff --git a/engine/renderer/src/shadowpass.cpp b/engine/renderer/src/shadowpass.cpp index 9551bb9..80b257b 100755 --- a/engine/renderer/src/shadowpass.cpp +++ b/engine/renderer/src/shadowpass.cpp @@ -8,6 +8,7 @@ #include "materialcompiler.hpp" #include "assertions.hpp" #include "frustum.hpp" +#include "renderer.hpp" struct PushConstant { Matrix4x4 mvp, model; diff --git a/engine/utility/CMakeLists.txt b/engine/utility/CMakeLists.txt index 0e8ebc6..478ce2e 100755 --- a/engine/utility/CMakeLists.txt +++ b/engine/utility/CMakeLists.txt @@ -6,6 +6,8 @@ set(SRC include/common.hpp include/aabb.hpp include/file_utils.hpp + include/assertions.hpp + include/path.hpp src/string_utils.cpp) diff --git a/engine/utility/include/path.hpp b/engine/utility/include/path.hpp new file mode 100755 index 0000000..9443d18 --- /dev/null +++ b/engine/utility/include/path.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace file { + using Path = std::filesystem::path; +} diff --git a/tools/common/include/commoneditor.hpp b/tools/common/include/commoneditor.hpp index 7017645..0c74b36 100755 --- a/tools/common/include/commoneditor.hpp +++ b/tools/common/include/commoneditor.hpp @@ -19,6 +19,8 @@ #include "assertions.hpp" #include "log.hpp" #include "asset.hpp" +#include "scene.hpp" +#include "renderer.hpp" class TransformCommand : public Command { public: diff --git a/tools/common/src/commoneditor.cpp b/tools/common/src/commoneditor.cpp index cc7a9ee..e090784 100755 --- a/tools/common/src/commoneditor.cpp +++ b/tools/common/src/commoneditor.cpp @@ -20,6 +20,8 @@ #include "imgui_utility.hpp" #include "screen.hpp" #include "console.hpp" +#include "input.hpp" +#include "scenecapture.hpp" const std::map imToPl = { {ImGuiKey_Tab, InputButton::Tab}, diff --git a/tools/common/src/debugpass.cpp b/tools/common/src/debugpass.cpp index 7441f2a..1b9ea91 100755 --- a/tools/common/src/debugpass.cpp +++ b/tools/common/src/debugpass.cpp @@ -9,6 +9,7 @@ #include "asset.hpp" #include "log.hpp" #include "materialcompiler.hpp" +#include "renderer.hpp" struct BillPushConstant { Matrix4x4 view, mvp; diff --git a/tools/editor/src/uieditor.cpp b/tools/editor/src/uieditor.cpp index df85798..a46eeaa 100755 --- a/tools/editor/src/uieditor.cpp +++ b/tools/editor/src/uieditor.cpp @@ -1,5 +1,6 @@ #include "uieditor.hpp" +#include #include #include #include