Fix path being closed when resampling (#1542)

This commit is contained in:
0HyperCube 2024-01-03 14:39:12 +00:00 committed by GitHub
parent ed82c5f20f
commit 7251d81a65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -38,12 +38,12 @@ impl<ManipulatorGroupId: crate::Identifier> Subpath<ManipulatorGroupId> {
let mut accumulator = 0.;
for (index, length) in lengths.iter().enumerate() {
let length_ratio = length / total_length;
if accumulator <= global_t && global_t <= accumulator + length_ratio {
return (index, (global_t - accumulator) / length_ratio);
if (index == 0 || accumulator <= global_t) && global_t <= accumulator + length_ratio {
return (index, ((global_t - accumulator) / length_ratio).clamp(0., 1.));
}
accumulator += length_ratio;
}
(0, 0.)
(self.len() - 2, 1.)
}
/// Convert a [SubpathTValue] to a parametric `(segment_index, t)` tuple.