2026-05-13 15:10:37 +08:00
|
|
|
#pragma once
|
|
|
|
|
#include <TestProject/RNG/model/IModel.h>
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
using json = nlohmann::json;
|
|
|
|
|
|
|
|
|
|
struct DriftModel : IModel {
|
|
|
|
|
float base, drift_rate;
|
2026-05-13 16:34:00 +08:00
|
|
|
size_t period_ticks;
|
2026-05-13 15:10:37 +08:00
|
|
|
DriftModel(const json& params, float defaultVal)
|
2026-05-13 16:34:00 +08:00
|
|
|
: base(defaultVal), drift_rate(params.value("drift_rate", 0.0f))
|
|
|
|
|
, period_ticks(params.value("period_ms", 0) / 20) {}
|
|
|
|
|
float evaluate(size_t t) override {
|
|
|
|
|
if (period_ticks > 0) t %= period_ticks;
|
|
|
|
|
return base + drift_rate * t;
|
|
|
|
|
}
|
2026-05-13 15:10:37 +08:00
|
|
|
};
|