mirror of
https://git.chinosk6.cn/chinosk/gkms-local.git
synced 2026-02-06 01:32:28 +00:00
增加第一人称相机平滑 Y 轴模式
This commit is contained in:
@@ -164,7 +164,10 @@ namespace GakumasLocal::HookMain {
|
|||||||
*value = cacheRotation;
|
*value = cacheRotation;
|
||||||
}
|
}
|
||||||
else {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,9 +285,8 @@ namespace GKCamera {
|
|||||||
return UnityResolve::UnityType::Vector3(newX, newY, newZ);
|
return UnityResolve::UnityType::Vector3(newX, newY, newZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CheckNewY(const UnityResolve::UnityType::Vector3& targetPos, const bool recordY,
|
||||||
float CheckNewY(const UnityResolve::UnityType::Vector3& targetPos, const bool recordY) {
|
GakumasLocal::Misc::FixedSizeQueue<float>& recordsY) {
|
||||||
static GakumasLocal::Misc::FixedSizeQueue<float> recordsY(60);
|
|
||||||
const auto currentY = targetPos.y;
|
const auto currentY = targetPos.y;
|
||||||
static auto lastRetY = currentY;
|
static auto lastRetY = currentY;
|
||||||
|
|
||||||
@@ -315,11 +314,13 @@ namespace GKCamera {
|
|||||||
UnityResolve::UnityType::Vector3 CalcFollowModeLookAt(const UnityResolve::UnityType::Vector3& targetPos,
|
UnityResolve::UnityType::Vector3 CalcFollowModeLookAt(const UnityResolve::UnityType::Vector3& targetPos,
|
||||||
const UnityResolve::UnityType::Vector3& posOffset,
|
const UnityResolve::UnityType::Vector3& posOffset,
|
||||||
const bool recordY) {
|
const bool recordY) {
|
||||||
|
static GakumasLocal::Misc::FixedSizeQueue<float> recordsY(60);
|
||||||
|
|
||||||
const float angleX = posOffset.x;
|
const float angleX = posOffset.x;
|
||||||
const float angleRad = (angleX + (followPosOffset.z >= 0 ? 90.0f : -90.0f)) * (M_PI / 180.0f);
|
const float angleRad = (angleX + (followPosOffset.z >= 0 ? 90.0f : -90.0f)) * (M_PI / 180.0f);
|
||||||
|
|
||||||
UnityResolve::UnityType::Vector3 newTargetPos = targetPos;
|
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 offsetX = followLookAtOffset.x * sin(angleRad);
|
||||||
const float offsetZ = followLookAtOffset.x * cos(angleRad);
|
const float offsetZ = followLookAtOffset.x * cos(angleRad);
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ namespace GKCamera {
|
|||||||
extern int followCharaIndex;
|
extern int followCharaIndex;
|
||||||
extern GakumasLocal::Misc::CSEnum bodyPartsEnum;
|
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,
|
UnityResolve::UnityType::Vector3 CalcPositionFromLookAt(const UnityResolve::UnityType::Vector3& target,
|
||||||
const UnityResolve::UnityType::Vector3& offset);
|
const UnityResolve::UnityType::Vector3& offset);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user