2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CTIMESCALEFUNCTIONS_HPP__
|
|
|
|
#define __URDE_CTIMESCALEFUNCTIONS_HPP__
|
2016-04-11 03:59:54 +00:00
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
2018-01-30 01:04:01 +00:00
|
|
|
#include "CCharAnimTime.hpp"
|
2016-04-11 03:59:54 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
enum class EVaryingAnimationTimeScaleType
|
|
|
|
{
|
|
|
|
Constant,
|
|
|
|
Linear
|
|
|
|
};
|
|
|
|
|
|
|
|
class IVaryingAnimationTimeScale
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IVaryingAnimationTimeScale() = default;
|
|
|
|
virtual EVaryingAnimationTimeScaleType GetType() const=0;
|
2018-01-30 01:04:01 +00:00
|
|
|
virtual float VTimeScaleIntegral(float lowerLimit, float upperLimit) const=0;
|
|
|
|
virtual float VFindUpperLimit(float lowerLimit, float root) const=0;
|
|
|
|
virtual std::unique_ptr<IVaryingAnimationTimeScale> VClone() const=0;
|
|
|
|
virtual std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(float value) const=0;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> Clone() const;
|
2016-04-11 03:59:54 +00:00
|
|
|
};
|
|
|
|
|
2017-07-02 10:18:38 +00:00
|
|
|
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale
|
2016-04-11 03:59:54 +00:00
|
|
|
{
|
2017-07-02 10:18:38 +00:00
|
|
|
private:
|
2018-01-30 01:04:01 +00:00
|
|
|
float x4_scale;
|
2016-04-11 03:59:54 +00:00
|
|
|
public:
|
2018-01-30 01:04:01 +00:00
|
|
|
CConstantAnimationTimeScale(float scale) : x4_scale(scale) {}
|
2017-07-02 10:18:38 +00:00
|
|
|
|
|
|
|
EVaryingAnimationTimeScaleType GetType() const { return EVaryingAnimationTimeScaleType::Constant; }
|
2018-01-30 01:04:01 +00:00
|
|
|
float VTimeScaleIntegral(float lowerLimit, float upperLimit) const;
|
|
|
|
float VFindUpperLimit(float lowerLimit, float root) const;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VClone() const;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(float value) const;
|
2016-04-11 03:59:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale
|
|
|
|
{
|
|
|
|
struct CFunctionDescription
|
|
|
|
{
|
2018-01-30 01:04:01 +00:00
|
|
|
float x4_slope;
|
|
|
|
float x8_yIntercept;
|
|
|
|
float xc_t1;
|
|
|
|
float x10_t2;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> FunctionMirroredAround(float value) const;
|
|
|
|
} x4_desc;
|
|
|
|
static float FindUpperLimitFromRoot(const CFunctionDescription& desc,
|
|
|
|
float lowerLimit, float root);
|
|
|
|
static float TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc,
|
|
|
|
float lowerLimit, float upperLimit);
|
|
|
|
public:
|
|
|
|
CLinearAnimationTimeScale(const CCharAnimTime& t1, float y1,
|
|
|
|
const CCharAnimTime& t2, float y2);
|
2016-04-11 03:59:54 +00:00
|
|
|
|
|
|
|
EVaryingAnimationTimeScaleType GetType() const {return EVaryingAnimationTimeScaleType::Linear;}
|
2018-01-30 01:04:01 +00:00
|
|
|
float VTimeScaleIntegral(float lowerLimit, float upperLimit) const;
|
|
|
|
float VFindUpperLimit(float lowerLimit, float root) const;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VClone() const;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(float value) const;
|
2016-04-11 03:59:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CTIMESCALEFUNCTIONS_HPP__
|