Skip to content

Commit

Permalink
core: avoid recomputing unnecessary coastings, which sometimes crashed
Browse files Browse the repository at this point in the history
The forward coasting would sometimes not intersect with the
base curve, which causes some weirdness and 0-length steps.

That coasting would only happen if there's no intersection with
min speed limit. In that case, it's not actually necessary
to compute it (it's supposed to give the same result as the
backwards one).

Signed-off-by: Eloi Charpentier <[email protected]>
  • Loading branch information
eckter authored and Erashin committed Nov 25, 2024
1 parent d493d7e commit 46aa74f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ public static EnvelopePart coastFromEnd(

assert constrainedBuilder.getLastPos() < endPos;

if (!reachedLowLimit && constrainedBuilder.getLastPos() != envelope.getBeginPos())
if (!reachedLowLimit) {
return backwardPartBuilder.build();
// We only need to recompute a coasting going forward if the low speed limit has been reached,
// as we'd need to add accelerations in places where we've clipped the speed
}

var resultCoast = coastFromBeginning(
envelope, context, constrainedBuilder.getLastPos(), constrainedBuilder.getLastSpeed());
Expand Down

0 comments on commit 46aa74f

Please sign in to comment.