From 36596bf569a2764f527ab80a26992039daed9c67 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Mon, 12 Aug 2013 20:27:25 +0200
Subject: [PATCH] Bugfix: alignment code for rectilinear infill caused lack of
 infill (regression in 948b43f). #1387

---
 lib/Slic3r/Fill/Rectilinear.pm | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/Slic3r/Fill/Rectilinear.pm b/lib/Slic3r/Fill/Rectilinear.pm
index 50567dc39..7e3745a96 100644
--- a/lib/Slic3r/Fill/Rectilinear.pm
+++ b/lib/Slic3r/Fill/Rectilinear.pm
@@ -32,9 +32,8 @@ sub fill_surface {
         $flow_spacing = unscale $line_spacing;
     } else {
         # extend bounding box so that our pattern will be aligned with other layers
-        # $bounding_box->[X1] and [Y1] represent the displacement between new bounding box offset and old one
-        $bounding_box->extents->[X][MIN] -= $bounding_box->x_min;
-        $bounding_box->extents->[Y][MIN] -= $bounding_box->y_min;
+        $bounding_box->extents->[X][MIN] -= $bounding_box->x_min % $line_spacing;
+        $bounding_box->extents->[Y][MIN] -= $bounding_box->y_min % $line_spacing;
     }
     
     # generate the basic pattern