Fix #124431: Division by zero in Resample Curves

`get_count_input_from_length()` did not check whether length is zero,
this would cause division by zero exception. Now will return a segment
count of 1 when a zero length is given.

Pull Request: https://projects.blender.org/blender/blender/pulls/124440
This commit is contained in:
YimingWu
2024-07-10 14:23:35 +02:00
committed by YimingWu
parent 8025cd3933
commit 96cc9109fd

View File

@@ -37,6 +37,9 @@ static fn::Field<int> get_count_input_from_length(const fn::Field<float> &length
[](const float curve_length, const float sample_length) {
/* Find the number of sampled segments by dividing the total length by
* the sample length. Then there is one more sampled point than segment. */
if (UNLIKELY(sample_length == 0.0f)) {
return 1;
}
const int count = int(curve_length / sample_length) + 1;
return std::max(1, count);
},