summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-01-04 16:38:38 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-01-04 16:38:38 +0100
commitb88eddb6828061bfe5cbbeaf9a7991eb3e7ff98a (patch)
tree055730add6a86c52a532213b13c9fc1c4fb23cab /tests
parent0d18a945ca1424367d55bf4fd54270353939443f (diff)
parentacae38201077c8ee7013d2d9ec608dc8ee5c49c0 (diff)
downloadredot-engine-b88eddb6828061bfe5cbbeaf9a7991eb3e7ff98a.tar.gz
Merge pull request #78378 from 0xafbf/curve-evaluate-correct-transform
Changed the way the rotation of a curve at a point is evaluated to match PathFollow2D
Diffstat (limited to 'tests')
-rw-r--r--tests/scene/test_curve_2d.h36
1 files changed, 28 insertions, 8 deletions
diff --git a/tests/scene/test_curve_2d.h b/tests/scene/test_curve_2d.h
index fc141f3d09..099f6fefa9 100644
--- a/tests/scene/test_curve_2d.h
+++ b/tests/scene/test_curve_2d.h
@@ -155,17 +155,37 @@ TEST_CASE("[Curve2D] Sampling") {
SUBCASE("sample_baked_with_rotation") {
const real_t pi = 3.14159;
- Transform2D t = curve->sample_baked_with_rotation(curve->get_closest_offset(Vector2(0, 0)));
- CHECK(t.get_origin() == Vector2(0, 0));
- CHECK(Math::is_equal_approx(t.get_rotation(), pi));
-
- t = curve->sample_baked_with_rotation(curve->get_closest_offset(Vector2(0, 25)));
+ const real_t half_pi = pi * 0.5;
+ Ref<Curve2D> rot_curve = memnew(Curve2D);
+ Transform2D t;
+
+ rot_curve->clear_points();
+ rot_curve->add_point(Vector2());
+ rot_curve->add_point(Vector2(50, 0));
+ t = rot_curve->sample_baked_with_rotation(25);
+ CHECK(t.get_origin() == Vector2(25, 0));
+ CHECK(Math::is_equal_approx(t.get_rotation(), 0));
+
+ rot_curve->clear_points();
+ rot_curve->add_point(Vector2());
+ rot_curve->add_point(Vector2(0, 50));
+ t = rot_curve->sample_baked_with_rotation(25);
CHECK(t.get_origin() == Vector2(0, 25));
- CHECK(Math::is_equal_approx(t.get_rotation(), pi));
+ CHECK(Math::is_equal_approx(t.get_rotation(), half_pi));
- t = curve->sample_baked_with_rotation(curve->get_closest_offset(Vector2(0, 50)));
- CHECK(t.get_origin() == Vector2(0, 50));
+ rot_curve->clear_points();
+ rot_curve->add_point(Vector2());
+ rot_curve->add_point(Vector2(-50, 0));
+ t = rot_curve->sample_baked_with_rotation(25);
+ CHECK(t.get_origin() == Vector2(-25, 0));
CHECK(Math::is_equal_approx(t.get_rotation(), pi));
+
+ rot_curve->clear_points();
+ rot_curve->add_point(Vector2());
+ rot_curve->add_point(Vector2(0, -50));
+ t = rot_curve->sample_baked_with_rotation(25);
+ CHECK(t.get_origin() == Vector2(0, -25));
+ CHECK(Math::is_equal_approx(t.get_rotation(), -half_pi));
}
SUBCASE("get_closest_point") {