From cde662cb51677e782db9dee2fe227f58ee9ed950 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Fri, 9 Aug 2013 14:22:41 +0200
Subject: [PATCH] Fix collision detection for brim

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

diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm
index 5bcc4b92a..1ca8ef38e 100644
--- a/lib/Slic3r/Print.pm
+++ b/lib/Slic3r/Print.pm
@@ -680,8 +680,9 @@ sub make_brim {
     for my $i (reverse 1 .. $num_loops) {
         # JT_SQUARE ensures no vertex is outside the given offset distance
         # -0.5 because islands are not represented by their centerlines
-        # TODO: we need the offset inwards/offset outwards logic to avoid overlapping extrusions
-        push @loops, offset2(\@islands, ($i - 1.5) * $flow->scaled_spacing, +1.0 * $flow->scaled_spacing, undef, JT_SQUARE);
+        # (first offset more, then step back - reverse order than the one used for 
+        # perimeters because here we're offsetting outwards)
+        push @loops, offset2(\@islands, ($i + 1.0) * $flow->scaled_spacing, -1.5 * $flow->scaled_spacing, undef, JT_SQUARE);
     }
     
     @{$self->brim} = map Slic3r::ExtrusionLoop->pack(