diff --git a/SHADE_Engine/src/Camera/SHCameraArmComponent.cpp b/SHADE_Engine/src/Camera/SHCameraArmComponent.cpp index ed24e6a7..c560a1b0 100644 --- a/SHADE_Engine/src/Camera/SHCameraArmComponent.cpp +++ b/SHADE_Engine/src/Camera/SHCameraArmComponent.cpp @@ -1,6 +1,6 @@ #include "SHpch.h" #include "SHCameraArmComponent.h" - +#include "Math/SHMathHelpers.h" namespace SHADE @@ -16,6 +16,11 @@ namespace SHADE SHVec3 const& SHCameraArmComponent::GetOffset() const noexcept { + SHVec3 result = offset; + + result = SHVec3::RotateX(offset, -(SHMath::DegreesToRadians(GetPitch()))); + result = SHVec3::RotateY(offset, (SHMath::DegreesToRadians(GetYaw()))); + return offset; } diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.cpp b/SHADE_Engine/src/Camera/SHCameraSystem.cpp index 95a461f8..85f3b1b1 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.cpp +++ b/SHADE_Engine/src/Camera/SHCameraSystem.cpp @@ -172,11 +172,6 @@ namespace SHADE void SHCameraSystem::UpdateCameraArmComponent(SHCameraArmComponent& pivot) noexcept { - - - - - SHVec3 offset{ 0.0f,0.0f, 1.0f }; offset = SHVec3::RotateX(offset, -(SHMath::DegreesToRadians(pivot.GetPitch()))); offset = SHVec3::RotateY(offset, (SHMath::DegreesToRadians(pivot.GetYaw()))); @@ -212,12 +207,18 @@ namespace SHADE } + + + + + //Camera Collision stuff + SHVec3 cameraPos = camera->position + pivot.offset; SHVec3 cameraTarget = camera->position; - //SHLOG_INFO("Ray position: {},{},{} direction:{},{},{}",pivot.ray.position.x, pivot.ray.position.y, pivot.ray.position.z,pivot.ray.direction.x, pivot.ray.direction.y, pivot.ray.direction.z) + SHRaycaster::RaycastInfo info; - //info.layers = (SHCollisionTagMatrix::GetTag("7")->GetMask()); + info.layers = (uint16_t)(SHCollisionTagMatrix::GetTag("Camera")->GetMask()); info.distance = pivot.armLength; info.continuous = false; @@ -235,38 +236,10 @@ namespace SHADE newOffset = SHVec3::RotateY(newOffset, (SHMath::DegreesToRadians(pivot.GetYaw()))); newOffset = SHVec3::Normalise(newOffset) * (hitResult.distance * 0.95f); pivot.offset = newOffset; - //cameraPos = camera->position + pivot.offset; - //SHLOG_INFO("CAMERA COLLISION HIT, {} armlength: {}, true armlength: {}", hitResult.distance, hitResult.distance, (cameraPos - camera->position).Length()); - //SHLOG_INFO("Racoon Position {}, {}, {}, Camera Position: {}, {}, {}, Distance {}", cameraTarget.x, cameraTarget.y, cameraTarget.z, cameraPos.x, cameraPos.y, cameraPos.z, SHVec3::Distance(cameraTarget, cameraPos)); - //SHLOG_INFO("Camera Position: {}, {}, {}", cameraPos.x, cameraPos.y, cameraPos.z); - //auto otherTransform = SHComponentManager::GetComponent_s(hitResult.entityHit); - //SHVec3 otherPos = hitResult.position; - - - //SHLOG_INFO("hit distance{} other pos: {},{},{}, distance between: {}", hitResult.distance, otherPos.x, otherPos.y, otherPos.z, SHVec3::Distance(cameraTarget,otherPos)); break; } } - - ////auto result = physicsSystem->Raycast(pivot.ray); - //if (result && result.distance < pivot.GetArmLength()) - //{ - // - // SHVec3 newOffset = SHVec3{ 0.0f,0.0f, result.distance * 0.8f }; - // newOffset = SHVec3::RotateX(newOffset, -(SHMath::DegreesToRadians(pivot.GetPitch()))); - // newOffset = SHVec3::RotateY(newOffset, (SHMath::DegreesToRadians(pivot.GetYaw()))); - // pivot.offset = newOffset; - // //SHLOG_INFO("CAMERA COLLISION HIT, {}", result.distance); - //} - //else - //{ - // //SHLOG_INFO("CAMERA COLLISION CANT HIT CAMERA"); - //} - - - // pivot.rtMatrix = SHMatrix::Inverse(pivot.rtMatrix); - }