Skip to content

Commit

Permalink
Fix floating point rounding issue
Browse files Browse the repository at this point in the history
The calculated line width is quite important here, because GCodePath
objects may be merged (or not) depending on it, and sometimes the value
would be rounded to a very close value, but not equal. We now use llrint
to make sure we round to the neareset value.

CURA-12038
  • Loading branch information
wawanbreton committed Jul 11, 2024
1 parent 40a6bf2 commit a9574d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ void LayerPlan::addWall(
for (size_t piece = 0; piece < pieces; ++piece)
{
const double average_progress = (double(piece) + 0.5) / pieces; // How far along this line to sample the line width in the middle of this piece.
const coord_t line_width = p0.w_ + average_progress * delta_line_width;
const coord_t line_width = std::lrint(p0.w_ + average_progress * delta_line_width);
const Point2LL destination = p0.p_ + normal(line_vector, piece_length * (piece + 1));
if (is_small_feature)
{
Expand Down

0 comments on commit a9574d6

Please sign in to comment.