Skip to content

Commit

Permalink
Fix CubicCurve::iter_samples iteration count (#8049)
Browse files Browse the repository at this point in the history
# Objective

Fix `CubicCurve::iter_samples` iteration count.

## Solution

If I understand the function and the docs correctly, this should iterate
over `0..=subdivisions` instead of `0..subdivisions`.
For example: Now the iteration returns 3 points at `subdivisions = 2`,
as indicated in the documentation.
  • Loading branch information
jannik4 authored and cart committed Mar 31, 2023
1 parent 42732c0 commit 2bc7140
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_math/src/cubic_splines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ impl<P: Point> CubicCurve<P> {
subdivisions: usize,
sample_function: fn(&Self, f32) -> P,
) -> impl Iterator<Item = P> + '_ {
(0..subdivisions).map(move |i| {
(0..=subdivisions).map(move |i| {
let segments = self.segments.len() as f32;
let t = i as f32 / subdivisions as f32 * segments;
sample_function(self, t)
Expand Down

0 comments on commit 2bc7140

Please sign in to comment.