Short-circuit zero scaled 2D objects

translation1
Marius Kintel 2014-01-28 01:16:02 -05:00
parent 0600d80046
commit fbcb807463
1 changed files with 6 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include "Polygon2d.h"
#include "printutils.h"
#include <boost/foreach.hpp>
/*!
@ -54,6 +55,11 @@ bool Polygon2d::isEmpty() const
void Polygon2d::transform(const Transform2d &mat)
{
if (mat.matrix().determinant() == 0) {
PRINT("Warning: Scaling a 2D object with 0 - removing object");
this->theoutlines.clear();
return;
}
BOOST_FOREACH(Outline2d &o, this->theoutlines) {
BOOST_FOREACH(Vector2d &v, o.vertices) {
v = mat * v;