Sfoglia il codice sorgente

Fix incorrect comparison operator

Tomasz Zieliński 1 anno fa
parent
commit
37d062f1eb
1 ha cambiato i file con 5 aggiunte e 9 eliminazioni
  1. 5 9
      lib/rmg/PenroseTiling.cpp

+ 5 - 9
lib/rmg/PenroseTiling.cpp

@@ -38,14 +38,10 @@ Point2D Point2D::operator - (const Point2D& other) const
 
 bool Point2D::operator < (const Point2D& other) const
 {
-	if (x() < other.x())
-	{
-		return true;
-	}
-	else
-	{
-		return y() < other.y();
-	}
+	if (x() != other.x())
+		return x() < other.x();
+
+	return y() < other.y();
 }
 
 std::string Point2D::toString() const
@@ -177,7 +173,7 @@ std::set<Point2D> PenroseTiling::generatePenroseTiling(size_t numZones, CRandomG
 	std::set<Point2D> uniquePoints(points.begin(), points.end());
 	std::vector<Point2D> uniquePointsVec(uniquePoints.begin(), uniquePoints.end());
 	logGlobal->info("Generated %d vertices and %d unique vertices", points.size(), uniquePointsVec.size());
-	
+
 	// Find center of the mass, shift that center to (0.5, 0.5)
 	Point2D center = Point2D(0.0f, 0.0f);
 	for (const auto & point : uniquePointsVec)