2022-04-23 21:47:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <deque>
|
2023-08-07 13:35:19 +02:00
|
|
|
#include <array>
|
|
|
|
#include <vector>
|
2024-06-19 16:20:06 +02:00
|
|
|
#include "math/Math.hpp"
|
2022-04-23 21:47:16 +02:00
|
|
|
|
2023-03-03 14:17:11 +01:00
|
|
|
constexpr int BAKEDPOINTS = 255;
|
2022-04-23 23:16:43 +02:00
|
|
|
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;
|
|
|
|
|
2022-04-23 21:47:16 +02:00
|
|
|
// an implementation of a cubic bezier curve
|
|
|
|
// might do better later
|
|
|
|
class CBezierCurve {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2022-04-23 21:47:16 +02:00
|
|
|
// sets up the bezier curve.
|
|
|
|
// this EXCLUDES the 0,0 and 1,1 points,
|
2022-12-16 18:17:31 +01:00
|
|
|
void setup(std::vector<Vector2D>* points);
|
2022-04-23 21:47:16 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
float getYForT(float t);
|
|
|
|
float getXForT(float t);
|
|
|
|
float getYForPoint(float x);
|
2022-04-23 21:47:16 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
private:
|
2022-04-23 21:47:16 +02:00
|
|
|
// this INCLUDES the 0,0 and 1,1 points.
|
2022-12-16 18:17:31 +01:00
|
|
|
std::deque<Vector2D> m_dPoints;
|
2022-04-23 21:47:16 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
std::array<Vector2D, BAKEDPOINTS> m_aPointsBaked;
|
2023-09-17 19:48:11 +02:00
|
|
|
};
|