summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYaohua Xiong <xiongyaohua@gmail.com>2022-11-24 20:43:34 +0800
committerYaohua Xiong <xiongyaohua@gmail.com>2022-12-05 21:22:05 +0800
commit91e9ad92f5f78dd1578df46205f028599f095357 (patch)
treef13fa7ecddc68dc33d4bac4016f77184fd483169 /tests
parent8912f3e4a7c012443e941f4c6f2342c9913fa330 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/scene/test_curve.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/scene/test_curve.h b/tests/scene/test_curve.h
index 36ec0c0a4d..4afd5b293f 100644
--- a/tests/scene/test_curve.h
+++ b/tests/scene/test_curve.h
@@ -31,6 +31,7 @@
#ifndef TEST_CURVE_H
#define TEST_CURVE_H
+#include "core/math/math_funcs.h"
#include "scene/resources/curve.h"
#include "tests/test_macros.h"
@@ -229,7 +230,7 @@ TEST_CASE("[Curve2D] Linear sampling should return exact value") {
for (int i = 0; i < len; i++) {
Vector2 pos = curve->sample_baked(i);
- CHECK_MESSAGE(pos.x == i, "sample_baked should return exact value");
+ CHECK_MESSAGE(Math::is_equal_approx(pos.x, i), "sample_baked should return exact value");
}
}
@@ -245,7 +246,7 @@ TEST_CASE("[Curve3D] Linear sampling should return exact value") {
for (int i = 0; i < len; i++) {
Vector3 pos = curve->sample_baked(i);
- CHECK_MESSAGE(pos.x == i, "sample_baked should return exact value");
+ CHECK_MESSAGE(Math::is_equal_approx(pos.x, i), "sample_baked should return exact value");
}
}