HPC_Voxel_Engine 0.2.0
High-Performance C++ Voxel Engine
Loading...
Searching...
No Matches
InputHandler.h
Go to the documentation of this file.
1
6#pragma once
7#include <memory>
8
9// clang-format off
10#include "glad/glad.h"
11#include "GLFW/glfw3.h"
12// clang-format on
13
14#include "../core/camera.h"
15#include "../physics/PhysicsSystem.h"
16#include "../world/Chunk.h"
17#include "../world/ChunkManager.h"
18#include "../world/Player.h"
19
20namespace App {
21
28public:
29 InputHandler(const Core::Vec3& ObjStartPos);
30
34 void ProcessInput(GLFWwindow* pWindow, ChunkManager& objChunkManager, float fDeltaTime);
35
39 void UpdatePlayerPhysics(float fDeltaTime, const ChunkManager& objChunkManager);
40
46 const Core::Mat4& viewProjection);
47
48 float GetOrthoSize() const { return m_fOrthoSize; }
49 void SetOrthoSize(float fValue) { m_fOrthoSize = fValue; }
50
51 bool IsSIMDEnabled() const { return m_bEnableSIMD; }
52 void SetEnableSIMD(bool bValue) { m_bEnableSIMD = bValue; }
53
56
58 void SetFrustumCullingEnable(bool bValue) { m_bFrustumCullingEnabled = bValue; }
59
60 int GetActiveThreads() const { return m_iActiveThreads; }
61 void SetActiveThreads(int iCt) { m_iActiveThreads = iCt; }
62
63 bool IsPerspective() const { return m_bPerspective; }
64 void SetPerspective(bool bValue) { m_bPerspective = bValue; }
66 void SetLMBClickedFirstTime(bool bValue) { m_bLMBClickedFirstTime = bValue; }
67
68 Core::Camera& GetCamera() { return m_pPlayer->GetCamera(); }
69 Player* GetPlayer() { return m_pPlayer.get(); }
70 void SetMovementSpeed(float fMoveSpeed) {
71 if (m_pPlayer)
72 m_pPlayer->SetMovementSpeed(fMoveSpeed);
73 }
74 void SetFlyMode(bool bFlyMode) { m_bFlyMode = bFlyMode; }
75 void SetScreenWidth(int iWidth, int iHeight) {
76 m_iScreenWidth = iWidth;
77 m_iScreenHeight = iHeight;
78 }
79 unsigned int GetScreenWidth() const { return m_iScreenWidth; }
80 unsigned int GetScreenHeight() const { return m_iScreenHeight; }
81
82 int GetFrameCount() const { return m_iFrameCount; }
84 void ResetCounters();
85 float GetTime() const { return m_fTimer; }
86 void SetDeltaTime(float fDelTime);
88
89private:
91 std::unique_ptr<Player> m_pPlayer;
92
93 float m_fOrthoSize = 10.0f;
94 float m_fTimer = 0.0f;
95 float m_fDeltaTime = 0.0f;
96
99 int m_iScreenWidth = 1920;
100 int m_iScreenHeight = 1080;
101
102 bool m_bEnableSIMD = true;
105 bool m_bPerspective = true;
110 bool m_bFlyMode = false;
111};
112} // namespace App
Processes keyboard and mouse input, managing player movement, camera state, and world interaction.
Definition InputHandler.h:27
bool m_bEscClickedFirstTime
Definition InputHandler.h:106
void SetActiveThreads(int iCt)
Definition InputHandler.h:61
void SetLMBClickedFirstTime(bool bValue)
Definition InputHandler.h:66
int m_iScreenHeight
Definition InputHandler.h:100
void UpdatePlayerPhysics(float fDeltaTime, const ChunkManager &objChunkManager)
Updates player movement and collision based on elapsed time.
Definition InputHandler.cpp:20
void SetEnableSIMD(bool bValue)
Definition InputHandler.h:52
bool m_bLMBClickedFirstTime
Definition InputHandler.h:107
bool IsSIMDEnabled() const
Definition InputHandler.h:51
void SetNeighborCullingEnable(bool bValue)
Definition InputHandler.h:55
void SetDeltaTime(float fDelTime)
Definition InputHandler.cpp:218
bool m_bMMBClickedFirstTime
Definition InputHandler.h:109
Player * GetPlayer()
Definition InputHandler.h:69
std::unique_ptr< Player > m_pPlayer
Definition InputHandler.h:91
bool IsNeighborCullingEnabled() const
Definition InputHandler.h:54
int m_iScreenWidth
Definition InputHandler.h:99
float m_fTimer
Definition InputHandler.h:94
bool m_bNeighborCullingEnabled
Definition InputHandler.h:103
void SetFlyMode(bool bFlyMode)
Definition InputHandler.h:74
bool IsPerspective() const
Definition InputHandler.h:63
bool IsLMBClickedFirstTime() const
Definition InputHandler.h:65
float GetTime() const
Definition InputHandler.h:85
void ProcessInput(GLFWwindow *pWindow, ChunkManager &objChunkManager, float fDeltaTime)
Polls and processes raw input events to update global application state.
Definition InputHandler.cpp:26
void SetScreenWidth(int iWidth, int iHeight)
Definition InputHandler.h:75
bool m_bPerspective
Definition InputHandler.h:105
void SetOrthoSize(float fValue)
Definition InputHandler.h:49
bool m_bFlyMode
Definition InputHandler.h:110
float m_fDeltaTime
Definition InputHandler.h:95
void SetMovementSpeed(float fMoveSpeed)
Definition InputHandler.h:70
void AddFrameCount()
Definition InputHandler.h:83
bool IsFrustumCullingEnabled() const
Definition InputHandler.h:57
int GetFrameCount() const
Definition InputHandler.h:82
float m_fOrthoSize
Definition InputHandler.h:93
void ResetCounters()
Definition InputHandler.cpp:223
int GetActiveThreads() const
Definition InputHandler.h:60
Core::Vec3 m_objCameraPos
Definition InputHandler.h:90
bool m_bEnableSIMD
Definition InputHandler.h:102
Core::Camera & GetCamera()
Definition InputHandler.h:68
void SetPerspective(bool bValue)
Definition InputHandler.h:64
bool m_bRMBClickedFirstTime
Definition InputHandler.h:108
Core::Mat4 GetViewProjectionMatrix()
Definition InputHandler.cpp:204
bool m_bFrustumCullingEnabled
Definition InputHandler.h:104
int m_iActiveThreads
Definition InputHandler.h:98
unsigned int GetScreenHeight() const
Definition InputHandler.h:80
unsigned int GetScreenWidth() const
Definition InputHandler.h:79
int m_iFrameCount
Definition InputHandler.h:97
void SetFrustumCullingEnable(bool bValue)
Definition InputHandler.h:58
RayHit ProcessFirePreviewAndFire(ChunkManager &objChunkManager, const Core::Mat4 &viewProjection)
Raycasts into the world to preview, place, destroy, or inject heat into blocks.
Definition InputHandler.cpp:120
float GetOrthoSize() const
Definition InputHandler.h:48
Orchestrates infinite world generation, active chunk tracking, and multi-threaded data loading.
Definition ChunkManager.h:33
Processes input and calculates the View Matrix for OpenGL rendering.
Definition camera.h:21
Represents the user-controlled entity. Handles Camera synchronization and Input-to-Physics logic.
Definition Player.h:16
Definition InputHandler.cpp:14
A 4x4 Matrix structure stored in Column-Major order (OpenGL Standard).
Definition Matrix.h:18
A 3-component vector structure (x, y, z) with standard math operations.
Definition MathUtils.h:11
Encapsulates the result of a raycast query against the voxel world.
Definition PhysicsSystem.h:35