diff options
author | Jihyun Yu <yjh0502@gmail.com> | 2021-08-21 16:57:59 +0900 |
---|---|---|
committer | Jihyun Yu <yjh0502@gmail.com> | 2021-08-21 16:57:59 +0900 |
commit | 8a6fc54ccdba233b2951b8933798c03915739afd (patch) | |
tree | 13fd3f6d9c7c45df212ac440f8992427f880f64e /scene/resources/curve.h | |
parent | e599f1bdf0ca63b43350115941b6fba9b5333a5c (diff) | |
download | redot-engine-8a6fc54ccdba233b2951b8933798c03915739afd.tar.gz |
Curve2D/Curve3D: exact linear interpolation
While calculating interpolated points, intervals between two baked
points has been assummed to be `baked_interval`. The assumption could
cause significant error in some extreme cases (for example #7088).
To improve accuracy, `baked_dist_cache` is introduced, which stores
distance from starting point for each baked points. `interpolate_baked`
now returns exact linear-interpolated position along baked points.
Diffstat (limited to 'scene/resources/curve.h')
-rw-r--r-- | scene/resources/curve.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/scene/resources/curve.h b/scene/resources/curve.h index c25d307608..5808fd6508 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -161,6 +161,7 @@ class Curve2D : public Resource { mutable bool baked_cache_dirty = false; mutable PackedVector2Array baked_point_cache; + mutable PackedFloat32Array baked_dist_cache; mutable float baked_max_ofs = 0.0; void _bake() const; @@ -224,6 +225,7 @@ class Curve3D : public Resource { mutable PackedVector3Array baked_point_cache; mutable Vector<real_t> baked_tilt_cache; mutable PackedVector3Array baked_up_vector_cache; + mutable PackedFloat32Array baked_dist_cache; mutable float baked_max_ofs = 0.0; void _bake() const; |