Fixed editor camera spinning

This commit is contained in:
Antoine Pilote
2023-09-23 23:22:07 -04:00
parent d7f3e0cfb3
commit 557c5e281c
2 changed files with 9 additions and 6 deletions

View File

@@ -206,12 +206,14 @@ namespace Nuake
void EditorCamera::SetYaw(float yaw)
{
TargetYaw = yaw;
Yaw = yaw;
UpdateDirection();
}
void EditorCamera::SetPitch(float pitch)
{
TargetPitch = pitch;
Pitch = pitch;
UpdateDirection();
}
@@ -220,8 +222,8 @@ namespace Nuake
BEGIN_SERIALIZE();
SERIALIZE_VEC3(Translation);
j["Yaw"] = Yaw;
j["Pitch"] = Pitch;
j["Yaw"] = glm::clamp(Yaw, 0.f, 360.f);
j["Pitch"] = glm::clamp(Pitch, -90.f, 90.f);
return j;
}

View File

@@ -10,6 +10,7 @@ namespace Nuake
public:
EditorCamera()
{
Yaw = 0.0f;
Translation = Vector3(10, 10, 10);
SetDirection(Vector3(-1, -1, -1));
}
@@ -33,10 +34,10 @@ namespace Nuake
float mouseLastX;
float mouseLastY;
float Yaw = -135.f;
float Pitch = -45.f;
float TargetYaw = -135.f;
float TargetPitch = -45.f;
float Yaw = 0.0f;
float Pitch = 0.0f;
float TargetYaw = 0.f;
float TargetPitch = 0.0f;
void UpdateDirection();
};
}