blob: 116a6d7d33452aa37d7b086eb987399538ff7e7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}
|