From 37e98f61a04ad27c031d3dbd1ad0593eb87ba40c Mon Sep 17 00:00:00 2001 From: chinosk <2248589280@qq.com> Date: Wed, 5 Jun 2024 18:58:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AC=AC=E4=B8=80=E4=BA=BA?= =?UTF-8?q?=E7=A7=B0=E7=9B=B8=E6=9C=BA=E5=B9=B3=E6=BB=91=20Y=20=E8=BD=B4?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/GakumasLocalify/Hook.cpp | 5 ++++- app/src/main/cpp/GakumasLocalify/camera/camera.cpp | 9 +++++---- app/src/main/cpp/GakumasLocalify/camera/camera.hpp | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) 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);