From b31b242775a7de99411f68feaf9f8206cc850192 Mon Sep 17 00:00:00 2001 From: CatChow0 Date: Fri, 10 Oct 2025 15:31:39 +0200 Subject: [PATCH] Patch - Adds camera input handling - V14.5.32 Adds a system for managing camera input using a dedicated CameraInput struct and updates the camera class to process these inputs. This allows for more flexible and controlled camera movement. --- enginecustom/src/inc/system/camera_class.h | 12 ++++++++++++ enginecustom/src/inc/system/macro.h | 18 +++++++++++++++--- .../src/src/system/application_class.cpp | 1 + enginecustom/src/src/system/camera_class.cpp | 17 +++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/enginecustom/src/inc/system/camera_class.h b/enginecustom/src/inc/system/camera_class.h index 6f8ffcc..2c52321 100644 --- a/enginecustom/src/inc/system/camera_class.h +++ b/enginecustom/src/inc/system/camera_class.h @@ -9,6 +9,8 @@ // INCLUDES // ////////////// #include + +#include "input_class.h" #include "macro.h" using namespace DirectX; @@ -121,7 +123,15 @@ public: return upF; } + /** + * Move the camera + * @param std::vector inputs : forward, backward, left, right, up, down, scrollUp, scrollDown, rightClick + * @param float deltaTime : time since last frame + * @return void + */ + void move(float deltatime); + void update_camera_inputs_states(input_class* imputs); private: float position_x_, position_y_, position_z_; @@ -129,6 +139,8 @@ private: XMMATRIX view_matrix_; XMMATRIX reflection_view_matrix_; + float camera_speed_; + std::shared_ptr inputs_; }; #endif \ No newline at end of file diff --git a/enginecustom/src/inc/system/macro.h b/enginecustom/src/inc/system/macro.h index 3b3ad0e..cbb7af3 100644 --- a/enginecustom/src/inc/system/macro.h +++ b/enginecustom/src/inc/system/macro.h @@ -161,6 +161,18 @@ inline bool TestPlaneCorner( } \ } while (0); -// --------------------------------------- // -// --- Macros for the input processing --- // -// --------------------------------------- // +// ---------------------------------------------- // +// --- Macros for the camera input processing --- // +// ---------------------------------------------- // + +struct CameraInput { + bool move_forward = false; + bool move_backward = false; + bool move_left = false; + bool move_right = false; + bool move_up = false; + bool move_down = false; + bool scroll_up = false; + bool scroll_down = false; + bool right_click = false; +}; diff --git a/enginecustom/src/src/system/application_class.cpp b/enginecustom/src/src/system/application_class.cpp index cb27bd5..f2cde65 100644 --- a/enginecustom/src/src/system/application_class.cpp +++ b/enginecustom/src/src/system/application_class.cpp @@ -844,6 +844,7 @@ bool application_class::frame(input_class* Input) buttonS = Input->is_key_pressed(DIK_S); buttonA = Input->is_key_pressed(DIK_Q); buttonE = Input->is_key_pressed(DIK_E); + position_->MoveCamera(buttonZ, buttonS, buttonQ, buttonD, buttonE, buttonA, scrollUp, scrollDown, rightMouseDown); position_->GetPosition(positionX, positionY, positionZ); diff --git a/enginecustom/src/src/system/camera_class.cpp b/enginecustom/src/src/system/camera_class.cpp index fc0d9c0..597941c 100644 --- a/enginecustom/src/src/system/camera_class.cpp +++ b/enginecustom/src/src/system/camera_class.cpp @@ -13,6 +13,9 @@ camera_class::camera_class() rotation_x_ = 0.0f; rotation_y_ = 0.0f; rotation_z_ = 0.0f; + + camera_speed_ = 1.0f; + LOG_INIT("Camera class initialized"); } @@ -171,4 +174,18 @@ void camera_class::get_reflection_view_matrix(XMMATRIX& reflectionViewMatrix) co { reflectionViewMatrix = reflection_view_matrix_; return; +} + +void camera_class::move(float deltatime) +{ +} + +void camera_class::update_camera_inputs_states(input_class* inputs) +{ + inputs_->move_forward = inputs->is_key_pressed(DIK_W); + inputs_->move_backward = inputs->is_key_pressed(DIK_S); + inputs_->move_left = inputs->is_key_pressed(DIK_A); + inputs_->move_right = inputs->is_key_pressed(DIK_D); + inputs_->move_up = inputs->is_key_pressed(DIK_E); + inputs_->move_down = inputs->is_key_pressed(DIK_Q); } \ No newline at end of file