Refactor baking code for Curve2D

The main change is to caculate tangent directly from bezier curve, without going
through discretized polyline, avoiding pitfalls of discretization. A similar refacor
had been applied to Curve3D.

The test cases for Curve2D is updated, comparing floating point with is_equal_approxmiate()
instead of `==`, in order to avoid float precision problem.
This commit is contained in:
Yaohua Xiong
2022-11-24 20:43:34 +08:00
parent 8912f3e4a7
commit 91e9ad92f5
9 changed files with 221 additions and 142 deletions

View File

@@ -177,7 +177,7 @@ void PathFollow2D::_update_transform() {
}
if (rotates) {
Transform2D xform = c->sample_baked_with_rotation(progress, cubic, loop, lookahead);
Transform2D xform = c->sample_baked_with_rotation(progress, cubic);
xform.translate_local(v_offset, h_offset);
set_rotation(xform[1].angle());
set_position(xform[2]);