Skip to content

Commit

Permalink
refactor(tools): move most tools to the engine
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 29, 2024
1 parent f19856a commit f51baee
Show file tree
Hide file tree
Showing 60 changed files with 705 additions and 832 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Moved Glad and stb-image libs to another repositories, cubos-glad and cubos-stb, respectively (#1323, **@kuukitenshi**).
- Moved most tools from Tesseratos to the engine (#1322, **@RiscadoA**).

### Fixed

Expand Down
16 changes: 16 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ set(CUBOS_ENGINE_SOURCE
"src/render/shadow_atlas/shadow_atlas.cpp"
"src/render/shadow_atlas_rasterizer/plugin.cpp"
"src/render/shadow_atlas_rasterizer/shadow_atlas_rasterizer.cpp"

"src/tools/settings_inspector/plugin.cpp"
"src/tools/selection/plugin.cpp"
"src/tools/selection/selection.cpp"
"src/tools/world_inspector/plugin.cpp"
"src/tools/entity_inspector/plugin.cpp"
"src/tools/debug_camera/plugin.cpp"
"src/tools/toolbox/plugin.cpp"
"src/tools/toolbox/toolbox.cpp"
"src/tools/transform_gizmo/plugin.cpp"
"src/tools/metrics_panel/plugin.cpp"
"src/tools/collider_gizmos/plugin.cpp"
"src/tools/play_pause/plugin.cpp"
"src/tools/ecs_statistics/plugin.cpp"
"src/tools/console/plugin.cpp"
"src/tools/plugin.cpp"
)

# Create cubos engine
Expand Down
23 changes: 23 additions & 0 deletions engine/include/cubos/engine/tools/collider_gizmos/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// @dir
/// @brief @ref collider-gizmos-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup collider-gizmos-tool-plugin

#pragma once

#include <cubos/engine/api.hpp>
#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup collider-gizmos-tool-plugin Collider Gizmos
/// @ingroup tool-plugins
/// @brief Draws gizmos for colliders of selected entities.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup collider-gizmos-tool-plugin
CUBOS_ENGINE_API void colliderGizmosPlugin(Cubos& cubos);
} // namespace cubos::engine
22 changes: 22 additions & 0 deletions engine/include/cubos/engine/tools/console/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref console-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup console-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup console-tool-plugin Console
/// @ingroup tool-plugins
/// @brief Displays the log messages in an ImGui window.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup console-tool-plugin
void consolePlugin(Cubos& cubos);
} // namespace cubos::engine
22 changes: 22 additions & 0 deletions engine/include/cubos/engine/tools/debug_camera/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref debug-camera-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup debug-camera-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup debug-camera-tool-plugin Debug Camera
/// @ingroup tool-plugins
/// @brief Adds a toggleable debug camera.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup debug-camera-tool-plugin
void debugCameraPlugin(Cubos& cubos);
} // namespace cubos::engine
22 changes: 22 additions & 0 deletions engine/include/cubos/engine/tools/ecs_statistics/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref ecs-statistics-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup ecs-statistics-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup ecs-statistics-tool-plugin ECS Statistics
/// @ingroup tool-plugins
/// @brief Shows tons of statistics and information about the internal state of the ECS.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup ecs-statistics-tool-plugin
void ecsStatisticsPlugin(Cubos& cubos);
} // namespace cubos::engine
22 changes: 22 additions & 0 deletions engine/include/cubos/engine/tools/entity_inspector/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref entity-inspector-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup entity-inspector-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup entity-inspector-tool-plugin Entity Inspector
/// @ingroup tool-plugins
/// @brief Allows inspecting and modifying the components of the current @ref Selection.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup entity-inspector-tool-plugin
void entityInspectorPlugin(Cubos& cubos);
} // namespace cubos::engine
22 changes: 22 additions & 0 deletions engine/include/cubos/engine/tools/metrics_panel/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref metrics-panel-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup metrics-panel-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup metrics-panel-tool-plugin Metrics Panel
/// @ingroup tool-plugins
/// @brief Shows some useful performance metrics through a ImGui window.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup metrics-panel-tool-plugin
void metricsPanelPlugin(Cubos& cubos);
} // namespace cubos::engine
22 changes: 22 additions & 0 deletions engine/include/cubos/engine/tools/play_pause/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref play-pause-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup play-pause-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup play-pause-tool-plugin Play Pause
/// @ingroup tool-plugins
/// @brief Allows changing the current simulation speed, or even pause it.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup play-pause-tool-plugin
void playPauseToolPlugin(Cubos& cubos);
} // namespace cubos::engine
24 changes: 24 additions & 0 deletions engine/include/cubos/engine/tools/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// @dir
/// @brief @ref tool-plugins module.

/// @file
/// @brief Plugin entry point.
/// @ingroup tool-plugins

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup tool-plugins Tools
/// @ingroup engine
/// @brief Adds various debugging tool plugins.
///
/// Most of these tools provide their own ImGui windows which can be toggled with the @ref toolbox-plugin.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup tool-plugins
void toolsPlugin(Cubos& cubos);
} // namespace cubos::engine
28 changes: 28 additions & 0 deletions engine/include/cubos/engine/tools/selection/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// @dir
/// @brief @ref selection-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup selection-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>
#include <cubos/engine/tools/selection/selection.hpp>

namespace cubos::engine
{
/// @defgroup selection-tool-plugin Selection
/// @ingroup tool-plugins
/// @brief Adds a resource which keeps track of what the current selection is.
///
/// This plugins exists to reduce coupling between plugins. For example, a plugin which allows
/// selecting entities through a ImGui window only needs to depend on this plugin, instead of
/// having to know about all the plugins which care about it. The same applies in the other
/// direction.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup selection-tool-plugin
void selectionPlugin(Cubos& cubos);
} // namespace cubos::engine
19 changes: 19 additions & 0 deletions engine/include/cubos/engine/tools/selection/selection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// @file
/// @brief Resource @ref cubos::engine::Selection.
/// @ingroup selection-tool-plugin

#pragma once

#include <cubos/core/ecs/entity/entity.hpp>

namespace cubos::engine
{
/// @brief Resource which identifies the current selection.
/// @ingroup selection-tool-plugin
struct Selection
{
CUBOS_REFLECT;

cubos::core::ecs::Entity entity; ///< Selected entity, or null if none.
};
} // namespace cubos::engine
22 changes: 22 additions & 0 deletions engine/include/cubos/engine/tools/settings_inspector/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref settings-inspector-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup settings-inspector-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace cubos::engine
{
/// @defgroup settings-inspector-tool-plugin Settings Inspector
/// @ingroup tool-plugins
/// @brief Allows inspecting the current setting values through a ImGui window.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup settings-inspector-tool-plugin
void settingsInspectorPlugin(Cubos& cubos);
} // namespace cubos::engine
26 changes: 26 additions & 0 deletions engine/include/cubos/engine/tools/toolbox/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// @dir
/// @brief @ref toolbox-tool-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup toolbox-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>
#include <cubos/engine/tools/toolbox/toolbox.hpp>

namespace cubos::engine
{
/// @defgroup toolbox-tool-plugin Toolbox
/// @ingroup tool-plugins
/// @brief Allows toggling the visibility of other tools.
///
/// Most tools in the @ref tool-plugins module rely on the @ref Toolbox to keep track of whether they are open or
/// not.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup toolbox-tool-plugin
void toolboxPlugin(Cubos& cubos);
} // namespace cubos::engine
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
/// @dir
/// @brief @ref tesseratos-toolbox-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup tesseratos-toolbox-plugin
/// @brief Resource @ref cubos::engine::Toolbox.
/// @ingroup toolbox-tool-plugin

#pragma once

#include <cubos/engine/prelude.hpp>

namespace tesseratos
namespace cubos::engine
{
/// @defgroup tesseratos-toolbox-plugin Toolbox
/// @ingroup tesseratos
/// @brief Adds a resource used to keep track of whether each tool is open or not.
///
/// ## Resources
/// - @ref Toolbox
///
/// ## Dependencies
/// - @ref imguiPlugin

/// @brief Resource which manages other tools windows.
/// @ingroup tesseratos-toolbox-plugin
/// @brief Manages the visibility of each tool.
/// @ingroup toolbox-tool-plugin
class Toolbox final
{
public:
Expand All @@ -45,8 +32,8 @@ namespace tesseratos
/// @param toolName Tool name.
void toggle(const std::string& toolName);

/// @brief Returns the beggining of the map with known tools.
/// @return Begginng of the map.
/// @brief Returns the beginning of the map with known tools.
/// @return Beginning of the map.
auto begin() const
{
return mToolsMap.begin();
Expand All @@ -62,9 +49,4 @@ namespace tesseratos
private:
std::unordered_map<std::string, bool> mToolsMap;
};

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup tesseratos-toolbox-plugin
void toolboxPlugin(cubos::engine::Cubos& cubos);
} // namespace tesseratos
} // namespace cubos::engine
Loading

0 comments on commit f51baee

Please sign in to comment.