Fixed GCodeAnalyzer and GCodeTimeEstimator to avoid artifacts while rendering toolpaths due to numerical issues on extruder coordinate
This commit is contained in:
parent
5fe3ddf26f
commit
91acbd01ed
@ -311,24 +311,22 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line)
|
|||||||
{
|
{
|
||||||
auto axis_absolute_position = [this](GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1) -> float
|
auto axis_absolute_position = [this](GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1) -> float
|
||||||
{
|
{
|
||||||
float current_absolute_position = _get_axis_position(axis);
|
|
||||||
float current_origin = _get_axis_origin(axis);
|
|
||||||
float lengthsScaleFactor = (_get_units() == GCodeAnalyzer::Inches) ? INCHES_TO_MM : 1.0f;
|
|
||||||
|
|
||||||
bool is_relative = (_get_global_positioning_type() == Relative);
|
bool is_relative = (_get_global_positioning_type() == Relative);
|
||||||
if (axis == E)
|
if (axis == E)
|
||||||
is_relative |= (_get_e_local_positioning_type() == Relative);
|
is_relative |= (_get_e_local_positioning_type() == Relative);
|
||||||
|
|
||||||
if (lineG1.has(Slic3r::Axis(axis)))
|
if (lineG1.has(Slic3r::Axis(axis)))
|
||||||
{
|
{
|
||||||
|
float lengthsScaleFactor = (_get_units() == GCodeAnalyzer::Inches) ? INCHES_TO_MM : 1.0f;
|
||||||
float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor;
|
float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor;
|
||||||
return is_relative ? current_absolute_position + ret : ret + current_origin;
|
return is_relative ? _get_axis_position(axis) + ret : _get_axis_origin(axis) + ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return current_absolute_position;
|
return _get_axis_position(axis);
|
||||||
};
|
};
|
||||||
|
|
||||||
// updates axes positions from line
|
// updates axes positions from line
|
||||||
|
|
||||||
float new_pos[Num_Axis];
|
float new_pos[Num_Axis];
|
||||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||||
{
|
{
|
||||||
@ -352,7 +350,7 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line)
|
|||||||
if (delta_pos[E] < 0.0f)
|
if (delta_pos[E] < 0.0f)
|
||||||
{
|
{
|
||||||
if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f) || (delta_pos[Z] != 0.0f))
|
if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f) || (delta_pos[Z] != 0.0f))
|
||||||
type = GCodeMove::Move;
|
type = GCodeMove::Move;
|
||||||
else
|
else
|
||||||
type = GCodeMove::Retract;
|
type = GCodeMove::Retract;
|
||||||
}
|
}
|
||||||
@ -440,7 +438,9 @@ void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line)
|
|||||||
|
|
||||||
if (line.has_e())
|
if (line.has_e())
|
||||||
{
|
{
|
||||||
_set_axis_origin(E, _get_axis_position(E) - line.e() * lengthsScaleFactor);
|
// extruder coordinate can grow to the point where its float representation does not allow for proper addition with small increments,
|
||||||
|
// we set the value taken from the G92 line as the new current position for it
|
||||||
|
_set_axis_position(E, line.e() * lengthsScaleFactor);
|
||||||
anyFound = true;
|
anyFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1261,7 +1261,9 @@ namespace Slic3r {
|
|||||||
|
|
||||||
if (line.has_e())
|
if (line.has_e())
|
||||||
{
|
{
|
||||||
set_axis_origin(E, get_axis_position(E) - line.e() * lengthsScaleFactor);
|
// extruder coordinate can grow to the point where its float representation does not allow for proper addition with small increments,
|
||||||
|
// we set the value taken from the G92 line as the new current position for it
|
||||||
|
set_axis_position(E, line.e() * lengthsScaleFactor);
|
||||||
anyFound = true;
|
anyFound = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user