stepcompress: Optimize push_delta_const() for common XY or Z only moves
Most moves are on the XY plane - avoid a few multiplications in the inner loop in this case. When there is a Z move, it is almost always entirely a Z move - avoid the sqrt() call in the inner loop in this case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
9c932ad514
commit
4565a73e91
|
@ -465,12 +465,31 @@ stepcompress_push_delta_const(
|
||||||
clock_offset += 0.5;
|
clock_offset += 0.5;
|
||||||
start_pos += movexy_r*closestxy_d;
|
start_pos += movexy_r*closestxy_d;
|
||||||
height += .5 * step_dist;
|
height += .5 * step_dist;
|
||||||
while (qn < end) {
|
if (!movez_r) {
|
||||||
double relheight = movexy_r*height - movez_r*closestxy_d;
|
// Optmized case for common XY only moves (no Z movement)
|
||||||
double v = safe_sqrt(closest_height2 - relheight*relheight);
|
while (qn < end) {
|
||||||
double pos = start_pos + movez_r*height + (step_dist > 0. ? -v : v);
|
double v = safe_sqrt(closest_height2 - height*height);
|
||||||
*qn++ = clock_offset + pos * inv_velocity;
|
double pos = start_pos + (step_dist > 0. ? -v : v);
|
||||||
height += step_dist;
|
*qn++ = clock_offset + pos * inv_velocity;
|
||||||
|
height += step_dist;
|
||||||
|
}
|
||||||
|
} else if (!movexy_r) {
|
||||||
|
// Optmized case for Z only moves
|
||||||
|
double v = (step_dist > 0. ? -end_height : end_height);
|
||||||
|
while (qn < end) {
|
||||||
|
double pos = start_pos + movez_r*height + v;
|
||||||
|
*qn++ = clock_offset + pos * inv_velocity;
|
||||||
|
height += step_dist;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// General case (handles XY+Z moves)
|
||||||
|
while (qn < end) {
|
||||||
|
double relheight = movexy_r*height - movez_r*closestxy_d;
|
||||||
|
double v = safe_sqrt(closest_height2 - relheight*relheight);
|
||||||
|
double pos = start_pos + movez_r*height + (step_dist > 0. ? -v : v);
|
||||||
|
*qn++ = clock_offset + pos * inv_velocity;
|
||||||
|
height += step_dist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sc->queue_next = qn;
|
sc->queue_next = qn;
|
||||||
return step_dist > 0. ? count : -count;
|
return step_dist > 0. ? count : -count;
|
||||||
|
|
Loading…
Reference in New Issue