diff --git a/app/src/main/cpp/GakumasLocalify/Hook.cpp b/app/src/main/cpp/GakumasLocalify/Hook.cpp index d0002e2..1f30109 100644 --- a/app/src/main/cpp/GakumasLocalify/Hook.cpp +++ b/app/src/main/cpp/GakumasLocalify/Hook.cpp @@ -164,7 +164,10 @@ namespace GakumasLocal::HookMain { *value = cacheRotation; } else { - lookat_injected(_this, &cacheLookAt, &worldUp); + static GakumasLocal::Misc::FixedSizeQueue recordsY(60); + const auto newY = GKCamera::CheckNewY(cacheLookAt, true, recordsY); + UnityResolve::UnityType::Vector3 newCacheLookAt{cacheLookAt.x, newY, cacheLookAt.z}; + lookat_injected(_this, &newCacheLookAt, &worldUp); return; } } diff --git a/app/src/main/cpp/GakumasLocalify/camera/camera.cpp b/app/src/main/cpp/GakumasLocalify/camera/camera.cpp index fc5b11f..4e2373c 100644 --- a/app/src/main/cpp/GakumasLocalify/camera/camera.cpp +++ b/app/src/main/cpp/GakumasLocalify/camera/camera.cpp @@ -285,9 +285,8 @@ namespace GKCamera { return UnityResolve::UnityType::Vector3(newX, newY, newZ); } - - float CheckNewY(const UnityResolve::UnityType::Vector3& targetPos, const bool recordY) { - static GakumasLocal::Misc::FixedSizeQueue recordsY(60); + float CheckNewY(const UnityResolve::UnityType::Vector3& targetPos, const bool recordY, + GakumasLocal::Misc::FixedSizeQueue& recordsY) { const auto currentY = targetPos.y; static auto lastRetY = currentY; @@ -315,11 +314,13 @@ namespace GKCamera { UnityResolve::UnityType::Vector3 CalcFollowModeLookAt(const UnityResolve::UnityType::Vector3& targetPos, const UnityResolve::UnityType::Vector3& posOffset, const bool recordY) { + static GakumasLocal::Misc::FixedSizeQueue recordsY(60); + const float angleX = posOffset.x; const float angleRad = (angleX + (followPosOffset.z >= 0 ? 90.0f : -90.0f)) * (M_PI / 180.0f); UnityResolve::UnityType::Vector3 newTargetPos = targetPos; - newTargetPos.y = CheckNewY(targetPos, recordY); + newTargetPos.y = CheckNewY(targetPos, recordY, recordsY); const float offsetX = followLookAtOffset.x * sin(angleRad); const float offsetZ = followLookAtOffset.x * cos(angleRad); diff --git a/app/src/main/cpp/GakumasLocalify/camera/camera.hpp b/app/src/main/cpp/GakumasLocalify/camera/camera.hpp index 7ce2ebe..0b410e8 100644 --- a/app/src/main/cpp/GakumasLocalify/camera/camera.hpp +++ b/app/src/main/cpp/GakumasLocalify/camera/camera.hpp @@ -29,6 +29,9 @@ namespace GKCamera { extern int followCharaIndex; extern GakumasLocal::Misc::CSEnum bodyPartsEnum; + float CheckNewY(const UnityResolve::UnityType::Vector3& targetPos, const bool recordY, + GakumasLocal::Misc::FixedSizeQueue& recordsY); + UnityResolve::UnityType::Vector3 CalcPositionFromLookAt(const UnityResolve::UnityType::Vector3& target, const UnityResolve::UnityType::Vector3& offset);