1
0

增加第一人称相机平滑 Y 轴模式

This commit is contained in:
chinosk 2024-06-05 18:58:24 +08:00
parent d7ff38b3f0
commit 37e98f61a0
No known key found for this signature in database
GPG Key ID: 00610B08C1BF7BE9
3 changed files with 12 additions and 5 deletions

View File

@ -164,7 +164,10 @@ namespace GakumasLocal::HookMain {
*value = cacheRotation;
}
else {
lookat_injected(_this, &cacheLookAt, &worldUp);
static GakumasLocal::Misc::FixedSizeQueue<float> 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;
}
}

View File

@ -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<float> recordsY(60);
float CheckNewY(const UnityResolve::UnityType::Vector3& targetPos, const bool recordY,
GakumasLocal::Misc::FixedSizeQueue<float>& 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<float> 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);

View File

@ -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<float>& recordsY);
UnityResolve::UnityType::Vector3 CalcPositionFromLookAt(const UnityResolve::UnityType::Vector3& target,
const UnityResolve::UnityType::Vector3& offset);