mirror of https://github.com/axmolengine/axmol.git
29 lines
569 B
C++
29 lines
569 B
C++
|
#include "Base.h"
|
||
|
#include "MathUtil.h"
|
||
|
|
||
|
namespace gameplay
|
||
|
{
|
||
|
|
||
|
void MathUtil::smooth(float* x, float target, float elapsedTime, float responseTime)
|
||
|
{
|
||
|
GP_ASSERT(x);
|
||
|
|
||
|
if (elapsedTime > 0)
|
||
|
{
|
||
|
*x += (target - *x) * elapsedTime / (elapsedTime + responseTime);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void MathUtil::smooth(float* x, float target, float elapsedTime, float riseTime, float fallTime)
|
||
|
{
|
||
|
GP_ASSERT(x);
|
||
|
|
||
|
if (elapsedTime > 0)
|
||
|
{
|
||
|
float delta = target - *x;
|
||
|
*x += delta * elapsedTime / (elapsedTime + (delta > 0 ? riseTime : fallTime));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|