Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/curve_poly.cc')
-rw-r--r--source/blender/blenkernel/intern/curve_poly.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/curve_poly.cc b/source/blender/blenkernel/intern/curve_poly.cc
index 7ab92068d81..2b2cf9adeee 100644
--- a/source/blender/blenkernel/intern/curve_poly.cc
+++ b/source/blender/blenkernel/intern/curve_poly.cc
@@ -65,8 +65,21 @@ void calculate_tangents(const Span<float3> positions,
tangents.last() = direction_bisect(second_to_last, last, first, used_fallback);
}
else {
- tangents.first() = math::normalize(positions[1] - positions.first());
- tangents.last() = math::normalize(positions.last() - positions[positions.size() - 2]);
+ const float epsilon = 1e-6f;
+ if (math::almost_equal_relative(positions[0], positions[1], epsilon)) {
+ tangents.first() = {0.0f, 0.0f, 0.0f};
+ used_fallback = true;
+ }
+ else {
+ tangents.first() = math::normalize(positions[1] - positions[0]);
+ }
+ if (math::almost_equal_relative(positions.last(0), positions.last(1), epsilon)) {
+ tangents.last() = {0.0f, 0.0f, 0.0f};
+ used_fallback = true;
+ }
+ else {
+ tangents.last() = math::normalize(positions.last(0) - positions.last(1));
+ }
}
if (!used_fallback) {