Add camera transition smoothness
This commit is contained in:
@@ -40,6 +40,7 @@ static bool g_WorldTimeDilation_fix_enabled = false;
|
|||||||
static int g_AdditionalFOVValue = 0;
|
static int g_AdditionalFOVValue = 0;
|
||||||
static int g_CameraOffset = 0;
|
static int g_CameraOffset = 0;
|
||||||
static float g_WorldTimeDilationValue = 1.f;
|
static float g_WorldTimeDilationValue = 1.f;
|
||||||
|
static float g_CameraSmoothnessValue = 3.5f;
|
||||||
static float g_TransitionCameraOffset = 0.f;
|
static float g_TransitionCameraOffset = 0.f;
|
||||||
static float g_NativeCameraDistance = 80.f;
|
static float g_NativeCameraDistance = 80.f;
|
||||||
static float g_LastCameraDeltaTime = 1.f / 60.f; // fallback
|
static float g_LastCameraDeltaTime = 1.f / 60.f; // fallback
|
||||||
@@ -288,6 +289,11 @@ extern "C" __declspec(dllexport) void SetWorldTimeDilation(float timeDilation) {
|
|||||||
g_WorldTimeDilationValue = timeDilation;
|
g_WorldTimeDilationValue = timeDilation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void SetCameraSmoothness(float smoothness) {
|
||||||
|
g_CameraSmoothnessValue = smoothness;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Getters for Reshade addon call
|
// Getters for Reshade addon call
|
||||||
extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
||||||
if (!infos) return;
|
if (!infos) return;
|
||||||
@@ -501,16 +507,16 @@ static void CameraFixEnabled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float dt = g_LastCameraDeltaTime;
|
float dt = g_LastCameraDeltaTime;
|
||||||
float fadeInSpeed = 3.5f; // Camera speed when it's getting closer
|
float fadeInSpeed = g_CameraSmoothnessValue; // Camera speed when it's getting closer
|
||||||
float fadeOutSpeed = 3.5f; // Camera speed when it moves away
|
float fadeOutSpeed = g_CameraSmoothnessValue; // Camera speed when it moves away
|
||||||
// sécurité
|
// sécurité
|
||||||
if (dt <= 0.f || dt > 0.1f) dt = 1.f / 60.f;
|
if (dt <= 0.f || dt > 0.1f) dt = 1.f / 60.f;
|
||||||
|
|
||||||
float targetOffset = (bIsInPrinterMode || bIsInCinematicMode || bIsAiming) ?
|
float targetOffset = g_CameraOffset;
|
||||||
g_NativeCameraDistance : // Minimum offset
|
if (bIsInCinematicMode || bIsAiming) targetOffset = g_NativeCameraDistance;
|
||||||
(float)g_CameraOffset; // User offset
|
|
||||||
if (bIsInventoryOpen) targetOffset = INVENTORY_CAM_OFFSET;
|
if (bIsInventoryOpen) targetOffset = INVENTORY_CAM_OFFSET;
|
||||||
if (bIsInPrinterMode) targetOffset = FORGE_CAM_OFFSET;
|
else if (bIsInPrinterMode) targetOffset = FORGE_CAM_OFFSET;
|
||||||
|
|
||||||
float interpSpeed = (targetOffset < g_TransitionCameraOffset) ? fadeInSpeed : fadeOutSpeed;
|
float interpSpeed = (targetOffset < g_TransitionCameraOffset) ? fadeInSpeed : fadeOutSpeed;
|
||||||
|
|
||||||
g_TransitionCameraOffset = UKismetMathLibrary::FInterpTo(g_TransitionCameraOffset,
|
g_TransitionCameraOffset = UKismetMathLibrary::FInterpTo(g_TransitionCameraOffset,
|
||||||
|
|||||||
Reference in New Issue
Block a user