From 9f16e7e6745e1083388ddf77e0a27523a3997d41 Mon Sep 17 00:00:00 2001 From: Ricardo Antunes Date: Mon, 29 Jan 2024 19:41:56 +0000 Subject: [PATCH] refactor: move Cubos to core --- core/CMakeLists.txt | 1 + .../include/cubos/core/ecs}/cubos.hpp | 18 ++++++++---------- .../src/cubos/core/ecs}/cubos.cpp | 10 +++++++--- docs/pages/2_features/plugins.md | 8 ++++---- engine/CMakeLists.txt | 1 - engine/include/cubos/engine/assets/plugin.hpp | 2 +- .../include/cubos/engine/collisions/plugin.hpp | 2 +- engine/include/cubos/engine/gizmos/gizmos.hpp | 2 +- engine/include/cubos/engine/gizmos/plugin.hpp | 2 +- engine/include/cubos/engine/imgui/plugin.hpp | 2 +- engine/include/cubos/engine/input/plugin.hpp | 2 +- engine/include/cubos/engine/physics/plugin.hpp | 2 +- .../cubos/engine/physics/plugins/gravity.hpp | 2 +- engine/include/cubos/engine/prelude.hpp | 13 +++++++++++++ engine/include/cubos/engine/scene/plugin.hpp | 2 +- .../cubos/engine/screen_picker/plugin.hpp | 2 +- .../engine/screen_picker/screen_picker.hpp | 2 +- .../include/cubos/engine/settings/plugin.hpp | 2 +- .../cubos/engine/splitscreen/plugin.hpp | 2 +- .../include/cubos/engine/transform/plugin.hpp | 2 +- .../utils/free_camera_controller/plugin.hpp | 2 +- engine/include/cubos/engine/voxels/plugin.hpp | 2 +- engine/include/cubos/engine/window/plugin.hpp | 2 +- engine/samples/events/main.cpp | 2 +- engine/samples/gizmos/main.cpp | 2 +- engine/samples/hello-cubos/main.cpp | 2 +- engine/samples/settings/main.cpp | 2 +- .../engine/collisions/broad_phase/plugin.hpp | 2 +- .../src/cubos/engine/screen_picker/plugin.cpp | 2 +- .../include/tesseratos/debug_camera/plugin.hpp | 2 +- .../tesseratos/entity_inspector/plugin.hpp | 2 +- .../tesseratos/entity_selector/plugin.hpp | 2 +- .../tesseratos/metrics_panel/plugin.hpp | 2 +- tools/tesseratos/include/tesseratos/plugin.hpp | 2 +- .../include/tesseratos/scene_editor/plugin.hpp | 2 +- .../tesseratos/settings_inspector/plugin.hpp | 2 +- .../include/tesseratos/toolbox/plugin.hpp | 2 +- .../tesseratos/transform_gizmo/plugin.hpp | 2 +- .../tesseratos/voxel_palette_editor/plugin.hpp | 2 +- .../tesseratos/world_inspector/plugin.hpp | 2 +- 40 files changed, 67 insertions(+), 52 deletions(-) rename {engine/include/cubos/engine => core/include/cubos/core/ecs}/cubos.hpp (97%) rename {engine/src/cubos/engine => core/src/cubos/core/ecs}/cubos.cpp (93%) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index fb79a8a06..f1f4846b3 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -113,6 +113,7 @@ set(CUBOS_CORE_SOURCE "src/cubos/core/ecs/world.cpp" "src/cubos/core/ecs/command_buffer.cpp" "src/cubos/core/ecs/types.cpp" + "src/cubos/core/ecs/cubos.cpp" "src/cubos/core/geom/box.cpp" "src/cubos/core/geom/capsule.cpp" diff --git a/engine/include/cubos/engine/cubos.hpp b/core/include/cubos/core/ecs/cubos.hpp similarity index 97% rename from engine/include/cubos/engine/cubos.hpp rename to core/include/cubos/core/ecs/cubos.hpp index 5e52c1d4f..5ba6a8ec7 100644 --- a/engine/include/cubos/engine/cubos.hpp +++ b/core/include/cubos/core/ecs/cubos.hpp @@ -12,15 +12,13 @@ #include #include -#include - -namespace cubos::engine +namespace cubos::core::ecs { /// @brief Resource which stores the time since the last iteration of the main loop started. /// /// This resource is added and updated by the @ref Cubos class. /// - /// @ingroup engine + /// @ingroup core-ecs struct DeltaTime { DeltaTime(float value); @@ -32,7 +30,7 @@ namespace cubos::engine /// /// This resource is added by the @ref Cubos class, initially set to true. /// - /// @ingroup engine + /// @ingroup core-ecs struct ShouldQuit { ShouldQuit(bool value); @@ -44,7 +42,7 @@ namespace cubos::engine /// /// This resource is added by the @ref Cubos class. /// - /// @ingroup engine + /// @ingroup core-ecs struct Arguments { Arguments(std::vector value); @@ -53,7 +51,7 @@ namespace cubos::engine }; /// @brief Used to chain configurations related to tags. - /// @ingroup engine + /// @ingroup core-ecs class TagBuilder { public: @@ -87,7 +85,7 @@ namespace cubos::engine }; /// @brief Used to chain configurations related to systems - /// @ingroup engine + /// @ingroup core-ecs class SystemBuilder { public: @@ -126,7 +124,7 @@ namespace cubos::engine /// @brief Represents the engine itself, and exposes the interface with which the game /// developer interacts with. Ties up all the different parts of the engine together. - /// @ingroup engine + /// @ingroup core-ecs class Cubos final { public: @@ -269,4 +267,4 @@ namespace cubos::engine mStartupDispatcher.addSystem(func); return {mStartupDispatcher, mMainTags}; } -} // namespace cubos::engine +} // namespace cubos::core::ecs diff --git a/engine/src/cubos/engine/cubos.cpp b/core/src/cubos/core/ecs/cubos.cpp similarity index 93% rename from engine/src/cubos/engine/cubos.cpp rename to core/src/cubos/core/ecs/cubos.cpp index 8d4838782..bfeae295a 100644 --- a/engine/src/cubos/engine/cubos.cpp +++ b/core/src/cubos/core/ecs/cubos.cpp @@ -1,12 +1,16 @@ #include #include +#include #include #include -#include - -using namespace cubos::engine; +using cubos::core::ecs::Arguments; +using cubos::core::ecs::Cubos; +using cubos::core::ecs::DeltaTime; +using cubos::core::ecs::ShouldQuit; +using cubos::core::ecs::SystemBuilder; +using cubos::core::ecs::TagBuilder; DeltaTime::DeltaTime(float value) : value(value) diff --git a/docs/pages/2_features/plugins.md b/docs/pages/2_features/plugins.md index f2245e34e..21e225ca5 100644 --- a/docs/pages/2_features/plugins.md +++ b/docs/pages/2_features/plugins.md @@ -19,11 +19,11 @@ An application which just prints `"Hello World!"` and which does absolutely nothing else - not even open a window - would look like this: ```cpp -#include +#include #include -using Cubos = cubos::engine::Cubos; +using cubos::engine::Cubos; void helloWorld() { @@ -56,11 +56,11 @@ If we were to put the hello world functionality on a plugin, the previous example would look like this: ```cpp -#include +#include #include -using Cubos = cubos::engine::Cubos; +using cubos::engine::Cubos; void helloWorld() { diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 46efab826..c70274d91 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -9,7 +9,6 @@ message("# Building engine tests: " ${BUILD_ENGINE_TESTS}) # Set engine source files set(CUBOS_ENGINE_SOURCE - "src/cubos/engine/cubos.cpp" "src/cubos/engine/prelude.cpp" "src/cubos/engine/settings/plugin.cpp" diff --git a/engine/include/cubos/engine/assets/plugin.hpp b/engine/include/cubos/engine/assets/plugin.hpp index ae3a7a959..1072f6185 100644 --- a/engine/include/cubos/engine/assets/plugin.hpp +++ b/engine/include/cubos/engine/assets/plugin.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/collisions/plugin.hpp b/engine/include/cubos/engine/collisions/plugin.hpp index cfe101991..4179d5705 100644 --- a/engine/include/cubos/engine/collisions/plugin.hpp +++ b/engine/include/cubos/engine/collisions/plugin.hpp @@ -13,7 +13,7 @@ #pragma once -#include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/gizmos/gizmos.hpp b/engine/include/cubos/engine/gizmos/gizmos.hpp index 6035940ea..cd632d625 100644 --- a/engine/include/cubos/engine/gizmos/gizmos.hpp +++ b/engine/include/cubos/engine/gizmos/gizmos.hpp @@ -11,7 +11,7 @@ #include -#include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/gizmos/plugin.hpp b/engine/include/cubos/engine/gizmos/plugin.hpp index 1efdd6c3d..b048f24a0 100644 --- a/engine/include/cubos/engine/gizmos/plugin.hpp +++ b/engine/include/cubos/engine/gizmos/plugin.hpp @@ -7,8 +7,8 @@ #pragma once -#include #include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/imgui/plugin.hpp b/engine/include/cubos/engine/imgui/plugin.hpp index 6bcffe34b..29ba59edf 100644 --- a/engine/include/cubos/engine/imgui/plugin.hpp +++ b/engine/include/cubos/engine/imgui/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/input/plugin.hpp b/engine/include/cubos/engine/input/plugin.hpp index 9d32f86d1..e38fcfdef 100644 --- a/engine/include/cubos/engine/input/plugin.hpp +++ b/engine/include/cubos/engine/input/plugin.hpp @@ -7,8 +7,8 @@ #pragma once -#include #include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/physics/plugin.hpp b/engine/include/cubos/engine/physics/plugin.hpp index 0f46aff55..4ffe6bb0d 100644 --- a/engine/include/cubos/engine/physics/plugin.hpp +++ b/engine/include/cubos/engine/physics/plugin.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -21,6 +20,7 @@ #include #include #include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/physics/plugins/gravity.hpp b/engine/include/cubos/engine/physics/plugins/gravity.hpp index 30bb1a2f8..084ccb9e8 100644 --- a/engine/include/cubos/engine/physics/plugins/gravity.hpp +++ b/engine/include/cubos/engine/physics/plugins/gravity.hpp @@ -4,10 +4,10 @@ #pragma once -#include #include #include #include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/prelude.hpp b/engine/include/cubos/engine/prelude.hpp index bfb525fac..4e4309770 100644 --- a/engine/include/cubos/engine/prelude.hpp +++ b/engine/include/cubos/engine/prelude.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -8,6 +9,18 @@ namespace cubos::engine { + /// @copydoc cubos::core::ecs::Cubos + using Cubos = core::ecs::Cubos; + + /// @copydoc cubos::core::ecs::DeltaTime + using DeltaTime = core::ecs::DeltaTime; + + /// @copydoc cubos::core::ecs::ShouldQuit + using ShouldQuit = core::ecs::ShouldQuit; + + /// @copydoc cubos::core::ecs::Arguments + using Arguments = core::ecs::Arguments; + /// @copydoc cubos::core::ecs::Query template using Query = core::ecs::Query; diff --git a/engine/include/cubos/engine/scene/plugin.hpp b/engine/include/cubos/engine/scene/plugin.hpp index aa12c15e2..7e8dc7c99 100644 --- a/engine/include/cubos/engine/scene/plugin.hpp +++ b/engine/include/cubos/engine/scene/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include #include namespace cubos::engine diff --git a/engine/include/cubos/engine/screen_picker/plugin.hpp b/engine/include/cubos/engine/screen_picker/plugin.hpp index 81ec7b37e..ca3b25641 100644 --- a/engine/include/cubos/engine/screen_picker/plugin.hpp +++ b/engine/include/cubos/engine/screen_picker/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include #include namespace cubos::engine diff --git a/engine/include/cubos/engine/screen_picker/screen_picker.hpp b/engine/include/cubos/engine/screen_picker/screen_picker.hpp index 73823a34f..8fadc14a9 100644 --- a/engine/include/cubos/engine/screen_picker/screen_picker.hpp +++ b/engine/include/cubos/engine/screen_picker/screen_picker.hpp @@ -6,7 +6,7 @@ #include -#include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/settings/plugin.hpp b/engine/include/cubos/engine/settings/plugin.hpp index 9a0805020..c79d69290 100644 --- a/engine/include/cubos/engine/settings/plugin.hpp +++ b/engine/include/cubos/engine/settings/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include #include namespace cubos::engine diff --git a/engine/include/cubos/engine/splitscreen/plugin.hpp b/engine/include/cubos/engine/splitscreen/plugin.hpp index 5e0b7147f..ace4f11e2 100644 --- a/engine/include/cubos/engine/splitscreen/plugin.hpp +++ b/engine/include/cubos/engine/splitscreen/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/transform/plugin.hpp b/engine/include/cubos/engine/transform/plugin.hpp index 57103e671..70880f720 100644 --- a/engine/include/cubos/engine/transform/plugin.hpp +++ b/engine/include/cubos/engine/transform/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include diff --git a/engine/include/cubos/engine/utils/free_camera_controller/plugin.hpp b/engine/include/cubos/engine/utils/free_camera_controller/plugin.hpp index c841e30c9..894312e2c 100644 --- a/engine/include/cubos/engine/utils/free_camera_controller/plugin.hpp +++ b/engine/include/cubos/engine/utils/free_camera_controller/plugin.hpp @@ -9,9 +9,9 @@ #include -#include #include #include +#include #include #include #include diff --git a/engine/include/cubos/engine/voxels/plugin.hpp b/engine/include/cubos/engine/voxels/plugin.hpp index 548a63dac..a5c29c805 100644 --- a/engine/include/cubos/engine/voxels/plugin.hpp +++ b/engine/include/cubos/engine/voxels/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace cubos::engine { diff --git a/engine/include/cubos/engine/window/plugin.hpp b/engine/include/cubos/engine/window/plugin.hpp index b7d683a06..de60a26b1 100644 --- a/engine/include/cubos/engine/window/plugin.hpp +++ b/engine/include/cubos/engine/window/plugin.hpp @@ -9,7 +9,7 @@ #include -#include +#include namespace cubos::engine { diff --git a/engine/samples/events/main.cpp b/engine/samples/events/main.cpp index 219deaf84..049231d8c 100644 --- a/engine/samples/events/main.cpp +++ b/engine/samples/events/main.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include using namespace cubos::engine; diff --git a/engine/samples/gizmos/main.cpp b/engine/samples/gizmos/main.cpp index 2362b81f3..2267b094b 100644 --- a/engine/samples/gizmos/main.cpp +++ b/engine/samples/gizmos/main.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include #include diff --git a/engine/samples/hello-cubos/main.cpp b/engine/samples/hello-cubos/main.cpp index c5c5a6078..70d033af3 100644 --- a/engine/samples/hello-cubos/main.cpp +++ b/engine/samples/hello-cubos/main.cpp @@ -3,7 +3,7 @@ /// [Include Components] /// [Include] -#include +#include using cubos::engine::Cubos; /// [Include] diff --git a/engine/samples/settings/main.cpp b/engine/samples/settings/main.cpp index d9813892e..658b54661 100644 --- a/engine/samples/settings/main.cpp +++ b/engine/samples/settings/main.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include using namespace cubos::engine; diff --git a/engine/src/cubos/engine/collisions/broad_phase/plugin.hpp b/engine/src/cubos/engine/collisions/broad_phase/plugin.hpp index 42be4d8da..049190f00 100644 --- a/engine/src/cubos/engine/collisions/broad_phase/plugin.hpp +++ b/engine/src/cubos/engine/collisions/broad_phase/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace cubos::engine { diff --git a/engine/src/cubos/engine/screen_picker/plugin.cpp b/engine/src/cubos/engine/screen_picker/plugin.cpp index dd987d010..730267661 100644 --- a/engine/src/cubos/engine/screen_picker/plugin.cpp +++ b/engine/src/cubos/engine/screen_picker/plugin.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include diff --git a/tools/tesseratos/include/tesseratos/debug_camera/plugin.hpp b/tools/tesseratos/include/tesseratos/debug_camera/plugin.hpp index bb33b55aa..b9921d8ca 100644 --- a/tools/tesseratos/include/tesseratos/debug_camera/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/debug_camera/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/entity_inspector/plugin.hpp b/tools/tesseratos/include/tesseratos/entity_inspector/plugin.hpp index ed8074ca0..138e6c9a0 100644 --- a/tools/tesseratos/include/tesseratos/entity_inspector/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/entity_inspector/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/entity_selector/plugin.hpp b/tools/tesseratos/include/tesseratos/entity_selector/plugin.hpp index 266ecf4fd..74e1c9d20 100644 --- a/tools/tesseratos/include/tesseratos/entity_selector/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/entity_selector/plugin.hpp @@ -9,7 +9,7 @@ #include -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/metrics_panel/plugin.hpp b/tools/tesseratos/include/tesseratos/metrics_panel/plugin.hpp index bbfa91932..b67e5d8c4 100644 --- a/tools/tesseratos/include/tesseratos/metrics_panel/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/metrics_panel/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/plugin.hpp b/tools/tesseratos/include/tesseratos/plugin.hpp index 8a33baef0..811640ff5 100644 --- a/tools/tesseratos/include/tesseratos/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include /// @brief @ref tesseratos module. namespace tesseratos diff --git a/tools/tesseratos/include/tesseratos/scene_editor/plugin.hpp b/tools/tesseratos/include/tesseratos/scene_editor/plugin.hpp index 1b25f6b98..cdaffd323 100644 --- a/tools/tesseratos/include/tesseratos/scene_editor/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/scene_editor/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/settings_inspector/plugin.hpp b/tools/tesseratos/include/tesseratos/settings_inspector/plugin.hpp index b82a8514b..55f5b617b 100644 --- a/tools/tesseratos/include/tesseratos/settings_inspector/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/settings_inspector/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/toolbox/plugin.hpp b/tools/tesseratos/include/tesseratos/toolbox/plugin.hpp index 0f8bc271a..c63364dca 100644 --- a/tools/tesseratos/include/tesseratos/toolbox/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/toolbox/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/transform_gizmo/plugin.hpp b/tools/tesseratos/include/tesseratos/transform_gizmo/plugin.hpp index 7aff7e1c8..5c9432a0e 100644 --- a/tools/tesseratos/include/tesseratos/transform_gizmo/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/transform_gizmo/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/voxel_palette_editor/plugin.hpp b/tools/tesseratos/include/tesseratos/voxel_palette_editor/plugin.hpp index 91581c7c9..1175db081 100644 --- a/tools/tesseratos/include/tesseratos/voxel_palette_editor/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/voxel_palette_editor/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos { diff --git a/tools/tesseratos/include/tesseratos/world_inspector/plugin.hpp b/tools/tesseratos/include/tesseratos/world_inspector/plugin.hpp index 2ae0e2708..8dfe5eb07 100644 --- a/tools/tesseratos/include/tesseratos/world_inspector/plugin.hpp +++ b/tools/tesseratos/include/tesseratos/world_inspector/plugin.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace tesseratos {