From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/SmoothFloat.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Minecraft.World/SmoothFloat.cpp (limited to 'Minecraft.World/SmoothFloat.cpp') diff --git a/Minecraft.World/SmoothFloat.cpp b/Minecraft.World/SmoothFloat.cpp new file mode 100644 index 00000000..116a6d7d --- /dev/null +++ b/Minecraft.World/SmoothFloat.cpp @@ -0,0 +1,29 @@ +#include "stdafx.h" +#include "SmoothFloat.h" + +SmoothFloat::SmoothFloat() +{ + targetValue = 0.0f; + remainingValue = 0.0f; + lastAmount = 0.0f; +} + +float SmoothFloat::getNewDeltaValue(float deltaValue, float accelerationAmount) +{ + targetValue += deltaValue; + + deltaValue = (targetValue - remainingValue) * accelerationAmount; + lastAmount = lastAmount + (deltaValue - lastAmount) * 0.5f; + if ((deltaValue > 0 && deltaValue > lastAmount) || (deltaValue < 0 && deltaValue < lastAmount)) + { + deltaValue = lastAmount; + } + remainingValue += deltaValue; + + return deltaValue; +} + +float SmoothFloat::getTargetValue() +{ + return targetValue; +} \ No newline at end of file -- cgit v1.2.3