clamp camera + pi
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
static constexpr float PI = 3.14159265358979323846264338327950288f;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Vec2 {
|
struct Vec2 {
|
||||||
union {
|
union {
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ struct Camera {
|
|||||||
Vec3f CamPos {0, CamDistance, 0};
|
Vec3f CamPos {0, CamDistance, 0};
|
||||||
Vec2f CamLook {};
|
Vec2f CamLook {};
|
||||||
|
|
||||||
float m_Yaw = -3.141592653f / 2.0f;
|
float m_Yaw = -PI / 2.0f;
|
||||||
float m_Pitch = -3.141592653f / 2.0f - 0.0000001f;
|
float m_Pitch = -PI / 2.0f + 0.0000001f;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
public:
|
public:
|
||||||
static constexpr float m_AnimationSpeed = 2.0f;
|
static constexpr float m_AnimationSpeed = 2.0f;
|
||||||
|
static constexpr float m_MouseSensitivity = 100.0f;
|
||||||
|
|
||||||
struct Model {
|
struct Model {
|
||||||
GL::VertexArray* vao;
|
GL::VertexArray* vao;
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ void Renderer::SetZoom(float zoom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetCamMovement(const Vec2f& mov) {
|
void Renderer::SetCamMovement(const Vec2f& mov) {
|
||||||
m_Camera.m_Pitch -= mov.y / 50.0f;
|
m_Camera.m_Pitch = std::clamp(m_Camera.m_Pitch - mov.y / m_MouseSensitivity, -PI / 2.0f + 0.0000001f, -PI / 12.0f );
|
||||||
m_Camera.m_Yaw += mov.x / 50.0f;
|
m_Camera.m_Yaw += mov.x / m_MouseSensitivity;
|
||||||
SetCamLook(m_Camera.CamLook);
|
SetCamLook(m_Camera.CamLook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user