From e22e0763d94a94776a33f8557dddadc3432342cf Mon Sep 17 00:00:00 2001 From: XDA-Bam <1209896+XDA-Bam@users.noreply.github.com> Date: Mon, 11 May 2020 04:23:51 +0200 Subject: [PATCH] Reduce division in JD calc (#17945) --- Marlin/src/module/planner.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index f2b90cd994..60dbb612c7 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -910,8 +910,12 @@ class Planner { FORCE_INLINE static float limit_value_by_axis_maximum(const float &max_value, xyze_float_t &unit_vec) { float limit_value = max_value; - LOOP_XYZE(idx) if (unit_vec[idx]) // Avoid divide by zero - NOMORE(limit_value, ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx])); + LOOP_XYZE(idx) { + if (unit_vec[idx]) { + if (limit_value * ABS(unit_vec[idx]) > settings.max_acceleration_mm_per_s2[idx]) + limit_value = ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx]); + } + } return limit_value; }