Added a function for editor camera update
This commit is contained in:
parent
6039ec534d
commit
c15994532b
|
@ -9,7 +9,57 @@
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
void SHCameraSystem::UpdateEditorCamera(double dt) noexcept
|
||||||
|
{
|
||||||
|
|
||||||
|
auto& camera = editorCamera;
|
||||||
|
SHVec3 view, right, UP;
|
||||||
|
GetCameraAxis(camera, view, right, UP);
|
||||||
|
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::A))
|
||||||
|
{
|
||||||
|
camera.position -= right * dt * camera.movementSpeed;
|
||||||
|
camera.dirtyView = true;
|
||||||
|
}
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::D))
|
||||||
|
{
|
||||||
|
camera.position += right * dt * camera.movementSpeed;
|
||||||
|
camera.dirtyView = true;
|
||||||
|
}
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::W))
|
||||||
|
{
|
||||||
|
camera.position += view * dt * camera.movementSpeed;
|
||||||
|
camera.dirtyView = true;
|
||||||
|
}
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::S))
|
||||||
|
{
|
||||||
|
camera.position -= view * dt * camera.movementSpeed;
|
||||||
|
camera.dirtyView = true;
|
||||||
|
}
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::Q))
|
||||||
|
{
|
||||||
|
camera.position += UP * dt * camera.movementSpeed;
|
||||||
|
camera.dirtyView = true;
|
||||||
|
}
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::E))
|
||||||
|
{
|
||||||
|
camera.position -= UP * dt * camera.movementSpeed;
|
||||||
|
camera.dirtyView = true;
|
||||||
|
}
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::RMB))
|
||||||
|
{
|
||||||
|
double mouseX, mouseY;
|
||||||
|
SHInputManager::GetMouseVelocity(&mouseX, &mouseY);
|
||||||
|
|
||||||
|
//std::cout << camera.yaw << std::endl;
|
||||||
|
|
||||||
|
camera.pitch -= mouseY * dt * camera.turnSpeed.x;
|
||||||
|
camera.yaw -= mouseX * dt * camera.turnSpeed.y;
|
||||||
|
camera.dirtyView = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateCameraComponent(editorCamera);
|
||||||
|
}
|
||||||
void SHCameraSystem::EditorCameraUpdate::Execute(double dt) noexcept
|
void SHCameraSystem::EditorCameraUpdate::Execute(double dt) noexcept
|
||||||
{
|
{
|
||||||
SHCameraSystem* system = static_cast<SHCameraSystem*>(GetSystem());
|
SHCameraSystem* system = static_cast<SHCameraSystem*>(GetSystem());
|
||||||
|
@ -222,6 +272,9 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
void SHCameraSystem::ClampCameraRotation(SHCameraComponent& camera) noexcept
|
void SHCameraSystem::ClampCameraRotation(SHCameraComponent& camera) noexcept
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (camera.pitch > 85)
|
if (camera.pitch > 85)
|
||||||
camera.SetPitch(85);
|
camera.SetPitch(85);
|
||||||
if (camera.pitch < -85)
|
if (camera.pitch < -85)
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace SHADE
|
||||||
DirectorHandle CreateDirector() noexcept;
|
DirectorHandle CreateDirector() noexcept;
|
||||||
DirectorHandle GetDirector(size_t index) noexcept;
|
DirectorHandle GetDirector(size_t index) noexcept;
|
||||||
void ClampCameraRotation(SHCameraComponent& camera) noexcept;
|
void ClampCameraRotation(SHCameraComponent& camera) noexcept;
|
||||||
|
void UpdateEditorCamera(double dt) noexcept;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void UpdateCameraComponent(SHCameraComponent& camera) noexcept;
|
void UpdateCameraComponent(SHCameraComponent& camera) noexcept;
|
||||||
|
|
Loading…
Reference in New Issue