mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
refactor(input): use relative mouse motion and simplify camera mouse update
This commit is contained in:
@@ -13,7 +13,7 @@ class App {
|
||||
public:
|
||||
App();
|
||||
~App();
|
||||
void handle_cursor_position(float xpos, float ypos);
|
||||
void handle_mouse_move(float xpos, float ypos, float xrel, float yrel);
|
||||
void handle_sdl_key(SDL_Event& e);
|
||||
void handle_sdl_mouse_button(SDL_Event& e);
|
||||
void handle_window_focus(bool focused);
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
void camera_init(ClientPlayer* player);
|
||||
void hot_reload();
|
||||
void reset_camera();
|
||||
void update_cursor_position_camera(double xpos, double ypos);
|
||||
void update_cursor_position_camera(float offset_x, float offset_y);
|
||||
|
||||
const glm::mat4 get_camera_lookat() const;
|
||||
const glm::vec3& get_camera_pos() const;
|
||||
|
||||
@@ -11,8 +11,10 @@ namespace Cubed {
|
||||
struct MouseMoveEvent {
|
||||
float xpos;
|
||||
float ypos;
|
||||
|
||||
MouseMoveEvent(float x, float y) : xpos(x), ypos(y) {}
|
||||
float xrel;
|
||||
float yrel;
|
||||
MouseMoveEvent(float x, float y, float dx, float dy)
|
||||
: xpos(x), ypos(y), xrel(dx), yrel(dy) {}
|
||||
};
|
||||
|
||||
struct MouseButtonEvent {
|
||||
|
||||
@@ -41,14 +41,17 @@ public:
|
||||
|
||||
void set_vsync(bool enable);
|
||||
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
private:
|
||||
bool m_mouse_enable = true;
|
||||
bool m_imgui_init = false;
|
||||
bool m_game_running = false;
|
||||
SDL_Window* m_window;
|
||||
SDL_GLContext m_context;
|
||||
int m_window_width;
|
||||
int m_window_height;
|
||||
int m_window_width = 0;
|
||||
int m_window_height = 0;
|
||||
Config& m_config;
|
||||
Camera* m_camera = nullptr;
|
||||
bool m_imgui_enable = false;
|
||||
|
||||
Reference in New Issue
Block a user