Browse Source

Add more default value initialization for various classes and structs

master
C. J. Howard 1 year ago
parent
commit
ccd4b39549
32 changed files with 151 additions and 230 deletions
  1. +2
    -0
      README.md
  2. +4
    -4
      src/engine/app/display-events.hpp
  3. +7
    -7
      src/engine/app/display.hpp
  4. +9
    -9
      src/engine/app/window-events.hpp
  5. +10
    -20
      src/engine/app/window.hpp
  6. +2
    -10
      src/engine/gl/framebuffer.cpp
  7. +5
    -5
      src/engine/gl/framebuffer.hpp
  8. +3
    -3
      src/engine/gl/rasterizer.hpp
  9. +1
    -1
      src/engine/gl/shader-object.hpp
  10. +1
    -6
      src/engine/gl/shader-variable.hpp
  11. +2
    -2
      src/engine/gl/texture-cube.hpp
  12. +7
    -7
      src/engine/gl/texture.hpp
  13. +5
    -5
      src/engine/gl/vertex-attribute.hpp
  14. +4
    -4
      src/engine/input/action-events.hpp
  15. +0
    -5
      src/engine/input/action-map.cpp
  16. +2
    -7
      src/engine/input/action-map.hpp
  17. +1
    -1
      src/engine/input/action.hpp
  18. +2
    -2
      src/engine/input/device-events.hpp
  19. +3
    -1
      src/engine/input/device-type.hpp
  20. +0
    -4
      src/engine/input/device.cpp
  21. +1
    -7
      src/engine/input/device.hpp
  22. +7
    -7
      src/engine/input/gamepad-events.hpp
  23. +1
    -5
      src/engine/input/gamepad.cpp
  24. +7
    -9
      src/engine/input/gamepad.hpp
  25. +7
    -7
      src/engine/input/keyboard-events.hpp
  26. +1
    -9
      src/engine/input/keyboard.hpp
  27. +17
    -17
      src/engine/input/mapping.cpp
  28. +23
    -41
      src/engine/input/mapping.hpp
  29. +12
    -12
      src/engine/input/mouse-events.hpp
  30. +2
    -10
      src/engine/input/mouse.hpp
  31. +2
    -2
      src/engine/utility/hash/fnv1a.hpp
  32. +1
    -1
      src/engine/utility/uuid.hpp

+ 2
- 0
README.md View File

@ -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.

+ 4
- 4
src/engine/app/display-events.hpp View File

@ -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

+ 7
- 7
src/engine/app/display.hpp View File

@ -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<int> bounds;
geom::primitive::rectangle<int> usable_bounds;
int refresh_rate;
float dpi;
display_orientation orientation;
bool connected;
geom::primitive::rectangle<int> bounds{0};
geom::primitive::rectangle<int> usable_bounds{0};
int refresh_rate{0};
float dpi{0.0f};
display_orientation orientation{0};
bool connected{false};
event::publisher<display_connected_event> connected_publisher;
event::publisher<display_disconnected_event> disconnected_publisher;

+ 9
- 9
src/engine/app/window-events.hpp View File

@ -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<int, 2> position;
math::vector<int, 2> 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<int, 2> size;
math::vector<int, 2> size{0, 0};
};
} // namespace app

+ 10
- 20
src/engine/app/window.hpp View File

@ -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<int, 2> windowed_position;
math::vector<int, 2> position;
math::vector<int, 2> windowed_size;
math::vector<int, 2> size;
math::vector<int, 2> minimum_size;
math::vector<int, 2> maximum_size;
math::vector<int, 2> viewport_size;
bool maximized;
bool fullscreen;
bool v_sync;
math::vector<int, 2> windowed_position{0, 0};
math::vector<int, 2> position{0, 0};
math::vector<int, 2> windowed_size{0, 0};
math::vector<int, 2> size{0, 0};
math::vector<int, 2> minimum_size{0, 0};
math::vector<int, 2> maximum_size{0, 0};
math::vector<int, 2> viewport_size{0, 0};
bool maximized{false};
bool fullscreen{false};
bool v_sync{false};
event::publisher<window_closed_event> closed_publisher;
event::publisher<window_focus_changed_event> focus_changed_publisher;

+ 2
- 10
src/engine/gl/framebuffer.cpp View File

@ -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()

+ 5
- 5
src/engine/gl/framebuffer.hpp View File

@ -75,11 +75,11 @@ public:
private:
friend class rasterizer;
unsigned int gl_framebuffer_id;
std::array<int, 2> dimensions;
texture_2d* color_attachment;
texture_2d* depth_attachment;
texture_2d* stencil_attachment;
unsigned int gl_framebuffer_id{0};
std::array<int, 2> dimensions{0, 0};
texture_2d* color_attachment{nullptr};
texture_2d* depth_attachment{nullptr};
texture_2d* stencil_attachment{nullptr};
};
inline const std::array<int, 2>& framebuffer::get_dimensions() const

+ 3
- 3
src/engine/gl/rasterizer.hpp View File

@ -129,9 +129,9 @@ public:
private:
std::unique_ptr<framebuffer> 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

+ 1
- 1
src/engine/gl/shader-object.hpp View File

@ -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;
};

+ 1
- 6
src/engine/gl/shader-variable.hpp View File

@ -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

+ 2
- 2
src/engine/gl/texture-cube.hpp View File

@ -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

+ 7
- 7
src/engine/gl/texture.hpp View File

@ -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<std::uint16_t, 3> 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<std::uint16_t, 3> dimensions{0, 0, 0};
gl::pixel_type pixel_type{0};
gl::pixel_format pixel_format{0};
gl::color_space color_space{0};
std::array<texture_wrapping, 3> wrapping;
std::tuple<texture_min_filter, texture_mag_filter> filters;
float max_anisotropy;
float max_anisotropy{0.0f};
};
inline const std::array<std::uint16_t, 3>& texture::get_dimensions() const

+ 5
- 5
src/engine/gl/vertex-attribute.hpp View File

@ -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

+ 4
- 4
src/engine/input/action-events.hpp View File

@ -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

+ 0
- 5
src/engine/input/action-map.cpp View File

@ -25,11 +25,6 @@
namespace input {
action_map::action_map():
event_queue(nullptr),
enabled(false)
{}
void action_map::enable()
{
if (!enabled)

+ 2
- 7
src/engine/input/action-map.hpp View File

@ -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<std::shared_ptr<::event::subscription>> subscriptions;
std::vector<std::tuple<action*, gamepad_axis_mapping>> gamepad_axis_mappings;
std::vector<std::tuple<action*, gamepad_button_mapping>> gamepad_button_mappings;

+ 1
- 1
src/engine/input/action.hpp View File

@ -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;

+ 2
- 2
src/engine/input/device-events.hpp View File

@ -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

+ 3
- 1
src/engine/input/device-type.hpp View File

@ -20,10 +20,12 @@
#ifndef ANTKEEPER_INPUT_DEVICE_TYPE_HPP
#define ANTKEEPER_INPUT_DEVICE_TYPE_HPP
#include <cstdint>
namespace input {
/// Input device types.
enum class device_type
enum class device_type: std::uint8_t
{
/// Gamepad input device.
gamepad,

+ 0
- 4
src/engine/input/device.cpp View File

@ -21,10 +21,6 @@
namespace input {
device::device():
connected(true)
{}
void device::connect()
{
connected = true;

+ 1
- 7
src/engine/input/device.hpp View File

@ -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<device_connected_event> connected_publisher;
::event::publisher<device_disconnected_event> disconnected_publisher;

+ 7
- 7
src/engine/input/gamepad-events.hpp View File

@ -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

+ 1
- 5
src/engine/input/gamepad.cpp View File

@ -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)
{

+ 7
- 9
src/engine/input/gamepad.hpp View File

@ -25,11 +25,12 @@
#include <engine/input/gamepad-axis.hpp>
#include <engine/input/gamepad-button.hpp>
#include <engine/event/publisher.hpp>
#include <cstdint>
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<gamepad_button_pressed_event> button_pressed_publisher;
::event::publisher<gamepad_button_released_event> button_released_publisher;

+ 7
- 7
src/engine/input/keyboard-events.hpp View File

@ -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

+ 1
- 9
src/engine/input/keyboard.hpp View File

@ -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;
}

+ 17
- 17
src/engine/input/mapping.cpp View File

@ -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

+ 23
- 41
src/engine/input/mapping.hpp View File

@ -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

+ 12
- 12
src/engine/input/mouse-events.hpp View File

@ -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<std::int32_t, 2> position;
math::vector<std::int32_t, 2> position{0, 0};
/// Relative movement of the mouse, in pixels.
math::vector<std::int32_t, 2> difference;
math::vector<std::int32_t, 2> 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<std::int32_t, 2> position;
math::vector<std::int32_t, 2> 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<std::int32_t, 2> position;
math::vector<std::int32_t, 2> 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<std::int32_t, 2> position;
math::vector<std::int32_t, 2> position{0, 0};
/// Scroll velocity.
math::vector<float, 2> velocity;
math::vector<float, 2> velocity{0.0f, 0.0f};
};
} // namespace input

+ 2
- 10
src/engine/input/mouse.hpp View File

@ -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<std::int32_t, 2> position;
math::vector<std::int32_t, 2> position{0, 0};
::event::publisher<mouse_button_pressed_event> button_pressed_publisher;
::event::publisher<mouse_button_released_event> button_released_publisher;

+ 2
- 2
src/engine/utility/hash/fnv1a.hpp View File

@ -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));

+ 1
- 1
src/engine/utility/uuid.hpp View File

@ -34,7 +34,7 @@ struct uuid
[[nodiscard]] std::string string() const;
/// UUID data.
std::array<std::byte, 16> data;
std::array<std::byte, 16> data{};
};
/**

Loading…
Cancel
Save