Bugfix: 2D scale or mirror sometimes caused flipped normals which caused larger issues downstream. Fixes #1055

master
Marius Kintel 2014-12-07 20:09:45 -05:00
parent 6c6882fb2e
commit ccea6fdde9
1 changed files with 6 additions and 1 deletions

View File

@ -547,7 +547,12 @@ Response GeometryEvaluator::visit(State &state, const TransformNode &node)
node.matrix(1,0), node.matrix(1,1), node.matrix(1,3),
node.matrix(3,0), node.matrix(3,1), node.matrix(3,3);
newpoly->transform(mat2);
geom = newpoly;
// A 2D transformation may flip the winding order of a polygon.
// If that happens with a sanitized polygon, we need to reverse
// the winding order for it to be correct.
if (newpoly->isSanitized() && mat2.matrix().determinant() <= 0) {
geom.reset(ClipperUtils::sanitize(*newpoly));
}
}
else if (geom->getDimension() == 3) {
shared_ptr<const PolySet> ps = dynamic_pointer_cast<const PolySet>(geom);