diff --git a/README.md b/README.md index 6305f7a..666327e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ec1d9f614fdf4d5b8effa6b7b72b3d5e)](https://www.codacy.com/gh/antkeeper/antkeeper-source/dashboard?utm_source=github.com&utm_medium=referral&utm_content=antkeeper/antkeeper-source&utm_campaign=Badge_Grade) + # Antkeeper Source Antkeeper is a 3D ant colony simulation game currently in development for Windows, Mac, and Linux. This repository contains all of the source code to Antkeeper. diff --git a/src/engine/app/display-events.hpp b/src/engine/app/display-events.hpp index 612ba8c..e299040 100644 --- a/src/engine/app/display-events.hpp +++ b/src/engine/app/display-events.hpp @@ -32,7 +32,7 @@ class display; struct display_connected_event { /// Pointer to the display that has been connected. - const display* display; + const display* display{nullptr}; }; /** @@ -41,7 +41,7 @@ struct display_connected_event struct display_disconnected_event { /// Pointer to the display that has been disconnected. - const display* display; + const display* display{nullptr}; }; /** @@ -50,10 +50,10 @@ struct display_disconnected_event struct display_orientation_changed_event { /// Pointer to the display that has had it's orientation changed. - const display* display; + const display* display{nullptr}; /// Orientation of the display. - display_orientation orientation; + display_orientation orientation{0}; }; } // namespace app diff --git a/src/engine/app/display.hpp b/src/engine/app/display.hpp index 8cb1a2a..c6d0e0e 100644 --- a/src/engine/app/display.hpp +++ b/src/engine/app/display.hpp @@ -172,14 +172,14 @@ private: friend class window_manager; friend class sdl_window_manager; - int index; + int index{0}; std::string name; - geom::primitive::rectangle bounds; - geom::primitive::rectangle usable_bounds; - int refresh_rate; - float dpi; - display_orientation orientation; - bool connected; + geom::primitive::rectangle bounds{0}; + geom::primitive::rectangle usable_bounds{0}; + int refresh_rate{0}; + float dpi{0.0f}; + display_orientation orientation{0}; + bool connected{false}; event::publisher connected_publisher; event::publisher disconnected_publisher; diff --git a/src/engine/app/window-events.hpp b/src/engine/app/window-events.hpp index be5af71..8074663 100644 --- a/src/engine/app/window-events.hpp +++ b/src/engine/app/window-events.hpp @@ -32,7 +32,7 @@ class window; struct window_closed_event { /// Pointer to the window that has been requested to close. - window* window; + window* window{nullptr}; }; /** @@ -41,10 +41,10 @@ struct window_closed_event struct window_focus_changed_event { /// Pointer to the window that has gained or lost focus. - window* window; + window* window{nullptr}; /// `true` if the window is in focus, `false` otherwise. - bool in_focus; + bool in_focus{false}; }; /** @@ -53,10 +53,10 @@ struct window_focus_changed_event struct window_moved_event { /// Pointer to the window that has been moved. - window* window; + window* window{nullptr}; /// Position of the window, in display units. - math::vector position; + math::vector position{0, 0}; }; /** @@ -65,7 +65,7 @@ struct window_moved_event struct window_maximized_event { /// Pointer to the window that has been maximized. - window* window; + window* window{nullptr}; }; /** @@ -74,7 +74,7 @@ struct window_maximized_event struct window_minimized_event { /// Pointer to the window that has been minimized. - window* window; + window* window{nullptr}; }; /** @@ -92,10 +92,10 @@ struct window_restored_event struct window_resized_event { /// Pointer to the window that has been resized. - window* window; + window* window{nullptr}; /// Window size, in display units. - math::vector size; + math::vector size{0, 0}; }; } // namespace app diff --git a/src/engine/app/window.hpp b/src/engine/app/window.hpp index da5c49f..4075616 100644 --- a/src/engine/app/window.hpp +++ b/src/engine/app/window.hpp @@ -36,16 +36,6 @@ class window_manager; class window { public: - /** - * Constructs a window. - */ - window() = default; - - /** - * Destructs a window. - */ - virtual ~window() = default; - /** * Changes the title of the window. * @@ -227,16 +217,16 @@ protected: friend class window_manager; std::string title; - math::vector windowed_position; - math::vector position; - math::vector windowed_size; - math::vector size; - math::vector minimum_size; - math::vector maximum_size; - math::vector viewport_size; - bool maximized; - bool fullscreen; - bool v_sync; + math::vector windowed_position{0, 0}; + math::vector position{0, 0}; + math::vector windowed_size{0, 0}; + math::vector size{0, 0}; + math::vector minimum_size{0, 0}; + math::vector maximum_size{0, 0}; + math::vector viewport_size{0, 0}; + bool maximized{false}; + bool fullscreen{false}; + bool v_sync{false}; event::publisher closed_publisher; event::publisher focus_changed_publisher; diff --git a/src/engine/gl/framebuffer.cpp b/src/engine/gl/framebuffer.cpp index cf5fe56..98fb3f5 100644 --- a/src/engine/gl/framebuffer.cpp +++ b/src/engine/gl/framebuffer.cpp @@ -31,21 +31,13 @@ static constexpr GLenum attachment_lut[] = }; framebuffer::framebuffer(int width, int height): - gl_framebuffer_id(0), - dimensions({width, height}), - color_attachment(nullptr), - depth_attachment(nullptr), - stencil_attachment(nullptr) + dimensions{width, height} { glGenFramebuffers(1, &gl_framebuffer_id); } framebuffer::framebuffer(): - gl_framebuffer_id(0), - dimensions({0, 0}), - color_attachment(nullptr), - depth_attachment(nullptr), - stencil_attachment(nullptr) + framebuffer(0, 0) {} framebuffer::~framebuffer() diff --git a/src/engine/gl/framebuffer.hpp b/src/engine/gl/framebuffer.hpp index 39ee243..691ce23 100644 --- a/src/engine/gl/framebuffer.hpp +++ b/src/engine/gl/framebuffer.hpp @@ -75,11 +75,11 @@ public: private: friend class rasterizer; - unsigned int gl_framebuffer_id; - std::array dimensions; - texture_2d* color_attachment; - texture_2d* depth_attachment; - texture_2d* stencil_attachment; + unsigned int gl_framebuffer_id{0}; + std::array dimensions{0, 0}; + texture_2d* color_attachment{nullptr}; + texture_2d* depth_attachment{nullptr}; + texture_2d* stencil_attachment{nullptr}; }; inline const std::array& framebuffer::get_dimensions() const diff --git a/src/engine/gl/rasterizer.hpp b/src/engine/gl/rasterizer.hpp index 6372a3d..547e767 100644 --- a/src/engine/gl/rasterizer.hpp +++ b/src/engine/gl/rasterizer.hpp @@ -129,9 +129,9 @@ public: private: std::unique_ptr default_framebuffer; - const framebuffer* bound_framebuffer; - const vertex_array* bound_vao; - const shader_program* bound_shader_program; + const framebuffer* bound_framebuffer{nullptr}; + const vertex_array* bound_vao{nullptr}; + const shader_program* bound_shader_program{nullptr}; }; } // namespace gl diff --git a/src/engine/gl/shader-object.hpp b/src/engine/gl/shader-object.hpp index 8144861..044c82b 100644 --- a/src/engine/gl/shader-object.hpp +++ b/src/engine/gl/shader-object.hpp @@ -99,7 +99,7 @@ private: friend class shader_program; unsigned int gl_shader_id{0}; - shader_stage m_stage; + shader_stage m_stage{0}; bool m_compiled{false}; std::string info_log; }; diff --git a/src/engine/gl/shader-variable.hpp b/src/engine/gl/shader-variable.hpp index 5158a2d..e5dde56 100644 --- a/src/engine/gl/shader-variable.hpp +++ b/src/engine/gl/shader-variable.hpp @@ -39,11 +39,6 @@ class texture_cube; class shader_variable { public: - /** - * Destructs a shader variable. - */ - virtual ~shader_variable() = default; - /** * Returns the shader variable data type. */ @@ -187,7 +182,7 @@ protected: explicit shader_variable(std::size_t size) noexcept; private: - const std::size_t m_size; + const std::size_t m_size{0}; }; } // namespace gl diff --git a/src/engine/gl/texture-cube.hpp b/src/engine/gl/texture-cube.hpp index a95191c..5fc4d80 100644 --- a/src/engine/gl/texture-cube.hpp +++ b/src/engine/gl/texture-cube.hpp @@ -41,8 +41,8 @@ public: /// Returns the linear size of a cube face, in pixels. int get_face_size() const; - unsigned int gl_texture_id; - int face_size; + unsigned int gl_texture_id{0}; + int face_size{0}; }; inline int texture_cube::get_face_size() const diff --git a/src/engine/gl/texture.hpp b/src/engine/gl/texture.hpp index 9bc8f03..38f4bc9 100644 --- a/src/engine/gl/texture.hpp +++ b/src/engine/gl/texture.hpp @@ -153,15 +153,15 @@ private: friend class gl_shader_texture_3d; friend class gl_shader_texture_cube; - unsigned int gl_texture_target; - unsigned int gl_texture_id; - std::array dimensions; - gl::pixel_type pixel_type; - gl::pixel_format pixel_format; - gl::color_space color_space; + unsigned int gl_texture_target{0}; + unsigned int gl_texture_id{0}; + std::array dimensions{0, 0, 0}; + gl::pixel_type pixel_type{0}; + gl::pixel_format pixel_format{0}; + gl::color_space color_space{0}; std::array wrapping; std::tuple filters; - float max_anisotropy; + float max_anisotropy{0.0f}; }; inline const std::array& texture::get_dimensions() const diff --git a/src/engine/gl/vertex-attribute.hpp b/src/engine/gl/vertex-attribute.hpp index 5c9673b..41db4bf 100644 --- a/src/engine/gl/vertex-attribute.hpp +++ b/src/engine/gl/vertex-attribute.hpp @@ -49,19 +49,19 @@ enum class vertex_attribute_type: std::uint8_t struct vertex_attribute { /// Pointer to the vertex buffer containing vertex attribute data. - const vertex_buffer* buffer; + const vertex_buffer* buffer{nullptr}; /// Offset to the first component of the first instance of this attribute in the vertex buffer, in bytes. - std::size_t offset; + std::size_t offset{0}; /// Number of bytes between consecutive instances of this attribute in the vertex buffer. A value of `0` indicates attribute instances are tightly packed. - std::size_t stride; + std::size_t stride{0}; /// Data type of each component in the attribute. - vertex_attribute_type type; + vertex_attribute_type type{0}; /// Number of components per attribute instance. Supported values are `1`, `2`, `3`, and `4`. - std::uint8_t components; + std::uint8_t components{0}; }; } // namespace gl diff --git a/src/engine/input/action-events.hpp b/src/engine/input/action-events.hpp index a9860c9..8c2da93 100644 --- a/src/engine/input/action-events.hpp +++ b/src/engine/input/action-events.hpp @@ -30,7 +30,7 @@ class action; struct action_activated_event { /// Control that was activated. - action* action; + action* action{nullptr}; }; /** @@ -39,10 +39,10 @@ struct action_activated_event struct action_active_event { /// Active action. - action* action; + action* action{nullptr}; /// Control input value. - float input_value; + float input_value{0.0f}; }; /** @@ -51,7 +51,7 @@ struct action_active_event struct action_deactivated_event { /// Control that was deactivated. - action* action; + action* action{nullptr}; }; } // namespace input diff --git a/src/engine/input/action-map.cpp b/src/engine/input/action-map.cpp index 728df9e..329b6b2 100644 --- a/src/engine/input/action-map.cpp +++ b/src/engine/input/action-map.cpp @@ -25,11 +25,6 @@ namespace input { -action_map::action_map(): - event_queue(nullptr), - enabled(false) -{} - void action_map::enable() { if (!enabled) diff --git a/src/engine/input/action-map.hpp b/src/engine/input/action-map.hpp index 3e3b35f..b7cd9db 100644 --- a/src/engine/input/action-map.hpp +++ b/src/engine/input/action-map.hpp @@ -40,11 +40,6 @@ namespace input { class action_map { public: - /** - * Constructs an action map. - */ - action_map(); - /** * Enables the mapping of input events to actions. */ @@ -154,8 +149,8 @@ private: void handle_mouse_moved(const mouse_moved_event& event); void handle_mouse_scrolled(const mouse_scrolled_event& event); - event::queue* event_queue; - bool enabled; + event::queue* event_queue{nullptr}; + bool enabled{false}; std::vector> subscriptions; std::vector> gamepad_axis_mappings; std::vector> gamepad_button_mappings; diff --git a/src/engine/input/action.hpp b/src/engine/input/action.hpp index bd6d836..83174f1 100644 --- a/src/engine/input/action.hpp +++ b/src/engine/input/action.hpp @@ -93,7 +93,7 @@ public: private: threshold_function_type threshold_function; - bool active; + bool active{false}; action_activated_event activated_event; action_active_event active_event; diff --git a/src/engine/input/device-events.hpp b/src/engine/input/device-events.hpp index 15c2a1e..3c02988 100644 --- a/src/engine/input/device-events.hpp +++ b/src/engine/input/device-events.hpp @@ -30,7 +30,7 @@ class device; struct device_connected_event { /// Device that was connected. - device* device; + device* device{nullptr}; }; /** @@ -39,7 +39,7 @@ struct device_connected_event struct device_disconnected_event { /// Device that was disconnected. - device* device; + device* device{nullptr}; }; } // namespace input diff --git a/src/engine/input/device-type.hpp b/src/engine/input/device-type.hpp index b7bc41b..893b842 100644 --- a/src/engine/input/device-type.hpp +++ b/src/engine/input/device-type.hpp @@ -20,10 +20,12 @@ #ifndef ANTKEEPER_INPUT_DEVICE_TYPE_HPP #define ANTKEEPER_INPUT_DEVICE_TYPE_HPP +#include + namespace input { /// Input device types. -enum class device_type +enum class device_type: std::uint8_t { /// Gamepad input device. gamepad, diff --git a/src/engine/input/device.cpp b/src/engine/input/device.cpp index 0a50648..90878c1 100644 --- a/src/engine/input/device.cpp +++ b/src/engine/input/device.cpp @@ -21,10 +21,6 @@ namespace input { -device::device(): - connected(true) -{} - void device::connect() { connected = true; diff --git a/src/engine/input/device.hpp b/src/engine/input/device.hpp index 9bd8ca1..2779e14 100644 --- a/src/engine/input/device.hpp +++ b/src/engine/input/device.hpp @@ -35,12 +35,6 @@ namespace input { class device { public: - /// Constructs an input device. - device(); - - /// Destructs an input device. - virtual ~device() = default; - /** * Simulates the device being connected. */ @@ -89,7 +83,7 @@ public: private: ::uuid uuid; - bool connected; + bool connected{false}; ::event::publisher connected_publisher; ::event::publisher disconnected_publisher; diff --git a/src/engine/input/gamepad-events.hpp b/src/engine/input/gamepad-events.hpp index 84c3ce0..b56cc31 100644 --- a/src/engine/input/gamepad-events.hpp +++ b/src/engine/input/gamepad-events.hpp @@ -33,10 +33,10 @@ class gamepad; struct gamepad_button_pressed_event { /// Gamepad that generated the event. - gamepad* gamepad; + gamepad* gamepad{nullptr}; /// Gamepad button being pressed. - gamepad_button button; + gamepad_button button{0}; }; /** @@ -45,10 +45,10 @@ struct gamepad_button_pressed_event struct gamepad_button_released_event { /// Gamepad that generated the event. - gamepad* gamepad; + gamepad* gamepad{nullptr}; /// Gamepad button being released. - gamepad_button button; + gamepad_button button{0}; }; /** @@ -57,13 +57,13 @@ struct gamepad_button_released_event struct gamepad_axis_moved_event { /// Gamepad that generated the event. - gamepad* gamepad; + gamepad* gamepad{nullptr}; /// Gamepad axis being moved. - gamepad_axis axis; + gamepad_axis axis{0}; /// Position of the gamepad axis, on `[-1, 1]`. - float position; + float position{0.0f}; }; } // namespace input diff --git a/src/engine/input/gamepad.cpp b/src/engine/input/gamepad.cpp index 7084c1b..619a8e3 100644 --- a/src/engine/input/gamepad.cpp +++ b/src/engine/input/gamepad.cpp @@ -25,11 +25,7 @@ namespace input { -gamepad::gamepad(): - left_deadzone_cross(true), - right_deadzone_cross(true), - left_deadzone_roundness(0.0f), - right_deadzone_roundness(0.0f) +gamepad::gamepad() { for (int i = 0; i < 6; ++i) { diff --git a/src/engine/input/gamepad.hpp b/src/engine/input/gamepad.hpp index 1b64670..a045664 100644 --- a/src/engine/input/gamepad.hpp +++ b/src/engine/input/gamepad.hpp @@ -25,11 +25,12 @@ #include #include #include +#include namespace input { /// Gamepad axis activation response curves. -enum class gamepad_response_curve +enum class gamepad_response_curve: std::uint8_t { /// Linear response curve. linear, @@ -52,9 +53,6 @@ public: */ gamepad(); - /// Destructs a gamepad input device. - virtual ~gamepad() = default; - /** * Sets the activation threshold for a gamepad axis. * @@ -141,7 +139,7 @@ public: } /// Returns device_type::gamepad. - [[nodiscard]] inline virtual constexpr device_type get_device_type() const noexcept + [[nodiscard]] inline constexpr device_type get_device_type() const noexcept override { return device_type::gamepad; } @@ -155,10 +153,10 @@ private: float axis_activation_min[6]; float axis_activation_max[6]; gamepad_response_curve axis_response_curves[6]; - bool left_deadzone_cross; - bool right_deadzone_cross; - float left_deadzone_roundness; - float right_deadzone_roundness; + bool left_deadzone_cross{true}; + bool right_deadzone_cross{true}; + float left_deadzone_roundness{0.0f}; + float right_deadzone_roundness{0.0f}; ::event::publisher button_pressed_publisher; ::event::publisher button_released_publisher; diff --git a/src/engine/input/keyboard-events.hpp b/src/engine/input/keyboard-events.hpp index bddafc8..5bd39a2 100644 --- a/src/engine/input/keyboard-events.hpp +++ b/src/engine/input/keyboard-events.hpp @@ -34,16 +34,16 @@ class keyboard; struct key_pressed_event { /// Keyboard that generated the event. - keyboard* keyboard; + keyboard* keyboard{nullptr}; /// Scancode of the key being pressed. - scancode scancode; + scancode scancode{0}; /// Bit mask containing the active modifier keys. - std::uint16_t modifiers; + std::uint16_t modifiers{0}; /// `true` if the key press was generated by a key repeat, `false` otherwise. - bool repeat; + bool repeat{false}; }; /** @@ -52,13 +52,13 @@ struct key_pressed_event struct key_released_event { /// Keyboard that generated the event. - keyboard* keyboard; + keyboard* keyboard{nullptr}; /// Scancode of the key being released. - scancode scancode; + scancode scancode{0}; /// Bit mask containing the active modifier keys. - std::uint16_t modifiers; + std::uint16_t modifiers{0}; }; } // namespace input diff --git a/src/engine/input/keyboard.hpp b/src/engine/input/keyboard.hpp index cbf28ff..c33bf8c 100644 --- a/src/engine/input/keyboard.hpp +++ b/src/engine/input/keyboard.hpp @@ -34,14 +34,6 @@ namespace input { class keyboard: public device { public: - /** - * Constructs a keyboard input device. - */ - keyboard() = default; - - /// Destructs a keyboard input device. - virtual ~keyboard() = default; - /** * Simulates a key press. * @@ -72,7 +64,7 @@ public: } /// Returns device_type::keyboard. - [[nodiscard]] inline virtual constexpr device_type get_device_type() const noexcept + [[nodiscard]] inline constexpr device_type get_device_type() const noexcept override { return device_type::keyboard; } diff --git a/src/engine/input/mapping.cpp b/src/engine/input/mapping.cpp index 03302dd..d3f635b 100644 --- a/src/engine/input/mapping.cpp +++ b/src/engine/input/mapping.cpp @@ -26,38 +26,38 @@ namespace input { gamepad_axis_mapping::gamepad_axis_mapping(input::gamepad* gamepad, gamepad_axis axis, bool direction): - gamepad(gamepad), - axis(axis), - direction(direction) + gamepad{gamepad}, + axis{axis}, + direction{direction} {} gamepad_button_mapping::gamepad_button_mapping(input::gamepad* gamepad, gamepad_button button): - gamepad(gamepad), - button(button) + gamepad{gamepad}, + button{button} {} key_mapping::key_mapping(input::keyboard* keyboard, input::scancode scancode, std::uint16_t modifiers, bool repeat): - keyboard(keyboard), - scancode(scancode), - repeat(repeat), - modifiers(modifiers) + keyboard{keyboard}, + scancode{scancode}, + repeat{repeat}, + modifiers{modifiers} {} mouse_button_mapping::mouse_button_mapping(input::mouse* mouse, mouse_button button): - mouse(mouse), - button(button) + mouse{mouse}, + button{button} {} mouse_motion_mapping::mouse_motion_mapping(input::mouse* mouse, mouse_motion_axis axis, bool direction): - mouse(mouse), - axis(axis), - direction(direction) + mouse{mouse}, + axis{axis}, + direction{direction} {} mouse_scroll_mapping::mouse_scroll_mapping(input::mouse* mouse, mouse_scroll_axis axis, bool direction): - mouse(mouse), - axis(axis), - direction(direction) + mouse{mouse}, + axis{axis}, + direction{direction} {} } // namespace input diff --git a/src/engine/input/mapping.hpp b/src/engine/input/mapping.hpp index 03df301..4541a9b 100644 --- a/src/engine/input/mapping.hpp +++ b/src/engine/input/mapping.hpp @@ -72,23 +72,20 @@ public: gamepad_axis_mapping() = default; /// @} - /// Destructs a gamepad axis mapping. - virtual ~gamepad_axis_mapping() = default; - /// Returns mapping_type::gamepad_axis. - [[nodiscard]] inline virtual constexpr mapping_type get_mapping_type() const noexcept + [[nodiscard]] inline constexpr mapping_type get_mapping_type() const noexcept override { return mapping_type::gamepad_axis; } /// Pointer to the mapped gamepad, or `nullptr` if input from any gamepad is accepted. - input::gamepad* gamepad; + input::gamepad* gamepad{nullptr}; /// Mapped gamepad axis. - gamepad_axis axis; + gamepad_axis axis{0}; /// Sign bit of the mapped direction. - bool direction; + bool direction{false}; }; /** @@ -108,20 +105,17 @@ public: gamepad_button_mapping() = default; /// @} - /// Destructs a gamepad button mapping. - virtual ~gamepad_button_mapping() = default; - /// Returns mapping_type::gamepad_button. - [[nodiscard]] inline virtual constexpr mapping_type get_mapping_type() const noexcept + [[nodiscard]] inline constexpr mapping_type get_mapping_type() const noexcept override { return mapping_type::gamepad_button; } /// Pointer to the mapped gamepad, or `nullptr` if input from any gamepad is accepted. - input::gamepad* gamepad; + input::gamepad* gamepad{nullptr}; /// Mapped gamepad button. - gamepad_button button; + gamepad_button button{0}; }; /** @@ -143,26 +137,23 @@ public: key_mapping() = default; /// @} - /// Destructs a keyboard key mapping. - virtual ~key_mapping() = default; - /// Returns mapping_type::key. - [[nodiscard]] inline virtual constexpr mapping_type get_mapping_type() const noexcept + [[nodiscard]] inline constexpr mapping_type get_mapping_type() const noexcept override { return mapping_type::key; } /// Pointer to the mapped keyboard, or `nullptr` if input from any keyboard is accepted. - input::keyboard* keyboard; + input::keyboard* keyboard{nullptr}; /// Scancode of the mapped key. - scancode scancode; + scancode scancode{0}; /// Modifier keys bitbask. - std::uint16_t modifiers; + std::uint16_t modifiers{0}; /// `false` if the mapping ignores key repeats, `true` otherwise. - bool repeat; + bool repeat{false}; }; /** @@ -182,20 +173,17 @@ public: mouse_button_mapping() = default; /// @} - /// Destructs a mouse button mapping. - virtual ~mouse_button_mapping() = default; - /// Returns mapping_type::mouse_button. - [[nodiscard]] inline virtual constexpr mapping_type get_mapping_type() const noexcept + [[nodiscard]] inline constexpr mapping_type get_mapping_type() const noexcept override { return mapping_type::mouse_button; } /// Pointer to the mapped mouse, or `nullptr` if input from any mouse is accepted. - input::mouse* mouse; + input::mouse* mouse{nullptr}; /// Mapped mouse button. - mouse_button button; + mouse_button button{0}; }; /** @@ -216,23 +204,20 @@ public: mouse_motion_mapping() = default; /// @} - /// Destructs a mouse motion mapping. - virtual ~mouse_motion_mapping() = default; - /// Returns mapping_type::mouse_motion. - [[nodiscard]] inline virtual constexpr mapping_type get_mapping_type() const noexcept + [[nodiscard]] inline constexpr mapping_type get_mapping_type() const noexcept override { return mapping_type::mouse_motion; } /// Pointer to the mapped mouse, or `nullptr` if input from any mouse is accepted. - input::mouse* mouse; + input::mouse* mouse{nullptr}; /// Mapped mouse motion axis. - mouse_motion_axis axis; + mouse_motion_axis axis{0}; /// Sign bit of the mapped direction. - bool direction; + bool direction{false}; }; /** @@ -254,23 +239,20 @@ public: mouse_scroll_mapping() = default; /// @} - /// Destructs a mouse scroll mapping. - virtual ~mouse_scroll_mapping() = default; - /// Returns mapping_type::mouse_scroll. - [[nodiscard]] inline virtual constexpr mapping_type get_mapping_type() const noexcept + [[nodiscard]] inline constexpr mapping_type get_mapping_type() const noexcept override { return mapping_type::mouse_scroll; } /// Pointer to the mapped mouse, or `nullptr` if input from any mouse is accepted. - input::mouse* mouse; + input::mouse* mouse{nullptr}; /// Mapped mouse scroll axis. - mouse_scroll_axis axis; + mouse_scroll_axis axis{0}; /// Sign bit of the mapped direction. - bool direction; + bool direction{false}; }; } // namespace input diff --git a/src/engine/input/mouse-events.hpp b/src/engine/input/mouse-events.hpp index 7d29271..a0aecad 100644 --- a/src/engine/input/mouse-events.hpp +++ b/src/engine/input/mouse-events.hpp @@ -36,13 +36,13 @@ class mouse; struct mouse_moved_event { /// Mouse that generated the event. - mouse* mouse; + mouse* mouse{nullptr}; /// Mouse position, in pixels, relative to the window. - math::vector position; + math::vector position{0, 0}; /// Relative movement of the mouse, in pixels. - math::vector difference; + math::vector difference{0, 0}; }; /** @@ -51,13 +51,13 @@ struct mouse_moved_event struct mouse_button_pressed_event { /// Mouse that generated the event. - mouse* mouse; + mouse* mouse{nullptr}; /// Mouse position, in pixels, relative to the window, when the button was pressed. - math::vector position; + math::vector position{0, 0}; /// Mouse button being pressed. - mouse_button button; + mouse_button button{0}; }; /** @@ -66,13 +66,13 @@ struct mouse_button_pressed_event struct mouse_button_released_event { /// Mouse that generated the event. - mouse* mouse; + mouse* mouse{nullptr}; /// Mouse position, in pixels, relative to the window, when the button was released. - math::vector position; + math::vector position{0, 0}; /// Mouse button being released. - mouse_button button; + mouse_button button{0}; }; /** @@ -81,13 +81,13 @@ struct mouse_button_released_event struct mouse_scrolled_event { /// Mouse that generated the event. - mouse* mouse; + mouse* mouse{nullptr}; /// Mouse position, in pixels, relative to the window, when the mouse was scrolled. - math::vector position; + math::vector position{0, 0}; /// Scroll velocity. - math::vector velocity; + math::vector velocity{0.0f, 0.0f}; }; } // namespace input diff --git a/src/engine/input/mouse.hpp b/src/engine/input/mouse.hpp index 9371cb8..cbeffdb 100644 --- a/src/engine/input/mouse.hpp +++ b/src/engine/input/mouse.hpp @@ -35,14 +35,6 @@ namespace input { class mouse: public device { public: - /** - * Constructs a mouse input device. - */ - mouse() = default; - - /// Destructs a mouse input device. - virtual ~mouse() = default; - /** * Simulates a mouse button press. * @@ -103,13 +95,13 @@ public: } /// Returns device_type::mouse. - [[nodiscard]] inline virtual constexpr device_type get_device_type() const noexcept + [[nodiscard]] inline constexpr device_type get_device_type() const noexcept override { return device_type::mouse; } private: - math::vector position; + math::vector position{0, 0}; ::event::publisher button_pressed_publisher; ::event::publisher button_released_publisher; diff --git a/src/engine/utility/hash/fnv1a.hpp b/src/engine/utility/hash/fnv1a.hpp index ddebc2c..b2e1245 100644 --- a/src/engine/utility/hash/fnv1a.hpp +++ b/src/engine/utility/hash/fnv1a.hpp @@ -164,7 +164,7 @@ struct fnv1a32_t } /// 32-bit FNV-1a hash value. - value_type value; + value_type value{0}; }; static_assert(sizeof(fnv1a32_t) == sizeof(std::uint32_t)); @@ -220,7 +220,7 @@ struct fnv1a64_t } /// 64-bit FNV-1a hash value. - value_type value; + value_type value{0}; }; static_assert(sizeof(fnv1a64_t) == sizeof(std::uint64_t)); diff --git a/src/engine/utility/uuid.hpp b/src/engine/utility/uuid.hpp index af7ba50..06d1a0d 100644 --- a/src/engine/utility/uuid.hpp +++ b/src/engine/utility/uuid.hpp @@ -34,7 +34,7 @@ struct uuid [[nodiscard]] std::string string() const; /// UUID data. - std::array data; + std::array data{}; }; /**