diff --git a/src/libslic3r/GCodeTimeEstimator.cpp b/src/libslic3r/GCodeTimeEstimator.cpp index 44b6a3d24..bc432ad1b 100644 --- a/src/libslic3r/GCodeTimeEstimator.cpp +++ b/src/libslic3r/GCodeTimeEstimator.cpp @@ -46,19 +46,19 @@ namespace Slic3r { ::memset(abs_axis_feedrate, 0, Num_Axis * sizeof(float)); } - float GCodeTimeEstimator::Block::Trapezoid::acceleration_time(float acceleration) const + float GCodeTimeEstimator::Block::Trapezoid::acceleration_time(float entry_feedrate, float acceleration) const { - return acceleration_time_from_distance(feedrate.entry, accelerate_until, acceleration); + return acceleration_time_from_distance(entry_feedrate, accelerate_until, acceleration); } float GCodeTimeEstimator::Block::Trapezoid::cruise_time() const { - return (feedrate.cruise != 0.0f) ? cruise_distance() / feedrate.cruise : 0.0f; + return (cruise_feedrate != 0.0f) ? cruise_distance() / cruise_feedrate : 0.0f; } - float GCodeTimeEstimator::Block::Trapezoid::deceleration_time(float acceleration) const + float GCodeTimeEstimator::Block::Trapezoid::deceleration_time(float distance, float acceleration) const { - return acceleration_time_from_distance(feedrate.cruise, (distance - decelerate_after), -acceleration); + return acceleration_time_from_distance(cruise_feedrate, (distance - decelerate_after), -acceleration); } float GCodeTimeEstimator::Block::Trapezoid::cruise_distance() const @@ -78,10 +78,6 @@ namespace Slic3r { return ::sqrt(value); } - GCodeTimeEstimator::Block::Block() - { - } - float GCodeTimeEstimator::Block::move_length() const { float length = ::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z])); @@ -100,7 +96,7 @@ namespace Slic3r { float GCodeTimeEstimator::Block::acceleration_time() const { - return trapezoid.acceleration_time(acceleration); + return trapezoid.acceleration_time(feedrate.entry, acceleration); } float GCodeTimeEstimator::Block::cruise_time() const @@ -110,7 +106,7 @@ namespace Slic3r { float GCodeTimeEstimator::Block::deceleration_time() const { - return trapezoid.deceleration_time(acceleration); + return trapezoid.deceleration_time(move_length(), acceleration); } float GCodeTimeEstimator::Block::cruise_distance() const @@ -122,8 +118,7 @@ namespace Slic3r { { float distance = move_length(); - trapezoid.distance = distance; - trapezoid.feedrate = feedrate; + trapezoid.cruise_feedrate = feedrate.cruise; float accelerate_distance = std::max(0.0f, estimate_acceleration_distance(feedrate.entry, feedrate.cruise, acceleration)); float decelerate_distance = std::max(0.0f, estimate_acceleration_distance(feedrate.cruise, feedrate.exit, -acceleration)); @@ -136,7 +131,7 @@ namespace Slic3r { { accelerate_distance = clamp(0.0f, distance, intersection_distance(feedrate.entry, feedrate.exit, acceleration, distance)); cruise_distance = 0.0f; - trapezoid.feedrate.cruise = Trapezoid::speed_from_distance(feedrate.entry, accelerate_distance, acceleration); + trapezoid.cruise_feedrate = Trapezoid::speed_from_distance(feedrate.entry, accelerate_distance, acceleration); } trapezoid.accelerate_until = accelerate_distance; @@ -833,6 +828,7 @@ namespace Slic3r { void GCodeTimeEstimator::_calculate_time() { PROFILE_FUNC(); + _forward_pass(); _reverse_pass(); _recalculate_trapezoids(); diff --git a/src/libslic3r/GCodeTimeEstimator.hpp b/src/libslic3r/GCodeTimeEstimator.hpp index 7c364d9eb..01b285456 100644 --- a/src/libslic3r/GCodeTimeEstimator.hpp +++ b/src/libslic3r/GCodeTimeEstimator.hpp @@ -125,14 +125,13 @@ namespace Slic3r { struct Trapezoid { - float distance; // mm float accelerate_until; // mm float decelerate_after; // mm - FeedrateProfile feedrate; + float cruise_feedrate; // mm/sec - float acceleration_time(float acceleration) const; + float acceleration_time(float entry_feedrate, float acceleration) const; float cruise_time() const; - float deceleration_time(float acceleration) const; + float deceleration_time(float distance, float acceleration) const; float cruise_distance() const; // This function gives the time needed to accelerate from an initial speed to reach a final distance. @@ -162,7 +161,7 @@ namespace Slic3r { Trapezoid trapezoid; float elapsed_time; - Block(); + Block() = default; // Returns the length of the move covered by this block, in mm float move_length() const;