Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_length_parameterize.hh
| Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | inline void sample_at_length(const Span<float> accumulated_segment_lengths, | ||||
| float &r_factor, | float &r_factor, | ||||
| SampleSegmentHint *hint = nullptr) | SampleSegmentHint *hint = nullptr) | ||||
| { | { | ||||
| /* Use a shorter variable name. */ | /* Use a shorter variable name. */ | ||||
| const Span<float> lengths = accumulated_segment_lengths; | const Span<float> lengths = accumulated_segment_lengths; | ||||
| BLI_assert(lengths.size() > 0); | BLI_assert(lengths.size() > 0); | ||||
| BLI_assert(sample_length >= 0.0f); | BLI_assert(sample_length >= 0.0f); | ||||
| BLI_assert(sample_length <= lengths.last()); | BLI_assert(sample_length <= lengths.last() + 0.00001f); | ||||
| if (hint != nullptr && hint->segment_index >= 0) { | if (hint != nullptr && hint->segment_index >= 0) { | ||||
| const float length_in_segment = sample_length - hint->segment_start; | const float length_in_segment = sample_length - hint->segment_start; | ||||
| const float factor = length_in_segment * hint->segment_length_inv; | const float factor = length_in_segment * hint->segment_length_inv; | ||||
| if (factor >= 0.0f && factor < 1.0f) { | if (factor >= 0.0f && factor < 1.0f) { | ||||
| r_segment_index = hint->segment_index; | r_segment_index = hint->segment_index; | ||||
| r_factor = factor; | r_factor = factor; | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines | |||||