Browse Source

Explicitly optimize x/x in Classic Jerk (#18112)

Can we outsmart the compiler?
vanilla_fb_2.0.x
XDA-Bam 4 years ago
committed by GitHub
parent
commit
5fbea83840
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      Marlin/src/module/planner.cpp

16
Marlin/src/module/planner.cpp

@ -2456,16 +2456,16 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
// Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
CACHED_SQRT(previous_nominal_speed, previous_nominal_speed_sqr);
vmax_junction = _MIN(nominal_speed, previous_nominal_speed);
float smaller_speed_factor = 1.0f;
if (nominal_speed < previous_nominal_speed) {
vmax_junction = nominal_speed;
smaller_speed_factor = vmax_junction / previous_nominal_speed;
}
else
vmax_junction = previous_nominal_speed;
// Now limit the jerk in all axes.
const float smaller_speed_factor = vmax_junction / previous_nominal_speed;
#if HAS_LINEAR_E_JERK
LOOP_XYZ(axis)
#else
LOOP_XYZE(axis)
#endif
{
TERN(HAS_LINEAR_E_JERK, LOOP_XYZ, LOOP_XYZE)(axis) {
// Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop.
float v_exit = previous_speed[axis] * smaller_speed_factor,
v_entry = current_speed[axis];

Loading…
Cancel
Save