mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 05:07:51 -06:00
Reduced ram used by GCodeTimeEstimator by removing unused redundant data from GCodeTimeEstimator::Block::Trapezoid
This commit is contained in:
parent
bf3888fc49
commit
da86472bf1
2 changed files with 14 additions and 19 deletions
|
@ -46,19 +46,19 @@ namespace Slic3r {
|
||||||
::memset(abs_axis_feedrate, 0, Num_Axis * sizeof(float));
|
::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
|
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
|
float GCodeTimeEstimator::Block::Trapezoid::cruise_distance() const
|
||||||
|
@ -78,10 +78,6 @@ namespace Slic3r {
|
||||||
return ::sqrt(value);
|
return ::sqrt(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
GCodeTimeEstimator::Block::Block()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
float GCodeTimeEstimator::Block::move_length() const
|
float GCodeTimeEstimator::Block::move_length() const
|
||||||
{
|
{
|
||||||
float length = ::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
|
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
|
float GCodeTimeEstimator::Block::acceleration_time() const
|
||||||
{
|
{
|
||||||
return trapezoid.acceleration_time(acceleration);
|
return trapezoid.acceleration_time(feedrate.entry, acceleration);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GCodeTimeEstimator::Block::cruise_time() const
|
float GCodeTimeEstimator::Block::cruise_time() const
|
||||||
|
@ -110,7 +106,7 @@ namespace Slic3r {
|
||||||
|
|
||||||
float GCodeTimeEstimator::Block::deceleration_time() const
|
float GCodeTimeEstimator::Block::deceleration_time() const
|
||||||
{
|
{
|
||||||
return trapezoid.deceleration_time(acceleration);
|
return trapezoid.deceleration_time(move_length(), acceleration);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GCodeTimeEstimator::Block::cruise_distance() const
|
float GCodeTimeEstimator::Block::cruise_distance() const
|
||||||
|
@ -122,8 +118,7 @@ namespace Slic3r {
|
||||||
{
|
{
|
||||||
float distance = move_length();
|
float distance = move_length();
|
||||||
|
|
||||||
trapezoid.distance = distance;
|
trapezoid.cruise_feedrate = feedrate.cruise;
|
||||||
trapezoid.feedrate = feedrate;
|
|
||||||
|
|
||||||
float accelerate_distance = std::max(0.0f, estimate_acceleration_distance(feedrate.entry, feedrate.cruise, acceleration));
|
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));
|
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));
|
accelerate_distance = clamp(0.0f, distance, intersection_distance(feedrate.entry, feedrate.exit, acceleration, distance));
|
||||||
cruise_distance = 0.0f;
|
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;
|
trapezoid.accelerate_until = accelerate_distance;
|
||||||
|
@ -833,6 +828,7 @@ namespace Slic3r {
|
||||||
void GCodeTimeEstimator::_calculate_time()
|
void GCodeTimeEstimator::_calculate_time()
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
PROFILE_FUNC();
|
||||||
|
|
||||||
_forward_pass();
|
_forward_pass();
|
||||||
_reverse_pass();
|
_reverse_pass();
|
||||||
_recalculate_trapezoids();
|
_recalculate_trapezoids();
|
||||||
|
|
|
@ -125,14 +125,13 @@ namespace Slic3r {
|
||||||
|
|
||||||
struct Trapezoid
|
struct Trapezoid
|
||||||
{
|
{
|
||||||
float distance; // mm
|
|
||||||
float accelerate_until; // mm
|
float accelerate_until; // mm
|
||||||
float decelerate_after; // 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 cruise_time() const;
|
||||||
float deceleration_time(float acceleration) const;
|
float deceleration_time(float distance, float acceleration) const;
|
||||||
float cruise_distance() const;
|
float cruise_distance() const;
|
||||||
|
|
||||||
// This function gives the time needed to accelerate from an initial speed to reach a final distance.
|
// 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;
|
Trapezoid trapezoid;
|
||||||
float elapsed_time;
|
float elapsed_time;
|
||||||
|
|
||||||
Block();
|
Block() = default;
|
||||||
|
|
||||||
// Returns the length of the move covered by this block, in mm
|
// Returns the length of the move covered by this block, in mm
|
||||||
float move_length() const;
|
float move_length() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue