4jcraft/targets/minecraft/util/SmoothFloat.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

24 lines
685 B
C++

#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; }