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/spline_base.cc')
-rw-r--r--source/blender/blenkernel/intern/spline_base.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc
index a7caae967f6..dda7abea0fc 100644
--- a/source/blender/blenkernel/intern/spline_base.cc
+++ b/source/blender/blenkernel/intern/spline_base.cc
@@ -189,7 +189,11 @@ static float3 direction_bisect(const float3 &prev, const float3 &middle, const f
const float3 dir_prev = (middle - prev).normalized();
const float3 dir_next = (next - middle).normalized();
- return (dir_prev + dir_next).normalized();
+ const float3 result = (dir_prev + dir_next).normalized();
+ if (UNLIKELY(result.is_zero())) {
+ return float3(0.0f, 0.0f, 1.0f);
+ }
+ return result;
}
static void calculate_tangents(Span<float3> positions,
@@ -197,6 +201,7 @@ static void calculate_tangents(Span<float3> positions,
MutableSpan<float3> tangents)
{
if (positions.size() == 1) {
+ tangents.first() = float3(0.0f, 0.0f, 1.0f);
return;
}
@@ -237,13 +242,8 @@ Span<float3> Spline::evaluated_tangents() const
Span<float3> positions = this->evaluated_positions();
- if (eval_size == 1) {
- evaluated_tangents_cache_.first() = float3(1.0f, 0.0f, 0.0f);
- }
- else {
- calculate_tangents(positions, is_cyclic_, evaluated_tangents_cache_);
- this->correct_end_tangents();
- }
+ calculate_tangents(positions, is_cyclic_, evaluated_tangents_cache_);
+ this->correct_end_tangents();
tangent_cache_dirty_ = false;
return evaluated_tangents_cache_;