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

Fixed Camera Collision
This commit is contained in:
XiaoQiDigipen 2023-03-10 19:00:31 +08:00 committed by GitHub
commit 01256f6e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -206,6 +206,16 @@ namespace SHADE
camera->dirtyView = true; camera->dirtyView = true;
} }
camera->offset = offset;
SHVec3 tOffset = pivot.GetTargetOffset();
tOffset = SHVec3::RotateY(tOffset, SHMath::DegreesToRadians(pivot.GetYaw()));
if (pivot.lookAtCameraOrigin)
CameraLookAt(*camera, camera->position + pivot.GetTargetOffset());
@ -250,7 +260,7 @@ namespace SHADE
if (camera.isActive == false) if (camera.isActive == false)
return; return;
if (SHComponentManager::HasComponent<SHTransformComponent>(camera.GetEID()) == true && &camera != &editorCamera) if (SHComponentManager::HasComponent<SHTransformComponent>(camera.GetEID()) == true && SHComponentManager::HasComponent<SHCameraArmComponent>(camera.GetEID()) == false && &camera != &editorCamera)
{ {
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(camera.GetEID()); auto transform = SHComponentManager::GetComponent<SHTransformComponent>(camera.GetEID());
SHVec3 rotation = transform->GetWorldRotation(); SHVec3 rotation = transform->GetWorldRotation();
@ -273,14 +283,14 @@ namespace SHADE
{ {
camera.offset = arm->GetOffset(); camera.offset = arm->GetOffset();
SHVec3 tOffset = arm->GetTargetOffset(); /*SHVec3 tOffset = arm->GetTargetOffset();
tOffset = SHVec3::RotateY(tOffset, SHMath::DegreesToRadians(arm->GetYaw())); tOffset = SHVec3::RotateY(tOffset, SHMath::DegreesToRadians(arm->GetYaw()));
if (arm->lookAtCameraOrigin) if (arm->lookAtCameraOrigin)
CameraLookAt(camera, camera.position + tOffset); CameraLookAt(camera, camera.position + arm->GetTargetOffset());*/
} }