VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
curveEvaluator.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3#pragma once
4
5#include <limits>
6#include <vector>
7
8namespace visutwin::canvas
9{
10 class Curve;
11
13 {
14 public:
15 explicit CurveEvaluator(Curve* curve, float time = 0.0f);
16
17 float evaluate(float time, bool forceReset = false);
18
19 private:
20 void reset(float time);
21 void calcTangents(const std::vector<std::pair<float, float>>& keys, size_t index);
22
23 static float evaluateHermite(float p0, float p1, float m0, float m1, float t);
24
25 Curve* _curve = nullptr;
26
27 float _left = -std::numeric_limits<float>::infinity();
28 float _right = std::numeric_limits<float>::infinity();
29
30 float _recip = 0.0f;
31 float _p0 = 0.0f;
32 float _p1 = 0.0f;
33 float _m0 = 0.0f;
34 float _m1 = 0.0f;
35 };
36}
float evaluate(float time, bool forceReset=false)
CurveEvaluator(Curve *curve, float time=0.0f)