2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
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
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-04-11 03:59:54 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EVaryingAnimationTimeScaleType { Constant, Linear };
|
2016-04-11 03:59:54 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class IVaryingAnimationTimeScale {
|
2016-04-11 03:59:54 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual ~IVaryingAnimationTimeScale() = default;
|
|
|
|
virtual EVaryingAnimationTimeScaleType GetType() const = 0;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale {
|
2017-07-02 10:18:38 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
float x4_scale;
|
|
|
|
|
2016-04-11 03:59:54 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CConstantAnimationTimeScale(float scale) : x4_scale(scale) {}
|
2017-07-02 10:18:38 +00:00
|
|
|
|
2019-08-09 19:46:49 +00:00
|
|
|
EVaryingAnimationTimeScaleType GetType() const override { return EVaryingAnimationTimeScaleType::Constant; }
|
|
|
|
float VTimeScaleIntegral(float lowerLimit, float upperLimit) const override;
|
|
|
|
float VFindUpperLimit(float lowerLimit, float root) const override;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VClone() const override;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(float value) const override;
|
2016-04-11 03:59:54 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale {
|
|
|
|
struct CFunctionDescription {
|
|
|
|
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);
|
|
|
|
|
2018-01-30 01:04:01 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CLinearAnimationTimeScale(const CCharAnimTime& t1, float y1, const CCharAnimTime& t2, float y2);
|
2016-04-11 03:59:54 +00:00
|
|
|
|
2019-08-09 19:46:49 +00:00
|
|
|
EVaryingAnimationTimeScaleType GetType() const override { return EVaryingAnimationTimeScaleType::Linear; }
|
|
|
|
float VTimeScaleIntegral(float lowerLimit, float upperLimit) const override;
|
|
|
|
float VFindUpperLimit(float lowerLimit, float root) const override;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VClone() const override;
|
|
|
|
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(float value) const override;
|
2016-04-11 03:59:54 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|