diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/STL.pm index 25288010..ac584340 100644 --- a/lib/Slic3r/STL.pm +++ b/lib/Slic3r/STL.pm @@ -2,6 +2,7 @@ package Slic3r::STL; use Moo; use CAD::Format::STL; +use Math::Clipper qw(is_counter_clockwise); use XXX; use constant X => 0; @@ -107,8 +108,7 @@ sub _facet { # the normal using the right-hand rule # (this relies on the STL to be well-formed) # recompute the normal using the right-hand rule - my $clockwise = ($vertices[2]->[X] - $vertices[0]->[X]) * ($vertices[1]->[Y] - $vertices[0]->[Y]) - - ($vertices[1]->[X] - $vertices[0]->[X]) * ($vertices[2]->[Y] - $vertices[0]->[Y]); + my $clockwise = !is_counter_clockwise([@vertices]); # defensive programming and/or input check if (($normal->[Z] > 0 && $clockwise > 0) || ($normal->[Z] < 0 && $clockwise < 0)) { diff --git a/slic3r.pl b/slic3r.pl index 430a2812..d7855d95 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -119,7 +119,7 @@ if ($action eq 'skein') { my $processing_time = tv_interval($t0); printf "Done. Process took %d minutes and %.3f seconds\n", - int($processing_time/60), $processing_time - int($processing_time/60); + int($processing_time/60), $processing_time - int($processing_time/60)*60; } sub usage {