Merge pull request #109 from SHADE-DP/SP3-141-Camera-System

Fixed editor camera
This commit is contained in:
XiaoQiDigipen 2022-10-23 15:07:10 +08:00 committed by GitHub
commit 438bce43f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -69,6 +69,7 @@ namespace SHADE
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::A)) if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::A))
{ {
std::cout << "Camera movement: "<<right.x<<", " << right.y << std::endl;
camera.position -= right * dt * camera.movementSpeed; camera.position -= right * dt * camera.movementSpeed;
camera.dirtyView = true; camera.dirtyView = true;
} }
@ -109,6 +110,7 @@ namespace SHADE
camera.dirtyView = true; camera.dirtyView = true;
} }
std::cout << "Camera position: " << camera.position.x << " " << camera.position.y << std::endl;
system->UpdateCameraComponent(system->editorCamera); system->UpdateCameraComponent(system->editorCamera);
} }
@ -134,14 +136,14 @@ namespace SHADE
void SHCameraSystem::UpdateCameraComponent(SHCameraComponent& camera) noexcept void SHCameraSystem::UpdateCameraComponent(SHCameraComponent& camera) noexcept
{ {
if (SHComponentManager::HasComponent<SHTransformComponent>(camera.GetEID()) == true) if (SHComponentManager::HasComponent<SHTransformComponent>(camera.GetEID()) == true && &camera != &editorCamera)
{ {
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(camera.GetEID()); auto transform = SHComponentManager::GetComponent<SHTransformComponent>(camera.GetEID());
SHVec3 rotation = transform->GetWorldRotation(); SHVec3 rotation = transform->GetWorldRotation();
camera.pitch = rotation.x; camera.pitch = rotation.x;
camera.yaw = rotation.y; camera.yaw = rotation.y;
camera.roll = rotation.z; camera.roll = rotation.z;
camera.position = transform->GetWorldPosition(); camera.position = transform->GetWorldPosition();
} }
@ -151,7 +153,7 @@ namespace SHADE
SHVec3 view, right, UP; SHVec3 view, right, UP;
ClampCameraRotation(camera); //ClampCameraRotation(camera);
GetCameraAxis(camera, view, right, UP); GetCameraAxis(camera, view, right, UP);